yvan-ext-mobile.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657
  1. define(['exports'], function (exports) { 'use strict';
  2. var bind = function bind(fn, thisArg) {
  3. return function wrap() {
  4. var args = new Array(arguments.length);
  5. for (var i = 0; i < args.length; i++) {
  6. args[i] = arguments[i];
  7. }
  8. return fn.apply(thisArg, args);
  9. };
  10. };
  11. /*global toString:true*/
  12. // utils is a library of generic helper functions non-specific to axios
  13. var toString = Object.prototype.toString;
  14. /**
  15. * Determine if a value is an Array
  16. *
  17. * @param {Object} val The value to test
  18. * @returns {boolean} True if value is an Array, otherwise false
  19. */
  20. function isArray(val) {
  21. return toString.call(val) === '[object Array]';
  22. }
  23. /**
  24. * Determine if a value is undefined
  25. *
  26. * @param {Object} val The value to test
  27. * @returns {boolean} True if the value is undefined, otherwise false
  28. */
  29. function isUndefined(val) {
  30. return typeof val === 'undefined';
  31. }
  32. /**
  33. * Determine if a value is a Buffer
  34. *
  35. * @param {Object} val The value to test
  36. * @returns {boolean} True if value is a Buffer, otherwise false
  37. */
  38. function isBuffer(val) {
  39. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  40. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  41. }
  42. /**
  43. * Determine if a value is an ArrayBuffer
  44. *
  45. * @param {Object} val The value to test
  46. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  47. */
  48. function isArrayBuffer(val) {
  49. return toString.call(val) === '[object ArrayBuffer]';
  50. }
  51. /**
  52. * Determine if a value is a FormData
  53. *
  54. * @param {Object} val The value to test
  55. * @returns {boolean} True if value is an FormData, otherwise false
  56. */
  57. function isFormData(val) {
  58. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  59. }
  60. /**
  61. * Determine if a value is a view on an ArrayBuffer
  62. *
  63. * @param {Object} val The value to test
  64. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  65. */
  66. function isArrayBufferView(val) {
  67. var result;
  68. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  69. result = ArrayBuffer.isView(val);
  70. } else {
  71. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  72. }
  73. return result;
  74. }
  75. /**
  76. * Determine if a value is a String
  77. *
  78. * @param {Object} val The value to test
  79. * @returns {boolean} True if value is a String, otherwise false
  80. */
  81. function isString(val) {
  82. return typeof val === 'string';
  83. }
  84. /**
  85. * Determine if a value is a Number
  86. *
  87. * @param {Object} val The value to test
  88. * @returns {boolean} True if value is a Number, otherwise false
  89. */
  90. function isNumber(val) {
  91. return typeof val === 'number';
  92. }
  93. /**
  94. * Determine if a value is an Object
  95. *
  96. * @param {Object} val The value to test
  97. * @returns {boolean} True if value is an Object, otherwise false
  98. */
  99. function isObject(val) {
  100. return val !== null && typeof val === 'object';
  101. }
  102. /**
  103. * Determine if a value is a plain Object
  104. *
  105. * @param {Object} val The value to test
  106. * @return {boolean} True if value is a plain Object, otherwise false
  107. */
  108. function isPlainObject(val) {
  109. if (toString.call(val) !== '[object Object]') {
  110. return false;
  111. }
  112. var prototype = Object.getPrototypeOf(val);
  113. return prototype === null || prototype === Object.prototype;
  114. }
  115. /**
  116. * Determine if a value is a Date
  117. *
  118. * @param {Object} val The value to test
  119. * @returns {boolean} True if value is a Date, otherwise false
  120. */
  121. function isDate(val) {
  122. return toString.call(val) === '[object Date]';
  123. }
  124. /**
  125. * Determine if a value is a File
  126. *
  127. * @param {Object} val The value to test
  128. * @returns {boolean} True if value is a File, otherwise false
  129. */
  130. function isFile(val) {
  131. return toString.call(val) === '[object File]';
  132. }
  133. /**
  134. * Determine if a value is a Blob
  135. *
  136. * @param {Object} val The value to test
  137. * @returns {boolean} True if value is a Blob, otherwise false
  138. */
  139. function isBlob(val) {
  140. return toString.call(val) === '[object Blob]';
  141. }
  142. /**
  143. * Determine if a value is a Function
  144. *
  145. * @param {Object} val The value to test
  146. * @returns {boolean} True if value is a Function, otherwise false
  147. */
  148. function isFunction(val) {
  149. return toString.call(val) === '[object Function]';
  150. }
  151. /**
  152. * Determine if a value is a Stream
  153. *
  154. * @param {Object} val The value to test
  155. * @returns {boolean} True if value is a Stream, otherwise false
  156. */
  157. function isStream(val) {
  158. return isObject(val) && isFunction(val.pipe);
  159. }
  160. /**
  161. * Determine if a value is a URLSearchParams object
  162. *
  163. * @param {Object} val The value to test
  164. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  165. */
  166. function isURLSearchParams(val) {
  167. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  168. }
  169. /**
  170. * Trim excess whitespace off the beginning and end of a string
  171. *
  172. * @param {String} str The String to trim
  173. * @returns {String} The String freed of excess whitespace
  174. */
  175. function trim(str) {
  176. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  177. }
  178. /**
  179. * Determine if we're running in a standard browser environment
  180. *
  181. * This allows axios to run in a web worker, and react-native.
  182. * Both environments support XMLHttpRequest, but not fully standard globals.
  183. *
  184. * web workers:
  185. * typeof window -> undefined
  186. * typeof document -> undefined
  187. *
  188. * react-native:
  189. * navigator.product -> 'ReactNative'
  190. * nativescript
  191. * navigator.product -> 'NativeScript' or 'NS'
  192. */
  193. function isStandardBrowserEnv() {
  194. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  195. navigator.product === 'NativeScript' ||
  196. navigator.product === 'NS')) {
  197. return false;
  198. }
  199. return (
  200. typeof window !== 'undefined' &&
  201. typeof document !== 'undefined'
  202. );
  203. }
  204. /**
  205. * Iterate over an Array or an Object invoking a function for each item.
  206. *
  207. * If `obj` is an Array callback will be called passing
  208. * the value, index, and complete array for each item.
  209. *
  210. * If 'obj' is an Object callback will be called passing
  211. * the value, key, and complete object for each property.
  212. *
  213. * @param {Object|Array} obj The object to iterate
  214. * @param {Function} fn The callback to invoke for each item
  215. */
  216. function forEach(obj, fn) {
  217. // Don't bother if no value provided
  218. if (obj === null || typeof obj === 'undefined') {
  219. return;
  220. }
  221. // Force an array if not already something iterable
  222. if (typeof obj !== 'object') {
  223. /*eslint no-param-reassign:0*/
  224. obj = [obj];
  225. }
  226. if (isArray(obj)) {
  227. // Iterate over array values
  228. for (var i = 0, l = obj.length; i < l; i++) {
  229. fn.call(null, obj[i], i, obj);
  230. }
  231. } else {
  232. // Iterate over object keys
  233. for (var key in obj) {
  234. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  235. fn.call(null, obj[key], key, obj);
  236. }
  237. }
  238. }
  239. }
  240. /**
  241. * Accepts varargs expecting each argument to be an object, then
  242. * immutably merges the properties of each object and returns result.
  243. *
  244. * When multiple objects contain the same key the later object in
  245. * the arguments list will take precedence.
  246. *
  247. * Example:
  248. *
  249. * ```js
  250. * var result = merge({foo: 123}, {foo: 456});
  251. * console.log(result.foo); // outputs 456
  252. * ```
  253. *
  254. * @param {Object} obj1 Object to merge
  255. * @returns {Object} Result of all merge properties
  256. */
  257. function merge(/* obj1, obj2, obj3, ... */) {
  258. var result = {};
  259. function assignValue(val, key) {
  260. if (isPlainObject(result[key]) && isPlainObject(val)) {
  261. result[key] = merge(result[key], val);
  262. } else if (isPlainObject(val)) {
  263. result[key] = merge({}, val);
  264. } else if (isArray(val)) {
  265. result[key] = val.slice();
  266. } else {
  267. result[key] = val;
  268. }
  269. }
  270. for (var i = 0, l = arguments.length; i < l; i++) {
  271. forEach(arguments[i], assignValue);
  272. }
  273. return result;
  274. }
  275. /**
  276. * Extends object a by mutably adding to it the properties of object b.
  277. *
  278. * @param {Object} a The object to be extended
  279. * @param {Object} b The object to copy properties from
  280. * @param {Object} thisArg The object to bind function to
  281. * @return {Object} The resulting value of object a
  282. */
  283. function extend(a, b, thisArg) {
  284. forEach(b, function assignValue(val, key) {
  285. if (thisArg && typeof val === 'function') {
  286. a[key] = bind(val, thisArg);
  287. } else {
  288. a[key] = val;
  289. }
  290. });
  291. return a;
  292. }
  293. /**
  294. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  295. *
  296. * @param {string} content with BOM
  297. * @return {string} content value without BOM
  298. */
  299. function stripBOM(content) {
  300. if (content.charCodeAt(0) === 0xFEFF) {
  301. content = content.slice(1);
  302. }
  303. return content;
  304. }
  305. var utils = {
  306. isArray: isArray,
  307. isArrayBuffer: isArrayBuffer,
  308. isBuffer: isBuffer,
  309. isFormData: isFormData,
  310. isArrayBufferView: isArrayBufferView,
  311. isString: isString,
  312. isNumber: isNumber,
  313. isObject: isObject,
  314. isPlainObject: isPlainObject,
  315. isUndefined: isUndefined,
  316. isDate: isDate,
  317. isFile: isFile,
  318. isBlob: isBlob,
  319. isFunction: isFunction,
  320. isStream: isStream,
  321. isURLSearchParams: isURLSearchParams,
  322. isStandardBrowserEnv: isStandardBrowserEnv,
  323. forEach: forEach,
  324. merge: merge,
  325. extend: extend,
  326. trim: trim,
  327. stripBOM: stripBOM
  328. };
  329. function encode(val) {
  330. return encodeURIComponent(val).
  331. replace(/%3A/gi, ':').
  332. replace(/%24/g, '$').
  333. replace(/%2C/gi, ',').
  334. replace(/%20/g, '+').
  335. replace(/%5B/gi, '[').
  336. replace(/%5D/gi, ']');
  337. }
  338. /**
  339. * Build a URL by appending params to the end
  340. *
  341. * @param {string} url The base of the url (e.g., http://www.google.com)
  342. * @param {object} [params] The params to be appended
  343. * @returns {string} The formatted url
  344. */
  345. var buildURL = function buildURL(url, params, paramsSerializer) {
  346. /*eslint no-param-reassign:0*/
  347. if (!params) {
  348. return url;
  349. }
  350. var serializedParams;
  351. if (paramsSerializer) {
  352. serializedParams = paramsSerializer(params);
  353. } else if (utils.isURLSearchParams(params)) {
  354. serializedParams = params.toString();
  355. } else {
  356. var parts = [];
  357. utils.forEach(params, function serialize(val, key) {
  358. if (val === null || typeof val === 'undefined') {
  359. return;
  360. }
  361. if (utils.isArray(val)) {
  362. key = key + '[]';
  363. } else {
  364. val = [val];
  365. }
  366. utils.forEach(val, function parseValue(v) {
  367. if (utils.isDate(v)) {
  368. v = v.toISOString();
  369. } else if (utils.isObject(v)) {
  370. v = JSON.stringify(v);
  371. }
  372. parts.push(encode(key) + '=' + encode(v));
  373. });
  374. });
  375. serializedParams = parts.join('&');
  376. }
  377. if (serializedParams) {
  378. var hashmarkIndex = url.indexOf('#');
  379. if (hashmarkIndex !== -1) {
  380. url = url.slice(0, hashmarkIndex);
  381. }
  382. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  383. }
  384. return url;
  385. };
  386. function InterceptorManager() {
  387. this.handlers = [];
  388. }
  389. /**
  390. * Add a new interceptor to the stack
  391. *
  392. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  393. * @param {Function} rejected The function to handle `reject` for a `Promise`
  394. *
  395. * @return {Number} An ID used to remove interceptor later
  396. */
  397. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  398. this.handlers.push({
  399. fulfilled: fulfilled,
  400. rejected: rejected
  401. });
  402. return this.handlers.length - 1;
  403. };
  404. /**
  405. * Remove an interceptor from the stack
  406. *
  407. * @param {Number} id The ID that was returned by `use`
  408. */
  409. InterceptorManager.prototype.eject = function eject(id) {
  410. if (this.handlers[id]) {
  411. this.handlers[id] = null;
  412. }
  413. };
  414. /**
  415. * Iterate over all the registered interceptors
  416. *
  417. * This method is particularly useful for skipping over any
  418. * interceptors that may have become `null` calling `eject`.
  419. *
  420. * @param {Function} fn The function to call for each interceptor
  421. */
  422. InterceptorManager.prototype.forEach = function forEach(fn) {
  423. utils.forEach(this.handlers, function forEachHandler(h) {
  424. if (h !== null) {
  425. fn(h);
  426. }
  427. });
  428. };
  429. var InterceptorManager_1 = InterceptorManager;
  430. /**
  431. * Transform the data for a request or a response
  432. *
  433. * @param {Object|String} data The data to be transformed
  434. * @param {Array} headers The headers for the request or response
  435. * @param {Array|Function} fns A single function or Array of functions
  436. * @returns {*} The resulting transformed data
  437. */
  438. var transformData = function transformData(data, headers, fns) {
  439. /*eslint no-param-reassign:0*/
  440. utils.forEach(fns, function transform(fn) {
  441. data = fn(data, headers);
  442. });
  443. return data;
  444. };
  445. var isCancel = function isCancel(value) {
  446. return !!(value && value.__CANCEL__);
  447. };
  448. var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
  449. utils.forEach(headers, function processHeader(value, name) {
  450. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  451. headers[normalizedName] = value;
  452. delete headers[name];
  453. }
  454. });
  455. };
  456. /**
  457. * Update an Error with the specified config, error code, and response.
  458. *
  459. * @param {Error} error The error to update.
  460. * @param {Object} config The config.
  461. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  462. * @param {Object} [request] The request.
  463. * @param {Object} [response] The response.
  464. * @returns {Error} The error.
  465. */
  466. var enhanceError = function enhanceError(error, config, code, request, response) {
  467. error.config = config;
  468. if (code) {
  469. error.code = code;
  470. }
  471. error.request = request;
  472. error.response = response;
  473. error.isAxiosError = true;
  474. error.toJSON = function toJSON() {
  475. return {
  476. // Standard
  477. message: this.message,
  478. name: this.name,
  479. // Microsoft
  480. description: this.description,
  481. number: this.number,
  482. // Mozilla
  483. fileName: this.fileName,
  484. lineNumber: this.lineNumber,
  485. columnNumber: this.columnNumber,
  486. stack: this.stack,
  487. // Axios
  488. config: this.config,
  489. code: this.code
  490. };
  491. };
  492. return error;
  493. };
  494. /**
  495. * Create an Error with the specified message, config, error code, request and response.
  496. *
  497. * @param {string} message The error message.
  498. * @param {Object} config The config.
  499. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  500. * @param {Object} [request] The request.
  501. * @param {Object} [response] The response.
  502. * @returns {Error} The created error.
  503. */
  504. var createError = function createError(message, config, code, request, response) {
  505. var error = new Error(message);
  506. return enhanceError(error, config, code, request, response);
  507. };
  508. /**
  509. * Resolve or reject a Promise based on response status.
  510. *
  511. * @param {Function} resolve A function that resolves the promise.
  512. * @param {Function} reject A function that rejects the promise.
  513. * @param {object} response The response.
  514. */
  515. var settle = function settle(resolve, reject, response) {
  516. var validateStatus = response.config.validateStatus;
  517. if (!response.status || !validateStatus || validateStatus(response.status)) {
  518. resolve(response);
  519. } else {
  520. reject(createError(
  521. 'Request failed with status code ' + response.status,
  522. response.config,
  523. null,
  524. response.request,
  525. response
  526. ));
  527. }
  528. };
  529. var cookies = (
  530. utils.isStandardBrowserEnv() ?
  531. // Standard browser envs support document.cookie
  532. (function standardBrowserEnv() {
  533. return {
  534. write: function write(name, value, expires, path, domain, secure) {
  535. var cookie = [];
  536. cookie.push(name + '=' + encodeURIComponent(value));
  537. if (utils.isNumber(expires)) {
  538. cookie.push('expires=' + new Date(expires).toGMTString());
  539. }
  540. if (utils.isString(path)) {
  541. cookie.push('path=' + path);
  542. }
  543. if (utils.isString(domain)) {
  544. cookie.push('domain=' + domain);
  545. }
  546. if (secure === true) {
  547. cookie.push('secure');
  548. }
  549. document.cookie = cookie.join('; ');
  550. },
  551. read: function read(name) {
  552. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  553. return (match ? decodeURIComponent(match[3]) : null);
  554. },
  555. remove: function remove(name) {
  556. this.write(name, '', Date.now() - 86400000);
  557. }
  558. };
  559. })() :
  560. // Non standard browser env (web workers, react-native) lack needed support.
  561. (function nonStandardBrowserEnv() {
  562. return {
  563. write: function write() {},
  564. read: function read() { return null; },
  565. remove: function remove() {}
  566. };
  567. })()
  568. );
  569. /**
  570. * Determines whether the specified URL is absolute
  571. *
  572. * @param {string} url The URL to test
  573. * @returns {boolean} True if the specified URL is absolute, otherwise false
  574. */
  575. var isAbsoluteURL = function isAbsoluteURL(url) {
  576. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  577. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  578. // by any combination of letters, digits, plus, period, or hyphen.
  579. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  580. };
  581. /**
  582. * Creates a new URL by combining the specified URLs
  583. *
  584. * @param {string} baseURL The base URL
  585. * @param {string} relativeURL The relative URL
  586. * @returns {string} The combined URL
  587. */
  588. var combineURLs = function combineURLs(baseURL, relativeURL) {
  589. return relativeURL
  590. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  591. : baseURL;
  592. };
  593. /**
  594. * Creates a new URL by combining the baseURL with the requestedURL,
  595. * only when the requestedURL is not already an absolute URL.
  596. * If the requestURL is absolute, this function returns the requestedURL untouched.
  597. *
  598. * @param {string} baseURL The base URL
  599. * @param {string} requestedURL Absolute or relative URL to combine
  600. * @returns {string} The combined full path
  601. */
  602. var buildFullPath = function buildFullPath(baseURL, requestedURL) {
  603. if (baseURL && !isAbsoluteURL(requestedURL)) {
  604. return combineURLs(baseURL, requestedURL);
  605. }
  606. return requestedURL;
  607. };
  608. // Headers whose duplicates are ignored by node
  609. // c.f. https://nodejs.org/api/http.html#http_message_headers
  610. var ignoreDuplicateOf = [
  611. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  612. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  613. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  614. 'referer', 'retry-after', 'user-agent'
  615. ];
  616. /**
  617. * Parse headers into an object
  618. *
  619. * ```
  620. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  621. * Content-Type: application/json
  622. * Connection: keep-alive
  623. * Transfer-Encoding: chunked
  624. * ```
  625. *
  626. * @param {String} headers Headers needing to be parsed
  627. * @returns {Object} Headers parsed into an object
  628. */
  629. var parseHeaders = function parseHeaders(headers) {
  630. var parsed = {};
  631. var key;
  632. var val;
  633. var i;
  634. if (!headers) { return parsed; }
  635. utils.forEach(headers.split('\n'), function parser(line) {
  636. i = line.indexOf(':');
  637. key = utils.trim(line.substr(0, i)).toLowerCase();
  638. val = utils.trim(line.substr(i + 1));
  639. if (key) {
  640. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  641. return;
  642. }
  643. if (key === 'set-cookie') {
  644. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  645. } else {
  646. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  647. }
  648. }
  649. });
  650. return parsed;
  651. };
  652. var isURLSameOrigin = (
  653. utils.isStandardBrowserEnv() ?
  654. // Standard browser envs have full support of the APIs needed to test
  655. // whether the request URL is of the same origin as current location.
  656. (function standardBrowserEnv() {
  657. var msie = /(msie|trident)/i.test(navigator.userAgent);
  658. var urlParsingNode = document.createElement('a');
  659. var originURL;
  660. /**
  661. * Parse a URL to discover it's components
  662. *
  663. * @param {String} url The URL to be parsed
  664. * @returns {Object}
  665. */
  666. function resolveURL(url) {
  667. var href = url;
  668. if (msie) {
  669. // IE needs attribute set twice to normalize properties
  670. urlParsingNode.setAttribute('href', href);
  671. href = urlParsingNode.href;
  672. }
  673. urlParsingNode.setAttribute('href', href);
  674. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  675. return {
  676. href: urlParsingNode.href,
  677. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  678. host: urlParsingNode.host,
  679. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  680. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  681. hostname: urlParsingNode.hostname,
  682. port: urlParsingNode.port,
  683. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  684. urlParsingNode.pathname :
  685. '/' + urlParsingNode.pathname
  686. };
  687. }
  688. originURL = resolveURL(window.location.href);
  689. /**
  690. * Determine if a URL shares the same origin as the current location
  691. *
  692. * @param {String} requestURL The URL to test
  693. * @returns {boolean} True if URL shares the same origin, otherwise false
  694. */
  695. return function isURLSameOrigin(requestURL) {
  696. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  697. return (parsed.protocol === originURL.protocol &&
  698. parsed.host === originURL.host);
  699. };
  700. })() :
  701. // Non standard browser envs (web workers, react-native) lack needed support.
  702. (function nonStandardBrowserEnv() {
  703. return function isURLSameOrigin() {
  704. return true;
  705. };
  706. })()
  707. );
  708. var xhr = function xhrAdapter(config) {
  709. return new Promise(function dispatchXhrRequest(resolve, reject) {
  710. var requestData = config.data;
  711. var requestHeaders = config.headers;
  712. if (utils.isFormData(requestData)) {
  713. delete requestHeaders['Content-Type']; // Let the browser set it
  714. }
  715. if (
  716. (utils.isBlob(requestData) || utils.isFile(requestData)) &&
  717. requestData.type
  718. ) {
  719. delete requestHeaders['Content-Type']; // Let the browser set it
  720. }
  721. var request = new XMLHttpRequest();
  722. // HTTP basic authentication
  723. if (config.auth) {
  724. var username = config.auth.username || '';
  725. var password = unescape(encodeURIComponent(config.auth.password)) || '';
  726. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  727. }
  728. var fullPath = buildFullPath(config.baseURL, config.url);
  729. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  730. // Set the request timeout in MS
  731. request.timeout = config.timeout;
  732. // Listen for ready state
  733. request.onreadystatechange = function handleLoad() {
  734. if (!request || request.readyState !== 4) {
  735. return;
  736. }
  737. // The request errored out and we didn't get a response, this will be
  738. // handled by onerror instead
  739. // With one exception: request that using file: protocol, most browsers
  740. // will return status as 0 even though it's a successful request
  741. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  742. return;
  743. }
  744. // Prepare the response
  745. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  746. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  747. var response = {
  748. data: responseData,
  749. status: request.status,
  750. statusText: request.statusText,
  751. headers: responseHeaders,
  752. config: config,
  753. request: request
  754. };
  755. settle(resolve, reject, response);
  756. // Clean up request
  757. request = null;
  758. };
  759. // Handle browser request cancellation (as opposed to a manual cancellation)
  760. request.onabort = function handleAbort() {
  761. if (!request) {
  762. return;
  763. }
  764. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  765. // Clean up request
  766. request = null;
  767. };
  768. // Handle low level network errors
  769. request.onerror = function handleError() {
  770. // Real errors are hidden from us by the browser
  771. // onerror should only fire if it's a network error
  772. reject(createError('Network Error', config, null, request));
  773. // Clean up request
  774. request = null;
  775. };
  776. // Handle timeout
  777. request.ontimeout = function handleTimeout() {
  778. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  779. if (config.timeoutErrorMessage) {
  780. timeoutErrorMessage = config.timeoutErrorMessage;
  781. }
  782. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  783. request));
  784. // Clean up request
  785. request = null;
  786. };
  787. // Add xsrf header
  788. // This is only done if running in a standard browser environment.
  789. // Specifically not if we're in a web worker, or react-native.
  790. if (utils.isStandardBrowserEnv()) {
  791. // Add xsrf header
  792. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  793. cookies.read(config.xsrfCookieName) :
  794. undefined;
  795. if (xsrfValue) {
  796. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  797. }
  798. }
  799. // Add headers to the request
  800. if ('setRequestHeader' in request) {
  801. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  802. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  803. // Remove Content-Type if data is undefined
  804. delete requestHeaders[key];
  805. } else {
  806. // Otherwise add header to the request
  807. request.setRequestHeader(key, val);
  808. }
  809. });
  810. }
  811. // Add withCredentials to request if needed
  812. if (!utils.isUndefined(config.withCredentials)) {
  813. request.withCredentials = !!config.withCredentials;
  814. }
  815. // Add responseType to request if needed
  816. if (config.responseType) {
  817. try {
  818. request.responseType = config.responseType;
  819. } catch (e) {
  820. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  821. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  822. if (config.responseType !== 'json') {
  823. throw e;
  824. }
  825. }
  826. }
  827. // Handle progress if needed
  828. if (typeof config.onDownloadProgress === 'function') {
  829. request.addEventListener('progress', config.onDownloadProgress);
  830. }
  831. // Not all browsers support upload events
  832. if (typeof config.onUploadProgress === 'function' && request.upload) {
  833. request.upload.addEventListener('progress', config.onUploadProgress);
  834. }
  835. if (config.cancelToken) {
  836. // Handle cancellation
  837. config.cancelToken.promise.then(function onCanceled(cancel) {
  838. if (!request) {
  839. return;
  840. }
  841. request.abort();
  842. reject(cancel);
  843. // Clean up request
  844. request = null;
  845. });
  846. }
  847. if (!requestData) {
  848. requestData = null;
  849. }
  850. // Send the request
  851. request.send(requestData);
  852. });
  853. };
  854. var DEFAULT_CONTENT_TYPE = {
  855. 'Content-Type': 'application/x-www-form-urlencoded'
  856. };
  857. function setContentTypeIfUnset(headers, value) {
  858. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  859. headers['Content-Type'] = value;
  860. }
  861. }
  862. function getDefaultAdapter() {
  863. var adapter;
  864. if (typeof XMLHttpRequest !== 'undefined') {
  865. // For browsers use XHR adapter
  866. adapter = xhr;
  867. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  868. // For node use HTTP adapter
  869. adapter = xhr;
  870. }
  871. return adapter;
  872. }
  873. var defaults = {
  874. adapter: getDefaultAdapter(),
  875. transformRequest: [function transformRequest(data, headers) {
  876. normalizeHeaderName(headers, 'Accept');
  877. normalizeHeaderName(headers, 'Content-Type');
  878. if (utils.isFormData(data) ||
  879. utils.isArrayBuffer(data) ||
  880. utils.isBuffer(data) ||
  881. utils.isStream(data) ||
  882. utils.isFile(data) ||
  883. utils.isBlob(data)
  884. ) {
  885. return data;
  886. }
  887. if (utils.isArrayBufferView(data)) {
  888. return data.buffer;
  889. }
  890. if (utils.isURLSearchParams(data)) {
  891. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  892. return data.toString();
  893. }
  894. if (utils.isObject(data)) {
  895. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  896. return JSON.stringify(data);
  897. }
  898. return data;
  899. }],
  900. transformResponse: [function transformResponse(data) {
  901. /*eslint no-param-reassign:0*/
  902. if (typeof data === 'string') {
  903. try {
  904. data = JSON.parse(data);
  905. } catch (e) { /* Ignore */ }
  906. }
  907. return data;
  908. }],
  909. /**
  910. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  911. * timeout is not created.
  912. */
  913. timeout: 0,
  914. xsrfCookieName: 'XSRF-TOKEN',
  915. xsrfHeaderName: 'X-XSRF-TOKEN',
  916. maxContentLength: -1,
  917. maxBodyLength: -1,
  918. validateStatus: function validateStatus(status) {
  919. return status >= 200 && status < 300;
  920. }
  921. };
  922. defaults.headers = {
  923. common: {
  924. 'Accept': 'application/json, text/plain, */*'
  925. }
  926. };
  927. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  928. defaults.headers[method] = {};
  929. });
  930. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  931. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  932. });
  933. var defaults_1 = defaults;
  934. /**
  935. * Throws a `Cancel` if cancellation has been requested.
  936. */
  937. function throwIfCancellationRequested(config) {
  938. if (config.cancelToken) {
  939. config.cancelToken.throwIfRequested();
  940. }
  941. }
  942. /**
  943. * Dispatch a request to the server using the configured adapter.
  944. *
  945. * @param {object} config The config that is to be used for the request
  946. * @returns {Promise} The Promise to be fulfilled
  947. */
  948. var dispatchRequest = function dispatchRequest(config) {
  949. throwIfCancellationRequested(config);
  950. // Ensure headers exist
  951. config.headers = config.headers || {};
  952. // Transform request data
  953. config.data = transformData(
  954. config.data,
  955. config.headers,
  956. config.transformRequest
  957. );
  958. // Flatten headers
  959. config.headers = utils.merge(
  960. config.headers.common || {},
  961. config.headers[config.method] || {},
  962. config.headers
  963. );
  964. utils.forEach(
  965. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  966. function cleanHeaderConfig(method) {
  967. delete config.headers[method];
  968. }
  969. );
  970. var adapter = config.adapter || defaults_1.adapter;
  971. return adapter(config).then(function onAdapterResolution(response) {
  972. throwIfCancellationRequested(config);
  973. // Transform response data
  974. response.data = transformData(
  975. response.data,
  976. response.headers,
  977. config.transformResponse
  978. );
  979. return response;
  980. }, function onAdapterRejection(reason) {
  981. if (!isCancel(reason)) {
  982. throwIfCancellationRequested(config);
  983. // Transform response data
  984. if (reason && reason.response) {
  985. reason.response.data = transformData(
  986. reason.response.data,
  987. reason.response.headers,
  988. config.transformResponse
  989. );
  990. }
  991. }
  992. return Promise.reject(reason);
  993. });
  994. };
  995. /**
  996. * Config-specific merge-function which creates a new config-object
  997. * by merging two configuration objects together.
  998. *
  999. * @param {Object} config1
  1000. * @param {Object} config2
  1001. * @returns {Object} New object resulting from merging config2 to config1
  1002. */
  1003. var mergeConfig = function mergeConfig(config1, config2) {
  1004. // eslint-disable-next-line no-param-reassign
  1005. config2 = config2 || {};
  1006. var config = {};
  1007. var valueFromConfig2Keys = ['url', 'method', 'data'];
  1008. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  1009. var defaultToConfig2Keys = [
  1010. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  1011. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  1012. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  1013. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  1014. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  1015. ];
  1016. var directMergeKeys = ['validateStatus'];
  1017. function getMergedValue(target, source) {
  1018. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  1019. return utils.merge(target, source);
  1020. } else if (utils.isPlainObject(source)) {
  1021. return utils.merge({}, source);
  1022. } else if (utils.isArray(source)) {
  1023. return source.slice();
  1024. }
  1025. return source;
  1026. }
  1027. function mergeDeepProperties(prop) {
  1028. if (!utils.isUndefined(config2[prop])) {
  1029. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1030. } else if (!utils.isUndefined(config1[prop])) {
  1031. config[prop] = getMergedValue(undefined, config1[prop]);
  1032. }
  1033. }
  1034. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  1035. if (!utils.isUndefined(config2[prop])) {
  1036. config[prop] = getMergedValue(undefined, config2[prop]);
  1037. }
  1038. });
  1039. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  1040. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  1041. if (!utils.isUndefined(config2[prop])) {
  1042. config[prop] = getMergedValue(undefined, config2[prop]);
  1043. } else if (!utils.isUndefined(config1[prop])) {
  1044. config[prop] = getMergedValue(undefined, config1[prop]);
  1045. }
  1046. });
  1047. utils.forEach(directMergeKeys, function merge(prop) {
  1048. if (prop in config2) {
  1049. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1050. } else if (prop in config1) {
  1051. config[prop] = getMergedValue(undefined, config1[prop]);
  1052. }
  1053. });
  1054. var axiosKeys = valueFromConfig2Keys
  1055. .concat(mergeDeepPropertiesKeys)
  1056. .concat(defaultToConfig2Keys)
  1057. .concat(directMergeKeys);
  1058. var otherKeys = Object
  1059. .keys(config1)
  1060. .concat(Object.keys(config2))
  1061. .filter(function filterAxiosKeys(key) {
  1062. return axiosKeys.indexOf(key) === -1;
  1063. });
  1064. utils.forEach(otherKeys, mergeDeepProperties);
  1065. return config;
  1066. };
  1067. /**
  1068. * Create a new instance of Axios
  1069. *
  1070. * @param {Object} instanceConfig The default config for the instance
  1071. */
  1072. function Axios(instanceConfig) {
  1073. this.defaults = instanceConfig;
  1074. this.interceptors = {
  1075. request: new InterceptorManager_1(),
  1076. response: new InterceptorManager_1()
  1077. };
  1078. }
  1079. /**
  1080. * Dispatch a request
  1081. *
  1082. * @param {Object} config The config specific for this request (merged with this.defaults)
  1083. */
  1084. Axios.prototype.request = function request(config) {
  1085. /*eslint no-param-reassign:0*/
  1086. // Allow for axios('example/url'[, config]) a la fetch API
  1087. if (typeof config === 'string') {
  1088. config = arguments[1] || {};
  1089. config.url = arguments[0];
  1090. } else {
  1091. config = config || {};
  1092. }
  1093. config = mergeConfig(this.defaults, config);
  1094. // Set config.method
  1095. if (config.method) {
  1096. config.method = config.method.toLowerCase();
  1097. } else if (this.defaults.method) {
  1098. config.method = this.defaults.method.toLowerCase();
  1099. } else {
  1100. config.method = 'get';
  1101. }
  1102. // Hook up interceptors middleware
  1103. var chain = [dispatchRequest, undefined];
  1104. var promise = Promise.resolve(config);
  1105. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  1106. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  1107. });
  1108. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  1109. chain.push(interceptor.fulfilled, interceptor.rejected);
  1110. });
  1111. while (chain.length) {
  1112. promise = promise.then(chain.shift(), chain.shift());
  1113. }
  1114. return promise;
  1115. };
  1116. Axios.prototype.getUri = function getUri(config) {
  1117. config = mergeConfig(this.defaults, config);
  1118. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  1119. };
  1120. // Provide aliases for supported request methods
  1121. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  1122. /*eslint func-names:0*/
  1123. Axios.prototype[method] = function(url, config) {
  1124. return this.request(mergeConfig(config || {}, {
  1125. method: method,
  1126. url: url
  1127. }));
  1128. };
  1129. });
  1130. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1131. /*eslint func-names:0*/
  1132. Axios.prototype[method] = function(url, data, config) {
  1133. return this.request(mergeConfig(config || {}, {
  1134. method: method,
  1135. url: url,
  1136. data: data
  1137. }));
  1138. };
  1139. });
  1140. var Axios_1 = Axios;
  1141. /**
  1142. * A `Cancel` is an object that is thrown when an operation is canceled.
  1143. *
  1144. * @class
  1145. * @param {string=} message The message.
  1146. */
  1147. function Cancel(message) {
  1148. this.message = message;
  1149. }
  1150. Cancel.prototype.toString = function toString() {
  1151. return 'Cancel' + (this.message ? ': ' + this.message : '');
  1152. };
  1153. Cancel.prototype.__CANCEL__ = true;
  1154. var Cancel_1 = Cancel;
  1155. /**
  1156. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  1157. *
  1158. * @class
  1159. * @param {Function} executor The executor function.
  1160. */
  1161. function CancelToken(executor) {
  1162. if (typeof executor !== 'function') {
  1163. throw new TypeError('executor must be a function.');
  1164. }
  1165. var resolvePromise;
  1166. this.promise = new Promise(function promiseExecutor(resolve) {
  1167. resolvePromise = resolve;
  1168. });
  1169. var token = this;
  1170. executor(function cancel(message) {
  1171. if (token.reason) {
  1172. // Cancellation has already been requested
  1173. return;
  1174. }
  1175. token.reason = new Cancel_1(message);
  1176. resolvePromise(token.reason);
  1177. });
  1178. }
  1179. /**
  1180. * Throws a `Cancel` if cancellation has been requested.
  1181. */
  1182. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  1183. if (this.reason) {
  1184. throw this.reason;
  1185. }
  1186. };
  1187. /**
  1188. * Returns an object that contains a new `CancelToken` and a function that, when called,
  1189. * cancels the `CancelToken`.
  1190. */
  1191. CancelToken.source = function source() {
  1192. var cancel;
  1193. var token = new CancelToken(function executor(c) {
  1194. cancel = c;
  1195. });
  1196. return {
  1197. token: token,
  1198. cancel: cancel
  1199. };
  1200. };
  1201. var CancelToken_1 = CancelToken;
  1202. /**
  1203. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1204. *
  1205. * Common use case would be to use `Function.prototype.apply`.
  1206. *
  1207. * ```js
  1208. * function f(x, y, z) {}
  1209. * var args = [1, 2, 3];
  1210. * f.apply(null, args);
  1211. * ```
  1212. *
  1213. * With `spread` this example can be re-written.
  1214. *
  1215. * ```js
  1216. * spread(function(x, y, z) {})([1, 2, 3]);
  1217. * ```
  1218. *
  1219. * @param {Function} callback
  1220. * @returns {Function}
  1221. */
  1222. var spread = function spread(callback) {
  1223. return function wrap(arr) {
  1224. return callback.apply(null, arr);
  1225. };
  1226. };
  1227. /**
  1228. * Create an instance of Axios
  1229. *
  1230. * @param {Object} defaultConfig The default config for the instance
  1231. * @return {Axios} A new instance of Axios
  1232. */
  1233. function createInstance(defaultConfig) {
  1234. var context = new Axios_1(defaultConfig);
  1235. var instance = bind(Axios_1.prototype.request, context);
  1236. // Copy axios.prototype to instance
  1237. utils.extend(instance, Axios_1.prototype, context);
  1238. // Copy context to instance
  1239. utils.extend(instance, context);
  1240. return instance;
  1241. }
  1242. // Create the default instance to be exported
  1243. var axios = createInstance(defaults_1);
  1244. // Expose Axios class to allow class inheritance
  1245. axios.Axios = Axios_1;
  1246. // Factory for creating new instances
  1247. axios.create = function create(instanceConfig) {
  1248. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  1249. };
  1250. // Expose Cancel & CancelToken
  1251. axios.Cancel = Cancel_1;
  1252. axios.CancelToken = CancelToken_1;
  1253. axios.isCancel = isCancel;
  1254. // Expose all/spread
  1255. axios.all = function all(promises) {
  1256. return Promise.all(promises);
  1257. };
  1258. axios.spread = spread;
  1259. var axios_1 = axios;
  1260. // Allow use of default import syntax in TypeScript
  1261. var default_1 = axios;
  1262. axios_1.default = default_1;
  1263. var axios$1 = axios_1;
  1264. var index = /*#__PURE__*/Object.freeze({
  1265. __proto__: null,
  1266. 'default': axios$1,
  1267. __moduleExports: axios$1
  1268. });
  1269. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  1270. function commonjsRequire () {
  1271. throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
  1272. }
  1273. function createCommonjsModule(fn, module) {
  1274. return module = { exports: {} }, fn(module, module.exports), module.exports;
  1275. }
  1276. var utils$1 = createCommonjsModule(function (module, exports) {
  1277. var has = Object.prototype.hasOwnProperty;
  1278. var hexTable = (function () {
  1279. var array = [];
  1280. for (var i = 0; i < 256; ++i) {
  1281. array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
  1282. }
  1283. return array;
  1284. }());
  1285. var compactQueue = function compactQueue(queue) {
  1286. var obj;
  1287. while (queue.length) {
  1288. var item = queue.pop();
  1289. obj = item.obj[item.prop];
  1290. if (Array.isArray(obj)) {
  1291. var compacted = [];
  1292. for (var j = 0; j < obj.length; ++j) {
  1293. if (typeof obj[j] !== 'undefined') {
  1294. compacted.push(obj[j]);
  1295. }
  1296. }
  1297. item.obj[item.prop] = compacted;
  1298. }
  1299. }
  1300. return obj;
  1301. };
  1302. exports.arrayToObject = function arrayToObject(source, options) {
  1303. var obj = options && options.plainObjects ? Object.create(null) : {};
  1304. for (var i = 0; i < source.length; ++i) {
  1305. if (typeof source[i] !== 'undefined') {
  1306. obj[i] = source[i];
  1307. }
  1308. }
  1309. return obj;
  1310. };
  1311. exports.merge = function merge(target, source, options) {
  1312. if (!source) {
  1313. return target;
  1314. }
  1315. if (typeof source !== 'object') {
  1316. if (Array.isArray(target)) {
  1317. target.push(source);
  1318. } else if (typeof target === 'object') {
  1319. if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
  1320. target[source] = true;
  1321. }
  1322. } else {
  1323. return [target, source];
  1324. }
  1325. return target;
  1326. }
  1327. if (typeof target !== 'object') {
  1328. return [target].concat(source);
  1329. }
  1330. var mergeTarget = target;
  1331. if (Array.isArray(target) && !Array.isArray(source)) {
  1332. mergeTarget = exports.arrayToObject(target, options);
  1333. }
  1334. if (Array.isArray(target) && Array.isArray(source)) {
  1335. source.forEach(function (item, i) {
  1336. if (has.call(target, i)) {
  1337. if (target[i] && typeof target[i] === 'object') {
  1338. target[i] = exports.merge(target[i], item, options);
  1339. } else {
  1340. target.push(item);
  1341. }
  1342. } else {
  1343. target[i] = item;
  1344. }
  1345. });
  1346. return target;
  1347. }
  1348. return Object.keys(source).reduce(function (acc, key) {
  1349. var value = source[key];
  1350. if (has.call(acc, key)) {
  1351. acc[key] = exports.merge(acc[key], value, options);
  1352. } else {
  1353. acc[key] = value;
  1354. }
  1355. return acc;
  1356. }, mergeTarget);
  1357. };
  1358. exports.assign = function assignSingleSource(target, source) {
  1359. return Object.keys(source).reduce(function (acc, key) {
  1360. acc[key] = source[key];
  1361. return acc;
  1362. }, target);
  1363. };
  1364. exports.decode = function (str) {
  1365. try {
  1366. return decodeURIComponent(str.replace(/\+/g, ' '));
  1367. } catch (e) {
  1368. return str;
  1369. }
  1370. };
  1371. exports.encode = function encode(str) {
  1372. // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
  1373. // It has been adapted here for stricter adherence to RFC 3986
  1374. if (str.length === 0) {
  1375. return str;
  1376. }
  1377. var string = typeof str === 'string' ? str : String(str);
  1378. var out = '';
  1379. for (var i = 0; i < string.length; ++i) {
  1380. var c = string.charCodeAt(i);
  1381. if (
  1382. c === 0x2D // -
  1383. || c === 0x2E // .
  1384. || c === 0x5F // _
  1385. || c === 0x7E // ~
  1386. || (c >= 0x30 && c <= 0x39) // 0-9
  1387. || (c >= 0x41 && c <= 0x5A) // a-z
  1388. || (c >= 0x61 && c <= 0x7A) // A-Z
  1389. ) {
  1390. out += string.charAt(i);
  1391. continue;
  1392. }
  1393. if (c < 0x80) {
  1394. out = out + hexTable[c];
  1395. continue;
  1396. }
  1397. if (c < 0x800) {
  1398. out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
  1399. continue;
  1400. }
  1401. if (c < 0xD800 || c >= 0xE000) {
  1402. out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
  1403. continue;
  1404. }
  1405. i += 1;
  1406. c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
  1407. out += hexTable[0xF0 | (c >> 18)]
  1408. + hexTable[0x80 | ((c >> 12) & 0x3F)]
  1409. + hexTable[0x80 | ((c >> 6) & 0x3F)]
  1410. + hexTable[0x80 | (c & 0x3F)];
  1411. }
  1412. return out;
  1413. };
  1414. exports.compact = function compact(value) {
  1415. var queue = [{ obj: { o: value }, prop: 'o' }];
  1416. var refs = [];
  1417. for (var i = 0; i < queue.length; ++i) {
  1418. var item = queue[i];
  1419. var obj = item.obj[item.prop];
  1420. var keys = Object.keys(obj);
  1421. for (var j = 0; j < keys.length; ++j) {
  1422. var key = keys[j];
  1423. var val = obj[key];
  1424. if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
  1425. queue.push({ obj: obj, prop: key });
  1426. refs.push(val);
  1427. }
  1428. }
  1429. }
  1430. return compactQueue(queue);
  1431. };
  1432. exports.isRegExp = function isRegExp(obj) {
  1433. return Object.prototype.toString.call(obj) === '[object RegExp]';
  1434. };
  1435. exports.isBuffer = function isBuffer(obj) {
  1436. if (obj === null || typeof obj === 'undefined') {
  1437. return false;
  1438. }
  1439. return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
  1440. };
  1441. });
  1442. var utils_1 = utils$1.arrayToObject;
  1443. var utils_2 = utils$1.merge;
  1444. var utils_3 = utils$1.assign;
  1445. var utils_4 = utils$1.decode;
  1446. var utils_5 = utils$1.encode;
  1447. var utils_6 = utils$1.compact;
  1448. var utils_7 = utils$1.isRegExp;
  1449. var utils_8 = utils$1.isBuffer;
  1450. var replace = String.prototype.replace;
  1451. var percentTwenties = /%20/g;
  1452. var formats = {
  1453. 'default': 'RFC3986',
  1454. formatters: {
  1455. RFC1738: function (value) {
  1456. return replace.call(value, percentTwenties, '+');
  1457. },
  1458. RFC3986: function (value) {
  1459. return value;
  1460. }
  1461. },
  1462. RFC1738: 'RFC1738',
  1463. RFC3986: 'RFC3986'
  1464. };
  1465. var arrayPrefixGenerators = {
  1466. brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
  1467. return prefix + '[]';
  1468. },
  1469. indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
  1470. return prefix + '[' + key + ']';
  1471. },
  1472. repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
  1473. return prefix;
  1474. }
  1475. };
  1476. var toISO = Date.prototype.toISOString;
  1477. var defaults$1 = {
  1478. delimiter: '&',
  1479. encode: true,
  1480. encoder: utils$1.encode,
  1481. encodeValuesOnly: false,
  1482. serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
  1483. return toISO.call(date);
  1484. },
  1485. skipNulls: false,
  1486. strictNullHandling: false
  1487. };
  1488. var stringify = function stringify( // eslint-disable-line func-name-matching
  1489. object,
  1490. prefix,
  1491. generateArrayPrefix,
  1492. strictNullHandling,
  1493. skipNulls,
  1494. encoder,
  1495. filter,
  1496. sort,
  1497. allowDots,
  1498. serializeDate,
  1499. formatter,
  1500. encodeValuesOnly
  1501. ) {
  1502. var obj = object;
  1503. if (typeof filter === 'function') {
  1504. obj = filter(prefix, obj);
  1505. } else if (obj instanceof Date) {
  1506. obj = serializeDate(obj);
  1507. } else if (obj === null) {
  1508. if (strictNullHandling) {
  1509. return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder) : prefix;
  1510. }
  1511. obj = '';
  1512. }
  1513. if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils$1.isBuffer(obj)) {
  1514. if (encoder) {
  1515. var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder);
  1516. return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder))];
  1517. }
  1518. return [formatter(prefix) + '=' + formatter(String(obj))];
  1519. }
  1520. var values = [];
  1521. if (typeof obj === 'undefined') {
  1522. return values;
  1523. }
  1524. var objKeys;
  1525. if (Array.isArray(filter)) {
  1526. objKeys = filter;
  1527. } else {
  1528. var keys = Object.keys(obj);
  1529. objKeys = sort ? keys.sort(sort) : keys;
  1530. }
  1531. for (var i = 0; i < objKeys.length; ++i) {
  1532. var key = objKeys[i];
  1533. if (skipNulls && obj[key] === null) {
  1534. continue;
  1535. }
  1536. if (Array.isArray(obj)) {
  1537. values = values.concat(stringify(
  1538. obj[key],
  1539. generateArrayPrefix(prefix, key),
  1540. generateArrayPrefix,
  1541. strictNullHandling,
  1542. skipNulls,
  1543. encoder,
  1544. filter,
  1545. sort,
  1546. allowDots,
  1547. serializeDate,
  1548. formatter,
  1549. encodeValuesOnly
  1550. ));
  1551. } else {
  1552. values = values.concat(stringify(
  1553. obj[key],
  1554. prefix + (allowDots ? '.' + key : '[' + key + ']'),
  1555. generateArrayPrefix,
  1556. strictNullHandling,
  1557. skipNulls,
  1558. encoder,
  1559. filter,
  1560. sort,
  1561. allowDots,
  1562. serializeDate,
  1563. formatter,
  1564. encodeValuesOnly
  1565. ));
  1566. }
  1567. }
  1568. return values;
  1569. };
  1570. var stringify_1 = function (object, opts) {
  1571. var obj = object;
  1572. var options = opts ? utils$1.assign({}, opts) : {};
  1573. if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
  1574. throw new TypeError('Encoder has to be a function.');
  1575. }
  1576. var delimiter = typeof options.delimiter === 'undefined' ? defaults$1.delimiter : options.delimiter;
  1577. var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults$1.strictNullHandling;
  1578. var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults$1.skipNulls;
  1579. var encode = typeof options.encode === 'boolean' ? options.encode : defaults$1.encode;
  1580. var encoder = typeof options.encoder === 'function' ? options.encoder : defaults$1.encoder;
  1581. var sort = typeof options.sort === 'function' ? options.sort : null;
  1582. var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
  1583. var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults$1.serializeDate;
  1584. var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults$1.encodeValuesOnly;
  1585. if (typeof options.format === 'undefined') {
  1586. options.format = formats['default'];
  1587. } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
  1588. throw new TypeError('Unknown format option provided.');
  1589. }
  1590. var formatter = formats.formatters[options.format];
  1591. var objKeys;
  1592. var filter;
  1593. if (typeof options.filter === 'function') {
  1594. filter = options.filter;
  1595. obj = filter('', obj);
  1596. } else if (Array.isArray(options.filter)) {
  1597. filter = options.filter;
  1598. objKeys = filter;
  1599. }
  1600. var keys = [];
  1601. if (typeof obj !== 'object' || obj === null) {
  1602. return '';
  1603. }
  1604. var arrayFormat;
  1605. if (options.arrayFormat in arrayPrefixGenerators) {
  1606. arrayFormat = options.arrayFormat;
  1607. } else if ('indices' in options) {
  1608. arrayFormat = options.indices ? 'indices' : 'repeat';
  1609. } else {
  1610. arrayFormat = 'indices';
  1611. }
  1612. var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
  1613. if (!objKeys) {
  1614. objKeys = Object.keys(obj);
  1615. }
  1616. if (sort) {
  1617. objKeys.sort(sort);
  1618. }
  1619. for (var i = 0; i < objKeys.length; ++i) {
  1620. var key = objKeys[i];
  1621. if (skipNulls && obj[key] === null) {
  1622. continue;
  1623. }
  1624. keys = keys.concat(stringify(
  1625. obj[key],
  1626. key,
  1627. generateArrayPrefix,
  1628. strictNullHandling,
  1629. skipNulls,
  1630. encode ? encoder : null,
  1631. filter,
  1632. sort,
  1633. allowDots,
  1634. serializeDate,
  1635. formatter,
  1636. encodeValuesOnly
  1637. ));
  1638. }
  1639. var joined = keys.join(delimiter);
  1640. var prefix = options.addQueryPrefix === true ? '?' : '';
  1641. return joined.length > 0 ? prefix + joined : '';
  1642. };
  1643. var has = Object.prototype.hasOwnProperty;
  1644. var defaults$2 = {
  1645. allowDots: false,
  1646. allowPrototypes: false,
  1647. arrayLimit: 20,
  1648. decoder: utils$1.decode,
  1649. delimiter: '&',
  1650. depth: 5,
  1651. parameterLimit: 1000,
  1652. plainObjects: false,
  1653. strictNullHandling: false
  1654. };
  1655. var parseValues = function parseQueryStringValues(str, options) {
  1656. var obj = {};
  1657. var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
  1658. var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
  1659. var parts = cleanStr.split(options.delimiter, limit);
  1660. for (var i = 0; i < parts.length; ++i) {
  1661. var part = parts[i];
  1662. var bracketEqualsPos = part.indexOf(']=');
  1663. var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
  1664. var key, val;
  1665. if (pos === -1) {
  1666. key = options.decoder(part, defaults$2.decoder);
  1667. val = options.strictNullHandling ? null : '';
  1668. } else {
  1669. key = options.decoder(part.slice(0, pos), defaults$2.decoder);
  1670. val = options.decoder(part.slice(pos + 1), defaults$2.decoder);
  1671. }
  1672. if (has.call(obj, key)) {
  1673. obj[key] = [].concat(obj[key]).concat(val);
  1674. } else {
  1675. obj[key] = val;
  1676. }
  1677. }
  1678. return obj;
  1679. };
  1680. var parseObject = function (chain, val, options) {
  1681. var leaf = val;
  1682. for (var i = chain.length - 1; i >= 0; --i) {
  1683. var obj;
  1684. var root = chain[i];
  1685. if (root === '[]') {
  1686. obj = [];
  1687. obj = obj.concat(leaf);
  1688. } else {
  1689. obj = options.plainObjects ? Object.create(null) : {};
  1690. var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
  1691. var index = parseInt(cleanRoot, 10);
  1692. if (
  1693. !isNaN(index)
  1694. && root !== cleanRoot
  1695. && String(index) === cleanRoot
  1696. && index >= 0
  1697. && (options.parseArrays && index <= options.arrayLimit)
  1698. ) {
  1699. obj = [];
  1700. obj[index] = leaf;
  1701. } else {
  1702. obj[cleanRoot] = leaf;
  1703. }
  1704. }
  1705. leaf = obj;
  1706. }
  1707. return leaf;
  1708. };
  1709. var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
  1710. if (!givenKey) {
  1711. return;
  1712. }
  1713. // Transform dot notation to bracket notation
  1714. var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
  1715. // The regex chunks
  1716. var brackets = /(\[[^[\]]*])/;
  1717. var child = /(\[[^[\]]*])/g;
  1718. // Get the parent
  1719. var segment = brackets.exec(key);
  1720. var parent = segment ? key.slice(0, segment.index) : key;
  1721. // Stash the parent if it exists
  1722. var keys = [];
  1723. if (parent) {
  1724. // If we aren't using plain objects, optionally prefix keys
  1725. // that would overwrite object prototype properties
  1726. if (!options.plainObjects && has.call(Object.prototype, parent)) {
  1727. if (!options.allowPrototypes) {
  1728. return;
  1729. }
  1730. }
  1731. keys.push(parent);
  1732. }
  1733. // Loop through children appending to the array until we hit depth
  1734. var i = 0;
  1735. while ((segment = child.exec(key)) !== null && i < options.depth) {
  1736. i += 1;
  1737. if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
  1738. if (!options.allowPrototypes) {
  1739. return;
  1740. }
  1741. }
  1742. keys.push(segment[1]);
  1743. }
  1744. // If there's a remainder, just add whatever is left
  1745. if (segment) {
  1746. keys.push('[' + key.slice(segment.index) + ']');
  1747. }
  1748. return parseObject(keys, val, options);
  1749. };
  1750. var parse = function (str, opts) {
  1751. var options = opts ? utils$1.assign({}, opts) : {};
  1752. if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
  1753. throw new TypeError('Decoder has to be a function.');
  1754. }
  1755. options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
  1756. options.delimiter = typeof options.delimiter === 'string' || utils$1.isRegExp(options.delimiter) ? options.delimiter : defaults$2.delimiter;
  1757. options.depth = typeof options.depth === 'number' ? options.depth : defaults$2.depth;
  1758. options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults$2.arrayLimit;
  1759. options.parseArrays = options.parseArrays !== false;
  1760. options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults$2.decoder;
  1761. options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults$2.allowDots;
  1762. options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults$2.plainObjects;
  1763. options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults$2.allowPrototypes;
  1764. options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults$2.parameterLimit;
  1765. options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults$2.strictNullHandling;
  1766. if (str === '' || str === null || typeof str === 'undefined') {
  1767. return options.plainObjects ? Object.create(null) : {};
  1768. }
  1769. var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
  1770. var obj = options.plainObjects ? Object.create(null) : {};
  1771. // Iterate over the keys and setup the new object
  1772. var keys = Object.keys(tempObj);
  1773. for (var i = 0; i < keys.length; ++i) {
  1774. var key = keys[i];
  1775. var newObj = parseKeys(key, tempObj[key], options);
  1776. obj = utils$1.merge(obj, newObj, options);
  1777. }
  1778. return utils$1.compact(obj);
  1779. };
  1780. var lib = {
  1781. formats: formats,
  1782. parse: parse,
  1783. stringify: stringify_1
  1784. };
  1785. var lodash = createCommonjsModule(function (module, exports) {
  1786. (function() {
  1787. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  1788. var undefined$1;
  1789. /** Used as the semantic version number. */
  1790. var VERSION = '4.17.21';
  1791. /** Used as the size to enable large array optimizations. */
  1792. var LARGE_ARRAY_SIZE = 200;
  1793. /** Error message constants. */
  1794. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  1795. FUNC_ERROR_TEXT = 'Expected a function',
  1796. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  1797. /** Used to stand-in for `undefined` hash values. */
  1798. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1799. /** Used as the maximum memoize cache size. */
  1800. var MAX_MEMOIZE_SIZE = 500;
  1801. /** Used as the internal argument placeholder. */
  1802. var PLACEHOLDER = '__lodash_placeholder__';
  1803. /** Used to compose bitmasks for cloning. */
  1804. var CLONE_DEEP_FLAG = 1,
  1805. CLONE_FLAT_FLAG = 2,
  1806. CLONE_SYMBOLS_FLAG = 4;
  1807. /** Used to compose bitmasks for value comparisons. */
  1808. var COMPARE_PARTIAL_FLAG = 1,
  1809. COMPARE_UNORDERED_FLAG = 2;
  1810. /** Used to compose bitmasks for function metadata. */
  1811. var WRAP_BIND_FLAG = 1,
  1812. WRAP_BIND_KEY_FLAG = 2,
  1813. WRAP_CURRY_BOUND_FLAG = 4,
  1814. WRAP_CURRY_FLAG = 8,
  1815. WRAP_CURRY_RIGHT_FLAG = 16,
  1816. WRAP_PARTIAL_FLAG = 32,
  1817. WRAP_PARTIAL_RIGHT_FLAG = 64,
  1818. WRAP_ARY_FLAG = 128,
  1819. WRAP_REARG_FLAG = 256,
  1820. WRAP_FLIP_FLAG = 512;
  1821. /** Used as default options for `_.truncate`. */
  1822. var DEFAULT_TRUNC_LENGTH = 30,
  1823. DEFAULT_TRUNC_OMISSION = '...';
  1824. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  1825. var HOT_COUNT = 800,
  1826. HOT_SPAN = 16;
  1827. /** Used to indicate the type of lazy iteratees. */
  1828. var LAZY_FILTER_FLAG = 1,
  1829. LAZY_MAP_FLAG = 2,
  1830. LAZY_WHILE_FLAG = 3;
  1831. /** Used as references for various `Number` constants. */
  1832. var INFINITY = 1 / 0,
  1833. MAX_SAFE_INTEGER = 9007199254740991,
  1834. MAX_INTEGER = 1.7976931348623157e+308,
  1835. NAN = 0 / 0;
  1836. /** Used as references for the maximum length and index of an array. */
  1837. var MAX_ARRAY_LENGTH = 4294967295,
  1838. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1839. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1840. /** Used to associate wrap methods with their bit flags. */
  1841. var wrapFlags = [
  1842. ['ary', WRAP_ARY_FLAG],
  1843. ['bind', WRAP_BIND_FLAG],
  1844. ['bindKey', WRAP_BIND_KEY_FLAG],
  1845. ['curry', WRAP_CURRY_FLAG],
  1846. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  1847. ['flip', WRAP_FLIP_FLAG],
  1848. ['partial', WRAP_PARTIAL_FLAG],
  1849. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  1850. ['rearg', WRAP_REARG_FLAG]
  1851. ];
  1852. /** `Object#toString` result references. */
  1853. var argsTag = '[object Arguments]',
  1854. arrayTag = '[object Array]',
  1855. asyncTag = '[object AsyncFunction]',
  1856. boolTag = '[object Boolean]',
  1857. dateTag = '[object Date]',
  1858. domExcTag = '[object DOMException]',
  1859. errorTag = '[object Error]',
  1860. funcTag = '[object Function]',
  1861. genTag = '[object GeneratorFunction]',
  1862. mapTag = '[object Map]',
  1863. numberTag = '[object Number]',
  1864. nullTag = '[object Null]',
  1865. objectTag = '[object Object]',
  1866. promiseTag = '[object Promise]',
  1867. proxyTag = '[object Proxy]',
  1868. regexpTag = '[object RegExp]',
  1869. setTag = '[object Set]',
  1870. stringTag = '[object String]',
  1871. symbolTag = '[object Symbol]',
  1872. undefinedTag = '[object Undefined]',
  1873. weakMapTag = '[object WeakMap]',
  1874. weakSetTag = '[object WeakSet]';
  1875. var arrayBufferTag = '[object ArrayBuffer]',
  1876. dataViewTag = '[object DataView]',
  1877. float32Tag = '[object Float32Array]',
  1878. float64Tag = '[object Float64Array]',
  1879. int8Tag = '[object Int8Array]',
  1880. int16Tag = '[object Int16Array]',
  1881. int32Tag = '[object Int32Array]',
  1882. uint8Tag = '[object Uint8Array]',
  1883. uint8ClampedTag = '[object Uint8ClampedArray]',
  1884. uint16Tag = '[object Uint16Array]',
  1885. uint32Tag = '[object Uint32Array]';
  1886. /** Used to match empty string literals in compiled template source. */
  1887. var reEmptyStringLeading = /\b__p \+= '';/g,
  1888. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  1889. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  1890. /** Used to match HTML entities and HTML characters. */
  1891. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  1892. reUnescapedHtml = /[&<>"']/g,
  1893. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  1894. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  1895. /** Used to match template delimiters. */
  1896. var reEscape = /<%-([\s\S]+?)%>/g,
  1897. reEvaluate = /<%([\s\S]+?)%>/g,
  1898. reInterpolate = /<%=([\s\S]+?)%>/g;
  1899. /** Used to match property names within property paths. */
  1900. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1901. reIsPlainProp = /^\w*$/,
  1902. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1903. /**
  1904. * Used to match `RegExp`
  1905. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1906. */
  1907. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  1908. reHasRegExpChar = RegExp(reRegExpChar.source);
  1909. /** Used to match leading whitespace. */
  1910. var reTrimStart = /^\s+/;
  1911. /** Used to match a single whitespace character. */
  1912. var reWhitespace = /\s/;
  1913. /** Used to match wrap detail comments. */
  1914. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  1915. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  1916. reSplitDetails = /,? & /;
  1917. /** Used to match words composed of alphanumeric characters. */
  1918. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  1919. /**
  1920. * Used to validate the `validate` option in `_.template` variable.
  1921. *
  1922. * Forbids characters which could potentially change the meaning of the function argument definition:
  1923. * - "()," (modification of function parameters)
  1924. * - "=" (default value)
  1925. * - "[]{}" (destructuring of function parameters)
  1926. * - "/" (beginning of a comment)
  1927. * - whitespace
  1928. */
  1929. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  1930. /** Used to match backslashes in property paths. */
  1931. var reEscapeChar = /\\(\\)?/g;
  1932. /**
  1933. * Used to match
  1934. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  1935. */
  1936. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  1937. /** Used to match `RegExp` flags from their coerced string values. */
  1938. var reFlags = /\w*$/;
  1939. /** Used to detect bad signed hexadecimal string values. */
  1940. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1941. /** Used to detect binary string values. */
  1942. var reIsBinary = /^0b[01]+$/i;
  1943. /** Used to detect host constructors (Safari). */
  1944. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1945. /** Used to detect octal string values. */
  1946. var reIsOctal = /^0o[0-7]+$/i;
  1947. /** Used to detect unsigned integer values. */
  1948. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1949. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  1950. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  1951. /** Used to ensure capturing order of template delimiters. */
  1952. var reNoMatch = /($^)/;
  1953. /** Used to match unescaped characters in compiled string literals. */
  1954. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  1955. /** Used to compose unicode character classes. */
  1956. var rsAstralRange = '\\ud800-\\udfff',
  1957. rsComboMarksRange = '\\u0300-\\u036f',
  1958. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1959. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1960. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1961. rsDingbatRange = '\\u2700-\\u27bf',
  1962. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1963. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1964. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1965. rsPunctuationRange = '\\u2000-\\u206f',
  1966. 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',
  1967. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1968. rsVarRange = '\\ufe0e\\ufe0f',
  1969. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1970. /** Used to compose unicode capture groups. */
  1971. var rsApos = "['\u2019]",
  1972. rsAstral = '[' + rsAstralRange + ']',
  1973. rsBreak = '[' + rsBreakRange + ']',
  1974. rsCombo = '[' + rsComboRange + ']',
  1975. rsDigits = '\\d+',
  1976. rsDingbat = '[' + rsDingbatRange + ']',
  1977. rsLower = '[' + rsLowerRange + ']',
  1978. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1979. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1980. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1981. rsNonAstral = '[^' + rsAstralRange + ']',
  1982. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1983. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1984. rsUpper = '[' + rsUpperRange + ']',
  1985. rsZWJ = '\\u200d';
  1986. /** Used to compose unicode regexes. */
  1987. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1988. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1989. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1990. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1991. reOptMod = rsModifier + '?',
  1992. rsOptVar = '[' + rsVarRange + ']?',
  1993. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1994. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  1995. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  1996. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1997. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1998. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1999. /** Used to match apostrophes. */
  2000. var reApos = RegExp(rsApos, 'g');
  2001. /**
  2002. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  2003. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  2004. */
  2005. var reComboMark = RegExp(rsCombo, 'g');
  2006. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  2007. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  2008. /** Used to match complex or compound words. */
  2009. var reUnicodeWord = RegExp([
  2010. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  2011. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  2012. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  2013. rsUpper + '+' + rsOptContrUpper,
  2014. rsOrdUpper,
  2015. rsOrdLower,
  2016. rsDigits,
  2017. rsEmoji
  2018. ].join('|'), 'g');
  2019. /** 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/). */
  2020. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  2021. /** Used to detect strings that need a more robust regexp to match words. */
  2022. 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 ]/;
  2023. /** Used to assign default `context` object properties. */
  2024. var contextProps = [
  2025. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  2026. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  2027. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  2028. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  2029. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  2030. ];
  2031. /** Used to make template sourceURLs easier to identify. */
  2032. var templateCounter = -1;
  2033. /** Used to identify `toStringTag` values of typed arrays. */
  2034. var typedArrayTags = {};
  2035. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  2036. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  2037. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  2038. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  2039. typedArrayTags[uint32Tag] = true;
  2040. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  2041. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  2042. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  2043. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  2044. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  2045. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  2046. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  2047. typedArrayTags[weakMapTag] = false;
  2048. /** Used to identify `toStringTag` values supported by `_.clone`. */
  2049. var cloneableTags = {};
  2050. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  2051. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  2052. cloneableTags[boolTag] = cloneableTags[dateTag] =
  2053. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  2054. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  2055. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  2056. cloneableTags[numberTag] = cloneableTags[objectTag] =
  2057. cloneableTags[regexpTag] = cloneableTags[setTag] =
  2058. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  2059. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  2060. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  2061. cloneableTags[errorTag] = cloneableTags[funcTag] =
  2062. cloneableTags[weakMapTag] = false;
  2063. /** Used to map Latin Unicode letters to basic Latin letters. */
  2064. var deburredLetters = {
  2065. // Latin-1 Supplement block.
  2066. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  2067. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  2068. '\xc7': 'C', '\xe7': 'c',
  2069. '\xd0': 'D', '\xf0': 'd',
  2070. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  2071. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  2072. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  2073. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  2074. '\xd1': 'N', '\xf1': 'n',
  2075. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  2076. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  2077. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  2078. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  2079. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  2080. '\xc6': 'Ae', '\xe6': 'ae',
  2081. '\xde': 'Th', '\xfe': 'th',
  2082. '\xdf': 'ss',
  2083. // Latin Extended-A block.
  2084. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  2085. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  2086. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  2087. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  2088. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  2089. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  2090. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  2091. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  2092. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  2093. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  2094. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  2095. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  2096. '\u0134': 'J', '\u0135': 'j',
  2097. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  2098. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  2099. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  2100. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  2101. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  2102. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  2103. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  2104. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  2105. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  2106. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  2107. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  2108. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  2109. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  2110. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  2111. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  2112. '\u0174': 'W', '\u0175': 'w',
  2113. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  2114. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  2115. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  2116. '\u0132': 'IJ', '\u0133': 'ij',
  2117. '\u0152': 'Oe', '\u0153': 'oe',
  2118. '\u0149': "'n", '\u017f': 's'
  2119. };
  2120. /** Used to map characters to HTML entities. */
  2121. var htmlEscapes = {
  2122. '&': '&amp;',
  2123. '<': '&lt;',
  2124. '>': '&gt;',
  2125. '"': '&quot;',
  2126. "'": '&#39;'
  2127. };
  2128. /** Used to map HTML entities to characters. */
  2129. var htmlUnescapes = {
  2130. '&amp;': '&',
  2131. '&lt;': '<',
  2132. '&gt;': '>',
  2133. '&quot;': '"',
  2134. '&#39;': "'"
  2135. };
  2136. /** Used to escape characters for inclusion in compiled string literals. */
  2137. var stringEscapes = {
  2138. '\\': '\\',
  2139. "'": "'",
  2140. '\n': 'n',
  2141. '\r': 'r',
  2142. '\u2028': 'u2028',
  2143. '\u2029': 'u2029'
  2144. };
  2145. /** Built-in method references without a dependency on `root`. */
  2146. var freeParseFloat = parseFloat,
  2147. freeParseInt = parseInt;
  2148. /** Detect free variable `global` from Node.js. */
  2149. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  2150. /** Detect free variable `self`. */
  2151. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2152. /** Used as a reference to the global object. */
  2153. var root = freeGlobal || freeSelf || Function('return this')();
  2154. /** Detect free variable `exports`. */
  2155. var freeExports = exports && !exports.nodeType && exports;
  2156. /** Detect free variable `module`. */
  2157. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  2158. /** Detect the popular CommonJS extension `module.exports`. */
  2159. var moduleExports = freeModule && freeModule.exports === freeExports;
  2160. /** Detect free variable `process` from Node.js. */
  2161. var freeProcess = moduleExports && freeGlobal.process;
  2162. /** Used to access faster Node.js helpers. */
  2163. var nodeUtil = (function() {
  2164. try {
  2165. // Use `util.types` for Node.js 10+.
  2166. var types = freeModule && freeModule.require && freeModule.require('util').types;
  2167. if (types) {
  2168. return types;
  2169. }
  2170. // Legacy `process.binding('util')` for Node.js < 10.
  2171. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  2172. } catch (e) {}
  2173. }());
  2174. /* Node.js helper references. */
  2175. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  2176. nodeIsDate = nodeUtil && nodeUtil.isDate,
  2177. nodeIsMap = nodeUtil && nodeUtil.isMap,
  2178. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  2179. nodeIsSet = nodeUtil && nodeUtil.isSet,
  2180. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  2181. /*--------------------------------------------------------------------------*/
  2182. /**
  2183. * A faster alternative to `Function#apply`, this function invokes `func`
  2184. * with the `this` binding of `thisArg` and the arguments of `args`.
  2185. *
  2186. * @private
  2187. * @param {Function} func The function to invoke.
  2188. * @param {*} thisArg The `this` binding of `func`.
  2189. * @param {Array} args The arguments to invoke `func` with.
  2190. * @returns {*} Returns the result of `func`.
  2191. */
  2192. function apply(func, thisArg, args) {
  2193. switch (args.length) {
  2194. case 0: return func.call(thisArg);
  2195. case 1: return func.call(thisArg, args[0]);
  2196. case 2: return func.call(thisArg, args[0], args[1]);
  2197. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  2198. }
  2199. return func.apply(thisArg, args);
  2200. }
  2201. /**
  2202. * A specialized version of `baseAggregator` for arrays.
  2203. *
  2204. * @private
  2205. * @param {Array} [array] The array to iterate over.
  2206. * @param {Function} setter The function to set `accumulator` values.
  2207. * @param {Function} iteratee The iteratee to transform keys.
  2208. * @param {Object} accumulator The initial aggregated object.
  2209. * @returns {Function} Returns `accumulator`.
  2210. */
  2211. function arrayAggregator(array, setter, iteratee, accumulator) {
  2212. var index = -1,
  2213. length = array == null ? 0 : array.length;
  2214. while (++index < length) {
  2215. var value = array[index];
  2216. setter(accumulator, value, iteratee(value), array);
  2217. }
  2218. return accumulator;
  2219. }
  2220. /**
  2221. * A specialized version of `_.forEach` for arrays without support for
  2222. * iteratee shorthands.
  2223. *
  2224. * @private
  2225. * @param {Array} [array] The array to iterate over.
  2226. * @param {Function} iteratee The function invoked per iteration.
  2227. * @returns {Array} Returns `array`.
  2228. */
  2229. function arrayEach(array, iteratee) {
  2230. var index = -1,
  2231. length = array == null ? 0 : array.length;
  2232. while (++index < length) {
  2233. if (iteratee(array[index], index, array) === false) {
  2234. break;
  2235. }
  2236. }
  2237. return array;
  2238. }
  2239. /**
  2240. * A specialized version of `_.forEachRight` for arrays without support for
  2241. * iteratee shorthands.
  2242. *
  2243. * @private
  2244. * @param {Array} [array] The array to iterate over.
  2245. * @param {Function} iteratee The function invoked per iteration.
  2246. * @returns {Array} Returns `array`.
  2247. */
  2248. function arrayEachRight(array, iteratee) {
  2249. var length = array == null ? 0 : array.length;
  2250. while (length--) {
  2251. if (iteratee(array[length], length, array) === false) {
  2252. break;
  2253. }
  2254. }
  2255. return array;
  2256. }
  2257. /**
  2258. * A specialized version of `_.every` for arrays without support for
  2259. * iteratee shorthands.
  2260. *
  2261. * @private
  2262. * @param {Array} [array] The array to iterate over.
  2263. * @param {Function} predicate The function invoked per iteration.
  2264. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  2265. * else `false`.
  2266. */
  2267. function arrayEvery(array, predicate) {
  2268. var index = -1,
  2269. length = array == null ? 0 : array.length;
  2270. while (++index < length) {
  2271. if (!predicate(array[index], index, array)) {
  2272. return false;
  2273. }
  2274. }
  2275. return true;
  2276. }
  2277. /**
  2278. * A specialized version of `_.filter` for arrays without support for
  2279. * iteratee shorthands.
  2280. *
  2281. * @private
  2282. * @param {Array} [array] The array to iterate over.
  2283. * @param {Function} predicate The function invoked per iteration.
  2284. * @returns {Array} Returns the new filtered array.
  2285. */
  2286. function arrayFilter(array, predicate) {
  2287. var index = -1,
  2288. length = array == null ? 0 : array.length,
  2289. resIndex = 0,
  2290. result = [];
  2291. while (++index < length) {
  2292. var value = array[index];
  2293. if (predicate(value, index, array)) {
  2294. result[resIndex++] = value;
  2295. }
  2296. }
  2297. return result;
  2298. }
  2299. /**
  2300. * A specialized version of `_.includes` for arrays without support for
  2301. * specifying an index to search from.
  2302. *
  2303. * @private
  2304. * @param {Array} [array] The array to inspect.
  2305. * @param {*} target The value to search for.
  2306. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2307. */
  2308. function arrayIncludes(array, value) {
  2309. var length = array == null ? 0 : array.length;
  2310. return !!length && baseIndexOf(array, value, 0) > -1;
  2311. }
  2312. /**
  2313. * This function is like `arrayIncludes` except that it accepts a comparator.
  2314. *
  2315. * @private
  2316. * @param {Array} [array] The array to inspect.
  2317. * @param {*} target The value to search for.
  2318. * @param {Function} comparator The comparator invoked per element.
  2319. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2320. */
  2321. function arrayIncludesWith(array, value, comparator) {
  2322. var index = -1,
  2323. length = array == null ? 0 : array.length;
  2324. while (++index < length) {
  2325. if (comparator(value, array[index])) {
  2326. return true;
  2327. }
  2328. }
  2329. return false;
  2330. }
  2331. /**
  2332. * A specialized version of `_.map` for arrays without support for iteratee
  2333. * shorthands.
  2334. *
  2335. * @private
  2336. * @param {Array} [array] The array to iterate over.
  2337. * @param {Function} iteratee The function invoked per iteration.
  2338. * @returns {Array} Returns the new mapped array.
  2339. */
  2340. function arrayMap(array, iteratee) {
  2341. var index = -1,
  2342. length = array == null ? 0 : array.length,
  2343. result = Array(length);
  2344. while (++index < length) {
  2345. result[index] = iteratee(array[index], index, array);
  2346. }
  2347. return result;
  2348. }
  2349. /**
  2350. * Appends the elements of `values` to `array`.
  2351. *
  2352. * @private
  2353. * @param {Array} array The array to modify.
  2354. * @param {Array} values The values to append.
  2355. * @returns {Array} Returns `array`.
  2356. */
  2357. function arrayPush(array, values) {
  2358. var index = -1,
  2359. length = values.length,
  2360. offset = array.length;
  2361. while (++index < length) {
  2362. array[offset + index] = values[index];
  2363. }
  2364. return array;
  2365. }
  2366. /**
  2367. * A specialized version of `_.reduce` for arrays without support for
  2368. * iteratee shorthands.
  2369. *
  2370. * @private
  2371. * @param {Array} [array] The array to iterate over.
  2372. * @param {Function} iteratee The function invoked per iteration.
  2373. * @param {*} [accumulator] The initial value.
  2374. * @param {boolean} [initAccum] Specify using the first element of `array` as
  2375. * the initial value.
  2376. * @returns {*} Returns the accumulated value.
  2377. */
  2378. function arrayReduce(array, iteratee, accumulator, initAccum) {
  2379. var index = -1,
  2380. length = array == null ? 0 : array.length;
  2381. if (initAccum && length) {
  2382. accumulator = array[++index];
  2383. }
  2384. while (++index < length) {
  2385. accumulator = iteratee(accumulator, array[index], index, array);
  2386. }
  2387. return accumulator;
  2388. }
  2389. /**
  2390. * A specialized version of `_.reduceRight` for arrays without support for
  2391. * iteratee shorthands.
  2392. *
  2393. * @private
  2394. * @param {Array} [array] The array to iterate over.
  2395. * @param {Function} iteratee The function invoked per iteration.
  2396. * @param {*} [accumulator] The initial value.
  2397. * @param {boolean} [initAccum] Specify using the last element of `array` as
  2398. * the initial value.
  2399. * @returns {*} Returns the accumulated value.
  2400. */
  2401. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  2402. var length = array == null ? 0 : array.length;
  2403. if (initAccum && length) {
  2404. accumulator = array[--length];
  2405. }
  2406. while (length--) {
  2407. accumulator = iteratee(accumulator, array[length], length, array);
  2408. }
  2409. return accumulator;
  2410. }
  2411. /**
  2412. * A specialized version of `_.some` for arrays without support for iteratee
  2413. * shorthands.
  2414. *
  2415. * @private
  2416. * @param {Array} [array] The array to iterate over.
  2417. * @param {Function} predicate The function invoked per iteration.
  2418. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2419. * else `false`.
  2420. */
  2421. function arraySome(array, predicate) {
  2422. var index = -1,
  2423. length = array == null ? 0 : array.length;
  2424. while (++index < length) {
  2425. if (predicate(array[index], index, array)) {
  2426. return true;
  2427. }
  2428. }
  2429. return false;
  2430. }
  2431. /**
  2432. * Gets the size of an ASCII `string`.
  2433. *
  2434. * @private
  2435. * @param {string} string The string inspect.
  2436. * @returns {number} Returns the string size.
  2437. */
  2438. var asciiSize = baseProperty('length');
  2439. /**
  2440. * Converts an ASCII `string` to an array.
  2441. *
  2442. * @private
  2443. * @param {string} string The string to convert.
  2444. * @returns {Array} Returns the converted array.
  2445. */
  2446. function asciiToArray(string) {
  2447. return string.split('');
  2448. }
  2449. /**
  2450. * Splits an ASCII `string` into an array of its words.
  2451. *
  2452. * @private
  2453. * @param {string} The string to inspect.
  2454. * @returns {Array} Returns the words of `string`.
  2455. */
  2456. function asciiWords(string) {
  2457. return string.match(reAsciiWord) || [];
  2458. }
  2459. /**
  2460. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  2461. * without support for iteratee shorthands, which iterates over `collection`
  2462. * using `eachFunc`.
  2463. *
  2464. * @private
  2465. * @param {Array|Object} collection The collection to inspect.
  2466. * @param {Function} predicate The function invoked per iteration.
  2467. * @param {Function} eachFunc The function to iterate over `collection`.
  2468. * @returns {*} Returns the found element or its key, else `undefined`.
  2469. */
  2470. function baseFindKey(collection, predicate, eachFunc) {
  2471. var result;
  2472. eachFunc(collection, function(value, key, collection) {
  2473. if (predicate(value, key, collection)) {
  2474. result = key;
  2475. return false;
  2476. }
  2477. });
  2478. return result;
  2479. }
  2480. /**
  2481. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  2482. * support for iteratee shorthands.
  2483. *
  2484. * @private
  2485. * @param {Array} array The array to inspect.
  2486. * @param {Function} predicate The function invoked per iteration.
  2487. * @param {number} fromIndex The index to search from.
  2488. * @param {boolean} [fromRight] Specify iterating from right to left.
  2489. * @returns {number} Returns the index of the matched value, else `-1`.
  2490. */
  2491. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  2492. var length = array.length,
  2493. index = fromIndex + (fromRight ? 1 : -1);
  2494. while ((fromRight ? index-- : ++index < length)) {
  2495. if (predicate(array[index], index, array)) {
  2496. return index;
  2497. }
  2498. }
  2499. return -1;
  2500. }
  2501. /**
  2502. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  2503. *
  2504. * @private
  2505. * @param {Array} array The array to inspect.
  2506. * @param {*} value The value to search for.
  2507. * @param {number} fromIndex The index to search from.
  2508. * @returns {number} Returns the index of the matched value, else `-1`.
  2509. */
  2510. function baseIndexOf(array, value, fromIndex) {
  2511. return value === value
  2512. ? strictIndexOf(array, value, fromIndex)
  2513. : baseFindIndex(array, baseIsNaN, fromIndex);
  2514. }
  2515. /**
  2516. * This function is like `baseIndexOf` except that it accepts a comparator.
  2517. *
  2518. * @private
  2519. * @param {Array} array The array to inspect.
  2520. * @param {*} value The value to search for.
  2521. * @param {number} fromIndex The index to search from.
  2522. * @param {Function} comparator The comparator invoked per element.
  2523. * @returns {number} Returns the index of the matched value, else `-1`.
  2524. */
  2525. function baseIndexOfWith(array, value, fromIndex, comparator) {
  2526. var index = fromIndex - 1,
  2527. length = array.length;
  2528. while (++index < length) {
  2529. if (comparator(array[index], value)) {
  2530. return index;
  2531. }
  2532. }
  2533. return -1;
  2534. }
  2535. /**
  2536. * The base implementation of `_.isNaN` without support for number objects.
  2537. *
  2538. * @private
  2539. * @param {*} value The value to check.
  2540. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  2541. */
  2542. function baseIsNaN(value) {
  2543. return value !== value;
  2544. }
  2545. /**
  2546. * The base implementation of `_.mean` and `_.meanBy` without support for
  2547. * iteratee shorthands.
  2548. *
  2549. * @private
  2550. * @param {Array} array The array to iterate over.
  2551. * @param {Function} iteratee The function invoked per iteration.
  2552. * @returns {number} Returns the mean.
  2553. */
  2554. function baseMean(array, iteratee) {
  2555. var length = array == null ? 0 : array.length;
  2556. return length ? (baseSum(array, iteratee) / length) : NAN;
  2557. }
  2558. /**
  2559. * The base implementation of `_.property` without support for deep paths.
  2560. *
  2561. * @private
  2562. * @param {string} key The key of the property to get.
  2563. * @returns {Function} Returns the new accessor function.
  2564. */
  2565. function baseProperty(key) {
  2566. return function(object) {
  2567. return object == null ? undefined$1 : object[key];
  2568. };
  2569. }
  2570. /**
  2571. * The base implementation of `_.propertyOf` without support for deep paths.
  2572. *
  2573. * @private
  2574. * @param {Object} object The object to query.
  2575. * @returns {Function} Returns the new accessor function.
  2576. */
  2577. function basePropertyOf(object) {
  2578. return function(key) {
  2579. return object == null ? undefined$1 : object[key];
  2580. };
  2581. }
  2582. /**
  2583. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  2584. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  2585. *
  2586. * @private
  2587. * @param {Array|Object} collection The collection to iterate over.
  2588. * @param {Function} iteratee The function invoked per iteration.
  2589. * @param {*} accumulator The initial value.
  2590. * @param {boolean} initAccum Specify using the first or last element of
  2591. * `collection` as the initial value.
  2592. * @param {Function} eachFunc The function to iterate over `collection`.
  2593. * @returns {*} Returns the accumulated value.
  2594. */
  2595. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  2596. eachFunc(collection, function(value, index, collection) {
  2597. accumulator = initAccum
  2598. ? (initAccum = false, value)
  2599. : iteratee(accumulator, value, index, collection);
  2600. });
  2601. return accumulator;
  2602. }
  2603. /**
  2604. * The base implementation of `_.sortBy` which uses `comparer` to define the
  2605. * sort order of `array` and replaces criteria objects with their corresponding
  2606. * values.
  2607. *
  2608. * @private
  2609. * @param {Array} array The array to sort.
  2610. * @param {Function} comparer The function to define sort order.
  2611. * @returns {Array} Returns `array`.
  2612. */
  2613. function baseSortBy(array, comparer) {
  2614. var length = array.length;
  2615. array.sort(comparer);
  2616. while (length--) {
  2617. array[length] = array[length].value;
  2618. }
  2619. return array;
  2620. }
  2621. /**
  2622. * The base implementation of `_.sum` and `_.sumBy` without support for
  2623. * iteratee shorthands.
  2624. *
  2625. * @private
  2626. * @param {Array} array The array to iterate over.
  2627. * @param {Function} iteratee The function invoked per iteration.
  2628. * @returns {number} Returns the sum.
  2629. */
  2630. function baseSum(array, iteratee) {
  2631. var result,
  2632. index = -1,
  2633. length = array.length;
  2634. while (++index < length) {
  2635. var current = iteratee(array[index]);
  2636. if (current !== undefined$1) {
  2637. result = result === undefined$1 ? current : (result + current);
  2638. }
  2639. }
  2640. return result;
  2641. }
  2642. /**
  2643. * The base implementation of `_.times` without support for iteratee shorthands
  2644. * or max array length checks.
  2645. *
  2646. * @private
  2647. * @param {number} n The number of times to invoke `iteratee`.
  2648. * @param {Function} iteratee The function invoked per iteration.
  2649. * @returns {Array} Returns the array of results.
  2650. */
  2651. function baseTimes(n, iteratee) {
  2652. var index = -1,
  2653. result = Array(n);
  2654. while (++index < n) {
  2655. result[index] = iteratee(index);
  2656. }
  2657. return result;
  2658. }
  2659. /**
  2660. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  2661. * of key-value pairs for `object` corresponding to the property names of `props`.
  2662. *
  2663. * @private
  2664. * @param {Object} object The object to query.
  2665. * @param {Array} props The property names to get values for.
  2666. * @returns {Object} Returns the key-value pairs.
  2667. */
  2668. function baseToPairs(object, props) {
  2669. return arrayMap(props, function(key) {
  2670. return [key, object[key]];
  2671. });
  2672. }
  2673. /**
  2674. * The base implementation of `_.trim`.
  2675. *
  2676. * @private
  2677. * @param {string} string The string to trim.
  2678. * @returns {string} Returns the trimmed string.
  2679. */
  2680. function baseTrim(string) {
  2681. return string
  2682. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  2683. : string;
  2684. }
  2685. /**
  2686. * The base implementation of `_.unary` without support for storing metadata.
  2687. *
  2688. * @private
  2689. * @param {Function} func The function to cap arguments for.
  2690. * @returns {Function} Returns the new capped function.
  2691. */
  2692. function baseUnary(func) {
  2693. return function(value) {
  2694. return func(value);
  2695. };
  2696. }
  2697. /**
  2698. * The base implementation of `_.values` and `_.valuesIn` which creates an
  2699. * array of `object` property values corresponding to the property names
  2700. * of `props`.
  2701. *
  2702. * @private
  2703. * @param {Object} object The object to query.
  2704. * @param {Array} props The property names to get values for.
  2705. * @returns {Object} Returns the array of property values.
  2706. */
  2707. function baseValues(object, props) {
  2708. return arrayMap(props, function(key) {
  2709. return object[key];
  2710. });
  2711. }
  2712. /**
  2713. * Checks if a `cache` value for `key` exists.
  2714. *
  2715. * @private
  2716. * @param {Object} cache The cache to query.
  2717. * @param {string} key The key of the entry to check.
  2718. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2719. */
  2720. function cacheHas(cache, key) {
  2721. return cache.has(key);
  2722. }
  2723. /**
  2724. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  2725. * that is not found in the character symbols.
  2726. *
  2727. * @private
  2728. * @param {Array} strSymbols The string symbols to inspect.
  2729. * @param {Array} chrSymbols The character symbols to find.
  2730. * @returns {number} Returns the index of the first unmatched string symbol.
  2731. */
  2732. function charsStartIndex(strSymbols, chrSymbols) {
  2733. var index = -1,
  2734. length = strSymbols.length;
  2735. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2736. return index;
  2737. }
  2738. /**
  2739. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  2740. * that is not found in the character symbols.
  2741. *
  2742. * @private
  2743. * @param {Array} strSymbols The string symbols to inspect.
  2744. * @param {Array} chrSymbols The character symbols to find.
  2745. * @returns {number} Returns the index of the last unmatched string symbol.
  2746. */
  2747. function charsEndIndex(strSymbols, chrSymbols) {
  2748. var index = strSymbols.length;
  2749. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2750. return index;
  2751. }
  2752. /**
  2753. * Gets the number of `placeholder` occurrences in `array`.
  2754. *
  2755. * @private
  2756. * @param {Array} array The array to inspect.
  2757. * @param {*} placeholder The placeholder to search for.
  2758. * @returns {number} Returns the placeholder count.
  2759. */
  2760. function countHolders(array, placeholder) {
  2761. var length = array.length,
  2762. result = 0;
  2763. while (length--) {
  2764. if (array[length] === placeholder) {
  2765. ++result;
  2766. }
  2767. }
  2768. return result;
  2769. }
  2770. /**
  2771. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  2772. * letters to basic Latin letters.
  2773. *
  2774. * @private
  2775. * @param {string} letter The matched letter to deburr.
  2776. * @returns {string} Returns the deburred letter.
  2777. */
  2778. var deburrLetter = basePropertyOf(deburredLetters);
  2779. /**
  2780. * Used by `_.escape` to convert characters to HTML entities.
  2781. *
  2782. * @private
  2783. * @param {string} chr The matched character to escape.
  2784. * @returns {string} Returns the escaped character.
  2785. */
  2786. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  2787. /**
  2788. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  2789. *
  2790. * @private
  2791. * @param {string} chr The matched character to escape.
  2792. * @returns {string} Returns the escaped character.
  2793. */
  2794. function escapeStringChar(chr) {
  2795. return '\\' + stringEscapes[chr];
  2796. }
  2797. /**
  2798. * Gets the value at `key` of `object`.
  2799. *
  2800. * @private
  2801. * @param {Object} [object] The object to query.
  2802. * @param {string} key The key of the property to get.
  2803. * @returns {*} Returns the property value.
  2804. */
  2805. function getValue(object, key) {
  2806. return object == null ? undefined$1 : object[key];
  2807. }
  2808. /**
  2809. * Checks if `string` contains Unicode symbols.
  2810. *
  2811. * @private
  2812. * @param {string} string The string to inspect.
  2813. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  2814. */
  2815. function hasUnicode(string) {
  2816. return reHasUnicode.test(string);
  2817. }
  2818. /**
  2819. * Checks if `string` contains a word composed of Unicode symbols.
  2820. *
  2821. * @private
  2822. * @param {string} string The string to inspect.
  2823. * @returns {boolean} Returns `true` if a word is found, else `false`.
  2824. */
  2825. function hasUnicodeWord(string) {
  2826. return reHasUnicodeWord.test(string);
  2827. }
  2828. /**
  2829. * Converts `iterator` to an array.
  2830. *
  2831. * @private
  2832. * @param {Object} iterator The iterator to convert.
  2833. * @returns {Array} Returns the converted array.
  2834. */
  2835. function iteratorToArray(iterator) {
  2836. var data,
  2837. result = [];
  2838. while (!(data = iterator.next()).done) {
  2839. result.push(data.value);
  2840. }
  2841. return result;
  2842. }
  2843. /**
  2844. * Converts `map` to its key-value pairs.
  2845. *
  2846. * @private
  2847. * @param {Object} map The map to convert.
  2848. * @returns {Array} Returns the key-value pairs.
  2849. */
  2850. function mapToArray(map) {
  2851. var index = -1,
  2852. result = Array(map.size);
  2853. map.forEach(function(value, key) {
  2854. result[++index] = [key, value];
  2855. });
  2856. return result;
  2857. }
  2858. /**
  2859. * Creates a unary function that invokes `func` with its argument transformed.
  2860. *
  2861. * @private
  2862. * @param {Function} func The function to wrap.
  2863. * @param {Function} transform The argument transform.
  2864. * @returns {Function} Returns the new function.
  2865. */
  2866. function overArg(func, transform) {
  2867. return function(arg) {
  2868. return func(transform(arg));
  2869. };
  2870. }
  2871. /**
  2872. * Replaces all `placeholder` elements in `array` with an internal placeholder
  2873. * and returns an array of their indexes.
  2874. *
  2875. * @private
  2876. * @param {Array} array The array to modify.
  2877. * @param {*} placeholder The placeholder to replace.
  2878. * @returns {Array} Returns the new array of placeholder indexes.
  2879. */
  2880. function replaceHolders(array, placeholder) {
  2881. var index = -1,
  2882. length = array.length,
  2883. resIndex = 0,
  2884. result = [];
  2885. while (++index < length) {
  2886. var value = array[index];
  2887. if (value === placeholder || value === PLACEHOLDER) {
  2888. array[index] = PLACEHOLDER;
  2889. result[resIndex++] = index;
  2890. }
  2891. }
  2892. return result;
  2893. }
  2894. /**
  2895. * Converts `set` to an array of its values.
  2896. *
  2897. * @private
  2898. * @param {Object} set The set to convert.
  2899. * @returns {Array} Returns the values.
  2900. */
  2901. function setToArray(set) {
  2902. var index = -1,
  2903. result = Array(set.size);
  2904. set.forEach(function(value) {
  2905. result[++index] = value;
  2906. });
  2907. return result;
  2908. }
  2909. /**
  2910. * Converts `set` to its value-value pairs.
  2911. *
  2912. * @private
  2913. * @param {Object} set The set to convert.
  2914. * @returns {Array} Returns the value-value pairs.
  2915. */
  2916. function setToPairs(set) {
  2917. var index = -1,
  2918. result = Array(set.size);
  2919. set.forEach(function(value) {
  2920. result[++index] = [value, value];
  2921. });
  2922. return result;
  2923. }
  2924. /**
  2925. * A specialized version of `_.indexOf` which performs strict equality
  2926. * comparisons of values, i.e. `===`.
  2927. *
  2928. * @private
  2929. * @param {Array} array The array to inspect.
  2930. * @param {*} value The value to search for.
  2931. * @param {number} fromIndex The index to search from.
  2932. * @returns {number} Returns the index of the matched value, else `-1`.
  2933. */
  2934. function strictIndexOf(array, value, fromIndex) {
  2935. var index = fromIndex - 1,
  2936. length = array.length;
  2937. while (++index < length) {
  2938. if (array[index] === value) {
  2939. return index;
  2940. }
  2941. }
  2942. return -1;
  2943. }
  2944. /**
  2945. * A specialized version of `_.lastIndexOf` which performs strict equality
  2946. * comparisons of values, i.e. `===`.
  2947. *
  2948. * @private
  2949. * @param {Array} array The array to inspect.
  2950. * @param {*} value The value to search for.
  2951. * @param {number} fromIndex The index to search from.
  2952. * @returns {number} Returns the index of the matched value, else `-1`.
  2953. */
  2954. function strictLastIndexOf(array, value, fromIndex) {
  2955. var index = fromIndex + 1;
  2956. while (index--) {
  2957. if (array[index] === value) {
  2958. return index;
  2959. }
  2960. }
  2961. return index;
  2962. }
  2963. /**
  2964. * Gets the number of symbols in `string`.
  2965. *
  2966. * @private
  2967. * @param {string} string The string to inspect.
  2968. * @returns {number} Returns the string size.
  2969. */
  2970. function stringSize(string) {
  2971. return hasUnicode(string)
  2972. ? unicodeSize(string)
  2973. : asciiSize(string);
  2974. }
  2975. /**
  2976. * Converts `string` to an array.
  2977. *
  2978. * @private
  2979. * @param {string} string The string to convert.
  2980. * @returns {Array} Returns the converted array.
  2981. */
  2982. function stringToArray(string) {
  2983. return hasUnicode(string)
  2984. ? unicodeToArray(string)
  2985. : asciiToArray(string);
  2986. }
  2987. /**
  2988. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  2989. * character of `string`.
  2990. *
  2991. * @private
  2992. * @param {string} string The string to inspect.
  2993. * @returns {number} Returns the index of the last non-whitespace character.
  2994. */
  2995. function trimmedEndIndex(string) {
  2996. var index = string.length;
  2997. while (index-- && reWhitespace.test(string.charAt(index))) {}
  2998. return index;
  2999. }
  3000. /**
  3001. * Used by `_.unescape` to convert HTML entities to characters.
  3002. *
  3003. * @private
  3004. * @param {string} chr The matched character to unescape.
  3005. * @returns {string} Returns the unescaped character.
  3006. */
  3007. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  3008. /**
  3009. * Gets the size of a Unicode `string`.
  3010. *
  3011. * @private
  3012. * @param {string} string The string inspect.
  3013. * @returns {number} Returns the string size.
  3014. */
  3015. function unicodeSize(string) {
  3016. var result = reUnicode.lastIndex = 0;
  3017. while (reUnicode.test(string)) {
  3018. ++result;
  3019. }
  3020. return result;
  3021. }
  3022. /**
  3023. * Converts a Unicode `string` to an array.
  3024. *
  3025. * @private
  3026. * @param {string} string The string to convert.
  3027. * @returns {Array} Returns the converted array.
  3028. */
  3029. function unicodeToArray(string) {
  3030. return string.match(reUnicode) || [];
  3031. }
  3032. /**
  3033. * Splits a Unicode `string` into an array of its words.
  3034. *
  3035. * @private
  3036. * @param {string} The string to inspect.
  3037. * @returns {Array} Returns the words of `string`.
  3038. */
  3039. function unicodeWords(string) {
  3040. return string.match(reUnicodeWord) || [];
  3041. }
  3042. /*--------------------------------------------------------------------------*/
  3043. /**
  3044. * Create a new pristine `lodash` function using the `context` object.
  3045. *
  3046. * @static
  3047. * @memberOf _
  3048. * @since 1.1.0
  3049. * @category Util
  3050. * @param {Object} [context=root] The context object.
  3051. * @returns {Function} Returns a new `lodash` function.
  3052. * @example
  3053. *
  3054. * _.mixin({ 'foo': _.constant('foo') });
  3055. *
  3056. * var lodash = _.runInContext();
  3057. * lodash.mixin({ 'bar': lodash.constant('bar') });
  3058. *
  3059. * _.isFunction(_.foo);
  3060. * // => true
  3061. * _.isFunction(_.bar);
  3062. * // => false
  3063. *
  3064. * lodash.isFunction(lodash.foo);
  3065. * // => false
  3066. * lodash.isFunction(lodash.bar);
  3067. * // => true
  3068. *
  3069. * // Create a suped-up `defer` in Node.js.
  3070. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  3071. */
  3072. var runInContext = (function runInContext(context) {
  3073. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  3074. /** Built-in constructor references. */
  3075. var Array = context.Array,
  3076. Date = context.Date,
  3077. Error = context.Error,
  3078. Function = context.Function,
  3079. Math = context.Math,
  3080. Object = context.Object,
  3081. RegExp = context.RegExp,
  3082. String = context.String,
  3083. TypeError = context.TypeError;
  3084. /** Used for built-in method references. */
  3085. var arrayProto = Array.prototype,
  3086. funcProto = Function.prototype,
  3087. objectProto = Object.prototype;
  3088. /** Used to detect overreaching core-js shims. */
  3089. var coreJsData = context['__core-js_shared__'];
  3090. /** Used to resolve the decompiled source of functions. */
  3091. var funcToString = funcProto.toString;
  3092. /** Used to check objects for own properties. */
  3093. var hasOwnProperty = objectProto.hasOwnProperty;
  3094. /** Used to generate unique IDs. */
  3095. var idCounter = 0;
  3096. /** Used to detect methods masquerading as native. */
  3097. var maskSrcKey = (function() {
  3098. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  3099. return uid ? ('Symbol(src)_1.' + uid) : '';
  3100. }());
  3101. /**
  3102. * Used to resolve the
  3103. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  3104. * of values.
  3105. */
  3106. var nativeObjectToString = objectProto.toString;
  3107. /** Used to infer the `Object` constructor. */
  3108. var objectCtorString = funcToString.call(Object);
  3109. /** Used to restore the original `_` reference in `_.noConflict`. */
  3110. var oldDash = root._;
  3111. /** Used to detect if a method is native. */
  3112. var reIsNative = RegExp('^' +
  3113. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  3114. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  3115. );
  3116. /** Built-in value references. */
  3117. var Buffer = moduleExports ? context.Buffer : undefined$1,
  3118. Symbol = context.Symbol,
  3119. Uint8Array = context.Uint8Array,
  3120. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined$1,
  3121. getPrototype = overArg(Object.getPrototypeOf, Object),
  3122. objectCreate = Object.create,
  3123. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  3124. splice = arrayProto.splice,
  3125. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined$1,
  3126. symIterator = Symbol ? Symbol.iterator : undefined$1,
  3127. symToStringTag = Symbol ? Symbol.toStringTag : undefined$1;
  3128. var defineProperty = (function() {
  3129. try {
  3130. var func = getNative(Object, 'defineProperty');
  3131. func({}, '', {});
  3132. return func;
  3133. } catch (e) {}
  3134. }());
  3135. /** Mocked built-ins. */
  3136. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  3137. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  3138. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  3139. /* Built-in method references for those with the same name as other `lodash` methods. */
  3140. var nativeCeil = Math.ceil,
  3141. nativeFloor = Math.floor,
  3142. nativeGetSymbols = Object.getOwnPropertySymbols,
  3143. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1,
  3144. nativeIsFinite = context.isFinite,
  3145. nativeJoin = arrayProto.join,
  3146. nativeKeys = overArg(Object.keys, Object),
  3147. nativeMax = Math.max,
  3148. nativeMin = Math.min,
  3149. nativeNow = Date.now,
  3150. nativeParseInt = context.parseInt,
  3151. nativeRandom = Math.random,
  3152. nativeReverse = arrayProto.reverse;
  3153. /* Built-in method references that are verified to be native. */
  3154. var DataView = getNative(context, 'DataView'),
  3155. Map = getNative(context, 'Map'),
  3156. Promise = getNative(context, 'Promise'),
  3157. Set = getNative(context, 'Set'),
  3158. WeakMap = getNative(context, 'WeakMap'),
  3159. nativeCreate = getNative(Object, 'create');
  3160. /** Used to store function metadata. */
  3161. var metaMap = WeakMap && new WeakMap;
  3162. /** Used to lookup unminified function names. */
  3163. var realNames = {};
  3164. /** Used to detect maps, sets, and weakmaps. */
  3165. var dataViewCtorString = toSource(DataView),
  3166. mapCtorString = toSource(Map),
  3167. promiseCtorString = toSource(Promise),
  3168. setCtorString = toSource(Set),
  3169. weakMapCtorString = toSource(WeakMap);
  3170. /** Used to convert symbols to primitives and strings. */
  3171. var symbolProto = Symbol ? Symbol.prototype : undefined$1,
  3172. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined$1,
  3173. symbolToString = symbolProto ? symbolProto.toString : undefined$1;
  3174. /*------------------------------------------------------------------------*/
  3175. /**
  3176. * Creates a `lodash` object which wraps `value` to enable implicit method
  3177. * chain sequences. Methods that operate on and return arrays, collections,
  3178. * and functions can be chained together. Methods that retrieve a single value
  3179. * or may return a primitive value will automatically end the chain sequence
  3180. * and return the unwrapped value. Otherwise, the value must be unwrapped
  3181. * with `_#value`.
  3182. *
  3183. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  3184. * enabled using `_.chain`.
  3185. *
  3186. * The execution of chained methods is lazy, that is, it's deferred until
  3187. * `_#value` is implicitly or explicitly called.
  3188. *
  3189. * Lazy evaluation allows several methods to support shortcut fusion.
  3190. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  3191. * the creation of intermediate arrays and can greatly reduce the number of
  3192. * iteratee executions. Sections of a chain sequence qualify for shortcut
  3193. * fusion if the section is applied to an array and iteratees accept only
  3194. * one argument. The heuristic for whether a section qualifies for shortcut
  3195. * fusion is subject to change.
  3196. *
  3197. * Chaining is supported in custom builds as long as the `_#value` method is
  3198. * directly or indirectly included in the build.
  3199. *
  3200. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  3201. *
  3202. * The wrapper `Array` methods are:
  3203. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  3204. *
  3205. * The wrapper `String` methods are:
  3206. * `replace` and `split`
  3207. *
  3208. * The wrapper methods that support shortcut fusion are:
  3209. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  3210. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  3211. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  3212. *
  3213. * The chainable wrapper methods are:
  3214. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  3215. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  3216. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  3217. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  3218. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  3219. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  3220. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  3221. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  3222. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  3223. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  3224. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  3225. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  3226. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  3227. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  3228. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  3229. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  3230. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  3231. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  3232. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  3233. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  3234. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  3235. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  3236. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  3237. * `zipObject`, `zipObjectDeep`, and `zipWith`
  3238. *
  3239. * The wrapper methods that are **not** chainable by default are:
  3240. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  3241. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  3242. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  3243. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  3244. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  3245. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  3246. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  3247. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  3248. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  3249. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  3250. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  3251. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  3252. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  3253. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  3254. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  3255. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  3256. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  3257. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  3258. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  3259. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  3260. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  3261. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  3262. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  3263. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  3264. * `upperFirst`, `value`, and `words`
  3265. *
  3266. * @name _
  3267. * @constructor
  3268. * @category Seq
  3269. * @param {*} value The value to wrap in a `lodash` instance.
  3270. * @returns {Object} Returns the new `lodash` wrapper instance.
  3271. * @example
  3272. *
  3273. * function square(n) {
  3274. * return n * n;
  3275. * }
  3276. *
  3277. * var wrapped = _([1, 2, 3]);
  3278. *
  3279. * // Returns an unwrapped value.
  3280. * wrapped.reduce(_.add);
  3281. * // => 6
  3282. *
  3283. * // Returns a wrapped value.
  3284. * var squares = wrapped.map(square);
  3285. *
  3286. * _.isArray(squares);
  3287. * // => false
  3288. *
  3289. * _.isArray(squares.value());
  3290. * // => true
  3291. */
  3292. function lodash(value) {
  3293. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  3294. if (value instanceof LodashWrapper) {
  3295. return value;
  3296. }
  3297. if (hasOwnProperty.call(value, '__wrapped__')) {
  3298. return wrapperClone(value);
  3299. }
  3300. }
  3301. return new LodashWrapper(value);
  3302. }
  3303. /**
  3304. * The base implementation of `_.create` without support for assigning
  3305. * properties to the created object.
  3306. *
  3307. * @private
  3308. * @param {Object} proto The object to inherit from.
  3309. * @returns {Object} Returns the new object.
  3310. */
  3311. var baseCreate = (function() {
  3312. function object() {}
  3313. return function(proto) {
  3314. if (!isObject(proto)) {
  3315. return {};
  3316. }
  3317. if (objectCreate) {
  3318. return objectCreate(proto);
  3319. }
  3320. object.prototype = proto;
  3321. var result = new object;
  3322. object.prototype = undefined$1;
  3323. return result;
  3324. };
  3325. }());
  3326. /**
  3327. * The function whose prototype chain sequence wrappers inherit from.
  3328. *
  3329. * @private
  3330. */
  3331. function baseLodash() {
  3332. // No operation performed.
  3333. }
  3334. /**
  3335. * The base constructor for creating `lodash` wrapper objects.
  3336. *
  3337. * @private
  3338. * @param {*} value The value to wrap.
  3339. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  3340. */
  3341. function LodashWrapper(value, chainAll) {
  3342. this.__wrapped__ = value;
  3343. this.__actions__ = [];
  3344. this.__chain__ = !!chainAll;
  3345. this.__index__ = 0;
  3346. this.__values__ = undefined$1;
  3347. }
  3348. /**
  3349. * By default, the template delimiters used by lodash are like those in
  3350. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  3351. * following template settings to use alternative delimiters.
  3352. *
  3353. * @static
  3354. * @memberOf _
  3355. * @type {Object}
  3356. */
  3357. lodash.templateSettings = {
  3358. /**
  3359. * Used to detect `data` property values to be HTML-escaped.
  3360. *
  3361. * @memberOf _.templateSettings
  3362. * @type {RegExp}
  3363. */
  3364. 'escape': reEscape,
  3365. /**
  3366. * Used to detect code to be evaluated.
  3367. *
  3368. * @memberOf _.templateSettings
  3369. * @type {RegExp}
  3370. */
  3371. 'evaluate': reEvaluate,
  3372. /**
  3373. * Used to detect `data` property values to inject.
  3374. *
  3375. * @memberOf _.templateSettings
  3376. * @type {RegExp}
  3377. */
  3378. 'interpolate': reInterpolate,
  3379. /**
  3380. * Used to reference the data object in the template text.
  3381. *
  3382. * @memberOf _.templateSettings
  3383. * @type {string}
  3384. */
  3385. 'variable': '',
  3386. /**
  3387. * Used to import variables into the compiled template.
  3388. *
  3389. * @memberOf _.templateSettings
  3390. * @type {Object}
  3391. */
  3392. 'imports': {
  3393. /**
  3394. * A reference to the `lodash` function.
  3395. *
  3396. * @memberOf _.templateSettings.imports
  3397. * @type {Function}
  3398. */
  3399. '_': lodash
  3400. }
  3401. };
  3402. // Ensure wrappers are instances of `baseLodash`.
  3403. lodash.prototype = baseLodash.prototype;
  3404. lodash.prototype.constructor = lodash;
  3405. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  3406. LodashWrapper.prototype.constructor = LodashWrapper;
  3407. /*------------------------------------------------------------------------*/
  3408. /**
  3409. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  3410. *
  3411. * @private
  3412. * @constructor
  3413. * @param {*} value The value to wrap.
  3414. */
  3415. function LazyWrapper(value) {
  3416. this.__wrapped__ = value;
  3417. this.__actions__ = [];
  3418. this.__dir__ = 1;
  3419. this.__filtered__ = false;
  3420. this.__iteratees__ = [];
  3421. this.__takeCount__ = MAX_ARRAY_LENGTH;
  3422. this.__views__ = [];
  3423. }
  3424. /**
  3425. * Creates a clone of the lazy wrapper object.
  3426. *
  3427. * @private
  3428. * @name clone
  3429. * @memberOf LazyWrapper
  3430. * @returns {Object} Returns the cloned `LazyWrapper` object.
  3431. */
  3432. function lazyClone() {
  3433. var result = new LazyWrapper(this.__wrapped__);
  3434. result.__actions__ = copyArray(this.__actions__);
  3435. result.__dir__ = this.__dir__;
  3436. result.__filtered__ = this.__filtered__;
  3437. result.__iteratees__ = copyArray(this.__iteratees__);
  3438. result.__takeCount__ = this.__takeCount__;
  3439. result.__views__ = copyArray(this.__views__);
  3440. return result;
  3441. }
  3442. /**
  3443. * Reverses the direction of lazy iteration.
  3444. *
  3445. * @private
  3446. * @name reverse
  3447. * @memberOf LazyWrapper
  3448. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  3449. */
  3450. function lazyReverse() {
  3451. if (this.__filtered__) {
  3452. var result = new LazyWrapper(this);
  3453. result.__dir__ = -1;
  3454. result.__filtered__ = true;
  3455. } else {
  3456. result = this.clone();
  3457. result.__dir__ *= -1;
  3458. }
  3459. return result;
  3460. }
  3461. /**
  3462. * Extracts the unwrapped value from its lazy wrapper.
  3463. *
  3464. * @private
  3465. * @name value
  3466. * @memberOf LazyWrapper
  3467. * @returns {*} Returns the unwrapped value.
  3468. */
  3469. function lazyValue() {
  3470. var array = this.__wrapped__.value(),
  3471. dir = this.__dir__,
  3472. isArr = isArray(array),
  3473. isRight = dir < 0,
  3474. arrLength = isArr ? array.length : 0,
  3475. view = getView(0, arrLength, this.__views__),
  3476. start = view.start,
  3477. end = view.end,
  3478. length = end - start,
  3479. index = isRight ? end : (start - 1),
  3480. iteratees = this.__iteratees__,
  3481. iterLength = iteratees.length,
  3482. resIndex = 0,
  3483. takeCount = nativeMin(length, this.__takeCount__);
  3484. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  3485. return baseWrapperValue(array, this.__actions__);
  3486. }
  3487. var result = [];
  3488. outer:
  3489. while (length-- && resIndex < takeCount) {
  3490. index += dir;
  3491. var iterIndex = -1,
  3492. value = array[index];
  3493. while (++iterIndex < iterLength) {
  3494. var data = iteratees[iterIndex],
  3495. iteratee = data.iteratee,
  3496. type = data.type,
  3497. computed = iteratee(value);
  3498. if (type == LAZY_MAP_FLAG) {
  3499. value = computed;
  3500. } else if (!computed) {
  3501. if (type == LAZY_FILTER_FLAG) {
  3502. continue outer;
  3503. } else {
  3504. break outer;
  3505. }
  3506. }
  3507. }
  3508. result[resIndex++] = value;
  3509. }
  3510. return result;
  3511. }
  3512. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  3513. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  3514. LazyWrapper.prototype.constructor = LazyWrapper;
  3515. /*------------------------------------------------------------------------*/
  3516. /**
  3517. * Creates a hash object.
  3518. *
  3519. * @private
  3520. * @constructor
  3521. * @param {Array} [entries] The key-value pairs to cache.
  3522. */
  3523. function Hash(entries) {
  3524. var index = -1,
  3525. length = entries == null ? 0 : entries.length;
  3526. this.clear();
  3527. while (++index < length) {
  3528. var entry = entries[index];
  3529. this.set(entry[0], entry[1]);
  3530. }
  3531. }
  3532. /**
  3533. * Removes all key-value entries from the hash.
  3534. *
  3535. * @private
  3536. * @name clear
  3537. * @memberOf Hash
  3538. */
  3539. function hashClear() {
  3540. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  3541. this.size = 0;
  3542. }
  3543. /**
  3544. * Removes `key` and its value from the hash.
  3545. *
  3546. * @private
  3547. * @name delete
  3548. * @memberOf Hash
  3549. * @param {Object} hash The hash to modify.
  3550. * @param {string} key The key of the value to remove.
  3551. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3552. */
  3553. function hashDelete(key) {
  3554. var result = this.has(key) && delete this.__data__[key];
  3555. this.size -= result ? 1 : 0;
  3556. return result;
  3557. }
  3558. /**
  3559. * Gets the hash value for `key`.
  3560. *
  3561. * @private
  3562. * @name get
  3563. * @memberOf Hash
  3564. * @param {string} key The key of the value to get.
  3565. * @returns {*} Returns the entry value.
  3566. */
  3567. function hashGet(key) {
  3568. var data = this.__data__;
  3569. if (nativeCreate) {
  3570. var result = data[key];
  3571. return result === HASH_UNDEFINED ? undefined$1 : result;
  3572. }
  3573. return hasOwnProperty.call(data, key) ? data[key] : undefined$1;
  3574. }
  3575. /**
  3576. * Checks if a hash value for `key` exists.
  3577. *
  3578. * @private
  3579. * @name has
  3580. * @memberOf Hash
  3581. * @param {string} key The key of the entry to check.
  3582. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3583. */
  3584. function hashHas(key) {
  3585. var data = this.__data__;
  3586. return nativeCreate ? (data[key] !== undefined$1) : hasOwnProperty.call(data, key);
  3587. }
  3588. /**
  3589. * Sets the hash `key` to `value`.
  3590. *
  3591. * @private
  3592. * @name set
  3593. * @memberOf Hash
  3594. * @param {string} key The key of the value to set.
  3595. * @param {*} value The value to set.
  3596. * @returns {Object} Returns the hash instance.
  3597. */
  3598. function hashSet(key, value) {
  3599. var data = this.__data__;
  3600. this.size += this.has(key) ? 0 : 1;
  3601. data[key] = (nativeCreate && value === undefined$1) ? HASH_UNDEFINED : value;
  3602. return this;
  3603. }
  3604. // Add methods to `Hash`.
  3605. Hash.prototype.clear = hashClear;
  3606. Hash.prototype['delete'] = hashDelete;
  3607. Hash.prototype.get = hashGet;
  3608. Hash.prototype.has = hashHas;
  3609. Hash.prototype.set = hashSet;
  3610. /*------------------------------------------------------------------------*/
  3611. /**
  3612. * Creates an list cache object.
  3613. *
  3614. * @private
  3615. * @constructor
  3616. * @param {Array} [entries] The key-value pairs to cache.
  3617. */
  3618. function ListCache(entries) {
  3619. var index = -1,
  3620. length = entries == null ? 0 : entries.length;
  3621. this.clear();
  3622. while (++index < length) {
  3623. var entry = entries[index];
  3624. this.set(entry[0], entry[1]);
  3625. }
  3626. }
  3627. /**
  3628. * Removes all key-value entries from the list cache.
  3629. *
  3630. * @private
  3631. * @name clear
  3632. * @memberOf ListCache
  3633. */
  3634. function listCacheClear() {
  3635. this.__data__ = [];
  3636. this.size = 0;
  3637. }
  3638. /**
  3639. * Removes `key` and its value from the list cache.
  3640. *
  3641. * @private
  3642. * @name delete
  3643. * @memberOf ListCache
  3644. * @param {string} key The key of the value to remove.
  3645. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3646. */
  3647. function listCacheDelete(key) {
  3648. var data = this.__data__,
  3649. index = assocIndexOf(data, key);
  3650. if (index < 0) {
  3651. return false;
  3652. }
  3653. var lastIndex = data.length - 1;
  3654. if (index == lastIndex) {
  3655. data.pop();
  3656. } else {
  3657. splice.call(data, index, 1);
  3658. }
  3659. --this.size;
  3660. return true;
  3661. }
  3662. /**
  3663. * Gets the list cache value for `key`.
  3664. *
  3665. * @private
  3666. * @name get
  3667. * @memberOf ListCache
  3668. * @param {string} key The key of the value to get.
  3669. * @returns {*} Returns the entry value.
  3670. */
  3671. function listCacheGet(key) {
  3672. var data = this.__data__,
  3673. index = assocIndexOf(data, key);
  3674. return index < 0 ? undefined$1 : data[index][1];
  3675. }
  3676. /**
  3677. * Checks if a list cache value for `key` exists.
  3678. *
  3679. * @private
  3680. * @name has
  3681. * @memberOf ListCache
  3682. * @param {string} key The key of the entry to check.
  3683. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3684. */
  3685. function listCacheHas(key) {
  3686. return assocIndexOf(this.__data__, key) > -1;
  3687. }
  3688. /**
  3689. * Sets the list cache `key` to `value`.
  3690. *
  3691. * @private
  3692. * @name set
  3693. * @memberOf ListCache
  3694. * @param {string} key The key of the value to set.
  3695. * @param {*} value The value to set.
  3696. * @returns {Object} Returns the list cache instance.
  3697. */
  3698. function listCacheSet(key, value) {
  3699. var data = this.__data__,
  3700. index = assocIndexOf(data, key);
  3701. if (index < 0) {
  3702. ++this.size;
  3703. data.push([key, value]);
  3704. } else {
  3705. data[index][1] = value;
  3706. }
  3707. return this;
  3708. }
  3709. // Add methods to `ListCache`.
  3710. ListCache.prototype.clear = listCacheClear;
  3711. ListCache.prototype['delete'] = listCacheDelete;
  3712. ListCache.prototype.get = listCacheGet;
  3713. ListCache.prototype.has = listCacheHas;
  3714. ListCache.prototype.set = listCacheSet;
  3715. /*------------------------------------------------------------------------*/
  3716. /**
  3717. * Creates a map cache object to store key-value pairs.
  3718. *
  3719. * @private
  3720. * @constructor
  3721. * @param {Array} [entries] The key-value pairs to cache.
  3722. */
  3723. function MapCache(entries) {
  3724. var index = -1,
  3725. length = entries == null ? 0 : entries.length;
  3726. this.clear();
  3727. while (++index < length) {
  3728. var entry = entries[index];
  3729. this.set(entry[0], entry[1]);
  3730. }
  3731. }
  3732. /**
  3733. * Removes all key-value entries from the map.
  3734. *
  3735. * @private
  3736. * @name clear
  3737. * @memberOf MapCache
  3738. */
  3739. function mapCacheClear() {
  3740. this.size = 0;
  3741. this.__data__ = {
  3742. 'hash': new Hash,
  3743. 'map': new (Map || ListCache),
  3744. 'string': new Hash
  3745. };
  3746. }
  3747. /**
  3748. * Removes `key` and its value from the map.
  3749. *
  3750. * @private
  3751. * @name delete
  3752. * @memberOf MapCache
  3753. * @param {string} key The key of the value to remove.
  3754. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3755. */
  3756. function mapCacheDelete(key) {
  3757. var result = getMapData(this, key)['delete'](key);
  3758. this.size -= result ? 1 : 0;
  3759. return result;
  3760. }
  3761. /**
  3762. * Gets the map value for `key`.
  3763. *
  3764. * @private
  3765. * @name get
  3766. * @memberOf MapCache
  3767. * @param {string} key The key of the value to get.
  3768. * @returns {*} Returns the entry value.
  3769. */
  3770. function mapCacheGet(key) {
  3771. return getMapData(this, key).get(key);
  3772. }
  3773. /**
  3774. * Checks if a map value for `key` exists.
  3775. *
  3776. * @private
  3777. * @name has
  3778. * @memberOf MapCache
  3779. * @param {string} key The key of the entry to check.
  3780. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3781. */
  3782. function mapCacheHas(key) {
  3783. return getMapData(this, key).has(key);
  3784. }
  3785. /**
  3786. * Sets the map `key` to `value`.
  3787. *
  3788. * @private
  3789. * @name set
  3790. * @memberOf MapCache
  3791. * @param {string} key The key of the value to set.
  3792. * @param {*} value The value to set.
  3793. * @returns {Object} Returns the map cache instance.
  3794. */
  3795. function mapCacheSet(key, value) {
  3796. var data = getMapData(this, key),
  3797. size = data.size;
  3798. data.set(key, value);
  3799. this.size += data.size == size ? 0 : 1;
  3800. return this;
  3801. }
  3802. // Add methods to `MapCache`.
  3803. MapCache.prototype.clear = mapCacheClear;
  3804. MapCache.prototype['delete'] = mapCacheDelete;
  3805. MapCache.prototype.get = mapCacheGet;
  3806. MapCache.prototype.has = mapCacheHas;
  3807. MapCache.prototype.set = mapCacheSet;
  3808. /*------------------------------------------------------------------------*/
  3809. /**
  3810. *
  3811. * Creates an array cache object to store unique values.
  3812. *
  3813. * @private
  3814. * @constructor
  3815. * @param {Array} [values] The values to cache.
  3816. */
  3817. function SetCache(values) {
  3818. var index = -1,
  3819. length = values == null ? 0 : values.length;
  3820. this.__data__ = new MapCache;
  3821. while (++index < length) {
  3822. this.add(values[index]);
  3823. }
  3824. }
  3825. /**
  3826. * Adds `value` to the array cache.
  3827. *
  3828. * @private
  3829. * @name add
  3830. * @memberOf SetCache
  3831. * @alias push
  3832. * @param {*} value The value to cache.
  3833. * @returns {Object} Returns the cache instance.
  3834. */
  3835. function setCacheAdd(value) {
  3836. this.__data__.set(value, HASH_UNDEFINED);
  3837. return this;
  3838. }
  3839. /**
  3840. * Checks if `value` is in the array cache.
  3841. *
  3842. * @private
  3843. * @name has
  3844. * @memberOf SetCache
  3845. * @param {*} value The value to search for.
  3846. * @returns {number} Returns `true` if `value` is found, else `false`.
  3847. */
  3848. function setCacheHas(value) {
  3849. return this.__data__.has(value);
  3850. }
  3851. // Add methods to `SetCache`.
  3852. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  3853. SetCache.prototype.has = setCacheHas;
  3854. /*------------------------------------------------------------------------*/
  3855. /**
  3856. * Creates a stack cache object to store key-value pairs.
  3857. *
  3858. * @private
  3859. * @constructor
  3860. * @param {Array} [entries] The key-value pairs to cache.
  3861. */
  3862. function Stack(entries) {
  3863. var data = this.__data__ = new ListCache(entries);
  3864. this.size = data.size;
  3865. }
  3866. /**
  3867. * Removes all key-value entries from the stack.
  3868. *
  3869. * @private
  3870. * @name clear
  3871. * @memberOf Stack
  3872. */
  3873. function stackClear() {
  3874. this.__data__ = new ListCache;
  3875. this.size = 0;
  3876. }
  3877. /**
  3878. * Removes `key` and its value from the stack.
  3879. *
  3880. * @private
  3881. * @name delete
  3882. * @memberOf Stack
  3883. * @param {string} key The key of the value to remove.
  3884. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3885. */
  3886. function stackDelete(key) {
  3887. var data = this.__data__,
  3888. result = data['delete'](key);
  3889. this.size = data.size;
  3890. return result;
  3891. }
  3892. /**
  3893. * Gets the stack value for `key`.
  3894. *
  3895. * @private
  3896. * @name get
  3897. * @memberOf Stack
  3898. * @param {string} key The key of the value to get.
  3899. * @returns {*} Returns the entry value.
  3900. */
  3901. function stackGet(key) {
  3902. return this.__data__.get(key);
  3903. }
  3904. /**
  3905. * Checks if a stack value for `key` exists.
  3906. *
  3907. * @private
  3908. * @name has
  3909. * @memberOf Stack
  3910. * @param {string} key The key of the entry to check.
  3911. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3912. */
  3913. function stackHas(key) {
  3914. return this.__data__.has(key);
  3915. }
  3916. /**
  3917. * Sets the stack `key` to `value`.
  3918. *
  3919. * @private
  3920. * @name set
  3921. * @memberOf Stack
  3922. * @param {string} key The key of the value to set.
  3923. * @param {*} value The value to set.
  3924. * @returns {Object} Returns the stack cache instance.
  3925. */
  3926. function stackSet(key, value) {
  3927. var data = this.__data__;
  3928. if (data instanceof ListCache) {
  3929. var pairs = data.__data__;
  3930. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3931. pairs.push([key, value]);
  3932. this.size = ++data.size;
  3933. return this;
  3934. }
  3935. data = this.__data__ = new MapCache(pairs);
  3936. }
  3937. data.set(key, value);
  3938. this.size = data.size;
  3939. return this;
  3940. }
  3941. // Add methods to `Stack`.
  3942. Stack.prototype.clear = stackClear;
  3943. Stack.prototype['delete'] = stackDelete;
  3944. Stack.prototype.get = stackGet;
  3945. Stack.prototype.has = stackHas;
  3946. Stack.prototype.set = stackSet;
  3947. /*------------------------------------------------------------------------*/
  3948. /**
  3949. * Creates an array of the enumerable property names of the array-like `value`.
  3950. *
  3951. * @private
  3952. * @param {*} value The value to query.
  3953. * @param {boolean} inherited Specify returning inherited property names.
  3954. * @returns {Array} Returns the array of property names.
  3955. */
  3956. function arrayLikeKeys(value, inherited) {
  3957. var isArr = isArray(value),
  3958. isArg = !isArr && isArguments(value),
  3959. isBuff = !isArr && !isArg && isBuffer(value),
  3960. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  3961. skipIndexes = isArr || isArg || isBuff || isType,
  3962. result = skipIndexes ? baseTimes(value.length, String) : [],
  3963. length = result.length;
  3964. for (var key in value) {
  3965. if ((inherited || hasOwnProperty.call(value, key)) &&
  3966. !(skipIndexes && (
  3967. // Safari 9 has enumerable `arguments.length` in strict mode.
  3968. key == 'length' ||
  3969. // Node.js 0.10 has enumerable non-index properties on buffers.
  3970. (isBuff && (key == 'offset' || key == 'parent')) ||
  3971. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3972. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3973. // Skip index properties.
  3974. isIndex(key, length)
  3975. ))) {
  3976. result.push(key);
  3977. }
  3978. }
  3979. return result;
  3980. }
  3981. /**
  3982. * A specialized version of `_.sample` for arrays.
  3983. *
  3984. * @private
  3985. * @param {Array} array The array to sample.
  3986. * @returns {*} Returns the random element.
  3987. */
  3988. function arraySample(array) {
  3989. var length = array.length;
  3990. return length ? array[baseRandom(0, length - 1)] : undefined$1;
  3991. }
  3992. /**
  3993. * A specialized version of `_.sampleSize` for arrays.
  3994. *
  3995. * @private
  3996. * @param {Array} array The array to sample.
  3997. * @param {number} n The number of elements to sample.
  3998. * @returns {Array} Returns the random elements.
  3999. */
  4000. function arraySampleSize(array, n) {
  4001. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  4002. }
  4003. /**
  4004. * A specialized version of `_.shuffle` for arrays.
  4005. *
  4006. * @private
  4007. * @param {Array} array The array to shuffle.
  4008. * @returns {Array} Returns the new shuffled array.
  4009. */
  4010. function arrayShuffle(array) {
  4011. return shuffleSelf(copyArray(array));
  4012. }
  4013. /**
  4014. * This function is like `assignValue` except that it doesn't assign
  4015. * `undefined` values.
  4016. *
  4017. * @private
  4018. * @param {Object} object The object to modify.
  4019. * @param {string} key The key of the property to assign.
  4020. * @param {*} value The value to assign.
  4021. */
  4022. function assignMergeValue(object, key, value) {
  4023. if ((value !== undefined$1 && !eq(object[key], value)) ||
  4024. (value === undefined$1 && !(key in object))) {
  4025. baseAssignValue(object, key, value);
  4026. }
  4027. }
  4028. /**
  4029. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  4030. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  4031. * for equality comparisons.
  4032. *
  4033. * @private
  4034. * @param {Object} object The object to modify.
  4035. * @param {string} key The key of the property to assign.
  4036. * @param {*} value The value to assign.
  4037. */
  4038. function assignValue(object, key, value) {
  4039. var objValue = object[key];
  4040. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  4041. (value === undefined$1 && !(key in object))) {
  4042. baseAssignValue(object, key, value);
  4043. }
  4044. }
  4045. /**
  4046. * Gets the index at which the `key` is found in `array` of key-value pairs.
  4047. *
  4048. * @private
  4049. * @param {Array} array The array to inspect.
  4050. * @param {*} key The key to search for.
  4051. * @returns {number} Returns the index of the matched value, else `-1`.
  4052. */
  4053. function assocIndexOf(array, key) {
  4054. var length = array.length;
  4055. while (length--) {
  4056. if (eq(array[length][0], key)) {
  4057. return length;
  4058. }
  4059. }
  4060. return -1;
  4061. }
  4062. /**
  4063. * Aggregates elements of `collection` on `accumulator` with keys transformed
  4064. * by `iteratee` and values set by `setter`.
  4065. *
  4066. * @private
  4067. * @param {Array|Object} collection The collection to iterate over.
  4068. * @param {Function} setter The function to set `accumulator` values.
  4069. * @param {Function} iteratee The iteratee to transform keys.
  4070. * @param {Object} accumulator The initial aggregated object.
  4071. * @returns {Function} Returns `accumulator`.
  4072. */
  4073. function baseAggregator(collection, setter, iteratee, accumulator) {
  4074. baseEach(collection, function(value, key, collection) {
  4075. setter(accumulator, value, iteratee(value), collection);
  4076. });
  4077. return accumulator;
  4078. }
  4079. /**
  4080. * The base implementation of `_.assign` without support for multiple sources
  4081. * or `customizer` functions.
  4082. *
  4083. * @private
  4084. * @param {Object} object The destination object.
  4085. * @param {Object} source The source object.
  4086. * @returns {Object} Returns `object`.
  4087. */
  4088. function baseAssign(object, source) {
  4089. return object && copyObject(source, keys(source), object);
  4090. }
  4091. /**
  4092. * The base implementation of `_.assignIn` without support for multiple sources
  4093. * or `customizer` functions.
  4094. *
  4095. * @private
  4096. * @param {Object} object The destination object.
  4097. * @param {Object} source The source object.
  4098. * @returns {Object} Returns `object`.
  4099. */
  4100. function baseAssignIn(object, source) {
  4101. return object && copyObject(source, keysIn(source), object);
  4102. }
  4103. /**
  4104. * The base implementation of `assignValue` and `assignMergeValue` without
  4105. * value checks.
  4106. *
  4107. * @private
  4108. * @param {Object} object The object to modify.
  4109. * @param {string} key The key of the property to assign.
  4110. * @param {*} value The value to assign.
  4111. */
  4112. function baseAssignValue(object, key, value) {
  4113. if (key == '__proto__' && defineProperty) {
  4114. defineProperty(object, key, {
  4115. 'configurable': true,
  4116. 'enumerable': true,
  4117. 'value': value,
  4118. 'writable': true
  4119. });
  4120. } else {
  4121. object[key] = value;
  4122. }
  4123. }
  4124. /**
  4125. * The base implementation of `_.at` without support for individual paths.
  4126. *
  4127. * @private
  4128. * @param {Object} object The object to iterate over.
  4129. * @param {string[]} paths The property paths to pick.
  4130. * @returns {Array} Returns the picked elements.
  4131. */
  4132. function baseAt(object, paths) {
  4133. var index = -1,
  4134. length = paths.length,
  4135. result = Array(length),
  4136. skip = object == null;
  4137. while (++index < length) {
  4138. result[index] = skip ? undefined$1 : get(object, paths[index]);
  4139. }
  4140. return result;
  4141. }
  4142. /**
  4143. * The base implementation of `_.clamp` which doesn't coerce arguments.
  4144. *
  4145. * @private
  4146. * @param {number} number The number to clamp.
  4147. * @param {number} [lower] The lower bound.
  4148. * @param {number} upper The upper bound.
  4149. * @returns {number} Returns the clamped number.
  4150. */
  4151. function baseClamp(number, lower, upper) {
  4152. if (number === number) {
  4153. if (upper !== undefined$1) {
  4154. number = number <= upper ? number : upper;
  4155. }
  4156. if (lower !== undefined$1) {
  4157. number = number >= lower ? number : lower;
  4158. }
  4159. }
  4160. return number;
  4161. }
  4162. /**
  4163. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  4164. * traversed objects.
  4165. *
  4166. * @private
  4167. * @param {*} value The value to clone.
  4168. * @param {boolean} bitmask The bitmask flags.
  4169. * 1 - Deep clone
  4170. * 2 - Flatten inherited properties
  4171. * 4 - Clone symbols
  4172. * @param {Function} [customizer] The function to customize cloning.
  4173. * @param {string} [key] The key of `value`.
  4174. * @param {Object} [object] The parent object of `value`.
  4175. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  4176. * @returns {*} Returns the cloned value.
  4177. */
  4178. function baseClone(value, bitmask, customizer, key, object, stack) {
  4179. var result,
  4180. isDeep = bitmask & CLONE_DEEP_FLAG,
  4181. isFlat = bitmask & CLONE_FLAT_FLAG,
  4182. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  4183. if (customizer) {
  4184. result = object ? customizer(value, key, object, stack) : customizer(value);
  4185. }
  4186. if (result !== undefined$1) {
  4187. return result;
  4188. }
  4189. if (!isObject(value)) {
  4190. return value;
  4191. }
  4192. var isArr = isArray(value);
  4193. if (isArr) {
  4194. result = initCloneArray(value);
  4195. if (!isDeep) {
  4196. return copyArray(value, result);
  4197. }
  4198. } else {
  4199. var tag = getTag(value),
  4200. isFunc = tag == funcTag || tag == genTag;
  4201. if (isBuffer(value)) {
  4202. return cloneBuffer(value, isDeep);
  4203. }
  4204. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  4205. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  4206. if (!isDeep) {
  4207. return isFlat
  4208. ? copySymbolsIn(value, baseAssignIn(result, value))
  4209. : copySymbols(value, baseAssign(result, value));
  4210. }
  4211. } else {
  4212. if (!cloneableTags[tag]) {
  4213. return object ? value : {};
  4214. }
  4215. result = initCloneByTag(value, tag, isDeep);
  4216. }
  4217. }
  4218. // Check for circular references and return its corresponding clone.
  4219. stack || (stack = new Stack);
  4220. var stacked = stack.get(value);
  4221. if (stacked) {
  4222. return stacked;
  4223. }
  4224. stack.set(value, result);
  4225. if (isSet(value)) {
  4226. value.forEach(function(subValue) {
  4227. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  4228. });
  4229. } else if (isMap(value)) {
  4230. value.forEach(function(subValue, key) {
  4231. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4232. });
  4233. }
  4234. var keysFunc = isFull
  4235. ? (isFlat ? getAllKeysIn : getAllKeys)
  4236. : (isFlat ? keysIn : keys);
  4237. var props = isArr ? undefined$1 : keysFunc(value);
  4238. arrayEach(props || value, function(subValue, key) {
  4239. if (props) {
  4240. key = subValue;
  4241. subValue = value[key];
  4242. }
  4243. // Recursively populate clone (susceptible to call stack limits).
  4244. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4245. });
  4246. return result;
  4247. }
  4248. /**
  4249. * The base implementation of `_.conforms` which doesn't clone `source`.
  4250. *
  4251. * @private
  4252. * @param {Object} source The object of property predicates to conform to.
  4253. * @returns {Function} Returns the new spec function.
  4254. */
  4255. function baseConforms(source) {
  4256. var props = keys(source);
  4257. return function(object) {
  4258. return baseConformsTo(object, source, props);
  4259. };
  4260. }
  4261. /**
  4262. * The base implementation of `_.conformsTo` which accepts `props` to check.
  4263. *
  4264. * @private
  4265. * @param {Object} object The object to inspect.
  4266. * @param {Object} source The object of property predicates to conform to.
  4267. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  4268. */
  4269. function baseConformsTo(object, source, props) {
  4270. var length = props.length;
  4271. if (object == null) {
  4272. return !length;
  4273. }
  4274. object = Object(object);
  4275. while (length--) {
  4276. var key = props[length],
  4277. predicate = source[key],
  4278. value = object[key];
  4279. if ((value === undefined$1 && !(key in object)) || !predicate(value)) {
  4280. return false;
  4281. }
  4282. }
  4283. return true;
  4284. }
  4285. /**
  4286. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  4287. * to provide to `func`.
  4288. *
  4289. * @private
  4290. * @param {Function} func The function to delay.
  4291. * @param {number} wait The number of milliseconds to delay invocation.
  4292. * @param {Array} args The arguments to provide to `func`.
  4293. * @returns {number|Object} Returns the timer id or timeout object.
  4294. */
  4295. function baseDelay(func, wait, args) {
  4296. if (typeof func != 'function') {
  4297. throw new TypeError(FUNC_ERROR_TEXT);
  4298. }
  4299. return setTimeout(function() { func.apply(undefined$1, args); }, wait);
  4300. }
  4301. /**
  4302. * The base implementation of methods like `_.difference` without support
  4303. * for excluding multiple arrays or iteratee shorthands.
  4304. *
  4305. * @private
  4306. * @param {Array} array The array to inspect.
  4307. * @param {Array} values The values to exclude.
  4308. * @param {Function} [iteratee] The iteratee invoked per element.
  4309. * @param {Function} [comparator] The comparator invoked per element.
  4310. * @returns {Array} Returns the new array of filtered values.
  4311. */
  4312. function baseDifference(array, values, iteratee, comparator) {
  4313. var index = -1,
  4314. includes = arrayIncludes,
  4315. isCommon = true,
  4316. length = array.length,
  4317. result = [],
  4318. valuesLength = values.length;
  4319. if (!length) {
  4320. return result;
  4321. }
  4322. if (iteratee) {
  4323. values = arrayMap(values, baseUnary(iteratee));
  4324. }
  4325. if (comparator) {
  4326. includes = arrayIncludesWith;
  4327. isCommon = false;
  4328. }
  4329. else if (values.length >= LARGE_ARRAY_SIZE) {
  4330. includes = cacheHas;
  4331. isCommon = false;
  4332. values = new SetCache(values);
  4333. }
  4334. outer:
  4335. while (++index < length) {
  4336. var value = array[index],
  4337. computed = iteratee == null ? value : iteratee(value);
  4338. value = (comparator || value !== 0) ? value : 0;
  4339. if (isCommon && computed === computed) {
  4340. var valuesIndex = valuesLength;
  4341. while (valuesIndex--) {
  4342. if (values[valuesIndex] === computed) {
  4343. continue outer;
  4344. }
  4345. }
  4346. result.push(value);
  4347. }
  4348. else if (!includes(values, computed, comparator)) {
  4349. result.push(value);
  4350. }
  4351. }
  4352. return result;
  4353. }
  4354. /**
  4355. * The base implementation of `_.forEach` without support for iteratee shorthands.
  4356. *
  4357. * @private
  4358. * @param {Array|Object} collection The collection to iterate over.
  4359. * @param {Function} iteratee The function invoked per iteration.
  4360. * @returns {Array|Object} Returns `collection`.
  4361. */
  4362. var baseEach = createBaseEach(baseForOwn);
  4363. /**
  4364. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  4365. *
  4366. * @private
  4367. * @param {Array|Object} collection The collection to iterate over.
  4368. * @param {Function} iteratee The function invoked per iteration.
  4369. * @returns {Array|Object} Returns `collection`.
  4370. */
  4371. var baseEachRight = createBaseEach(baseForOwnRight, true);
  4372. /**
  4373. * The base implementation of `_.every` without support for iteratee shorthands.
  4374. *
  4375. * @private
  4376. * @param {Array|Object} collection The collection to iterate over.
  4377. * @param {Function} predicate The function invoked per iteration.
  4378. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  4379. * else `false`
  4380. */
  4381. function baseEvery(collection, predicate) {
  4382. var result = true;
  4383. baseEach(collection, function(value, index, collection) {
  4384. result = !!predicate(value, index, collection);
  4385. return result;
  4386. });
  4387. return result;
  4388. }
  4389. /**
  4390. * The base implementation of methods like `_.max` and `_.min` which accepts a
  4391. * `comparator` to determine the extremum value.
  4392. *
  4393. * @private
  4394. * @param {Array} array The array to iterate over.
  4395. * @param {Function} iteratee The iteratee invoked per iteration.
  4396. * @param {Function} comparator The comparator used to compare values.
  4397. * @returns {*} Returns the extremum value.
  4398. */
  4399. function baseExtremum(array, iteratee, comparator) {
  4400. var index = -1,
  4401. length = array.length;
  4402. while (++index < length) {
  4403. var value = array[index],
  4404. current = iteratee(value);
  4405. if (current != null && (computed === undefined$1
  4406. ? (current === current && !isSymbol(current))
  4407. : comparator(current, computed)
  4408. )) {
  4409. var computed = current,
  4410. result = value;
  4411. }
  4412. }
  4413. return result;
  4414. }
  4415. /**
  4416. * The base implementation of `_.fill` without an iteratee call guard.
  4417. *
  4418. * @private
  4419. * @param {Array} array The array to fill.
  4420. * @param {*} value The value to fill `array` with.
  4421. * @param {number} [start=0] The start position.
  4422. * @param {number} [end=array.length] The end position.
  4423. * @returns {Array} Returns `array`.
  4424. */
  4425. function baseFill(array, value, start, end) {
  4426. var length = array.length;
  4427. start = toInteger(start);
  4428. if (start < 0) {
  4429. start = -start > length ? 0 : (length + start);
  4430. }
  4431. end = (end === undefined$1 || end > length) ? length : toInteger(end);
  4432. if (end < 0) {
  4433. end += length;
  4434. }
  4435. end = start > end ? 0 : toLength(end);
  4436. while (start < end) {
  4437. array[start++] = value;
  4438. }
  4439. return array;
  4440. }
  4441. /**
  4442. * The base implementation of `_.filter` without support for iteratee shorthands.
  4443. *
  4444. * @private
  4445. * @param {Array|Object} collection The collection to iterate over.
  4446. * @param {Function} predicate The function invoked per iteration.
  4447. * @returns {Array} Returns the new filtered array.
  4448. */
  4449. function baseFilter(collection, predicate) {
  4450. var result = [];
  4451. baseEach(collection, function(value, index, collection) {
  4452. if (predicate(value, index, collection)) {
  4453. result.push(value);
  4454. }
  4455. });
  4456. return result;
  4457. }
  4458. /**
  4459. * The base implementation of `_.flatten` with support for restricting flattening.
  4460. *
  4461. * @private
  4462. * @param {Array} array The array to flatten.
  4463. * @param {number} depth The maximum recursion depth.
  4464. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  4465. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  4466. * @param {Array} [result=[]] The initial result value.
  4467. * @returns {Array} Returns the new flattened array.
  4468. */
  4469. function baseFlatten(array, depth, predicate, isStrict, result) {
  4470. var index = -1,
  4471. length = array.length;
  4472. predicate || (predicate = isFlattenable);
  4473. result || (result = []);
  4474. while (++index < length) {
  4475. var value = array[index];
  4476. if (depth > 0 && predicate(value)) {
  4477. if (depth > 1) {
  4478. // Recursively flatten arrays (susceptible to call stack limits).
  4479. baseFlatten(value, depth - 1, predicate, isStrict, result);
  4480. } else {
  4481. arrayPush(result, value);
  4482. }
  4483. } else if (!isStrict) {
  4484. result[result.length] = value;
  4485. }
  4486. }
  4487. return result;
  4488. }
  4489. /**
  4490. * The base implementation of `baseForOwn` which iterates over `object`
  4491. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  4492. * Iteratee functions may exit iteration early by explicitly returning `false`.
  4493. *
  4494. * @private
  4495. * @param {Object} object The object to iterate over.
  4496. * @param {Function} iteratee The function invoked per iteration.
  4497. * @param {Function} keysFunc The function to get the keys of `object`.
  4498. * @returns {Object} Returns `object`.
  4499. */
  4500. var baseFor = createBaseFor();
  4501. /**
  4502. * This function is like `baseFor` except that it iterates over properties
  4503. * in the opposite order.
  4504. *
  4505. * @private
  4506. * @param {Object} object The object to iterate over.
  4507. * @param {Function} iteratee The function invoked per iteration.
  4508. * @param {Function} keysFunc The function to get the keys of `object`.
  4509. * @returns {Object} Returns `object`.
  4510. */
  4511. var baseForRight = createBaseFor(true);
  4512. /**
  4513. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  4514. *
  4515. * @private
  4516. * @param {Object} object The object to iterate over.
  4517. * @param {Function} iteratee The function invoked per iteration.
  4518. * @returns {Object} Returns `object`.
  4519. */
  4520. function baseForOwn(object, iteratee) {
  4521. return object && baseFor(object, iteratee, keys);
  4522. }
  4523. /**
  4524. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  4525. *
  4526. * @private
  4527. * @param {Object} object The object to iterate over.
  4528. * @param {Function} iteratee The function invoked per iteration.
  4529. * @returns {Object} Returns `object`.
  4530. */
  4531. function baseForOwnRight(object, iteratee) {
  4532. return object && baseForRight(object, iteratee, keys);
  4533. }
  4534. /**
  4535. * The base implementation of `_.functions` which creates an array of
  4536. * `object` function property names filtered from `props`.
  4537. *
  4538. * @private
  4539. * @param {Object} object The object to inspect.
  4540. * @param {Array} props The property names to filter.
  4541. * @returns {Array} Returns the function names.
  4542. */
  4543. function baseFunctions(object, props) {
  4544. return arrayFilter(props, function(key) {
  4545. return isFunction(object[key]);
  4546. });
  4547. }
  4548. /**
  4549. * The base implementation of `_.get` without support for default values.
  4550. *
  4551. * @private
  4552. * @param {Object} object The object to query.
  4553. * @param {Array|string} path The path of the property to get.
  4554. * @returns {*} Returns the resolved value.
  4555. */
  4556. function baseGet(object, path) {
  4557. path = castPath(path, object);
  4558. var index = 0,
  4559. length = path.length;
  4560. while (object != null && index < length) {
  4561. object = object[toKey(path[index++])];
  4562. }
  4563. return (index && index == length) ? object : undefined$1;
  4564. }
  4565. /**
  4566. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  4567. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  4568. * symbols of `object`.
  4569. *
  4570. * @private
  4571. * @param {Object} object The object to query.
  4572. * @param {Function} keysFunc The function to get the keys of `object`.
  4573. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  4574. * @returns {Array} Returns the array of property names and symbols.
  4575. */
  4576. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  4577. var result = keysFunc(object);
  4578. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  4579. }
  4580. /**
  4581. * The base implementation of `getTag` without fallbacks for buggy environments.
  4582. *
  4583. * @private
  4584. * @param {*} value The value to query.
  4585. * @returns {string} Returns the `toStringTag`.
  4586. */
  4587. function baseGetTag(value) {
  4588. if (value == null) {
  4589. return value === undefined$1 ? undefinedTag : nullTag;
  4590. }
  4591. return (symToStringTag && symToStringTag in Object(value))
  4592. ? getRawTag(value)
  4593. : objectToString(value);
  4594. }
  4595. /**
  4596. * The base implementation of `_.gt` which doesn't coerce arguments.
  4597. *
  4598. * @private
  4599. * @param {*} value The value to compare.
  4600. * @param {*} other The other value to compare.
  4601. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  4602. * else `false`.
  4603. */
  4604. function baseGt(value, other) {
  4605. return value > other;
  4606. }
  4607. /**
  4608. * The base implementation of `_.has` without support for deep paths.
  4609. *
  4610. * @private
  4611. * @param {Object} [object] The object to query.
  4612. * @param {Array|string} key The key to check.
  4613. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4614. */
  4615. function baseHas(object, key) {
  4616. return object != null && hasOwnProperty.call(object, key);
  4617. }
  4618. /**
  4619. * The base implementation of `_.hasIn` without support for deep paths.
  4620. *
  4621. * @private
  4622. * @param {Object} [object] The object to query.
  4623. * @param {Array|string} key The key to check.
  4624. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4625. */
  4626. function baseHasIn(object, key) {
  4627. return object != null && key in Object(object);
  4628. }
  4629. /**
  4630. * The base implementation of `_.inRange` which doesn't coerce arguments.
  4631. *
  4632. * @private
  4633. * @param {number} number The number to check.
  4634. * @param {number} start The start of the range.
  4635. * @param {number} end The end of the range.
  4636. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  4637. */
  4638. function baseInRange(number, start, end) {
  4639. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  4640. }
  4641. /**
  4642. * The base implementation of methods like `_.intersection`, without support
  4643. * for iteratee shorthands, that accepts an array of arrays to inspect.
  4644. *
  4645. * @private
  4646. * @param {Array} arrays The arrays to inspect.
  4647. * @param {Function} [iteratee] The iteratee invoked per element.
  4648. * @param {Function} [comparator] The comparator invoked per element.
  4649. * @returns {Array} Returns the new array of shared values.
  4650. */
  4651. function baseIntersection(arrays, iteratee, comparator) {
  4652. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  4653. length = arrays[0].length,
  4654. othLength = arrays.length,
  4655. othIndex = othLength,
  4656. caches = Array(othLength),
  4657. maxLength = Infinity,
  4658. result = [];
  4659. while (othIndex--) {
  4660. var array = arrays[othIndex];
  4661. if (othIndex && iteratee) {
  4662. array = arrayMap(array, baseUnary(iteratee));
  4663. }
  4664. maxLength = nativeMin(array.length, maxLength);
  4665. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  4666. ? new SetCache(othIndex && array)
  4667. : undefined$1;
  4668. }
  4669. array = arrays[0];
  4670. var index = -1,
  4671. seen = caches[0];
  4672. outer:
  4673. while (++index < length && result.length < maxLength) {
  4674. var value = array[index],
  4675. computed = iteratee ? iteratee(value) : value;
  4676. value = (comparator || value !== 0) ? value : 0;
  4677. if (!(seen
  4678. ? cacheHas(seen, computed)
  4679. : includes(result, computed, comparator)
  4680. )) {
  4681. othIndex = othLength;
  4682. while (--othIndex) {
  4683. var cache = caches[othIndex];
  4684. if (!(cache
  4685. ? cacheHas(cache, computed)
  4686. : includes(arrays[othIndex], computed, comparator))
  4687. ) {
  4688. continue outer;
  4689. }
  4690. }
  4691. if (seen) {
  4692. seen.push(computed);
  4693. }
  4694. result.push(value);
  4695. }
  4696. }
  4697. return result;
  4698. }
  4699. /**
  4700. * The base implementation of `_.invert` and `_.invertBy` which inverts
  4701. * `object` with values transformed by `iteratee` and set by `setter`.
  4702. *
  4703. * @private
  4704. * @param {Object} object The object to iterate over.
  4705. * @param {Function} setter The function to set `accumulator` values.
  4706. * @param {Function} iteratee The iteratee to transform values.
  4707. * @param {Object} accumulator The initial inverted object.
  4708. * @returns {Function} Returns `accumulator`.
  4709. */
  4710. function baseInverter(object, setter, iteratee, accumulator) {
  4711. baseForOwn(object, function(value, key, object) {
  4712. setter(accumulator, iteratee(value), key, object);
  4713. });
  4714. return accumulator;
  4715. }
  4716. /**
  4717. * The base implementation of `_.invoke` without support for individual
  4718. * method arguments.
  4719. *
  4720. * @private
  4721. * @param {Object} object The object to query.
  4722. * @param {Array|string} path The path of the method to invoke.
  4723. * @param {Array} args The arguments to invoke the method with.
  4724. * @returns {*} Returns the result of the invoked method.
  4725. */
  4726. function baseInvoke(object, path, args) {
  4727. path = castPath(path, object);
  4728. object = parent(object, path);
  4729. var func = object == null ? object : object[toKey(last(path))];
  4730. return func == null ? undefined$1 : apply(func, object, args);
  4731. }
  4732. /**
  4733. * The base implementation of `_.isArguments`.
  4734. *
  4735. * @private
  4736. * @param {*} value The value to check.
  4737. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4738. */
  4739. function baseIsArguments(value) {
  4740. return isObjectLike(value) && baseGetTag(value) == argsTag;
  4741. }
  4742. /**
  4743. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  4744. *
  4745. * @private
  4746. * @param {*} value The value to check.
  4747. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  4748. */
  4749. function baseIsArrayBuffer(value) {
  4750. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  4751. }
  4752. /**
  4753. * The base implementation of `_.isDate` without Node.js optimizations.
  4754. *
  4755. * @private
  4756. * @param {*} value The value to check.
  4757. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  4758. */
  4759. function baseIsDate(value) {
  4760. return isObjectLike(value) && baseGetTag(value) == dateTag;
  4761. }
  4762. /**
  4763. * The base implementation of `_.isEqual` which supports partial comparisons
  4764. * and tracks traversed objects.
  4765. *
  4766. * @private
  4767. * @param {*} value The value to compare.
  4768. * @param {*} other The other value to compare.
  4769. * @param {boolean} bitmask The bitmask flags.
  4770. * 1 - Unordered comparison
  4771. * 2 - Partial comparison
  4772. * @param {Function} [customizer] The function to customize comparisons.
  4773. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  4774. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4775. */
  4776. function baseIsEqual(value, other, bitmask, customizer, stack) {
  4777. if (value === other) {
  4778. return true;
  4779. }
  4780. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  4781. return value !== value && other !== other;
  4782. }
  4783. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  4784. }
  4785. /**
  4786. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4787. * deep comparisons and tracks traversed objects enabling objects with circular
  4788. * references to be compared.
  4789. *
  4790. * @private
  4791. * @param {Object} object The object to compare.
  4792. * @param {Object} other The other object to compare.
  4793. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  4794. * @param {Function} customizer The function to customize comparisons.
  4795. * @param {Function} equalFunc The function to determine equivalents of values.
  4796. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  4797. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4798. */
  4799. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  4800. var objIsArr = isArray(object),
  4801. othIsArr = isArray(other),
  4802. objTag = objIsArr ? arrayTag : getTag(object),
  4803. othTag = othIsArr ? arrayTag : getTag(other);
  4804. objTag = objTag == argsTag ? objectTag : objTag;
  4805. othTag = othTag == argsTag ? objectTag : othTag;
  4806. var objIsObj = objTag == objectTag,
  4807. othIsObj = othTag == objectTag,
  4808. isSameTag = objTag == othTag;
  4809. if (isSameTag && isBuffer(object)) {
  4810. if (!isBuffer(other)) {
  4811. return false;
  4812. }
  4813. objIsArr = true;
  4814. objIsObj = false;
  4815. }
  4816. if (isSameTag && !objIsObj) {
  4817. stack || (stack = new Stack);
  4818. return (objIsArr || isTypedArray(object))
  4819. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  4820. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  4821. }
  4822. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  4823. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4824. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4825. if (objIsWrapped || othIsWrapped) {
  4826. var objUnwrapped = objIsWrapped ? object.value() : object,
  4827. othUnwrapped = othIsWrapped ? other.value() : other;
  4828. stack || (stack = new Stack);
  4829. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  4830. }
  4831. }
  4832. if (!isSameTag) {
  4833. return false;
  4834. }
  4835. stack || (stack = new Stack);
  4836. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  4837. }
  4838. /**
  4839. * The base implementation of `_.isMap` without Node.js optimizations.
  4840. *
  4841. * @private
  4842. * @param {*} value The value to check.
  4843. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4844. */
  4845. function baseIsMap(value) {
  4846. return isObjectLike(value) && getTag(value) == mapTag;
  4847. }
  4848. /**
  4849. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  4850. *
  4851. * @private
  4852. * @param {Object} object The object to inspect.
  4853. * @param {Object} source The object of property values to match.
  4854. * @param {Array} matchData The property names, values, and compare flags to match.
  4855. * @param {Function} [customizer] The function to customize comparisons.
  4856. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  4857. */
  4858. function baseIsMatch(object, source, matchData, customizer) {
  4859. var index = matchData.length,
  4860. length = index,
  4861. noCustomizer = !customizer;
  4862. if (object == null) {
  4863. return !length;
  4864. }
  4865. object = Object(object);
  4866. while (index--) {
  4867. var data = matchData[index];
  4868. if ((noCustomizer && data[2])
  4869. ? data[1] !== object[data[0]]
  4870. : !(data[0] in object)
  4871. ) {
  4872. return false;
  4873. }
  4874. }
  4875. while (++index < length) {
  4876. data = matchData[index];
  4877. var key = data[0],
  4878. objValue = object[key],
  4879. srcValue = data[1];
  4880. if (noCustomizer && data[2]) {
  4881. if (objValue === undefined$1 && !(key in object)) {
  4882. return false;
  4883. }
  4884. } else {
  4885. var stack = new Stack;
  4886. if (customizer) {
  4887. var result = customizer(objValue, srcValue, key, object, source, stack);
  4888. }
  4889. if (!(result === undefined$1
  4890. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  4891. : result
  4892. )) {
  4893. return false;
  4894. }
  4895. }
  4896. }
  4897. return true;
  4898. }
  4899. /**
  4900. * The base implementation of `_.isNative` without bad shim checks.
  4901. *
  4902. * @private
  4903. * @param {*} value The value to check.
  4904. * @returns {boolean} Returns `true` if `value` is a native function,
  4905. * else `false`.
  4906. */
  4907. function baseIsNative(value) {
  4908. if (!isObject(value) || isMasked(value)) {
  4909. return false;
  4910. }
  4911. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  4912. return pattern.test(toSource(value));
  4913. }
  4914. /**
  4915. * The base implementation of `_.isRegExp` without Node.js optimizations.
  4916. *
  4917. * @private
  4918. * @param {*} value The value to check.
  4919. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  4920. */
  4921. function baseIsRegExp(value) {
  4922. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  4923. }
  4924. /**
  4925. * The base implementation of `_.isSet` without Node.js optimizations.
  4926. *
  4927. * @private
  4928. * @param {*} value The value to check.
  4929. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4930. */
  4931. function baseIsSet(value) {
  4932. return isObjectLike(value) && getTag(value) == setTag;
  4933. }
  4934. /**
  4935. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  4936. *
  4937. * @private
  4938. * @param {*} value The value to check.
  4939. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4940. */
  4941. function baseIsTypedArray(value) {
  4942. return isObjectLike(value) &&
  4943. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  4944. }
  4945. /**
  4946. * The base implementation of `_.iteratee`.
  4947. *
  4948. * @private
  4949. * @param {*} [value=_.identity] The value to convert to an iteratee.
  4950. * @returns {Function} Returns the iteratee.
  4951. */
  4952. function baseIteratee(value) {
  4953. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  4954. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  4955. if (typeof value == 'function') {
  4956. return value;
  4957. }
  4958. if (value == null) {
  4959. return identity;
  4960. }
  4961. if (typeof value == 'object') {
  4962. return isArray(value)
  4963. ? baseMatchesProperty(value[0], value[1])
  4964. : baseMatches(value);
  4965. }
  4966. return property(value);
  4967. }
  4968. /**
  4969. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  4970. *
  4971. * @private
  4972. * @param {Object} object The object to query.
  4973. * @returns {Array} Returns the array of property names.
  4974. */
  4975. function baseKeys(object) {
  4976. if (!isPrototype(object)) {
  4977. return nativeKeys(object);
  4978. }
  4979. var result = [];
  4980. for (var key in Object(object)) {
  4981. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4982. result.push(key);
  4983. }
  4984. }
  4985. return result;
  4986. }
  4987. /**
  4988. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4989. *
  4990. * @private
  4991. * @param {Object} object The object to query.
  4992. * @returns {Array} Returns the array of property names.
  4993. */
  4994. function baseKeysIn(object) {
  4995. if (!isObject(object)) {
  4996. return nativeKeysIn(object);
  4997. }
  4998. var isProto = isPrototype(object),
  4999. result = [];
  5000. for (var key in object) {
  5001. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  5002. result.push(key);
  5003. }
  5004. }
  5005. return result;
  5006. }
  5007. /**
  5008. * The base implementation of `_.lt` which doesn't coerce arguments.
  5009. *
  5010. * @private
  5011. * @param {*} value The value to compare.
  5012. * @param {*} other The other value to compare.
  5013. * @returns {boolean} Returns `true` if `value` is less than `other`,
  5014. * else `false`.
  5015. */
  5016. function baseLt(value, other) {
  5017. return value < other;
  5018. }
  5019. /**
  5020. * The base implementation of `_.map` without support for iteratee shorthands.
  5021. *
  5022. * @private
  5023. * @param {Array|Object} collection The collection to iterate over.
  5024. * @param {Function} iteratee The function invoked per iteration.
  5025. * @returns {Array} Returns the new mapped array.
  5026. */
  5027. function baseMap(collection, iteratee) {
  5028. var index = -1,
  5029. result = isArrayLike(collection) ? Array(collection.length) : [];
  5030. baseEach(collection, function(value, key, collection) {
  5031. result[++index] = iteratee(value, key, collection);
  5032. });
  5033. return result;
  5034. }
  5035. /**
  5036. * The base implementation of `_.matches` which doesn't clone `source`.
  5037. *
  5038. * @private
  5039. * @param {Object} source The object of property values to match.
  5040. * @returns {Function} Returns the new spec function.
  5041. */
  5042. function baseMatches(source) {
  5043. var matchData = getMatchData(source);
  5044. if (matchData.length == 1 && matchData[0][2]) {
  5045. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  5046. }
  5047. return function(object) {
  5048. return object === source || baseIsMatch(object, source, matchData);
  5049. };
  5050. }
  5051. /**
  5052. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  5053. *
  5054. * @private
  5055. * @param {string} path The path of the property to get.
  5056. * @param {*} srcValue The value to match.
  5057. * @returns {Function} Returns the new spec function.
  5058. */
  5059. function baseMatchesProperty(path, srcValue) {
  5060. if (isKey(path) && isStrictComparable(srcValue)) {
  5061. return matchesStrictComparable(toKey(path), srcValue);
  5062. }
  5063. return function(object) {
  5064. var objValue = get(object, path);
  5065. return (objValue === undefined$1 && objValue === srcValue)
  5066. ? hasIn(object, path)
  5067. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  5068. };
  5069. }
  5070. /**
  5071. * The base implementation of `_.merge` without support for multiple sources.
  5072. *
  5073. * @private
  5074. * @param {Object} object The destination object.
  5075. * @param {Object} source The source object.
  5076. * @param {number} srcIndex The index of `source`.
  5077. * @param {Function} [customizer] The function to customize merged values.
  5078. * @param {Object} [stack] Tracks traversed source values and their merged
  5079. * counterparts.
  5080. */
  5081. function baseMerge(object, source, srcIndex, customizer, stack) {
  5082. if (object === source) {
  5083. return;
  5084. }
  5085. baseFor(source, function(srcValue, key) {
  5086. stack || (stack = new Stack);
  5087. if (isObject(srcValue)) {
  5088. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  5089. }
  5090. else {
  5091. var newValue = customizer
  5092. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  5093. : undefined$1;
  5094. if (newValue === undefined$1) {
  5095. newValue = srcValue;
  5096. }
  5097. assignMergeValue(object, key, newValue);
  5098. }
  5099. }, keysIn);
  5100. }
  5101. /**
  5102. * A specialized version of `baseMerge` for arrays and objects which performs
  5103. * deep merges and tracks traversed objects enabling objects with circular
  5104. * references to be merged.
  5105. *
  5106. * @private
  5107. * @param {Object} object The destination object.
  5108. * @param {Object} source The source object.
  5109. * @param {string} key The key of the value to merge.
  5110. * @param {number} srcIndex The index of `source`.
  5111. * @param {Function} mergeFunc The function to merge values.
  5112. * @param {Function} [customizer] The function to customize assigned values.
  5113. * @param {Object} [stack] Tracks traversed source values and their merged
  5114. * counterparts.
  5115. */
  5116. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  5117. var objValue = safeGet(object, key),
  5118. srcValue = safeGet(source, key),
  5119. stacked = stack.get(srcValue);
  5120. if (stacked) {
  5121. assignMergeValue(object, key, stacked);
  5122. return;
  5123. }
  5124. var newValue = customizer
  5125. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  5126. : undefined$1;
  5127. var isCommon = newValue === undefined$1;
  5128. if (isCommon) {
  5129. var isArr = isArray(srcValue),
  5130. isBuff = !isArr && isBuffer(srcValue),
  5131. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  5132. newValue = srcValue;
  5133. if (isArr || isBuff || isTyped) {
  5134. if (isArray(objValue)) {
  5135. newValue = objValue;
  5136. }
  5137. else if (isArrayLikeObject(objValue)) {
  5138. newValue = copyArray(objValue);
  5139. }
  5140. else if (isBuff) {
  5141. isCommon = false;
  5142. newValue = cloneBuffer(srcValue, true);
  5143. }
  5144. else if (isTyped) {
  5145. isCommon = false;
  5146. newValue = cloneTypedArray(srcValue, true);
  5147. }
  5148. else {
  5149. newValue = [];
  5150. }
  5151. }
  5152. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  5153. newValue = objValue;
  5154. if (isArguments(objValue)) {
  5155. newValue = toPlainObject(objValue);
  5156. }
  5157. else if (!isObject(objValue) || isFunction(objValue)) {
  5158. newValue = initCloneObject(srcValue);
  5159. }
  5160. }
  5161. else {
  5162. isCommon = false;
  5163. }
  5164. }
  5165. if (isCommon) {
  5166. // Recursively merge objects and arrays (susceptible to call stack limits).
  5167. stack.set(srcValue, newValue);
  5168. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  5169. stack['delete'](srcValue);
  5170. }
  5171. assignMergeValue(object, key, newValue);
  5172. }
  5173. /**
  5174. * The base implementation of `_.nth` which doesn't coerce arguments.
  5175. *
  5176. * @private
  5177. * @param {Array} array The array to query.
  5178. * @param {number} n The index of the element to return.
  5179. * @returns {*} Returns the nth element of `array`.
  5180. */
  5181. function baseNth(array, n) {
  5182. var length = array.length;
  5183. if (!length) {
  5184. return;
  5185. }
  5186. n += n < 0 ? length : 0;
  5187. return isIndex(n, length) ? array[n] : undefined$1;
  5188. }
  5189. /**
  5190. * The base implementation of `_.orderBy` without param guards.
  5191. *
  5192. * @private
  5193. * @param {Array|Object} collection The collection to iterate over.
  5194. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  5195. * @param {string[]} orders The sort orders of `iteratees`.
  5196. * @returns {Array} Returns the new sorted array.
  5197. */
  5198. function baseOrderBy(collection, iteratees, orders) {
  5199. if (iteratees.length) {
  5200. iteratees = arrayMap(iteratees, function(iteratee) {
  5201. if (isArray(iteratee)) {
  5202. return function(value) {
  5203. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  5204. }
  5205. }
  5206. return iteratee;
  5207. });
  5208. } else {
  5209. iteratees = [identity];
  5210. }
  5211. var index = -1;
  5212. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5213. var result = baseMap(collection, function(value, key, collection) {
  5214. var criteria = arrayMap(iteratees, function(iteratee) {
  5215. return iteratee(value);
  5216. });
  5217. return { 'criteria': criteria, 'index': ++index, 'value': value };
  5218. });
  5219. return baseSortBy(result, function(object, other) {
  5220. return compareMultiple(object, other, orders);
  5221. });
  5222. }
  5223. /**
  5224. * The base implementation of `_.pick` without support for individual
  5225. * property identifiers.
  5226. *
  5227. * @private
  5228. * @param {Object} object The source object.
  5229. * @param {string[]} paths The property paths to pick.
  5230. * @returns {Object} Returns the new object.
  5231. */
  5232. function basePick(object, paths) {
  5233. return basePickBy(object, paths, function(value, path) {
  5234. return hasIn(object, path);
  5235. });
  5236. }
  5237. /**
  5238. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  5239. *
  5240. * @private
  5241. * @param {Object} object The source object.
  5242. * @param {string[]} paths The property paths to pick.
  5243. * @param {Function} predicate The function invoked per property.
  5244. * @returns {Object} Returns the new object.
  5245. */
  5246. function basePickBy(object, paths, predicate) {
  5247. var index = -1,
  5248. length = paths.length,
  5249. result = {};
  5250. while (++index < length) {
  5251. var path = paths[index],
  5252. value = baseGet(object, path);
  5253. if (predicate(value, path)) {
  5254. baseSet(result, castPath(path, object), value);
  5255. }
  5256. }
  5257. return result;
  5258. }
  5259. /**
  5260. * A specialized version of `baseProperty` which supports deep paths.
  5261. *
  5262. * @private
  5263. * @param {Array|string} path The path of the property to get.
  5264. * @returns {Function} Returns the new accessor function.
  5265. */
  5266. function basePropertyDeep(path) {
  5267. return function(object) {
  5268. return baseGet(object, path);
  5269. };
  5270. }
  5271. /**
  5272. * The base implementation of `_.pullAllBy` without support for iteratee
  5273. * shorthands.
  5274. *
  5275. * @private
  5276. * @param {Array} array The array to modify.
  5277. * @param {Array} values The values to remove.
  5278. * @param {Function} [iteratee] The iteratee invoked per element.
  5279. * @param {Function} [comparator] The comparator invoked per element.
  5280. * @returns {Array} Returns `array`.
  5281. */
  5282. function basePullAll(array, values, iteratee, comparator) {
  5283. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  5284. index = -1,
  5285. length = values.length,
  5286. seen = array;
  5287. if (array === values) {
  5288. values = copyArray(values);
  5289. }
  5290. if (iteratee) {
  5291. seen = arrayMap(array, baseUnary(iteratee));
  5292. }
  5293. while (++index < length) {
  5294. var fromIndex = 0,
  5295. value = values[index],
  5296. computed = iteratee ? iteratee(value) : value;
  5297. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  5298. if (seen !== array) {
  5299. splice.call(seen, fromIndex, 1);
  5300. }
  5301. splice.call(array, fromIndex, 1);
  5302. }
  5303. }
  5304. return array;
  5305. }
  5306. /**
  5307. * The base implementation of `_.pullAt` without support for individual
  5308. * indexes or capturing the removed elements.
  5309. *
  5310. * @private
  5311. * @param {Array} array The array to modify.
  5312. * @param {number[]} indexes The indexes of elements to remove.
  5313. * @returns {Array} Returns `array`.
  5314. */
  5315. function basePullAt(array, indexes) {
  5316. var length = array ? indexes.length : 0,
  5317. lastIndex = length - 1;
  5318. while (length--) {
  5319. var index = indexes[length];
  5320. if (length == lastIndex || index !== previous) {
  5321. var previous = index;
  5322. if (isIndex(index)) {
  5323. splice.call(array, index, 1);
  5324. } else {
  5325. baseUnset(array, index);
  5326. }
  5327. }
  5328. }
  5329. return array;
  5330. }
  5331. /**
  5332. * The base implementation of `_.random` without support for returning
  5333. * floating-point numbers.
  5334. *
  5335. * @private
  5336. * @param {number} lower The lower bound.
  5337. * @param {number} upper The upper bound.
  5338. * @returns {number} Returns the random number.
  5339. */
  5340. function baseRandom(lower, upper) {
  5341. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  5342. }
  5343. /**
  5344. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  5345. * coerce arguments.
  5346. *
  5347. * @private
  5348. * @param {number} start The start of the range.
  5349. * @param {number} end The end of the range.
  5350. * @param {number} step The value to increment or decrement by.
  5351. * @param {boolean} [fromRight] Specify iterating from right to left.
  5352. * @returns {Array} Returns the range of numbers.
  5353. */
  5354. function baseRange(start, end, step, fromRight) {
  5355. var index = -1,
  5356. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  5357. result = Array(length);
  5358. while (length--) {
  5359. result[fromRight ? length : ++index] = start;
  5360. start += step;
  5361. }
  5362. return result;
  5363. }
  5364. /**
  5365. * The base implementation of `_.repeat` which doesn't coerce arguments.
  5366. *
  5367. * @private
  5368. * @param {string} string The string to repeat.
  5369. * @param {number} n The number of times to repeat the string.
  5370. * @returns {string} Returns the repeated string.
  5371. */
  5372. function baseRepeat(string, n) {
  5373. var result = '';
  5374. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  5375. return result;
  5376. }
  5377. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  5378. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  5379. do {
  5380. if (n % 2) {
  5381. result += string;
  5382. }
  5383. n = nativeFloor(n / 2);
  5384. if (n) {
  5385. string += string;
  5386. }
  5387. } while (n);
  5388. return result;
  5389. }
  5390. /**
  5391. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  5392. *
  5393. * @private
  5394. * @param {Function} func The function to apply a rest parameter to.
  5395. * @param {number} [start=func.length-1] The start position of the rest parameter.
  5396. * @returns {Function} Returns the new function.
  5397. */
  5398. function baseRest(func, start) {
  5399. return setToString(overRest(func, start, identity), func + '');
  5400. }
  5401. /**
  5402. * The base implementation of `_.sample`.
  5403. *
  5404. * @private
  5405. * @param {Array|Object} collection The collection to sample.
  5406. * @returns {*} Returns the random element.
  5407. */
  5408. function baseSample(collection) {
  5409. return arraySample(values(collection));
  5410. }
  5411. /**
  5412. * The base implementation of `_.sampleSize` without param guards.
  5413. *
  5414. * @private
  5415. * @param {Array|Object} collection The collection to sample.
  5416. * @param {number} n The number of elements to sample.
  5417. * @returns {Array} Returns the random elements.
  5418. */
  5419. function baseSampleSize(collection, n) {
  5420. var array = values(collection);
  5421. return shuffleSelf(array, baseClamp(n, 0, array.length));
  5422. }
  5423. /**
  5424. * The base implementation of `_.set`.
  5425. *
  5426. * @private
  5427. * @param {Object} object The object to modify.
  5428. * @param {Array|string} path The path of the property to set.
  5429. * @param {*} value The value to set.
  5430. * @param {Function} [customizer] The function to customize path creation.
  5431. * @returns {Object} Returns `object`.
  5432. */
  5433. function baseSet(object, path, value, customizer) {
  5434. if (!isObject(object)) {
  5435. return object;
  5436. }
  5437. path = castPath(path, object);
  5438. var index = -1,
  5439. length = path.length,
  5440. lastIndex = length - 1,
  5441. nested = object;
  5442. while (nested != null && ++index < length) {
  5443. var key = toKey(path[index]),
  5444. newValue = value;
  5445. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  5446. return object;
  5447. }
  5448. if (index != lastIndex) {
  5449. var objValue = nested[key];
  5450. newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
  5451. if (newValue === undefined$1) {
  5452. newValue = isObject(objValue)
  5453. ? objValue
  5454. : (isIndex(path[index + 1]) ? [] : {});
  5455. }
  5456. }
  5457. assignValue(nested, key, newValue);
  5458. nested = nested[key];
  5459. }
  5460. return object;
  5461. }
  5462. /**
  5463. * The base implementation of `setData` without support for hot loop shorting.
  5464. *
  5465. * @private
  5466. * @param {Function} func The function to associate metadata with.
  5467. * @param {*} data The metadata.
  5468. * @returns {Function} Returns `func`.
  5469. */
  5470. var baseSetData = !metaMap ? identity : function(func, data) {
  5471. metaMap.set(func, data);
  5472. return func;
  5473. };
  5474. /**
  5475. * The base implementation of `setToString` without support for hot loop shorting.
  5476. *
  5477. * @private
  5478. * @param {Function} func The function to modify.
  5479. * @param {Function} string The `toString` result.
  5480. * @returns {Function} Returns `func`.
  5481. */
  5482. var baseSetToString = !defineProperty ? identity : function(func, string) {
  5483. return defineProperty(func, 'toString', {
  5484. 'configurable': true,
  5485. 'enumerable': false,
  5486. 'value': constant(string),
  5487. 'writable': true
  5488. });
  5489. };
  5490. /**
  5491. * The base implementation of `_.shuffle`.
  5492. *
  5493. * @private
  5494. * @param {Array|Object} collection The collection to shuffle.
  5495. * @returns {Array} Returns the new shuffled array.
  5496. */
  5497. function baseShuffle(collection) {
  5498. return shuffleSelf(values(collection));
  5499. }
  5500. /**
  5501. * The base implementation of `_.slice` without an iteratee call guard.
  5502. *
  5503. * @private
  5504. * @param {Array} array The array to slice.
  5505. * @param {number} [start=0] The start position.
  5506. * @param {number} [end=array.length] The end position.
  5507. * @returns {Array} Returns the slice of `array`.
  5508. */
  5509. function baseSlice(array, start, end) {
  5510. var index = -1,
  5511. length = array.length;
  5512. if (start < 0) {
  5513. start = -start > length ? 0 : (length + start);
  5514. }
  5515. end = end > length ? length : end;
  5516. if (end < 0) {
  5517. end += length;
  5518. }
  5519. length = start > end ? 0 : ((end - start) >>> 0);
  5520. start >>>= 0;
  5521. var result = Array(length);
  5522. while (++index < length) {
  5523. result[index] = array[index + start];
  5524. }
  5525. return result;
  5526. }
  5527. /**
  5528. * The base implementation of `_.some` without support for iteratee shorthands.
  5529. *
  5530. * @private
  5531. * @param {Array|Object} collection The collection to iterate over.
  5532. * @param {Function} predicate The function invoked per iteration.
  5533. * @returns {boolean} Returns `true` if any element passes the predicate check,
  5534. * else `false`.
  5535. */
  5536. function baseSome(collection, predicate) {
  5537. var result;
  5538. baseEach(collection, function(value, index, collection) {
  5539. result = predicate(value, index, collection);
  5540. return !result;
  5541. });
  5542. return !!result;
  5543. }
  5544. /**
  5545. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  5546. * performs a binary search of `array` to determine the index at which `value`
  5547. * should be inserted into `array` in order to maintain its sort order.
  5548. *
  5549. * @private
  5550. * @param {Array} array The sorted array to inspect.
  5551. * @param {*} value The value to evaluate.
  5552. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5553. * @returns {number} Returns the index at which `value` should be inserted
  5554. * into `array`.
  5555. */
  5556. function baseSortedIndex(array, value, retHighest) {
  5557. var low = 0,
  5558. high = array == null ? low : array.length;
  5559. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  5560. while (low < high) {
  5561. var mid = (low + high) >>> 1,
  5562. computed = array[mid];
  5563. if (computed !== null && !isSymbol(computed) &&
  5564. (retHighest ? (computed <= value) : (computed < value))) {
  5565. low = mid + 1;
  5566. } else {
  5567. high = mid;
  5568. }
  5569. }
  5570. return high;
  5571. }
  5572. return baseSortedIndexBy(array, value, identity, retHighest);
  5573. }
  5574. /**
  5575. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  5576. * which invokes `iteratee` for `value` and each element of `array` to compute
  5577. * their sort ranking. The iteratee is invoked with one argument; (value).
  5578. *
  5579. * @private
  5580. * @param {Array} array The sorted array to inspect.
  5581. * @param {*} value The value to evaluate.
  5582. * @param {Function} iteratee The iteratee invoked per element.
  5583. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5584. * @returns {number} Returns the index at which `value` should be inserted
  5585. * into `array`.
  5586. */
  5587. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  5588. var low = 0,
  5589. high = array == null ? 0 : array.length;
  5590. if (high === 0) {
  5591. return 0;
  5592. }
  5593. value = iteratee(value);
  5594. var valIsNaN = value !== value,
  5595. valIsNull = value === null,
  5596. valIsSymbol = isSymbol(value),
  5597. valIsUndefined = value === undefined$1;
  5598. while (low < high) {
  5599. var mid = nativeFloor((low + high) / 2),
  5600. computed = iteratee(array[mid]),
  5601. othIsDefined = computed !== undefined$1,
  5602. othIsNull = computed === null,
  5603. othIsReflexive = computed === computed,
  5604. othIsSymbol = isSymbol(computed);
  5605. if (valIsNaN) {
  5606. var setLow = retHighest || othIsReflexive;
  5607. } else if (valIsUndefined) {
  5608. setLow = othIsReflexive && (retHighest || othIsDefined);
  5609. } else if (valIsNull) {
  5610. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  5611. } else if (valIsSymbol) {
  5612. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  5613. } else if (othIsNull || othIsSymbol) {
  5614. setLow = false;
  5615. } else {
  5616. setLow = retHighest ? (computed <= value) : (computed < value);
  5617. }
  5618. if (setLow) {
  5619. low = mid + 1;
  5620. } else {
  5621. high = mid;
  5622. }
  5623. }
  5624. return nativeMin(high, MAX_ARRAY_INDEX);
  5625. }
  5626. /**
  5627. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  5628. * support for iteratee shorthands.
  5629. *
  5630. * @private
  5631. * @param {Array} array The array to inspect.
  5632. * @param {Function} [iteratee] The iteratee invoked per element.
  5633. * @returns {Array} Returns the new duplicate free array.
  5634. */
  5635. function baseSortedUniq(array, iteratee) {
  5636. var index = -1,
  5637. length = array.length,
  5638. resIndex = 0,
  5639. result = [];
  5640. while (++index < length) {
  5641. var value = array[index],
  5642. computed = iteratee ? iteratee(value) : value;
  5643. if (!index || !eq(computed, seen)) {
  5644. var seen = computed;
  5645. result[resIndex++] = value === 0 ? 0 : value;
  5646. }
  5647. }
  5648. return result;
  5649. }
  5650. /**
  5651. * The base implementation of `_.toNumber` which doesn't ensure correct
  5652. * conversions of binary, hexadecimal, or octal string values.
  5653. *
  5654. * @private
  5655. * @param {*} value The value to process.
  5656. * @returns {number} Returns the number.
  5657. */
  5658. function baseToNumber(value) {
  5659. if (typeof value == 'number') {
  5660. return value;
  5661. }
  5662. if (isSymbol(value)) {
  5663. return NAN;
  5664. }
  5665. return +value;
  5666. }
  5667. /**
  5668. * The base implementation of `_.toString` which doesn't convert nullish
  5669. * values to empty strings.
  5670. *
  5671. * @private
  5672. * @param {*} value The value to process.
  5673. * @returns {string} Returns the string.
  5674. */
  5675. function baseToString(value) {
  5676. // Exit early for strings to avoid a performance hit in some environments.
  5677. if (typeof value == 'string') {
  5678. return value;
  5679. }
  5680. if (isArray(value)) {
  5681. // Recursively convert values (susceptible to call stack limits).
  5682. return arrayMap(value, baseToString) + '';
  5683. }
  5684. if (isSymbol(value)) {
  5685. return symbolToString ? symbolToString.call(value) : '';
  5686. }
  5687. var result = (value + '');
  5688. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  5689. }
  5690. /**
  5691. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  5692. *
  5693. * @private
  5694. * @param {Array} array The array to inspect.
  5695. * @param {Function} [iteratee] The iteratee invoked per element.
  5696. * @param {Function} [comparator] The comparator invoked per element.
  5697. * @returns {Array} Returns the new duplicate free array.
  5698. */
  5699. function baseUniq(array, iteratee, comparator) {
  5700. var index = -1,
  5701. includes = arrayIncludes,
  5702. length = array.length,
  5703. isCommon = true,
  5704. result = [],
  5705. seen = result;
  5706. if (comparator) {
  5707. isCommon = false;
  5708. includes = arrayIncludesWith;
  5709. }
  5710. else if (length >= LARGE_ARRAY_SIZE) {
  5711. var set = iteratee ? null : createSet(array);
  5712. if (set) {
  5713. return setToArray(set);
  5714. }
  5715. isCommon = false;
  5716. includes = cacheHas;
  5717. seen = new SetCache;
  5718. }
  5719. else {
  5720. seen = iteratee ? [] : result;
  5721. }
  5722. outer:
  5723. while (++index < length) {
  5724. var value = array[index],
  5725. computed = iteratee ? iteratee(value) : value;
  5726. value = (comparator || value !== 0) ? value : 0;
  5727. if (isCommon && computed === computed) {
  5728. var seenIndex = seen.length;
  5729. while (seenIndex--) {
  5730. if (seen[seenIndex] === computed) {
  5731. continue outer;
  5732. }
  5733. }
  5734. if (iteratee) {
  5735. seen.push(computed);
  5736. }
  5737. result.push(value);
  5738. }
  5739. else if (!includes(seen, computed, comparator)) {
  5740. if (seen !== result) {
  5741. seen.push(computed);
  5742. }
  5743. result.push(value);
  5744. }
  5745. }
  5746. return result;
  5747. }
  5748. /**
  5749. * The base implementation of `_.unset`.
  5750. *
  5751. * @private
  5752. * @param {Object} object The object to modify.
  5753. * @param {Array|string} path The property path to unset.
  5754. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  5755. */
  5756. function baseUnset(object, path) {
  5757. path = castPath(path, object);
  5758. object = parent(object, path);
  5759. return object == null || delete object[toKey(last(path))];
  5760. }
  5761. /**
  5762. * The base implementation of `_.update`.
  5763. *
  5764. * @private
  5765. * @param {Object} object The object to modify.
  5766. * @param {Array|string} path The path of the property to update.
  5767. * @param {Function} updater The function to produce the updated value.
  5768. * @param {Function} [customizer] The function to customize path creation.
  5769. * @returns {Object} Returns `object`.
  5770. */
  5771. function baseUpdate(object, path, updater, customizer) {
  5772. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  5773. }
  5774. /**
  5775. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  5776. * without support for iteratee shorthands.
  5777. *
  5778. * @private
  5779. * @param {Array} array The array to query.
  5780. * @param {Function} predicate The function invoked per iteration.
  5781. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  5782. * @param {boolean} [fromRight] Specify iterating from right to left.
  5783. * @returns {Array} Returns the slice of `array`.
  5784. */
  5785. function baseWhile(array, predicate, isDrop, fromRight) {
  5786. var length = array.length,
  5787. index = fromRight ? length : -1;
  5788. while ((fromRight ? index-- : ++index < length) &&
  5789. predicate(array[index], index, array)) {}
  5790. return isDrop
  5791. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  5792. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  5793. }
  5794. /**
  5795. * The base implementation of `wrapperValue` which returns the result of
  5796. * performing a sequence of actions on the unwrapped `value`, where each
  5797. * successive action is supplied the return value of the previous.
  5798. *
  5799. * @private
  5800. * @param {*} value The unwrapped value.
  5801. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  5802. * @returns {*} Returns the resolved value.
  5803. */
  5804. function baseWrapperValue(value, actions) {
  5805. var result = value;
  5806. if (result instanceof LazyWrapper) {
  5807. result = result.value();
  5808. }
  5809. return arrayReduce(actions, function(result, action) {
  5810. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  5811. }, result);
  5812. }
  5813. /**
  5814. * The base implementation of methods like `_.xor`, without support for
  5815. * iteratee shorthands, that accepts an array of arrays to inspect.
  5816. *
  5817. * @private
  5818. * @param {Array} arrays The arrays to inspect.
  5819. * @param {Function} [iteratee] The iteratee invoked per element.
  5820. * @param {Function} [comparator] The comparator invoked per element.
  5821. * @returns {Array} Returns the new array of values.
  5822. */
  5823. function baseXor(arrays, iteratee, comparator) {
  5824. var length = arrays.length;
  5825. if (length < 2) {
  5826. return length ? baseUniq(arrays[0]) : [];
  5827. }
  5828. var index = -1,
  5829. result = Array(length);
  5830. while (++index < length) {
  5831. var array = arrays[index],
  5832. othIndex = -1;
  5833. while (++othIndex < length) {
  5834. if (othIndex != index) {
  5835. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  5836. }
  5837. }
  5838. }
  5839. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  5840. }
  5841. /**
  5842. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  5843. *
  5844. * @private
  5845. * @param {Array} props The property identifiers.
  5846. * @param {Array} values The property values.
  5847. * @param {Function} assignFunc The function to assign values.
  5848. * @returns {Object} Returns the new object.
  5849. */
  5850. function baseZipObject(props, values, assignFunc) {
  5851. var index = -1,
  5852. length = props.length,
  5853. valsLength = values.length,
  5854. result = {};
  5855. while (++index < length) {
  5856. var value = index < valsLength ? values[index] : undefined$1;
  5857. assignFunc(result, props[index], value);
  5858. }
  5859. return result;
  5860. }
  5861. /**
  5862. * Casts `value` to an empty array if it's not an array like object.
  5863. *
  5864. * @private
  5865. * @param {*} value The value to inspect.
  5866. * @returns {Array|Object} Returns the cast array-like object.
  5867. */
  5868. function castArrayLikeObject(value) {
  5869. return isArrayLikeObject(value) ? value : [];
  5870. }
  5871. /**
  5872. * Casts `value` to `identity` if it's not a function.
  5873. *
  5874. * @private
  5875. * @param {*} value The value to inspect.
  5876. * @returns {Function} Returns cast function.
  5877. */
  5878. function castFunction(value) {
  5879. return typeof value == 'function' ? value : identity;
  5880. }
  5881. /**
  5882. * Casts `value` to a path array if it's not one.
  5883. *
  5884. * @private
  5885. * @param {*} value The value to inspect.
  5886. * @param {Object} [object] The object to query keys on.
  5887. * @returns {Array} Returns the cast property path array.
  5888. */
  5889. function castPath(value, object) {
  5890. if (isArray(value)) {
  5891. return value;
  5892. }
  5893. return isKey(value, object) ? [value] : stringToPath(toString(value));
  5894. }
  5895. /**
  5896. * A `baseRest` alias which can be replaced with `identity` by module
  5897. * replacement plugins.
  5898. *
  5899. * @private
  5900. * @type {Function}
  5901. * @param {Function} func The function to apply a rest parameter to.
  5902. * @returns {Function} Returns the new function.
  5903. */
  5904. var castRest = baseRest;
  5905. /**
  5906. * Casts `array` to a slice if it's needed.
  5907. *
  5908. * @private
  5909. * @param {Array} array The array to inspect.
  5910. * @param {number} start The start position.
  5911. * @param {number} [end=array.length] The end position.
  5912. * @returns {Array} Returns the cast slice.
  5913. */
  5914. function castSlice(array, start, end) {
  5915. var length = array.length;
  5916. end = end === undefined$1 ? length : end;
  5917. return (!start && end >= length) ? array : baseSlice(array, start, end);
  5918. }
  5919. /**
  5920. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  5921. *
  5922. * @private
  5923. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  5924. */
  5925. var clearTimeout = ctxClearTimeout || function(id) {
  5926. return root.clearTimeout(id);
  5927. };
  5928. /**
  5929. * Creates a clone of `buffer`.
  5930. *
  5931. * @private
  5932. * @param {Buffer} buffer The buffer to clone.
  5933. * @param {boolean} [isDeep] Specify a deep clone.
  5934. * @returns {Buffer} Returns the cloned buffer.
  5935. */
  5936. function cloneBuffer(buffer, isDeep) {
  5937. if (isDeep) {
  5938. return buffer.slice();
  5939. }
  5940. var length = buffer.length,
  5941. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  5942. buffer.copy(result);
  5943. return result;
  5944. }
  5945. /**
  5946. * Creates a clone of `arrayBuffer`.
  5947. *
  5948. * @private
  5949. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  5950. * @returns {ArrayBuffer} Returns the cloned array buffer.
  5951. */
  5952. function cloneArrayBuffer(arrayBuffer) {
  5953. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  5954. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  5955. return result;
  5956. }
  5957. /**
  5958. * Creates a clone of `dataView`.
  5959. *
  5960. * @private
  5961. * @param {Object} dataView The data view to clone.
  5962. * @param {boolean} [isDeep] Specify a deep clone.
  5963. * @returns {Object} Returns the cloned data view.
  5964. */
  5965. function cloneDataView(dataView, isDeep) {
  5966. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  5967. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  5968. }
  5969. /**
  5970. * Creates a clone of `regexp`.
  5971. *
  5972. * @private
  5973. * @param {Object} regexp The regexp to clone.
  5974. * @returns {Object} Returns the cloned regexp.
  5975. */
  5976. function cloneRegExp(regexp) {
  5977. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5978. result.lastIndex = regexp.lastIndex;
  5979. return result;
  5980. }
  5981. /**
  5982. * Creates a clone of the `symbol` object.
  5983. *
  5984. * @private
  5985. * @param {Object} symbol The symbol object to clone.
  5986. * @returns {Object} Returns the cloned symbol object.
  5987. */
  5988. function cloneSymbol(symbol) {
  5989. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5990. }
  5991. /**
  5992. * Creates a clone of `typedArray`.
  5993. *
  5994. * @private
  5995. * @param {Object} typedArray The typed array to clone.
  5996. * @param {boolean} [isDeep] Specify a deep clone.
  5997. * @returns {Object} Returns the cloned typed array.
  5998. */
  5999. function cloneTypedArray(typedArray, isDeep) {
  6000. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  6001. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  6002. }
  6003. /**
  6004. * Compares values to sort them in ascending order.
  6005. *
  6006. * @private
  6007. * @param {*} value The value to compare.
  6008. * @param {*} other The other value to compare.
  6009. * @returns {number} Returns the sort order indicator for `value`.
  6010. */
  6011. function compareAscending(value, other) {
  6012. if (value !== other) {
  6013. var valIsDefined = value !== undefined$1,
  6014. valIsNull = value === null,
  6015. valIsReflexive = value === value,
  6016. valIsSymbol = isSymbol(value);
  6017. var othIsDefined = other !== undefined$1,
  6018. othIsNull = other === null,
  6019. othIsReflexive = other === other,
  6020. othIsSymbol = isSymbol(other);
  6021. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  6022. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  6023. (valIsNull && othIsDefined && othIsReflexive) ||
  6024. (!valIsDefined && othIsReflexive) ||
  6025. !valIsReflexive) {
  6026. return 1;
  6027. }
  6028. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  6029. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  6030. (othIsNull && valIsDefined && valIsReflexive) ||
  6031. (!othIsDefined && valIsReflexive) ||
  6032. !othIsReflexive) {
  6033. return -1;
  6034. }
  6035. }
  6036. return 0;
  6037. }
  6038. /**
  6039. * Used by `_.orderBy` to compare multiple properties of a value to another
  6040. * and stable sort them.
  6041. *
  6042. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  6043. * specify an order of "desc" for descending or "asc" for ascending sort order
  6044. * of corresponding values.
  6045. *
  6046. * @private
  6047. * @param {Object} object The object to compare.
  6048. * @param {Object} other The other object to compare.
  6049. * @param {boolean[]|string[]} orders The order to sort by for each property.
  6050. * @returns {number} Returns the sort order indicator for `object`.
  6051. */
  6052. function compareMultiple(object, other, orders) {
  6053. var index = -1,
  6054. objCriteria = object.criteria,
  6055. othCriteria = other.criteria,
  6056. length = objCriteria.length,
  6057. ordersLength = orders.length;
  6058. while (++index < length) {
  6059. var result = compareAscending(objCriteria[index], othCriteria[index]);
  6060. if (result) {
  6061. if (index >= ordersLength) {
  6062. return result;
  6063. }
  6064. var order = orders[index];
  6065. return result * (order == 'desc' ? -1 : 1);
  6066. }
  6067. }
  6068. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  6069. // that causes it, under certain circumstances, to provide the same value for
  6070. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  6071. // for more details.
  6072. //
  6073. // This also ensures a stable sort in V8 and other engines.
  6074. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  6075. return object.index - other.index;
  6076. }
  6077. /**
  6078. * Creates an array that is the composition of partially applied arguments,
  6079. * placeholders, and provided arguments into a single array of arguments.
  6080. *
  6081. * @private
  6082. * @param {Array} args The provided arguments.
  6083. * @param {Array} partials The arguments to prepend to those provided.
  6084. * @param {Array} holders The `partials` placeholder indexes.
  6085. * @params {boolean} [isCurried] Specify composing for a curried function.
  6086. * @returns {Array} Returns the new array of composed arguments.
  6087. */
  6088. function composeArgs(args, partials, holders, isCurried) {
  6089. var argsIndex = -1,
  6090. argsLength = args.length,
  6091. holdersLength = holders.length,
  6092. leftIndex = -1,
  6093. leftLength = partials.length,
  6094. rangeLength = nativeMax(argsLength - holdersLength, 0),
  6095. result = Array(leftLength + rangeLength),
  6096. isUncurried = !isCurried;
  6097. while (++leftIndex < leftLength) {
  6098. result[leftIndex] = partials[leftIndex];
  6099. }
  6100. while (++argsIndex < holdersLength) {
  6101. if (isUncurried || argsIndex < argsLength) {
  6102. result[holders[argsIndex]] = args[argsIndex];
  6103. }
  6104. }
  6105. while (rangeLength--) {
  6106. result[leftIndex++] = args[argsIndex++];
  6107. }
  6108. return result;
  6109. }
  6110. /**
  6111. * This function is like `composeArgs` except that the arguments composition
  6112. * is tailored for `_.partialRight`.
  6113. *
  6114. * @private
  6115. * @param {Array} args The provided arguments.
  6116. * @param {Array} partials The arguments to append to those provided.
  6117. * @param {Array} holders The `partials` placeholder indexes.
  6118. * @params {boolean} [isCurried] Specify composing for a curried function.
  6119. * @returns {Array} Returns the new array of composed arguments.
  6120. */
  6121. function composeArgsRight(args, partials, holders, isCurried) {
  6122. var argsIndex = -1,
  6123. argsLength = args.length,
  6124. holdersIndex = -1,
  6125. holdersLength = holders.length,
  6126. rightIndex = -1,
  6127. rightLength = partials.length,
  6128. rangeLength = nativeMax(argsLength - holdersLength, 0),
  6129. result = Array(rangeLength + rightLength),
  6130. isUncurried = !isCurried;
  6131. while (++argsIndex < rangeLength) {
  6132. result[argsIndex] = args[argsIndex];
  6133. }
  6134. var offset = argsIndex;
  6135. while (++rightIndex < rightLength) {
  6136. result[offset + rightIndex] = partials[rightIndex];
  6137. }
  6138. while (++holdersIndex < holdersLength) {
  6139. if (isUncurried || argsIndex < argsLength) {
  6140. result[offset + holders[holdersIndex]] = args[argsIndex++];
  6141. }
  6142. }
  6143. return result;
  6144. }
  6145. /**
  6146. * Copies the values of `source` to `array`.
  6147. *
  6148. * @private
  6149. * @param {Array} source The array to copy values from.
  6150. * @param {Array} [array=[]] The array to copy values to.
  6151. * @returns {Array} Returns `array`.
  6152. */
  6153. function copyArray(source, array) {
  6154. var index = -1,
  6155. length = source.length;
  6156. array || (array = Array(length));
  6157. while (++index < length) {
  6158. array[index] = source[index];
  6159. }
  6160. return array;
  6161. }
  6162. /**
  6163. * Copies properties of `source` to `object`.
  6164. *
  6165. * @private
  6166. * @param {Object} source The object to copy properties from.
  6167. * @param {Array} props The property identifiers to copy.
  6168. * @param {Object} [object={}] The object to copy properties to.
  6169. * @param {Function} [customizer] The function to customize copied values.
  6170. * @returns {Object} Returns `object`.
  6171. */
  6172. function copyObject(source, props, object, customizer) {
  6173. var isNew = !object;
  6174. object || (object = {});
  6175. var index = -1,
  6176. length = props.length;
  6177. while (++index < length) {
  6178. var key = props[index];
  6179. var newValue = customizer
  6180. ? customizer(object[key], source[key], key, object, source)
  6181. : undefined$1;
  6182. if (newValue === undefined$1) {
  6183. newValue = source[key];
  6184. }
  6185. if (isNew) {
  6186. baseAssignValue(object, key, newValue);
  6187. } else {
  6188. assignValue(object, key, newValue);
  6189. }
  6190. }
  6191. return object;
  6192. }
  6193. /**
  6194. * Copies own symbols of `source` to `object`.
  6195. *
  6196. * @private
  6197. * @param {Object} source The object to copy symbols from.
  6198. * @param {Object} [object={}] The object to copy symbols to.
  6199. * @returns {Object} Returns `object`.
  6200. */
  6201. function copySymbols(source, object) {
  6202. return copyObject(source, getSymbols(source), object);
  6203. }
  6204. /**
  6205. * Copies own and inherited symbols of `source` to `object`.
  6206. *
  6207. * @private
  6208. * @param {Object} source The object to copy symbols from.
  6209. * @param {Object} [object={}] The object to copy symbols to.
  6210. * @returns {Object} Returns `object`.
  6211. */
  6212. function copySymbolsIn(source, object) {
  6213. return copyObject(source, getSymbolsIn(source), object);
  6214. }
  6215. /**
  6216. * Creates a function like `_.groupBy`.
  6217. *
  6218. * @private
  6219. * @param {Function} setter The function to set accumulator values.
  6220. * @param {Function} [initializer] The accumulator object initializer.
  6221. * @returns {Function} Returns the new aggregator function.
  6222. */
  6223. function createAggregator(setter, initializer) {
  6224. return function(collection, iteratee) {
  6225. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  6226. accumulator = initializer ? initializer() : {};
  6227. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  6228. };
  6229. }
  6230. /**
  6231. * Creates a function like `_.assign`.
  6232. *
  6233. * @private
  6234. * @param {Function} assigner The function to assign values.
  6235. * @returns {Function} Returns the new assigner function.
  6236. */
  6237. function createAssigner(assigner) {
  6238. return baseRest(function(object, sources) {
  6239. var index = -1,
  6240. length = sources.length,
  6241. customizer = length > 1 ? sources[length - 1] : undefined$1,
  6242. guard = length > 2 ? sources[2] : undefined$1;
  6243. customizer = (assigner.length > 3 && typeof customizer == 'function')
  6244. ? (length--, customizer)
  6245. : undefined$1;
  6246. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  6247. customizer = length < 3 ? undefined$1 : customizer;
  6248. length = 1;
  6249. }
  6250. object = Object(object);
  6251. while (++index < length) {
  6252. var source = sources[index];
  6253. if (source) {
  6254. assigner(object, source, index, customizer);
  6255. }
  6256. }
  6257. return object;
  6258. });
  6259. }
  6260. /**
  6261. * Creates a `baseEach` or `baseEachRight` function.
  6262. *
  6263. * @private
  6264. * @param {Function} eachFunc The function to iterate over a collection.
  6265. * @param {boolean} [fromRight] Specify iterating from right to left.
  6266. * @returns {Function} Returns the new base function.
  6267. */
  6268. function createBaseEach(eachFunc, fromRight) {
  6269. return function(collection, iteratee) {
  6270. if (collection == null) {
  6271. return collection;
  6272. }
  6273. if (!isArrayLike(collection)) {
  6274. return eachFunc(collection, iteratee);
  6275. }
  6276. var length = collection.length,
  6277. index = fromRight ? length : -1,
  6278. iterable = Object(collection);
  6279. while ((fromRight ? index-- : ++index < length)) {
  6280. if (iteratee(iterable[index], index, iterable) === false) {
  6281. break;
  6282. }
  6283. }
  6284. return collection;
  6285. };
  6286. }
  6287. /**
  6288. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  6289. *
  6290. * @private
  6291. * @param {boolean} [fromRight] Specify iterating from right to left.
  6292. * @returns {Function} Returns the new base function.
  6293. */
  6294. function createBaseFor(fromRight) {
  6295. return function(object, iteratee, keysFunc) {
  6296. var index = -1,
  6297. iterable = Object(object),
  6298. props = keysFunc(object),
  6299. length = props.length;
  6300. while (length--) {
  6301. var key = props[fromRight ? length : ++index];
  6302. if (iteratee(iterable[key], key, iterable) === false) {
  6303. break;
  6304. }
  6305. }
  6306. return object;
  6307. };
  6308. }
  6309. /**
  6310. * Creates a function that wraps `func` to invoke it with the optional `this`
  6311. * binding of `thisArg`.
  6312. *
  6313. * @private
  6314. * @param {Function} func The function to wrap.
  6315. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6316. * @param {*} [thisArg] The `this` binding of `func`.
  6317. * @returns {Function} Returns the new wrapped function.
  6318. */
  6319. function createBind(func, bitmask, thisArg) {
  6320. var isBind = bitmask & WRAP_BIND_FLAG,
  6321. Ctor = createCtor(func);
  6322. function wrapper() {
  6323. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6324. return fn.apply(isBind ? thisArg : this, arguments);
  6325. }
  6326. return wrapper;
  6327. }
  6328. /**
  6329. * Creates a function like `_.lowerFirst`.
  6330. *
  6331. * @private
  6332. * @param {string} methodName The name of the `String` case method to use.
  6333. * @returns {Function} Returns the new case function.
  6334. */
  6335. function createCaseFirst(methodName) {
  6336. return function(string) {
  6337. string = toString(string);
  6338. var strSymbols = hasUnicode(string)
  6339. ? stringToArray(string)
  6340. : undefined$1;
  6341. var chr = strSymbols
  6342. ? strSymbols[0]
  6343. : string.charAt(0);
  6344. var trailing = strSymbols
  6345. ? castSlice(strSymbols, 1).join('')
  6346. : string.slice(1);
  6347. return chr[methodName]() + trailing;
  6348. };
  6349. }
  6350. /**
  6351. * Creates a function like `_.camelCase`.
  6352. *
  6353. * @private
  6354. * @param {Function} callback The function to combine each word.
  6355. * @returns {Function} Returns the new compounder function.
  6356. */
  6357. function createCompounder(callback) {
  6358. return function(string) {
  6359. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  6360. };
  6361. }
  6362. /**
  6363. * Creates a function that produces an instance of `Ctor` regardless of
  6364. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  6365. *
  6366. * @private
  6367. * @param {Function} Ctor The constructor to wrap.
  6368. * @returns {Function} Returns the new wrapped function.
  6369. */
  6370. function createCtor(Ctor) {
  6371. return function() {
  6372. // Use a `switch` statement to work with class constructors. See
  6373. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  6374. // for more details.
  6375. var args = arguments;
  6376. switch (args.length) {
  6377. case 0: return new Ctor;
  6378. case 1: return new Ctor(args[0]);
  6379. case 2: return new Ctor(args[0], args[1]);
  6380. case 3: return new Ctor(args[0], args[1], args[2]);
  6381. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  6382. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  6383. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  6384. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  6385. }
  6386. var thisBinding = baseCreate(Ctor.prototype),
  6387. result = Ctor.apply(thisBinding, args);
  6388. // Mimic the constructor's `return` behavior.
  6389. // See https://es5.github.io/#x13.2.2 for more details.
  6390. return isObject(result) ? result : thisBinding;
  6391. };
  6392. }
  6393. /**
  6394. * Creates a function that wraps `func` to enable currying.
  6395. *
  6396. * @private
  6397. * @param {Function} func The function to wrap.
  6398. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6399. * @param {number} arity The arity of `func`.
  6400. * @returns {Function} Returns the new wrapped function.
  6401. */
  6402. function createCurry(func, bitmask, arity) {
  6403. var Ctor = createCtor(func);
  6404. function wrapper() {
  6405. var length = arguments.length,
  6406. args = Array(length),
  6407. index = length,
  6408. placeholder = getHolder(wrapper);
  6409. while (index--) {
  6410. args[index] = arguments[index];
  6411. }
  6412. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  6413. ? []
  6414. : replaceHolders(args, placeholder);
  6415. length -= holders.length;
  6416. if (length < arity) {
  6417. return createRecurry(
  6418. func, bitmask, createHybrid, wrapper.placeholder, undefined$1,
  6419. args, holders, undefined$1, undefined$1, arity - length);
  6420. }
  6421. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6422. return apply(fn, this, args);
  6423. }
  6424. return wrapper;
  6425. }
  6426. /**
  6427. * Creates a `_.find` or `_.findLast` function.
  6428. *
  6429. * @private
  6430. * @param {Function} findIndexFunc The function to find the collection index.
  6431. * @returns {Function} Returns the new find function.
  6432. */
  6433. function createFind(findIndexFunc) {
  6434. return function(collection, predicate, fromIndex) {
  6435. var iterable = Object(collection);
  6436. if (!isArrayLike(collection)) {
  6437. var iteratee = getIteratee(predicate, 3);
  6438. collection = keys(collection);
  6439. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  6440. }
  6441. var index = findIndexFunc(collection, predicate, fromIndex);
  6442. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined$1;
  6443. };
  6444. }
  6445. /**
  6446. * Creates a `_.flow` or `_.flowRight` function.
  6447. *
  6448. * @private
  6449. * @param {boolean} [fromRight] Specify iterating from right to left.
  6450. * @returns {Function} Returns the new flow function.
  6451. */
  6452. function createFlow(fromRight) {
  6453. return flatRest(function(funcs) {
  6454. var length = funcs.length,
  6455. index = length,
  6456. prereq = LodashWrapper.prototype.thru;
  6457. if (fromRight) {
  6458. funcs.reverse();
  6459. }
  6460. while (index--) {
  6461. var func = funcs[index];
  6462. if (typeof func != 'function') {
  6463. throw new TypeError(FUNC_ERROR_TEXT);
  6464. }
  6465. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  6466. var wrapper = new LodashWrapper([], true);
  6467. }
  6468. }
  6469. index = wrapper ? index : length;
  6470. while (++index < length) {
  6471. func = funcs[index];
  6472. var funcName = getFuncName(func),
  6473. data = funcName == 'wrapper' ? getData(func) : undefined$1;
  6474. if (data && isLaziable(data[0]) &&
  6475. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  6476. !data[4].length && data[9] == 1
  6477. ) {
  6478. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  6479. } else {
  6480. wrapper = (func.length == 1 && isLaziable(func))
  6481. ? wrapper[funcName]()
  6482. : wrapper.thru(func);
  6483. }
  6484. }
  6485. return function() {
  6486. var args = arguments,
  6487. value = args[0];
  6488. if (wrapper && args.length == 1 && isArray(value)) {
  6489. return wrapper.plant(value).value();
  6490. }
  6491. var index = 0,
  6492. result = length ? funcs[index].apply(this, args) : value;
  6493. while (++index < length) {
  6494. result = funcs[index].call(this, result);
  6495. }
  6496. return result;
  6497. };
  6498. });
  6499. }
  6500. /**
  6501. * Creates a function that wraps `func` to invoke it with optional `this`
  6502. * binding of `thisArg`, partial application, and currying.
  6503. *
  6504. * @private
  6505. * @param {Function|string} func The function or method name to wrap.
  6506. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6507. * @param {*} [thisArg] The `this` binding of `func`.
  6508. * @param {Array} [partials] The arguments to prepend to those provided to
  6509. * the new function.
  6510. * @param {Array} [holders] The `partials` placeholder indexes.
  6511. * @param {Array} [partialsRight] The arguments to append to those provided
  6512. * to the new function.
  6513. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  6514. * @param {Array} [argPos] The argument positions of the new function.
  6515. * @param {number} [ary] The arity cap of `func`.
  6516. * @param {number} [arity] The arity of `func`.
  6517. * @returns {Function} Returns the new wrapped function.
  6518. */
  6519. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  6520. var isAry = bitmask & WRAP_ARY_FLAG,
  6521. isBind = bitmask & WRAP_BIND_FLAG,
  6522. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  6523. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  6524. isFlip = bitmask & WRAP_FLIP_FLAG,
  6525. Ctor = isBindKey ? undefined$1 : createCtor(func);
  6526. function wrapper() {
  6527. var length = arguments.length,
  6528. args = Array(length),
  6529. index = length;
  6530. while (index--) {
  6531. args[index] = arguments[index];
  6532. }
  6533. if (isCurried) {
  6534. var placeholder = getHolder(wrapper),
  6535. holdersCount = countHolders(args, placeholder);
  6536. }
  6537. if (partials) {
  6538. args = composeArgs(args, partials, holders, isCurried);
  6539. }
  6540. if (partialsRight) {
  6541. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  6542. }
  6543. length -= holdersCount;
  6544. if (isCurried && length < arity) {
  6545. var newHolders = replaceHolders(args, placeholder);
  6546. return createRecurry(
  6547. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  6548. args, newHolders, argPos, ary, arity - length
  6549. );
  6550. }
  6551. var thisBinding = isBind ? thisArg : this,
  6552. fn = isBindKey ? thisBinding[func] : func;
  6553. length = args.length;
  6554. if (argPos) {
  6555. args = reorder(args, argPos);
  6556. } else if (isFlip && length > 1) {
  6557. args.reverse();
  6558. }
  6559. if (isAry && ary < length) {
  6560. args.length = ary;
  6561. }
  6562. if (this && this !== root && this instanceof wrapper) {
  6563. fn = Ctor || createCtor(fn);
  6564. }
  6565. return fn.apply(thisBinding, args);
  6566. }
  6567. return wrapper;
  6568. }
  6569. /**
  6570. * Creates a function like `_.invertBy`.
  6571. *
  6572. * @private
  6573. * @param {Function} setter The function to set accumulator values.
  6574. * @param {Function} toIteratee The function to resolve iteratees.
  6575. * @returns {Function} Returns the new inverter function.
  6576. */
  6577. function createInverter(setter, toIteratee) {
  6578. return function(object, iteratee) {
  6579. return baseInverter(object, setter, toIteratee(iteratee), {});
  6580. };
  6581. }
  6582. /**
  6583. * Creates a function that performs a mathematical operation on two values.
  6584. *
  6585. * @private
  6586. * @param {Function} operator The function to perform the operation.
  6587. * @param {number} [defaultValue] The value used for `undefined` arguments.
  6588. * @returns {Function} Returns the new mathematical operation function.
  6589. */
  6590. function createMathOperation(operator, defaultValue) {
  6591. return function(value, other) {
  6592. var result;
  6593. if (value === undefined$1 && other === undefined$1) {
  6594. return defaultValue;
  6595. }
  6596. if (value !== undefined$1) {
  6597. result = value;
  6598. }
  6599. if (other !== undefined$1) {
  6600. if (result === undefined$1) {
  6601. return other;
  6602. }
  6603. if (typeof value == 'string' || typeof other == 'string') {
  6604. value = baseToString(value);
  6605. other = baseToString(other);
  6606. } else {
  6607. value = baseToNumber(value);
  6608. other = baseToNumber(other);
  6609. }
  6610. result = operator(value, other);
  6611. }
  6612. return result;
  6613. };
  6614. }
  6615. /**
  6616. * Creates a function like `_.over`.
  6617. *
  6618. * @private
  6619. * @param {Function} arrayFunc The function to iterate over iteratees.
  6620. * @returns {Function} Returns the new over function.
  6621. */
  6622. function createOver(arrayFunc) {
  6623. return flatRest(function(iteratees) {
  6624. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  6625. return baseRest(function(args) {
  6626. var thisArg = this;
  6627. return arrayFunc(iteratees, function(iteratee) {
  6628. return apply(iteratee, thisArg, args);
  6629. });
  6630. });
  6631. });
  6632. }
  6633. /**
  6634. * Creates the padding for `string` based on `length`. The `chars` string
  6635. * is truncated if the number of characters exceeds `length`.
  6636. *
  6637. * @private
  6638. * @param {number} length The padding length.
  6639. * @param {string} [chars=' '] The string used as padding.
  6640. * @returns {string} Returns the padding for `string`.
  6641. */
  6642. function createPadding(length, chars) {
  6643. chars = chars === undefined$1 ? ' ' : baseToString(chars);
  6644. var charsLength = chars.length;
  6645. if (charsLength < 2) {
  6646. return charsLength ? baseRepeat(chars, length) : chars;
  6647. }
  6648. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  6649. return hasUnicode(chars)
  6650. ? castSlice(stringToArray(result), 0, length).join('')
  6651. : result.slice(0, length);
  6652. }
  6653. /**
  6654. * Creates a function that wraps `func` to invoke it with the `this` binding
  6655. * of `thisArg` and `partials` prepended to the arguments it receives.
  6656. *
  6657. * @private
  6658. * @param {Function} func The function to wrap.
  6659. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6660. * @param {*} thisArg The `this` binding of `func`.
  6661. * @param {Array} partials The arguments to prepend to those provided to
  6662. * the new function.
  6663. * @returns {Function} Returns the new wrapped function.
  6664. */
  6665. function createPartial(func, bitmask, thisArg, partials) {
  6666. var isBind = bitmask & WRAP_BIND_FLAG,
  6667. Ctor = createCtor(func);
  6668. function wrapper() {
  6669. var argsIndex = -1,
  6670. argsLength = arguments.length,
  6671. leftIndex = -1,
  6672. leftLength = partials.length,
  6673. args = Array(leftLength + argsLength),
  6674. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6675. while (++leftIndex < leftLength) {
  6676. args[leftIndex] = partials[leftIndex];
  6677. }
  6678. while (argsLength--) {
  6679. args[leftIndex++] = arguments[++argsIndex];
  6680. }
  6681. return apply(fn, isBind ? thisArg : this, args);
  6682. }
  6683. return wrapper;
  6684. }
  6685. /**
  6686. * Creates a `_.range` or `_.rangeRight` function.
  6687. *
  6688. * @private
  6689. * @param {boolean} [fromRight] Specify iterating from right to left.
  6690. * @returns {Function} Returns the new range function.
  6691. */
  6692. function createRange(fromRight) {
  6693. return function(start, end, step) {
  6694. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  6695. end = step = undefined$1;
  6696. }
  6697. // Ensure the sign of `-0` is preserved.
  6698. start = toFinite(start);
  6699. if (end === undefined$1) {
  6700. end = start;
  6701. start = 0;
  6702. } else {
  6703. end = toFinite(end);
  6704. }
  6705. step = step === undefined$1 ? (start < end ? 1 : -1) : toFinite(step);
  6706. return baseRange(start, end, step, fromRight);
  6707. };
  6708. }
  6709. /**
  6710. * Creates a function that performs a relational operation on two values.
  6711. *
  6712. * @private
  6713. * @param {Function} operator The function to perform the operation.
  6714. * @returns {Function} Returns the new relational operation function.
  6715. */
  6716. function createRelationalOperation(operator) {
  6717. return function(value, other) {
  6718. if (!(typeof value == 'string' && typeof other == 'string')) {
  6719. value = toNumber(value);
  6720. other = toNumber(other);
  6721. }
  6722. return operator(value, other);
  6723. };
  6724. }
  6725. /**
  6726. * Creates a function that wraps `func` to continue currying.
  6727. *
  6728. * @private
  6729. * @param {Function} func The function to wrap.
  6730. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6731. * @param {Function} wrapFunc The function to create the `func` wrapper.
  6732. * @param {*} placeholder The placeholder value.
  6733. * @param {*} [thisArg] The `this` binding of `func`.
  6734. * @param {Array} [partials] The arguments to prepend to those provided to
  6735. * the new function.
  6736. * @param {Array} [holders] The `partials` placeholder indexes.
  6737. * @param {Array} [argPos] The argument positions of the new function.
  6738. * @param {number} [ary] The arity cap of `func`.
  6739. * @param {number} [arity] The arity of `func`.
  6740. * @returns {Function} Returns the new wrapped function.
  6741. */
  6742. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  6743. var isCurry = bitmask & WRAP_CURRY_FLAG,
  6744. newHolders = isCurry ? holders : undefined$1,
  6745. newHoldersRight = isCurry ? undefined$1 : holders,
  6746. newPartials = isCurry ? partials : undefined$1,
  6747. newPartialsRight = isCurry ? undefined$1 : partials;
  6748. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  6749. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  6750. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  6751. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  6752. }
  6753. var newData = [
  6754. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  6755. newHoldersRight, argPos, ary, arity
  6756. ];
  6757. var result = wrapFunc.apply(undefined$1, newData);
  6758. if (isLaziable(func)) {
  6759. setData(result, newData);
  6760. }
  6761. result.placeholder = placeholder;
  6762. return setWrapToString(result, func, bitmask);
  6763. }
  6764. /**
  6765. * Creates a function like `_.round`.
  6766. *
  6767. * @private
  6768. * @param {string} methodName The name of the `Math` method to use when rounding.
  6769. * @returns {Function} Returns the new round function.
  6770. */
  6771. function createRound(methodName) {
  6772. var func = Math[methodName];
  6773. return function(number, precision) {
  6774. number = toNumber(number);
  6775. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  6776. if (precision && nativeIsFinite(number)) {
  6777. // Shift with exponential notation to avoid floating-point issues.
  6778. // See [MDN](https://mdn.io/round#Examples) for more details.
  6779. var pair = (toString(number) + 'e').split('e'),
  6780. value = func(pair[0] + 'e' + (+pair[1] + precision));
  6781. pair = (toString(value) + 'e').split('e');
  6782. return +(pair[0] + 'e' + (+pair[1] - precision));
  6783. }
  6784. return func(number);
  6785. };
  6786. }
  6787. /**
  6788. * Creates a set object of `values`.
  6789. *
  6790. * @private
  6791. * @param {Array} values The values to add to the set.
  6792. * @returns {Object} Returns the new set.
  6793. */
  6794. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  6795. return new Set(values);
  6796. };
  6797. /**
  6798. * Creates a `_.toPairs` or `_.toPairsIn` function.
  6799. *
  6800. * @private
  6801. * @param {Function} keysFunc The function to get the keys of a given object.
  6802. * @returns {Function} Returns the new pairs function.
  6803. */
  6804. function createToPairs(keysFunc) {
  6805. return function(object) {
  6806. var tag = getTag(object);
  6807. if (tag == mapTag) {
  6808. return mapToArray(object);
  6809. }
  6810. if (tag == setTag) {
  6811. return setToPairs(object);
  6812. }
  6813. return baseToPairs(object, keysFunc(object));
  6814. };
  6815. }
  6816. /**
  6817. * Creates a function that either curries or invokes `func` with optional
  6818. * `this` binding and partially applied arguments.
  6819. *
  6820. * @private
  6821. * @param {Function|string} func The function or method name to wrap.
  6822. * @param {number} bitmask The bitmask flags.
  6823. * 1 - `_.bind`
  6824. * 2 - `_.bindKey`
  6825. * 4 - `_.curry` or `_.curryRight` of a bound function
  6826. * 8 - `_.curry`
  6827. * 16 - `_.curryRight`
  6828. * 32 - `_.partial`
  6829. * 64 - `_.partialRight`
  6830. * 128 - `_.rearg`
  6831. * 256 - `_.ary`
  6832. * 512 - `_.flip`
  6833. * @param {*} [thisArg] The `this` binding of `func`.
  6834. * @param {Array} [partials] The arguments to be partially applied.
  6835. * @param {Array} [holders] The `partials` placeholder indexes.
  6836. * @param {Array} [argPos] The argument positions of the new function.
  6837. * @param {number} [ary] The arity cap of `func`.
  6838. * @param {number} [arity] The arity of `func`.
  6839. * @returns {Function} Returns the new wrapped function.
  6840. */
  6841. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  6842. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  6843. if (!isBindKey && typeof func != 'function') {
  6844. throw new TypeError(FUNC_ERROR_TEXT);
  6845. }
  6846. var length = partials ? partials.length : 0;
  6847. if (!length) {
  6848. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  6849. partials = holders = undefined$1;
  6850. }
  6851. ary = ary === undefined$1 ? ary : nativeMax(toInteger(ary), 0);
  6852. arity = arity === undefined$1 ? arity : toInteger(arity);
  6853. length -= holders ? holders.length : 0;
  6854. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  6855. var partialsRight = partials,
  6856. holdersRight = holders;
  6857. partials = holders = undefined$1;
  6858. }
  6859. var data = isBindKey ? undefined$1 : getData(func);
  6860. var newData = [
  6861. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  6862. argPos, ary, arity
  6863. ];
  6864. if (data) {
  6865. mergeData(newData, data);
  6866. }
  6867. func = newData[0];
  6868. bitmask = newData[1];
  6869. thisArg = newData[2];
  6870. partials = newData[3];
  6871. holders = newData[4];
  6872. arity = newData[9] = newData[9] === undefined$1
  6873. ? (isBindKey ? 0 : func.length)
  6874. : nativeMax(newData[9] - length, 0);
  6875. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  6876. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  6877. }
  6878. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  6879. var result = createBind(func, bitmask, thisArg);
  6880. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  6881. result = createCurry(func, bitmask, arity);
  6882. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  6883. result = createPartial(func, bitmask, thisArg, partials);
  6884. } else {
  6885. result = createHybrid.apply(undefined$1, newData);
  6886. }
  6887. var setter = data ? baseSetData : setData;
  6888. return setWrapToString(setter(result, newData), func, bitmask);
  6889. }
  6890. /**
  6891. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  6892. * of source objects to the destination object for all destination properties
  6893. * that resolve to `undefined`.
  6894. *
  6895. * @private
  6896. * @param {*} objValue The destination value.
  6897. * @param {*} srcValue The source value.
  6898. * @param {string} key The key of the property to assign.
  6899. * @param {Object} object The parent object of `objValue`.
  6900. * @returns {*} Returns the value to assign.
  6901. */
  6902. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  6903. if (objValue === undefined$1 ||
  6904. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  6905. return srcValue;
  6906. }
  6907. return objValue;
  6908. }
  6909. /**
  6910. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  6911. * objects into destination objects that are passed thru.
  6912. *
  6913. * @private
  6914. * @param {*} objValue The destination value.
  6915. * @param {*} srcValue The source value.
  6916. * @param {string} key The key of the property to merge.
  6917. * @param {Object} object The parent object of `objValue`.
  6918. * @param {Object} source The parent object of `srcValue`.
  6919. * @param {Object} [stack] Tracks traversed source values and their merged
  6920. * counterparts.
  6921. * @returns {*} Returns the value to assign.
  6922. */
  6923. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  6924. if (isObject(objValue) && isObject(srcValue)) {
  6925. // Recursively merge objects and arrays (susceptible to call stack limits).
  6926. stack.set(srcValue, objValue);
  6927. baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
  6928. stack['delete'](srcValue);
  6929. }
  6930. return objValue;
  6931. }
  6932. /**
  6933. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  6934. * objects.
  6935. *
  6936. * @private
  6937. * @param {*} value The value to inspect.
  6938. * @param {string} key The key of the property to inspect.
  6939. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  6940. */
  6941. function customOmitClone(value) {
  6942. return isPlainObject(value) ? undefined$1 : value;
  6943. }
  6944. /**
  6945. * A specialized version of `baseIsEqualDeep` for arrays with support for
  6946. * partial deep comparisons.
  6947. *
  6948. * @private
  6949. * @param {Array} array The array to compare.
  6950. * @param {Array} other The other array to compare.
  6951. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6952. * @param {Function} customizer The function to customize comparisons.
  6953. * @param {Function} equalFunc The function to determine equivalents of values.
  6954. * @param {Object} stack Tracks traversed `array` and `other` objects.
  6955. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  6956. */
  6957. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  6958. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6959. arrLength = array.length,
  6960. othLength = other.length;
  6961. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  6962. return false;
  6963. }
  6964. // Check that cyclic values are equal.
  6965. var arrStacked = stack.get(array);
  6966. var othStacked = stack.get(other);
  6967. if (arrStacked && othStacked) {
  6968. return arrStacked == other && othStacked == array;
  6969. }
  6970. var index = -1,
  6971. result = true,
  6972. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined$1;
  6973. stack.set(array, other);
  6974. stack.set(other, array);
  6975. // Ignore non-index properties.
  6976. while (++index < arrLength) {
  6977. var arrValue = array[index],
  6978. othValue = other[index];
  6979. if (customizer) {
  6980. var compared = isPartial
  6981. ? customizer(othValue, arrValue, index, other, array, stack)
  6982. : customizer(arrValue, othValue, index, array, other, stack);
  6983. }
  6984. if (compared !== undefined$1) {
  6985. if (compared) {
  6986. continue;
  6987. }
  6988. result = false;
  6989. break;
  6990. }
  6991. // Recursively compare arrays (susceptible to call stack limits).
  6992. if (seen) {
  6993. if (!arraySome(other, function(othValue, othIndex) {
  6994. if (!cacheHas(seen, othIndex) &&
  6995. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6996. return seen.push(othIndex);
  6997. }
  6998. })) {
  6999. result = false;
  7000. break;
  7001. }
  7002. } else if (!(
  7003. arrValue === othValue ||
  7004. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  7005. )) {
  7006. result = false;
  7007. break;
  7008. }
  7009. }
  7010. stack['delete'](array);
  7011. stack['delete'](other);
  7012. return result;
  7013. }
  7014. /**
  7015. * A specialized version of `baseIsEqualDeep` for comparing objects of
  7016. * the same `toStringTag`.
  7017. *
  7018. * **Note:** This function only supports comparing values with tags of
  7019. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  7020. *
  7021. * @private
  7022. * @param {Object} object The object to compare.
  7023. * @param {Object} other The other object to compare.
  7024. * @param {string} tag The `toStringTag` of the objects to compare.
  7025. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7026. * @param {Function} customizer The function to customize comparisons.
  7027. * @param {Function} equalFunc The function to determine equivalents of values.
  7028. * @param {Object} stack Tracks traversed `object` and `other` objects.
  7029. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7030. */
  7031. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  7032. switch (tag) {
  7033. case dataViewTag:
  7034. if ((object.byteLength != other.byteLength) ||
  7035. (object.byteOffset != other.byteOffset)) {
  7036. return false;
  7037. }
  7038. object = object.buffer;
  7039. other = other.buffer;
  7040. case arrayBufferTag:
  7041. if ((object.byteLength != other.byteLength) ||
  7042. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  7043. return false;
  7044. }
  7045. return true;
  7046. case boolTag:
  7047. case dateTag:
  7048. case numberTag:
  7049. // Coerce booleans to `1` or `0` and dates to milliseconds.
  7050. // Invalid dates are coerced to `NaN`.
  7051. return eq(+object, +other);
  7052. case errorTag:
  7053. return object.name == other.name && object.message == other.message;
  7054. case regexpTag:
  7055. case stringTag:
  7056. // Coerce regexes to strings and treat strings, primitives and objects,
  7057. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  7058. // for more details.
  7059. return object == (other + '');
  7060. case mapTag:
  7061. var convert = mapToArray;
  7062. case setTag:
  7063. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  7064. convert || (convert = setToArray);
  7065. if (object.size != other.size && !isPartial) {
  7066. return false;
  7067. }
  7068. // Assume cyclic values are equal.
  7069. var stacked = stack.get(object);
  7070. if (stacked) {
  7071. return stacked == other;
  7072. }
  7073. bitmask |= COMPARE_UNORDERED_FLAG;
  7074. // Recursively compare objects (susceptible to call stack limits).
  7075. stack.set(object, other);
  7076. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  7077. stack['delete'](object);
  7078. return result;
  7079. case symbolTag:
  7080. if (symbolValueOf) {
  7081. return symbolValueOf.call(object) == symbolValueOf.call(other);
  7082. }
  7083. }
  7084. return false;
  7085. }
  7086. /**
  7087. * A specialized version of `baseIsEqualDeep` for objects with support for
  7088. * partial deep comparisons.
  7089. *
  7090. * @private
  7091. * @param {Object} object The object to compare.
  7092. * @param {Object} other The other object to compare.
  7093. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7094. * @param {Function} customizer The function to customize comparisons.
  7095. * @param {Function} equalFunc The function to determine equivalents of values.
  7096. * @param {Object} stack Tracks traversed `object` and `other` objects.
  7097. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7098. */
  7099. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  7100. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  7101. objProps = getAllKeys(object),
  7102. objLength = objProps.length,
  7103. othProps = getAllKeys(other),
  7104. othLength = othProps.length;
  7105. if (objLength != othLength && !isPartial) {
  7106. return false;
  7107. }
  7108. var index = objLength;
  7109. while (index--) {
  7110. var key = objProps[index];
  7111. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  7112. return false;
  7113. }
  7114. }
  7115. // Check that cyclic values are equal.
  7116. var objStacked = stack.get(object);
  7117. var othStacked = stack.get(other);
  7118. if (objStacked && othStacked) {
  7119. return objStacked == other && othStacked == object;
  7120. }
  7121. var result = true;
  7122. stack.set(object, other);
  7123. stack.set(other, object);
  7124. var skipCtor = isPartial;
  7125. while (++index < objLength) {
  7126. key = objProps[index];
  7127. var objValue = object[key],
  7128. othValue = other[key];
  7129. if (customizer) {
  7130. var compared = isPartial
  7131. ? customizer(othValue, objValue, key, other, object, stack)
  7132. : customizer(objValue, othValue, key, object, other, stack);
  7133. }
  7134. // Recursively compare objects (susceptible to call stack limits).
  7135. if (!(compared === undefined$1
  7136. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  7137. : compared
  7138. )) {
  7139. result = false;
  7140. break;
  7141. }
  7142. skipCtor || (skipCtor = key == 'constructor');
  7143. }
  7144. if (result && !skipCtor) {
  7145. var objCtor = object.constructor,
  7146. othCtor = other.constructor;
  7147. // Non `Object` object instances with different constructors are not equal.
  7148. if (objCtor != othCtor &&
  7149. ('constructor' in object && 'constructor' in other) &&
  7150. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  7151. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  7152. result = false;
  7153. }
  7154. }
  7155. stack['delete'](object);
  7156. stack['delete'](other);
  7157. return result;
  7158. }
  7159. /**
  7160. * A specialized version of `baseRest` which flattens the rest array.
  7161. *
  7162. * @private
  7163. * @param {Function} func The function to apply a rest parameter to.
  7164. * @returns {Function} Returns the new function.
  7165. */
  7166. function flatRest(func) {
  7167. return setToString(overRest(func, undefined$1, flatten), func + '');
  7168. }
  7169. /**
  7170. * Creates an array of own enumerable property names and symbols of `object`.
  7171. *
  7172. * @private
  7173. * @param {Object} object The object to query.
  7174. * @returns {Array} Returns the array of property names and symbols.
  7175. */
  7176. function getAllKeys(object) {
  7177. return baseGetAllKeys(object, keys, getSymbols);
  7178. }
  7179. /**
  7180. * Creates an array of own and inherited enumerable property names and
  7181. * symbols of `object`.
  7182. *
  7183. * @private
  7184. * @param {Object} object The object to query.
  7185. * @returns {Array} Returns the array of property names and symbols.
  7186. */
  7187. function getAllKeysIn(object) {
  7188. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  7189. }
  7190. /**
  7191. * Gets metadata for `func`.
  7192. *
  7193. * @private
  7194. * @param {Function} func The function to query.
  7195. * @returns {*} Returns the metadata for `func`.
  7196. */
  7197. var getData = !metaMap ? noop : function(func) {
  7198. return metaMap.get(func);
  7199. };
  7200. /**
  7201. * Gets the name of `func`.
  7202. *
  7203. * @private
  7204. * @param {Function} func The function to query.
  7205. * @returns {string} Returns the function name.
  7206. */
  7207. function getFuncName(func) {
  7208. var result = (func.name + ''),
  7209. array = realNames[result],
  7210. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  7211. while (length--) {
  7212. var data = array[length],
  7213. otherFunc = data.func;
  7214. if (otherFunc == null || otherFunc == func) {
  7215. return data.name;
  7216. }
  7217. }
  7218. return result;
  7219. }
  7220. /**
  7221. * Gets the argument placeholder value for `func`.
  7222. *
  7223. * @private
  7224. * @param {Function} func The function to inspect.
  7225. * @returns {*} Returns the placeholder value.
  7226. */
  7227. function getHolder(func) {
  7228. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  7229. return object.placeholder;
  7230. }
  7231. /**
  7232. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  7233. * this function returns the custom method, otherwise it returns `baseIteratee`.
  7234. * If arguments are provided, the chosen function is invoked with them and
  7235. * its result is returned.
  7236. *
  7237. * @private
  7238. * @param {*} [value] The value to convert to an iteratee.
  7239. * @param {number} [arity] The arity of the created iteratee.
  7240. * @returns {Function} Returns the chosen function or its result.
  7241. */
  7242. function getIteratee() {
  7243. var result = lodash.iteratee || iteratee;
  7244. result = result === iteratee ? baseIteratee : result;
  7245. return arguments.length ? result(arguments[0], arguments[1]) : result;
  7246. }
  7247. /**
  7248. * Gets the data for `map`.
  7249. *
  7250. * @private
  7251. * @param {Object} map The map to query.
  7252. * @param {string} key The reference key.
  7253. * @returns {*} Returns the map data.
  7254. */
  7255. function getMapData(map, key) {
  7256. var data = map.__data__;
  7257. return isKeyable(key)
  7258. ? data[typeof key == 'string' ? 'string' : 'hash']
  7259. : data.map;
  7260. }
  7261. /**
  7262. * Gets the property names, values, and compare flags of `object`.
  7263. *
  7264. * @private
  7265. * @param {Object} object The object to query.
  7266. * @returns {Array} Returns the match data of `object`.
  7267. */
  7268. function getMatchData(object) {
  7269. var result = keys(object),
  7270. length = result.length;
  7271. while (length--) {
  7272. var key = result[length],
  7273. value = object[key];
  7274. result[length] = [key, value, isStrictComparable(value)];
  7275. }
  7276. return result;
  7277. }
  7278. /**
  7279. * Gets the native function at `key` of `object`.
  7280. *
  7281. * @private
  7282. * @param {Object} object The object to query.
  7283. * @param {string} key The key of the method to get.
  7284. * @returns {*} Returns the function if it's native, else `undefined`.
  7285. */
  7286. function getNative(object, key) {
  7287. var value = getValue(object, key);
  7288. return baseIsNative(value) ? value : undefined$1;
  7289. }
  7290. /**
  7291. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  7292. *
  7293. * @private
  7294. * @param {*} value The value to query.
  7295. * @returns {string} Returns the raw `toStringTag`.
  7296. */
  7297. function getRawTag(value) {
  7298. var isOwn = hasOwnProperty.call(value, symToStringTag),
  7299. tag = value[symToStringTag];
  7300. try {
  7301. value[symToStringTag] = undefined$1;
  7302. var unmasked = true;
  7303. } catch (e) {}
  7304. var result = nativeObjectToString.call(value);
  7305. if (unmasked) {
  7306. if (isOwn) {
  7307. value[symToStringTag] = tag;
  7308. } else {
  7309. delete value[symToStringTag];
  7310. }
  7311. }
  7312. return result;
  7313. }
  7314. /**
  7315. * Creates an array of the own enumerable symbols of `object`.
  7316. *
  7317. * @private
  7318. * @param {Object} object The object to query.
  7319. * @returns {Array} Returns the array of symbols.
  7320. */
  7321. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  7322. if (object == null) {
  7323. return [];
  7324. }
  7325. object = Object(object);
  7326. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  7327. return propertyIsEnumerable.call(object, symbol);
  7328. });
  7329. };
  7330. /**
  7331. * Creates an array of the own and inherited enumerable symbols of `object`.
  7332. *
  7333. * @private
  7334. * @param {Object} object The object to query.
  7335. * @returns {Array} Returns the array of symbols.
  7336. */
  7337. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  7338. var result = [];
  7339. while (object) {
  7340. arrayPush(result, getSymbols(object));
  7341. object = getPrototype(object);
  7342. }
  7343. return result;
  7344. };
  7345. /**
  7346. * Gets the `toStringTag` of `value`.
  7347. *
  7348. * @private
  7349. * @param {*} value The value to query.
  7350. * @returns {string} Returns the `toStringTag`.
  7351. */
  7352. var getTag = baseGetTag;
  7353. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  7354. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  7355. (Map && getTag(new Map) != mapTag) ||
  7356. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  7357. (Set && getTag(new Set) != setTag) ||
  7358. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  7359. getTag = function(value) {
  7360. var result = baseGetTag(value),
  7361. Ctor = result == objectTag ? value.constructor : undefined$1,
  7362. ctorString = Ctor ? toSource(Ctor) : '';
  7363. if (ctorString) {
  7364. switch (ctorString) {
  7365. case dataViewCtorString: return dataViewTag;
  7366. case mapCtorString: return mapTag;
  7367. case promiseCtorString: return promiseTag;
  7368. case setCtorString: return setTag;
  7369. case weakMapCtorString: return weakMapTag;
  7370. }
  7371. }
  7372. return result;
  7373. };
  7374. }
  7375. /**
  7376. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  7377. *
  7378. * @private
  7379. * @param {number} start The start of the view.
  7380. * @param {number} end The end of the view.
  7381. * @param {Array} transforms The transformations to apply to the view.
  7382. * @returns {Object} Returns an object containing the `start` and `end`
  7383. * positions of the view.
  7384. */
  7385. function getView(start, end, transforms) {
  7386. var index = -1,
  7387. length = transforms.length;
  7388. while (++index < length) {
  7389. var data = transforms[index],
  7390. size = data.size;
  7391. switch (data.type) {
  7392. case 'drop': start += size; break;
  7393. case 'dropRight': end -= size; break;
  7394. case 'take': end = nativeMin(end, start + size); break;
  7395. case 'takeRight': start = nativeMax(start, end - size); break;
  7396. }
  7397. }
  7398. return { 'start': start, 'end': end };
  7399. }
  7400. /**
  7401. * Extracts wrapper details from the `source` body comment.
  7402. *
  7403. * @private
  7404. * @param {string} source The source to inspect.
  7405. * @returns {Array} Returns the wrapper details.
  7406. */
  7407. function getWrapDetails(source) {
  7408. var match = source.match(reWrapDetails);
  7409. return match ? match[1].split(reSplitDetails) : [];
  7410. }
  7411. /**
  7412. * Checks if `path` exists on `object`.
  7413. *
  7414. * @private
  7415. * @param {Object} object The object to query.
  7416. * @param {Array|string} path The path to check.
  7417. * @param {Function} hasFunc The function to check properties.
  7418. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  7419. */
  7420. function hasPath(object, path, hasFunc) {
  7421. path = castPath(path, object);
  7422. var index = -1,
  7423. length = path.length,
  7424. result = false;
  7425. while (++index < length) {
  7426. var key = toKey(path[index]);
  7427. if (!(result = object != null && hasFunc(object, key))) {
  7428. break;
  7429. }
  7430. object = object[key];
  7431. }
  7432. if (result || ++index != length) {
  7433. return result;
  7434. }
  7435. length = object == null ? 0 : object.length;
  7436. return !!length && isLength(length) && isIndex(key, length) &&
  7437. (isArray(object) || isArguments(object));
  7438. }
  7439. /**
  7440. * Initializes an array clone.
  7441. *
  7442. * @private
  7443. * @param {Array} array The array to clone.
  7444. * @returns {Array} Returns the initialized clone.
  7445. */
  7446. function initCloneArray(array) {
  7447. var length = array.length,
  7448. result = new array.constructor(length);
  7449. // Add properties assigned by `RegExp#exec`.
  7450. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  7451. result.index = array.index;
  7452. result.input = array.input;
  7453. }
  7454. return result;
  7455. }
  7456. /**
  7457. * Initializes an object clone.
  7458. *
  7459. * @private
  7460. * @param {Object} object The object to clone.
  7461. * @returns {Object} Returns the initialized clone.
  7462. */
  7463. function initCloneObject(object) {
  7464. return (typeof object.constructor == 'function' && !isPrototype(object))
  7465. ? baseCreate(getPrototype(object))
  7466. : {};
  7467. }
  7468. /**
  7469. * Initializes an object clone based on its `toStringTag`.
  7470. *
  7471. * **Note:** This function only supports cloning values with tags of
  7472. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  7473. *
  7474. * @private
  7475. * @param {Object} object The object to clone.
  7476. * @param {string} tag The `toStringTag` of the object to clone.
  7477. * @param {boolean} [isDeep] Specify a deep clone.
  7478. * @returns {Object} Returns the initialized clone.
  7479. */
  7480. function initCloneByTag(object, tag, isDeep) {
  7481. var Ctor = object.constructor;
  7482. switch (tag) {
  7483. case arrayBufferTag:
  7484. return cloneArrayBuffer(object);
  7485. case boolTag:
  7486. case dateTag:
  7487. return new Ctor(+object);
  7488. case dataViewTag:
  7489. return cloneDataView(object, isDeep);
  7490. case float32Tag: case float64Tag:
  7491. case int8Tag: case int16Tag: case int32Tag:
  7492. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  7493. return cloneTypedArray(object, isDeep);
  7494. case mapTag:
  7495. return new Ctor;
  7496. case numberTag:
  7497. case stringTag:
  7498. return new Ctor(object);
  7499. case regexpTag:
  7500. return cloneRegExp(object);
  7501. case setTag:
  7502. return new Ctor;
  7503. case symbolTag:
  7504. return cloneSymbol(object);
  7505. }
  7506. }
  7507. /**
  7508. * Inserts wrapper `details` in a comment at the top of the `source` body.
  7509. *
  7510. * @private
  7511. * @param {string} source The source to modify.
  7512. * @returns {Array} details The details to insert.
  7513. * @returns {string} Returns the modified source.
  7514. */
  7515. function insertWrapDetails(source, details) {
  7516. var length = details.length;
  7517. if (!length) {
  7518. return source;
  7519. }
  7520. var lastIndex = length - 1;
  7521. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  7522. details = details.join(length > 2 ? ', ' : ' ');
  7523. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  7524. }
  7525. /**
  7526. * Checks if `value` is a flattenable `arguments` object or array.
  7527. *
  7528. * @private
  7529. * @param {*} value The value to check.
  7530. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  7531. */
  7532. function isFlattenable(value) {
  7533. return isArray(value) || isArguments(value) ||
  7534. !!(spreadableSymbol && value && value[spreadableSymbol]);
  7535. }
  7536. /**
  7537. * Checks if `value` is a valid array-like index.
  7538. *
  7539. * @private
  7540. * @param {*} value The value to check.
  7541. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  7542. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  7543. */
  7544. function isIndex(value, length) {
  7545. var type = typeof value;
  7546. length = length == null ? MAX_SAFE_INTEGER : length;
  7547. return !!length &&
  7548. (type == 'number' ||
  7549. (type != 'symbol' && reIsUint.test(value))) &&
  7550. (value > -1 && value % 1 == 0 && value < length);
  7551. }
  7552. /**
  7553. * Checks if the given arguments are from an iteratee call.
  7554. *
  7555. * @private
  7556. * @param {*} value The potential iteratee value argument.
  7557. * @param {*} index The potential iteratee index or key argument.
  7558. * @param {*} object The potential iteratee object argument.
  7559. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  7560. * else `false`.
  7561. */
  7562. function isIterateeCall(value, index, object) {
  7563. if (!isObject(object)) {
  7564. return false;
  7565. }
  7566. var type = typeof index;
  7567. if (type == 'number'
  7568. ? (isArrayLike(object) && isIndex(index, object.length))
  7569. : (type == 'string' && index in object)
  7570. ) {
  7571. return eq(object[index], value);
  7572. }
  7573. return false;
  7574. }
  7575. /**
  7576. * Checks if `value` is a property name and not a property path.
  7577. *
  7578. * @private
  7579. * @param {*} value The value to check.
  7580. * @param {Object} [object] The object to query keys on.
  7581. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  7582. */
  7583. function isKey(value, object) {
  7584. if (isArray(value)) {
  7585. return false;
  7586. }
  7587. var type = typeof value;
  7588. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  7589. value == null || isSymbol(value)) {
  7590. return true;
  7591. }
  7592. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  7593. (object != null && value in Object(object));
  7594. }
  7595. /**
  7596. * Checks if `value` is suitable for use as unique object key.
  7597. *
  7598. * @private
  7599. * @param {*} value The value to check.
  7600. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  7601. */
  7602. function isKeyable(value) {
  7603. var type = typeof value;
  7604. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  7605. ? (value !== '__proto__')
  7606. : (value === null);
  7607. }
  7608. /**
  7609. * Checks if `func` has a lazy counterpart.
  7610. *
  7611. * @private
  7612. * @param {Function} func The function to check.
  7613. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  7614. * else `false`.
  7615. */
  7616. function isLaziable(func) {
  7617. var funcName = getFuncName(func),
  7618. other = lodash[funcName];
  7619. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  7620. return false;
  7621. }
  7622. if (func === other) {
  7623. return true;
  7624. }
  7625. var data = getData(other);
  7626. return !!data && func === data[0];
  7627. }
  7628. /**
  7629. * Checks if `func` has its source masked.
  7630. *
  7631. * @private
  7632. * @param {Function} func The function to check.
  7633. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  7634. */
  7635. function isMasked(func) {
  7636. return !!maskSrcKey && (maskSrcKey in func);
  7637. }
  7638. /**
  7639. * Checks if `func` is capable of being masked.
  7640. *
  7641. * @private
  7642. * @param {*} value The value to check.
  7643. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  7644. */
  7645. var isMaskable = coreJsData ? isFunction : stubFalse;
  7646. /**
  7647. * Checks if `value` is likely a prototype object.
  7648. *
  7649. * @private
  7650. * @param {*} value The value to check.
  7651. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  7652. */
  7653. function isPrototype(value) {
  7654. var Ctor = value && value.constructor,
  7655. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  7656. return value === proto;
  7657. }
  7658. /**
  7659. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  7660. *
  7661. * @private
  7662. * @param {*} value The value to check.
  7663. * @returns {boolean} Returns `true` if `value` if suitable for strict
  7664. * equality comparisons, else `false`.
  7665. */
  7666. function isStrictComparable(value) {
  7667. return value === value && !isObject(value);
  7668. }
  7669. /**
  7670. * A specialized version of `matchesProperty` for source values suitable
  7671. * for strict equality comparisons, i.e. `===`.
  7672. *
  7673. * @private
  7674. * @param {string} key The key of the property to get.
  7675. * @param {*} srcValue The value to match.
  7676. * @returns {Function} Returns the new spec function.
  7677. */
  7678. function matchesStrictComparable(key, srcValue) {
  7679. return function(object) {
  7680. if (object == null) {
  7681. return false;
  7682. }
  7683. return object[key] === srcValue &&
  7684. (srcValue !== undefined$1 || (key in Object(object)));
  7685. };
  7686. }
  7687. /**
  7688. * A specialized version of `_.memoize` which clears the memoized function's
  7689. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  7690. *
  7691. * @private
  7692. * @param {Function} func The function to have its output memoized.
  7693. * @returns {Function} Returns the new memoized function.
  7694. */
  7695. function memoizeCapped(func) {
  7696. var result = memoize(func, function(key) {
  7697. if (cache.size === MAX_MEMOIZE_SIZE) {
  7698. cache.clear();
  7699. }
  7700. return key;
  7701. });
  7702. var cache = result.cache;
  7703. return result;
  7704. }
  7705. /**
  7706. * Merges the function metadata of `source` into `data`.
  7707. *
  7708. * Merging metadata reduces the number of wrappers used to invoke a function.
  7709. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  7710. * may be applied regardless of execution order. Methods like `_.ary` and
  7711. * `_.rearg` modify function arguments, making the order in which they are
  7712. * executed important, preventing the merging of metadata. However, we make
  7713. * an exception for a safe combined case where curried functions have `_.ary`
  7714. * and or `_.rearg` applied.
  7715. *
  7716. * @private
  7717. * @param {Array} data The destination metadata.
  7718. * @param {Array} source The source metadata.
  7719. * @returns {Array} Returns `data`.
  7720. */
  7721. function mergeData(data, source) {
  7722. var bitmask = data[1],
  7723. srcBitmask = source[1],
  7724. newBitmask = bitmask | srcBitmask,
  7725. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  7726. var isCombo =
  7727. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  7728. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  7729. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  7730. // Exit early if metadata can't be merged.
  7731. if (!(isCommon || isCombo)) {
  7732. return data;
  7733. }
  7734. // Use source `thisArg` if available.
  7735. if (srcBitmask & WRAP_BIND_FLAG) {
  7736. data[2] = source[2];
  7737. // Set when currying a bound function.
  7738. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  7739. }
  7740. // Compose partial arguments.
  7741. var value = source[3];
  7742. if (value) {
  7743. var partials = data[3];
  7744. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  7745. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  7746. }
  7747. // Compose partial right arguments.
  7748. value = source[5];
  7749. if (value) {
  7750. partials = data[5];
  7751. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  7752. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  7753. }
  7754. // Use source `argPos` if available.
  7755. value = source[7];
  7756. if (value) {
  7757. data[7] = value;
  7758. }
  7759. // Use source `ary` if it's smaller.
  7760. if (srcBitmask & WRAP_ARY_FLAG) {
  7761. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  7762. }
  7763. // Use source `arity` if one is not provided.
  7764. if (data[9] == null) {
  7765. data[9] = source[9];
  7766. }
  7767. // Use source `func` and merge bitmasks.
  7768. data[0] = source[0];
  7769. data[1] = newBitmask;
  7770. return data;
  7771. }
  7772. /**
  7773. * This function is like
  7774. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7775. * except that it includes inherited enumerable properties.
  7776. *
  7777. * @private
  7778. * @param {Object} object The object to query.
  7779. * @returns {Array} Returns the array of property names.
  7780. */
  7781. function nativeKeysIn(object) {
  7782. var result = [];
  7783. if (object != null) {
  7784. for (var key in Object(object)) {
  7785. result.push(key);
  7786. }
  7787. }
  7788. return result;
  7789. }
  7790. /**
  7791. * Converts `value` to a string using `Object.prototype.toString`.
  7792. *
  7793. * @private
  7794. * @param {*} value The value to convert.
  7795. * @returns {string} Returns the converted string.
  7796. */
  7797. function objectToString(value) {
  7798. return nativeObjectToString.call(value);
  7799. }
  7800. /**
  7801. * A specialized version of `baseRest` which transforms the rest array.
  7802. *
  7803. * @private
  7804. * @param {Function} func The function to apply a rest parameter to.
  7805. * @param {number} [start=func.length-1] The start position of the rest parameter.
  7806. * @param {Function} transform The rest array transform.
  7807. * @returns {Function} Returns the new function.
  7808. */
  7809. function overRest(func, start, transform) {
  7810. start = nativeMax(start === undefined$1 ? (func.length - 1) : start, 0);
  7811. return function() {
  7812. var args = arguments,
  7813. index = -1,
  7814. length = nativeMax(args.length - start, 0),
  7815. array = Array(length);
  7816. while (++index < length) {
  7817. array[index] = args[start + index];
  7818. }
  7819. index = -1;
  7820. var otherArgs = Array(start + 1);
  7821. while (++index < start) {
  7822. otherArgs[index] = args[index];
  7823. }
  7824. otherArgs[start] = transform(array);
  7825. return apply(func, this, otherArgs);
  7826. };
  7827. }
  7828. /**
  7829. * Gets the parent value at `path` of `object`.
  7830. *
  7831. * @private
  7832. * @param {Object} object The object to query.
  7833. * @param {Array} path The path to get the parent value of.
  7834. * @returns {*} Returns the parent value.
  7835. */
  7836. function parent(object, path) {
  7837. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  7838. }
  7839. /**
  7840. * Reorder `array` according to the specified indexes where the element at
  7841. * the first index is assigned as the first element, the element at
  7842. * the second index is assigned as the second element, and so on.
  7843. *
  7844. * @private
  7845. * @param {Array} array The array to reorder.
  7846. * @param {Array} indexes The arranged array indexes.
  7847. * @returns {Array} Returns `array`.
  7848. */
  7849. function reorder(array, indexes) {
  7850. var arrLength = array.length,
  7851. length = nativeMin(indexes.length, arrLength),
  7852. oldArray = copyArray(array);
  7853. while (length--) {
  7854. var index = indexes[length];
  7855. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined$1;
  7856. }
  7857. return array;
  7858. }
  7859. /**
  7860. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  7861. *
  7862. * @private
  7863. * @param {Object} object The object to query.
  7864. * @param {string} key The key of the property to get.
  7865. * @returns {*} Returns the property value.
  7866. */
  7867. function safeGet(object, key) {
  7868. if (key === 'constructor' && typeof object[key] === 'function') {
  7869. return;
  7870. }
  7871. if (key == '__proto__') {
  7872. return;
  7873. }
  7874. return object[key];
  7875. }
  7876. /**
  7877. * Sets metadata for `func`.
  7878. *
  7879. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  7880. * period of time, it will trip its breaker and transition to an identity
  7881. * function to avoid garbage collection pauses in V8. See
  7882. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  7883. * for more details.
  7884. *
  7885. * @private
  7886. * @param {Function} func The function to associate metadata with.
  7887. * @param {*} data The metadata.
  7888. * @returns {Function} Returns `func`.
  7889. */
  7890. var setData = shortOut(baseSetData);
  7891. /**
  7892. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  7893. *
  7894. * @private
  7895. * @param {Function} func The function to delay.
  7896. * @param {number} wait The number of milliseconds to delay invocation.
  7897. * @returns {number|Object} Returns the timer id or timeout object.
  7898. */
  7899. var setTimeout = ctxSetTimeout || function(func, wait) {
  7900. return root.setTimeout(func, wait);
  7901. };
  7902. /**
  7903. * Sets the `toString` method of `func` to return `string`.
  7904. *
  7905. * @private
  7906. * @param {Function} func The function to modify.
  7907. * @param {Function} string The `toString` result.
  7908. * @returns {Function} Returns `func`.
  7909. */
  7910. var setToString = shortOut(baseSetToString);
  7911. /**
  7912. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  7913. * with wrapper details in a comment at the top of the source body.
  7914. *
  7915. * @private
  7916. * @param {Function} wrapper The function to modify.
  7917. * @param {Function} reference The reference function.
  7918. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7919. * @returns {Function} Returns `wrapper`.
  7920. */
  7921. function setWrapToString(wrapper, reference, bitmask) {
  7922. var source = (reference + '');
  7923. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  7924. }
  7925. /**
  7926. * Creates a function that'll short out and invoke `identity` instead
  7927. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  7928. * milliseconds.
  7929. *
  7930. * @private
  7931. * @param {Function} func The function to restrict.
  7932. * @returns {Function} Returns the new shortable function.
  7933. */
  7934. function shortOut(func) {
  7935. var count = 0,
  7936. lastCalled = 0;
  7937. return function() {
  7938. var stamp = nativeNow(),
  7939. remaining = HOT_SPAN - (stamp - lastCalled);
  7940. lastCalled = stamp;
  7941. if (remaining > 0) {
  7942. if (++count >= HOT_COUNT) {
  7943. return arguments[0];
  7944. }
  7945. } else {
  7946. count = 0;
  7947. }
  7948. return func.apply(undefined$1, arguments);
  7949. };
  7950. }
  7951. /**
  7952. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  7953. *
  7954. * @private
  7955. * @param {Array} array The array to shuffle.
  7956. * @param {number} [size=array.length] The size of `array`.
  7957. * @returns {Array} Returns `array`.
  7958. */
  7959. function shuffleSelf(array, size) {
  7960. var index = -1,
  7961. length = array.length,
  7962. lastIndex = length - 1;
  7963. size = size === undefined$1 ? length : size;
  7964. while (++index < size) {
  7965. var rand = baseRandom(index, lastIndex),
  7966. value = array[rand];
  7967. array[rand] = array[index];
  7968. array[index] = value;
  7969. }
  7970. array.length = size;
  7971. return array;
  7972. }
  7973. /**
  7974. * Converts `string` to a property path array.
  7975. *
  7976. * @private
  7977. * @param {string} string The string to convert.
  7978. * @returns {Array} Returns the property path array.
  7979. */
  7980. var stringToPath = memoizeCapped(function(string) {
  7981. var result = [];
  7982. if (string.charCodeAt(0) === 46 /* . */) {
  7983. result.push('');
  7984. }
  7985. string.replace(rePropName, function(match, number, quote, subString) {
  7986. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  7987. });
  7988. return result;
  7989. });
  7990. /**
  7991. * Converts `value` to a string key if it's not a string or symbol.
  7992. *
  7993. * @private
  7994. * @param {*} value The value to inspect.
  7995. * @returns {string|symbol} Returns the key.
  7996. */
  7997. function toKey(value) {
  7998. if (typeof value == 'string' || isSymbol(value)) {
  7999. return value;
  8000. }
  8001. var result = (value + '');
  8002. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  8003. }
  8004. /**
  8005. * Converts `func` to its source code.
  8006. *
  8007. * @private
  8008. * @param {Function} func The function to convert.
  8009. * @returns {string} Returns the source code.
  8010. */
  8011. function toSource(func) {
  8012. if (func != null) {
  8013. try {
  8014. return funcToString.call(func);
  8015. } catch (e) {}
  8016. try {
  8017. return (func + '');
  8018. } catch (e) {}
  8019. }
  8020. return '';
  8021. }
  8022. /**
  8023. * Updates wrapper `details` based on `bitmask` flags.
  8024. *
  8025. * @private
  8026. * @returns {Array} details The details to modify.
  8027. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  8028. * @returns {Array} Returns `details`.
  8029. */
  8030. function updateWrapDetails(details, bitmask) {
  8031. arrayEach(wrapFlags, function(pair) {
  8032. var value = '_.' + pair[0];
  8033. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  8034. details.push(value);
  8035. }
  8036. });
  8037. return details.sort();
  8038. }
  8039. /**
  8040. * Creates a clone of `wrapper`.
  8041. *
  8042. * @private
  8043. * @param {Object} wrapper The wrapper to clone.
  8044. * @returns {Object} Returns the cloned wrapper.
  8045. */
  8046. function wrapperClone(wrapper) {
  8047. if (wrapper instanceof LazyWrapper) {
  8048. return wrapper.clone();
  8049. }
  8050. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  8051. result.__actions__ = copyArray(wrapper.__actions__);
  8052. result.__index__ = wrapper.__index__;
  8053. result.__values__ = wrapper.__values__;
  8054. return result;
  8055. }
  8056. /*------------------------------------------------------------------------*/
  8057. /**
  8058. * Creates an array of elements split into groups the length of `size`.
  8059. * If `array` can't be split evenly, the final chunk will be the remaining
  8060. * elements.
  8061. *
  8062. * @static
  8063. * @memberOf _
  8064. * @since 3.0.0
  8065. * @category Array
  8066. * @param {Array} array The array to process.
  8067. * @param {number} [size=1] The length of each chunk
  8068. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8069. * @returns {Array} Returns the new array of chunks.
  8070. * @example
  8071. *
  8072. * _.chunk(['a', 'b', 'c', 'd'], 2);
  8073. * // => [['a', 'b'], ['c', 'd']]
  8074. *
  8075. * _.chunk(['a', 'b', 'c', 'd'], 3);
  8076. * // => [['a', 'b', 'c'], ['d']]
  8077. */
  8078. function chunk(array, size, guard) {
  8079. if ((guard ? isIterateeCall(array, size, guard) : size === undefined$1)) {
  8080. size = 1;
  8081. } else {
  8082. size = nativeMax(toInteger(size), 0);
  8083. }
  8084. var length = array == null ? 0 : array.length;
  8085. if (!length || size < 1) {
  8086. return [];
  8087. }
  8088. var index = 0,
  8089. resIndex = 0,
  8090. result = Array(nativeCeil(length / size));
  8091. while (index < length) {
  8092. result[resIndex++] = baseSlice(array, index, (index += size));
  8093. }
  8094. return result;
  8095. }
  8096. /**
  8097. * Creates an array with all falsey values removed. The values `false`, `null`,
  8098. * `0`, `""`, `undefined`, and `NaN` are falsey.
  8099. *
  8100. * @static
  8101. * @memberOf _
  8102. * @since 0.1.0
  8103. * @category Array
  8104. * @param {Array} array The array to compact.
  8105. * @returns {Array} Returns the new array of filtered values.
  8106. * @example
  8107. *
  8108. * _.compact([0, 1, false, 2, '', 3]);
  8109. * // => [1, 2, 3]
  8110. */
  8111. function compact(array) {
  8112. var index = -1,
  8113. length = array == null ? 0 : array.length,
  8114. resIndex = 0,
  8115. result = [];
  8116. while (++index < length) {
  8117. var value = array[index];
  8118. if (value) {
  8119. result[resIndex++] = value;
  8120. }
  8121. }
  8122. return result;
  8123. }
  8124. /**
  8125. * Creates a new array concatenating `array` with any additional arrays
  8126. * and/or values.
  8127. *
  8128. * @static
  8129. * @memberOf _
  8130. * @since 4.0.0
  8131. * @category Array
  8132. * @param {Array} array The array to concatenate.
  8133. * @param {...*} [values] The values to concatenate.
  8134. * @returns {Array} Returns the new concatenated array.
  8135. * @example
  8136. *
  8137. * var array = [1];
  8138. * var other = _.concat(array, 2, [3], [[4]]);
  8139. *
  8140. * console.log(other);
  8141. * // => [1, 2, 3, [4]]
  8142. *
  8143. * console.log(array);
  8144. * // => [1]
  8145. */
  8146. function concat() {
  8147. var length = arguments.length;
  8148. if (!length) {
  8149. return [];
  8150. }
  8151. var args = Array(length - 1),
  8152. array = arguments[0],
  8153. index = length;
  8154. while (index--) {
  8155. args[index - 1] = arguments[index];
  8156. }
  8157. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  8158. }
  8159. /**
  8160. * Creates an array of `array` values not included in the other given arrays
  8161. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8162. * for equality comparisons. The order and references of result values are
  8163. * determined by the first array.
  8164. *
  8165. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  8166. *
  8167. * @static
  8168. * @memberOf _
  8169. * @since 0.1.0
  8170. * @category Array
  8171. * @param {Array} array The array to inspect.
  8172. * @param {...Array} [values] The values to exclude.
  8173. * @returns {Array} Returns the new array of filtered values.
  8174. * @see _.without, _.xor
  8175. * @example
  8176. *
  8177. * _.difference([2, 1], [2, 3]);
  8178. * // => [1]
  8179. */
  8180. var difference = baseRest(function(array, values) {
  8181. return isArrayLikeObject(array)
  8182. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  8183. : [];
  8184. });
  8185. /**
  8186. * This method is like `_.difference` except that it accepts `iteratee` which
  8187. * is invoked for each element of `array` and `values` to generate the criterion
  8188. * by which they're compared. The order and references of result values are
  8189. * determined by the first array. The iteratee is invoked with one argument:
  8190. * (value).
  8191. *
  8192. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  8193. *
  8194. * @static
  8195. * @memberOf _
  8196. * @since 4.0.0
  8197. * @category Array
  8198. * @param {Array} array The array to inspect.
  8199. * @param {...Array} [values] The values to exclude.
  8200. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8201. * @returns {Array} Returns the new array of filtered values.
  8202. * @example
  8203. *
  8204. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8205. * // => [1.2]
  8206. *
  8207. * // The `_.property` iteratee shorthand.
  8208. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  8209. * // => [{ 'x': 2 }]
  8210. */
  8211. var differenceBy = baseRest(function(array, values) {
  8212. var iteratee = last(values);
  8213. if (isArrayLikeObject(iteratee)) {
  8214. iteratee = undefined$1;
  8215. }
  8216. return isArrayLikeObject(array)
  8217. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  8218. : [];
  8219. });
  8220. /**
  8221. * This method is like `_.difference` except that it accepts `comparator`
  8222. * which is invoked to compare elements of `array` to `values`. The order and
  8223. * references of result values are determined by the first array. The comparator
  8224. * is invoked with two arguments: (arrVal, othVal).
  8225. *
  8226. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  8227. *
  8228. * @static
  8229. * @memberOf _
  8230. * @since 4.0.0
  8231. * @category Array
  8232. * @param {Array} array The array to inspect.
  8233. * @param {...Array} [values] The values to exclude.
  8234. * @param {Function} [comparator] The comparator invoked per element.
  8235. * @returns {Array} Returns the new array of filtered values.
  8236. * @example
  8237. *
  8238. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8239. *
  8240. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  8241. * // => [{ 'x': 2, 'y': 1 }]
  8242. */
  8243. var differenceWith = baseRest(function(array, values) {
  8244. var comparator = last(values);
  8245. if (isArrayLikeObject(comparator)) {
  8246. comparator = undefined$1;
  8247. }
  8248. return isArrayLikeObject(array)
  8249. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined$1, comparator)
  8250. : [];
  8251. });
  8252. /**
  8253. * Creates a slice of `array` with `n` elements dropped from the beginning.
  8254. *
  8255. * @static
  8256. * @memberOf _
  8257. * @since 0.5.0
  8258. * @category Array
  8259. * @param {Array} array The array to query.
  8260. * @param {number} [n=1] The number of elements to drop.
  8261. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8262. * @returns {Array} Returns the slice of `array`.
  8263. * @example
  8264. *
  8265. * _.drop([1, 2, 3]);
  8266. * // => [2, 3]
  8267. *
  8268. * _.drop([1, 2, 3], 2);
  8269. * // => [3]
  8270. *
  8271. * _.drop([1, 2, 3], 5);
  8272. * // => []
  8273. *
  8274. * _.drop([1, 2, 3], 0);
  8275. * // => [1, 2, 3]
  8276. */
  8277. function drop(array, n, guard) {
  8278. var length = array == null ? 0 : array.length;
  8279. if (!length) {
  8280. return [];
  8281. }
  8282. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  8283. return baseSlice(array, n < 0 ? 0 : n, length);
  8284. }
  8285. /**
  8286. * Creates a slice of `array` with `n` elements dropped from the end.
  8287. *
  8288. * @static
  8289. * @memberOf _
  8290. * @since 3.0.0
  8291. * @category Array
  8292. * @param {Array} array The array to query.
  8293. * @param {number} [n=1] The number of elements to drop.
  8294. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8295. * @returns {Array} Returns the slice of `array`.
  8296. * @example
  8297. *
  8298. * _.dropRight([1, 2, 3]);
  8299. * // => [1, 2]
  8300. *
  8301. * _.dropRight([1, 2, 3], 2);
  8302. * // => [1]
  8303. *
  8304. * _.dropRight([1, 2, 3], 5);
  8305. * // => []
  8306. *
  8307. * _.dropRight([1, 2, 3], 0);
  8308. * // => [1, 2, 3]
  8309. */
  8310. function dropRight(array, n, guard) {
  8311. var length = array == null ? 0 : array.length;
  8312. if (!length) {
  8313. return [];
  8314. }
  8315. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  8316. n = length - n;
  8317. return baseSlice(array, 0, n < 0 ? 0 : n);
  8318. }
  8319. /**
  8320. * Creates a slice of `array` excluding elements dropped from the end.
  8321. * Elements are dropped until `predicate` returns falsey. The predicate is
  8322. * invoked with three arguments: (value, index, array).
  8323. *
  8324. * @static
  8325. * @memberOf _
  8326. * @since 3.0.0
  8327. * @category Array
  8328. * @param {Array} array The array to query.
  8329. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8330. * @returns {Array} Returns the slice of `array`.
  8331. * @example
  8332. *
  8333. * var users = [
  8334. * { 'user': 'barney', 'active': true },
  8335. * { 'user': 'fred', 'active': false },
  8336. * { 'user': 'pebbles', 'active': false }
  8337. * ];
  8338. *
  8339. * _.dropRightWhile(users, function(o) { return !o.active; });
  8340. * // => objects for ['barney']
  8341. *
  8342. * // The `_.matches` iteratee shorthand.
  8343. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  8344. * // => objects for ['barney', 'fred']
  8345. *
  8346. * // The `_.matchesProperty` iteratee shorthand.
  8347. * _.dropRightWhile(users, ['active', false]);
  8348. * // => objects for ['barney']
  8349. *
  8350. * // The `_.property` iteratee shorthand.
  8351. * _.dropRightWhile(users, 'active');
  8352. * // => objects for ['barney', 'fred', 'pebbles']
  8353. */
  8354. function dropRightWhile(array, predicate) {
  8355. return (array && array.length)
  8356. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  8357. : [];
  8358. }
  8359. /**
  8360. * Creates a slice of `array` excluding elements dropped from the beginning.
  8361. * Elements are dropped until `predicate` returns falsey. The predicate is
  8362. * invoked with three arguments: (value, index, array).
  8363. *
  8364. * @static
  8365. * @memberOf _
  8366. * @since 3.0.0
  8367. * @category Array
  8368. * @param {Array} array The array to query.
  8369. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8370. * @returns {Array} Returns the slice of `array`.
  8371. * @example
  8372. *
  8373. * var users = [
  8374. * { 'user': 'barney', 'active': false },
  8375. * { 'user': 'fred', 'active': false },
  8376. * { 'user': 'pebbles', 'active': true }
  8377. * ];
  8378. *
  8379. * _.dropWhile(users, function(o) { return !o.active; });
  8380. * // => objects for ['pebbles']
  8381. *
  8382. * // The `_.matches` iteratee shorthand.
  8383. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  8384. * // => objects for ['fred', 'pebbles']
  8385. *
  8386. * // The `_.matchesProperty` iteratee shorthand.
  8387. * _.dropWhile(users, ['active', false]);
  8388. * // => objects for ['pebbles']
  8389. *
  8390. * // The `_.property` iteratee shorthand.
  8391. * _.dropWhile(users, 'active');
  8392. * // => objects for ['barney', 'fred', 'pebbles']
  8393. */
  8394. function dropWhile(array, predicate) {
  8395. return (array && array.length)
  8396. ? baseWhile(array, getIteratee(predicate, 3), true)
  8397. : [];
  8398. }
  8399. /**
  8400. * Fills elements of `array` with `value` from `start` up to, but not
  8401. * including, `end`.
  8402. *
  8403. * **Note:** This method mutates `array`.
  8404. *
  8405. * @static
  8406. * @memberOf _
  8407. * @since 3.2.0
  8408. * @category Array
  8409. * @param {Array} array The array to fill.
  8410. * @param {*} value The value to fill `array` with.
  8411. * @param {number} [start=0] The start position.
  8412. * @param {number} [end=array.length] The end position.
  8413. * @returns {Array} Returns `array`.
  8414. * @example
  8415. *
  8416. * var array = [1, 2, 3];
  8417. *
  8418. * _.fill(array, 'a');
  8419. * console.log(array);
  8420. * // => ['a', 'a', 'a']
  8421. *
  8422. * _.fill(Array(3), 2);
  8423. * // => [2, 2, 2]
  8424. *
  8425. * _.fill([4, 6, 8, 10], '*', 1, 3);
  8426. * // => [4, '*', '*', 10]
  8427. */
  8428. function fill(array, value, start, end) {
  8429. var length = array == null ? 0 : array.length;
  8430. if (!length) {
  8431. return [];
  8432. }
  8433. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  8434. start = 0;
  8435. end = length;
  8436. }
  8437. return baseFill(array, value, start, end);
  8438. }
  8439. /**
  8440. * This method is like `_.find` except that it returns the index of the first
  8441. * element `predicate` returns truthy for instead of the element itself.
  8442. *
  8443. * @static
  8444. * @memberOf _
  8445. * @since 1.1.0
  8446. * @category Array
  8447. * @param {Array} array The array to inspect.
  8448. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8449. * @param {number} [fromIndex=0] The index to search from.
  8450. * @returns {number} Returns the index of the found element, else `-1`.
  8451. * @example
  8452. *
  8453. * var users = [
  8454. * { 'user': 'barney', 'active': false },
  8455. * { 'user': 'fred', 'active': false },
  8456. * { 'user': 'pebbles', 'active': true }
  8457. * ];
  8458. *
  8459. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  8460. * // => 0
  8461. *
  8462. * // The `_.matches` iteratee shorthand.
  8463. * _.findIndex(users, { 'user': 'fred', 'active': false });
  8464. * // => 1
  8465. *
  8466. * // The `_.matchesProperty` iteratee shorthand.
  8467. * _.findIndex(users, ['active', false]);
  8468. * // => 0
  8469. *
  8470. * // The `_.property` iteratee shorthand.
  8471. * _.findIndex(users, 'active');
  8472. * // => 2
  8473. */
  8474. function findIndex(array, predicate, fromIndex) {
  8475. var length = array == null ? 0 : array.length;
  8476. if (!length) {
  8477. return -1;
  8478. }
  8479. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8480. if (index < 0) {
  8481. index = nativeMax(length + index, 0);
  8482. }
  8483. return baseFindIndex(array, getIteratee(predicate, 3), index);
  8484. }
  8485. /**
  8486. * This method is like `_.findIndex` except that it iterates over elements
  8487. * of `collection` from right to left.
  8488. *
  8489. * @static
  8490. * @memberOf _
  8491. * @since 2.0.0
  8492. * @category Array
  8493. * @param {Array} array The array to inspect.
  8494. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8495. * @param {number} [fromIndex=array.length-1] The index to search from.
  8496. * @returns {number} Returns the index of the found element, else `-1`.
  8497. * @example
  8498. *
  8499. * var users = [
  8500. * { 'user': 'barney', 'active': true },
  8501. * { 'user': 'fred', 'active': false },
  8502. * { 'user': 'pebbles', 'active': false }
  8503. * ];
  8504. *
  8505. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  8506. * // => 2
  8507. *
  8508. * // The `_.matches` iteratee shorthand.
  8509. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  8510. * // => 0
  8511. *
  8512. * // The `_.matchesProperty` iteratee shorthand.
  8513. * _.findLastIndex(users, ['active', false]);
  8514. * // => 2
  8515. *
  8516. * // The `_.property` iteratee shorthand.
  8517. * _.findLastIndex(users, 'active');
  8518. * // => 0
  8519. */
  8520. function findLastIndex(array, predicate, fromIndex) {
  8521. var length = array == null ? 0 : array.length;
  8522. if (!length) {
  8523. return -1;
  8524. }
  8525. var index = length - 1;
  8526. if (fromIndex !== undefined$1) {
  8527. index = toInteger(fromIndex);
  8528. index = fromIndex < 0
  8529. ? nativeMax(length + index, 0)
  8530. : nativeMin(index, length - 1);
  8531. }
  8532. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  8533. }
  8534. /**
  8535. * Flattens `array` a single level deep.
  8536. *
  8537. * @static
  8538. * @memberOf _
  8539. * @since 0.1.0
  8540. * @category Array
  8541. * @param {Array} array The array to flatten.
  8542. * @returns {Array} Returns the new flattened array.
  8543. * @example
  8544. *
  8545. * _.flatten([1, [2, [3, [4]], 5]]);
  8546. * // => [1, 2, [3, [4]], 5]
  8547. */
  8548. function flatten(array) {
  8549. var length = array == null ? 0 : array.length;
  8550. return length ? baseFlatten(array, 1) : [];
  8551. }
  8552. /**
  8553. * Recursively flattens `array`.
  8554. *
  8555. * @static
  8556. * @memberOf _
  8557. * @since 3.0.0
  8558. * @category Array
  8559. * @param {Array} array The array to flatten.
  8560. * @returns {Array} Returns the new flattened array.
  8561. * @example
  8562. *
  8563. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  8564. * // => [1, 2, 3, 4, 5]
  8565. */
  8566. function flattenDeep(array) {
  8567. var length = array == null ? 0 : array.length;
  8568. return length ? baseFlatten(array, INFINITY) : [];
  8569. }
  8570. /**
  8571. * Recursively flatten `array` up to `depth` times.
  8572. *
  8573. * @static
  8574. * @memberOf _
  8575. * @since 4.4.0
  8576. * @category Array
  8577. * @param {Array} array The array to flatten.
  8578. * @param {number} [depth=1] The maximum recursion depth.
  8579. * @returns {Array} Returns the new flattened array.
  8580. * @example
  8581. *
  8582. * var array = [1, [2, [3, [4]], 5]];
  8583. *
  8584. * _.flattenDepth(array, 1);
  8585. * // => [1, 2, [3, [4]], 5]
  8586. *
  8587. * _.flattenDepth(array, 2);
  8588. * // => [1, 2, 3, [4], 5]
  8589. */
  8590. function flattenDepth(array, depth) {
  8591. var length = array == null ? 0 : array.length;
  8592. if (!length) {
  8593. return [];
  8594. }
  8595. depth = depth === undefined$1 ? 1 : toInteger(depth);
  8596. return baseFlatten(array, depth);
  8597. }
  8598. /**
  8599. * The inverse of `_.toPairs`; this method returns an object composed
  8600. * from key-value `pairs`.
  8601. *
  8602. * @static
  8603. * @memberOf _
  8604. * @since 4.0.0
  8605. * @category Array
  8606. * @param {Array} pairs The key-value pairs.
  8607. * @returns {Object} Returns the new object.
  8608. * @example
  8609. *
  8610. * _.fromPairs([['a', 1], ['b', 2]]);
  8611. * // => { 'a': 1, 'b': 2 }
  8612. */
  8613. function fromPairs(pairs) {
  8614. var index = -1,
  8615. length = pairs == null ? 0 : pairs.length,
  8616. result = {};
  8617. while (++index < length) {
  8618. var pair = pairs[index];
  8619. result[pair[0]] = pair[1];
  8620. }
  8621. return result;
  8622. }
  8623. /**
  8624. * Gets the first element of `array`.
  8625. *
  8626. * @static
  8627. * @memberOf _
  8628. * @since 0.1.0
  8629. * @alias first
  8630. * @category Array
  8631. * @param {Array} array The array to query.
  8632. * @returns {*} Returns the first element of `array`.
  8633. * @example
  8634. *
  8635. * _.head([1, 2, 3]);
  8636. * // => 1
  8637. *
  8638. * _.head([]);
  8639. * // => undefined
  8640. */
  8641. function head(array) {
  8642. return (array && array.length) ? array[0] : undefined$1;
  8643. }
  8644. /**
  8645. * Gets the index at which the first occurrence of `value` is found in `array`
  8646. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8647. * for equality comparisons. If `fromIndex` is negative, it's used as the
  8648. * offset from the end of `array`.
  8649. *
  8650. * @static
  8651. * @memberOf _
  8652. * @since 0.1.0
  8653. * @category Array
  8654. * @param {Array} array The array to inspect.
  8655. * @param {*} value The value to search for.
  8656. * @param {number} [fromIndex=0] The index to search from.
  8657. * @returns {number} Returns the index of the matched value, else `-1`.
  8658. * @example
  8659. *
  8660. * _.indexOf([1, 2, 1, 2], 2);
  8661. * // => 1
  8662. *
  8663. * // Search from the `fromIndex`.
  8664. * _.indexOf([1, 2, 1, 2], 2, 2);
  8665. * // => 3
  8666. */
  8667. function indexOf(array, value, fromIndex) {
  8668. var length = array == null ? 0 : array.length;
  8669. if (!length) {
  8670. return -1;
  8671. }
  8672. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8673. if (index < 0) {
  8674. index = nativeMax(length + index, 0);
  8675. }
  8676. return baseIndexOf(array, value, index);
  8677. }
  8678. /**
  8679. * Gets all but the last element of `array`.
  8680. *
  8681. * @static
  8682. * @memberOf _
  8683. * @since 0.1.0
  8684. * @category Array
  8685. * @param {Array} array The array to query.
  8686. * @returns {Array} Returns the slice of `array`.
  8687. * @example
  8688. *
  8689. * _.initial([1, 2, 3]);
  8690. * // => [1, 2]
  8691. */
  8692. function initial(array) {
  8693. var length = array == null ? 0 : array.length;
  8694. return length ? baseSlice(array, 0, -1) : [];
  8695. }
  8696. /**
  8697. * Creates an array of unique values that are included in all given arrays
  8698. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8699. * for equality comparisons. The order and references of result values are
  8700. * determined by the first array.
  8701. *
  8702. * @static
  8703. * @memberOf _
  8704. * @since 0.1.0
  8705. * @category Array
  8706. * @param {...Array} [arrays] The arrays to inspect.
  8707. * @returns {Array} Returns the new array of intersecting values.
  8708. * @example
  8709. *
  8710. * _.intersection([2, 1], [2, 3]);
  8711. * // => [2]
  8712. */
  8713. var intersection = baseRest(function(arrays) {
  8714. var mapped = arrayMap(arrays, castArrayLikeObject);
  8715. return (mapped.length && mapped[0] === arrays[0])
  8716. ? baseIntersection(mapped)
  8717. : [];
  8718. });
  8719. /**
  8720. * This method is like `_.intersection` except that it accepts `iteratee`
  8721. * which is invoked for each element of each `arrays` to generate the criterion
  8722. * by which they're compared. The order and references of result values are
  8723. * determined by the first array. The iteratee is invoked with one argument:
  8724. * (value).
  8725. *
  8726. * @static
  8727. * @memberOf _
  8728. * @since 4.0.0
  8729. * @category Array
  8730. * @param {...Array} [arrays] The arrays to inspect.
  8731. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8732. * @returns {Array} Returns the new array of intersecting values.
  8733. * @example
  8734. *
  8735. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8736. * // => [2.1]
  8737. *
  8738. * // The `_.property` iteratee shorthand.
  8739. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8740. * // => [{ 'x': 1 }]
  8741. */
  8742. var intersectionBy = baseRest(function(arrays) {
  8743. var iteratee = last(arrays),
  8744. mapped = arrayMap(arrays, castArrayLikeObject);
  8745. if (iteratee === last(mapped)) {
  8746. iteratee = undefined$1;
  8747. } else {
  8748. mapped.pop();
  8749. }
  8750. return (mapped.length && mapped[0] === arrays[0])
  8751. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  8752. : [];
  8753. });
  8754. /**
  8755. * This method is like `_.intersection` except that it accepts `comparator`
  8756. * which is invoked to compare elements of `arrays`. The order and references
  8757. * of result values are determined by the first array. The comparator is
  8758. * invoked with two arguments: (arrVal, othVal).
  8759. *
  8760. * @static
  8761. * @memberOf _
  8762. * @since 4.0.0
  8763. * @category Array
  8764. * @param {...Array} [arrays] The arrays to inspect.
  8765. * @param {Function} [comparator] The comparator invoked per element.
  8766. * @returns {Array} Returns the new array of intersecting values.
  8767. * @example
  8768. *
  8769. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8770. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8771. *
  8772. * _.intersectionWith(objects, others, _.isEqual);
  8773. * // => [{ 'x': 1, 'y': 2 }]
  8774. */
  8775. var intersectionWith = baseRest(function(arrays) {
  8776. var comparator = last(arrays),
  8777. mapped = arrayMap(arrays, castArrayLikeObject);
  8778. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  8779. if (comparator) {
  8780. mapped.pop();
  8781. }
  8782. return (mapped.length && mapped[0] === arrays[0])
  8783. ? baseIntersection(mapped, undefined$1, comparator)
  8784. : [];
  8785. });
  8786. /**
  8787. * Converts all elements in `array` into a string separated by `separator`.
  8788. *
  8789. * @static
  8790. * @memberOf _
  8791. * @since 4.0.0
  8792. * @category Array
  8793. * @param {Array} array The array to convert.
  8794. * @param {string} [separator=','] The element separator.
  8795. * @returns {string} Returns the joined string.
  8796. * @example
  8797. *
  8798. * _.join(['a', 'b', 'c'], '~');
  8799. * // => 'a~b~c'
  8800. */
  8801. function join(array, separator) {
  8802. return array == null ? '' : nativeJoin.call(array, separator);
  8803. }
  8804. /**
  8805. * Gets the last element of `array`.
  8806. *
  8807. * @static
  8808. * @memberOf _
  8809. * @since 0.1.0
  8810. * @category Array
  8811. * @param {Array} array The array to query.
  8812. * @returns {*} Returns the last element of `array`.
  8813. * @example
  8814. *
  8815. * _.last([1, 2, 3]);
  8816. * // => 3
  8817. */
  8818. function last(array) {
  8819. var length = array == null ? 0 : array.length;
  8820. return length ? array[length - 1] : undefined$1;
  8821. }
  8822. /**
  8823. * This method is like `_.indexOf` except that it iterates over elements of
  8824. * `array` from right to left.
  8825. *
  8826. * @static
  8827. * @memberOf _
  8828. * @since 0.1.0
  8829. * @category Array
  8830. * @param {Array} array The array to inspect.
  8831. * @param {*} value The value to search for.
  8832. * @param {number} [fromIndex=array.length-1] The index to search from.
  8833. * @returns {number} Returns the index of the matched value, else `-1`.
  8834. * @example
  8835. *
  8836. * _.lastIndexOf([1, 2, 1, 2], 2);
  8837. * // => 3
  8838. *
  8839. * // Search from the `fromIndex`.
  8840. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  8841. * // => 1
  8842. */
  8843. function lastIndexOf(array, value, fromIndex) {
  8844. var length = array == null ? 0 : array.length;
  8845. if (!length) {
  8846. return -1;
  8847. }
  8848. var index = length;
  8849. if (fromIndex !== undefined$1) {
  8850. index = toInteger(fromIndex);
  8851. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  8852. }
  8853. return value === value
  8854. ? strictLastIndexOf(array, value, index)
  8855. : baseFindIndex(array, baseIsNaN, index, true);
  8856. }
  8857. /**
  8858. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  8859. * element from the end is returned.
  8860. *
  8861. * @static
  8862. * @memberOf _
  8863. * @since 4.11.0
  8864. * @category Array
  8865. * @param {Array} array The array to query.
  8866. * @param {number} [n=0] The index of the element to return.
  8867. * @returns {*} Returns the nth element of `array`.
  8868. * @example
  8869. *
  8870. * var array = ['a', 'b', 'c', 'd'];
  8871. *
  8872. * _.nth(array, 1);
  8873. * // => 'b'
  8874. *
  8875. * _.nth(array, -2);
  8876. * // => 'c';
  8877. */
  8878. function nth(array, n) {
  8879. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined$1;
  8880. }
  8881. /**
  8882. * Removes all given values from `array` using
  8883. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8884. * for equality comparisons.
  8885. *
  8886. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  8887. * to remove elements from an array by predicate.
  8888. *
  8889. * @static
  8890. * @memberOf _
  8891. * @since 2.0.0
  8892. * @category Array
  8893. * @param {Array} array The array to modify.
  8894. * @param {...*} [values] The values to remove.
  8895. * @returns {Array} Returns `array`.
  8896. * @example
  8897. *
  8898. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8899. *
  8900. * _.pull(array, 'a', 'c');
  8901. * console.log(array);
  8902. * // => ['b', 'b']
  8903. */
  8904. var pull = baseRest(pullAll);
  8905. /**
  8906. * This method is like `_.pull` except that it accepts an array of values to remove.
  8907. *
  8908. * **Note:** Unlike `_.difference`, this method mutates `array`.
  8909. *
  8910. * @static
  8911. * @memberOf _
  8912. * @since 4.0.0
  8913. * @category Array
  8914. * @param {Array} array The array to modify.
  8915. * @param {Array} values The values to remove.
  8916. * @returns {Array} Returns `array`.
  8917. * @example
  8918. *
  8919. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8920. *
  8921. * _.pullAll(array, ['a', 'c']);
  8922. * console.log(array);
  8923. * // => ['b', 'b']
  8924. */
  8925. function pullAll(array, values) {
  8926. return (array && array.length && values && values.length)
  8927. ? basePullAll(array, values)
  8928. : array;
  8929. }
  8930. /**
  8931. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  8932. * invoked for each element of `array` and `values` to generate the criterion
  8933. * by which they're compared. The iteratee is invoked with one argument: (value).
  8934. *
  8935. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  8936. *
  8937. * @static
  8938. * @memberOf _
  8939. * @since 4.0.0
  8940. * @category Array
  8941. * @param {Array} array The array to modify.
  8942. * @param {Array} values The values to remove.
  8943. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8944. * @returns {Array} Returns `array`.
  8945. * @example
  8946. *
  8947. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  8948. *
  8949. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  8950. * console.log(array);
  8951. * // => [{ 'x': 2 }]
  8952. */
  8953. function pullAllBy(array, values, iteratee) {
  8954. return (array && array.length && values && values.length)
  8955. ? basePullAll(array, values, getIteratee(iteratee, 2))
  8956. : array;
  8957. }
  8958. /**
  8959. * This method is like `_.pullAll` except that it accepts `comparator` which
  8960. * is invoked to compare elements of `array` to `values`. The comparator is
  8961. * invoked with two arguments: (arrVal, othVal).
  8962. *
  8963. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  8964. *
  8965. * @static
  8966. * @memberOf _
  8967. * @since 4.6.0
  8968. * @category Array
  8969. * @param {Array} array The array to modify.
  8970. * @param {Array} values The values to remove.
  8971. * @param {Function} [comparator] The comparator invoked per element.
  8972. * @returns {Array} Returns `array`.
  8973. * @example
  8974. *
  8975. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  8976. *
  8977. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  8978. * console.log(array);
  8979. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  8980. */
  8981. function pullAllWith(array, values, comparator) {
  8982. return (array && array.length && values && values.length)
  8983. ? basePullAll(array, values, undefined$1, comparator)
  8984. : array;
  8985. }
  8986. /**
  8987. * Removes elements from `array` corresponding to `indexes` and returns an
  8988. * array of removed elements.
  8989. *
  8990. * **Note:** Unlike `_.at`, this method mutates `array`.
  8991. *
  8992. * @static
  8993. * @memberOf _
  8994. * @since 3.0.0
  8995. * @category Array
  8996. * @param {Array} array The array to modify.
  8997. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8998. * @returns {Array} Returns the new array of removed elements.
  8999. * @example
  9000. *
  9001. * var array = ['a', 'b', 'c', 'd'];
  9002. * var pulled = _.pullAt(array, [1, 3]);
  9003. *
  9004. * console.log(array);
  9005. * // => ['a', 'c']
  9006. *
  9007. * console.log(pulled);
  9008. * // => ['b', 'd']
  9009. */
  9010. var pullAt = flatRest(function(array, indexes) {
  9011. var length = array == null ? 0 : array.length,
  9012. result = baseAt(array, indexes);
  9013. basePullAt(array, arrayMap(indexes, function(index) {
  9014. return isIndex(index, length) ? +index : index;
  9015. }).sort(compareAscending));
  9016. return result;
  9017. });
  9018. /**
  9019. * Removes all elements from `array` that `predicate` returns truthy for
  9020. * and returns an array of the removed elements. The predicate is invoked
  9021. * with three arguments: (value, index, array).
  9022. *
  9023. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  9024. * to pull elements from an array by value.
  9025. *
  9026. * @static
  9027. * @memberOf _
  9028. * @since 2.0.0
  9029. * @category Array
  9030. * @param {Array} array The array to modify.
  9031. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9032. * @returns {Array} Returns the new array of removed elements.
  9033. * @example
  9034. *
  9035. * var array = [1, 2, 3, 4];
  9036. * var evens = _.remove(array, function(n) {
  9037. * return n % 2 == 0;
  9038. * });
  9039. *
  9040. * console.log(array);
  9041. * // => [1, 3]
  9042. *
  9043. * console.log(evens);
  9044. * // => [2, 4]
  9045. */
  9046. function remove(array, predicate) {
  9047. var result = [];
  9048. if (!(array && array.length)) {
  9049. return result;
  9050. }
  9051. var index = -1,
  9052. indexes = [],
  9053. length = array.length;
  9054. predicate = getIteratee(predicate, 3);
  9055. while (++index < length) {
  9056. var value = array[index];
  9057. if (predicate(value, index, array)) {
  9058. result.push(value);
  9059. indexes.push(index);
  9060. }
  9061. }
  9062. basePullAt(array, indexes);
  9063. return result;
  9064. }
  9065. /**
  9066. * Reverses `array` so that the first element becomes the last, the second
  9067. * element becomes the second to last, and so on.
  9068. *
  9069. * **Note:** This method mutates `array` and is based on
  9070. * [`Array#reverse`](https://mdn.io/Array/reverse).
  9071. *
  9072. * @static
  9073. * @memberOf _
  9074. * @since 4.0.0
  9075. * @category Array
  9076. * @param {Array} array The array to modify.
  9077. * @returns {Array} Returns `array`.
  9078. * @example
  9079. *
  9080. * var array = [1, 2, 3];
  9081. *
  9082. * _.reverse(array);
  9083. * // => [3, 2, 1]
  9084. *
  9085. * console.log(array);
  9086. * // => [3, 2, 1]
  9087. */
  9088. function reverse(array) {
  9089. return array == null ? array : nativeReverse.call(array);
  9090. }
  9091. /**
  9092. * Creates a slice of `array` from `start` up to, but not including, `end`.
  9093. *
  9094. * **Note:** This method is used instead of
  9095. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  9096. * returned.
  9097. *
  9098. * @static
  9099. * @memberOf _
  9100. * @since 3.0.0
  9101. * @category Array
  9102. * @param {Array} array The array to slice.
  9103. * @param {number} [start=0] The start position.
  9104. * @param {number} [end=array.length] The end position.
  9105. * @returns {Array} Returns the slice of `array`.
  9106. */
  9107. function slice(array, start, end) {
  9108. var length = array == null ? 0 : array.length;
  9109. if (!length) {
  9110. return [];
  9111. }
  9112. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  9113. start = 0;
  9114. end = length;
  9115. }
  9116. else {
  9117. start = start == null ? 0 : toInteger(start);
  9118. end = end === undefined$1 ? length : toInteger(end);
  9119. }
  9120. return baseSlice(array, start, end);
  9121. }
  9122. /**
  9123. * Uses a binary search to determine the lowest index at which `value`
  9124. * should be inserted into `array` in order to maintain its sort order.
  9125. *
  9126. * @static
  9127. * @memberOf _
  9128. * @since 0.1.0
  9129. * @category Array
  9130. * @param {Array} array The sorted array to inspect.
  9131. * @param {*} value The value to evaluate.
  9132. * @returns {number} Returns the index at which `value` should be inserted
  9133. * into `array`.
  9134. * @example
  9135. *
  9136. * _.sortedIndex([30, 50], 40);
  9137. * // => 1
  9138. */
  9139. function sortedIndex(array, value) {
  9140. return baseSortedIndex(array, value);
  9141. }
  9142. /**
  9143. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  9144. * which is invoked for `value` and each element of `array` to compute their
  9145. * sort ranking. The iteratee is invoked with one argument: (value).
  9146. *
  9147. * @static
  9148. * @memberOf _
  9149. * @since 4.0.0
  9150. * @category Array
  9151. * @param {Array} array The sorted array to inspect.
  9152. * @param {*} value The value to evaluate.
  9153. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9154. * @returns {number} Returns the index at which `value` should be inserted
  9155. * into `array`.
  9156. * @example
  9157. *
  9158. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  9159. *
  9160. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  9161. * // => 0
  9162. *
  9163. * // The `_.property` iteratee shorthand.
  9164. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  9165. * // => 0
  9166. */
  9167. function sortedIndexBy(array, value, iteratee) {
  9168. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  9169. }
  9170. /**
  9171. * This method is like `_.indexOf` except that it performs a binary
  9172. * search on a sorted `array`.
  9173. *
  9174. * @static
  9175. * @memberOf _
  9176. * @since 4.0.0
  9177. * @category Array
  9178. * @param {Array} array The array to inspect.
  9179. * @param {*} value The value to search for.
  9180. * @returns {number} Returns the index of the matched value, else `-1`.
  9181. * @example
  9182. *
  9183. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  9184. * // => 1
  9185. */
  9186. function sortedIndexOf(array, value) {
  9187. var length = array == null ? 0 : array.length;
  9188. if (length) {
  9189. var index = baseSortedIndex(array, value);
  9190. if (index < length && eq(array[index], value)) {
  9191. return index;
  9192. }
  9193. }
  9194. return -1;
  9195. }
  9196. /**
  9197. * This method is like `_.sortedIndex` except that it returns the highest
  9198. * index at which `value` should be inserted into `array` in order to
  9199. * maintain its sort order.
  9200. *
  9201. * @static
  9202. * @memberOf _
  9203. * @since 3.0.0
  9204. * @category Array
  9205. * @param {Array} array The sorted array to inspect.
  9206. * @param {*} value The value to evaluate.
  9207. * @returns {number} Returns the index at which `value` should be inserted
  9208. * into `array`.
  9209. * @example
  9210. *
  9211. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  9212. * // => 4
  9213. */
  9214. function sortedLastIndex(array, value) {
  9215. return baseSortedIndex(array, value, true);
  9216. }
  9217. /**
  9218. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  9219. * which is invoked for `value` and each element of `array` to compute their
  9220. * sort ranking. The iteratee is invoked with one argument: (value).
  9221. *
  9222. * @static
  9223. * @memberOf _
  9224. * @since 4.0.0
  9225. * @category Array
  9226. * @param {Array} array The sorted array to inspect.
  9227. * @param {*} value The value to evaluate.
  9228. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9229. * @returns {number} Returns the index at which `value` should be inserted
  9230. * into `array`.
  9231. * @example
  9232. *
  9233. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  9234. *
  9235. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  9236. * // => 1
  9237. *
  9238. * // The `_.property` iteratee shorthand.
  9239. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  9240. * // => 1
  9241. */
  9242. function sortedLastIndexBy(array, value, iteratee) {
  9243. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  9244. }
  9245. /**
  9246. * This method is like `_.lastIndexOf` except that it performs a binary
  9247. * search on a sorted `array`.
  9248. *
  9249. * @static
  9250. * @memberOf _
  9251. * @since 4.0.0
  9252. * @category Array
  9253. * @param {Array} array The array to inspect.
  9254. * @param {*} value The value to search for.
  9255. * @returns {number} Returns the index of the matched value, else `-1`.
  9256. * @example
  9257. *
  9258. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  9259. * // => 3
  9260. */
  9261. function sortedLastIndexOf(array, value) {
  9262. var length = array == null ? 0 : array.length;
  9263. if (length) {
  9264. var index = baseSortedIndex(array, value, true) - 1;
  9265. if (eq(array[index], value)) {
  9266. return index;
  9267. }
  9268. }
  9269. return -1;
  9270. }
  9271. /**
  9272. * This method is like `_.uniq` except that it's designed and optimized
  9273. * for sorted arrays.
  9274. *
  9275. * @static
  9276. * @memberOf _
  9277. * @since 4.0.0
  9278. * @category Array
  9279. * @param {Array} array The array to inspect.
  9280. * @returns {Array} Returns the new duplicate free array.
  9281. * @example
  9282. *
  9283. * _.sortedUniq([1, 1, 2]);
  9284. * // => [1, 2]
  9285. */
  9286. function sortedUniq(array) {
  9287. return (array && array.length)
  9288. ? baseSortedUniq(array)
  9289. : [];
  9290. }
  9291. /**
  9292. * This method is like `_.uniqBy` except that it's designed and optimized
  9293. * for sorted arrays.
  9294. *
  9295. * @static
  9296. * @memberOf _
  9297. * @since 4.0.0
  9298. * @category Array
  9299. * @param {Array} array The array to inspect.
  9300. * @param {Function} [iteratee] The iteratee invoked per element.
  9301. * @returns {Array} Returns the new duplicate free array.
  9302. * @example
  9303. *
  9304. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  9305. * // => [1.1, 2.3]
  9306. */
  9307. function sortedUniqBy(array, iteratee) {
  9308. return (array && array.length)
  9309. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  9310. : [];
  9311. }
  9312. /**
  9313. * Gets all but the first element of `array`.
  9314. *
  9315. * @static
  9316. * @memberOf _
  9317. * @since 4.0.0
  9318. * @category Array
  9319. * @param {Array} array The array to query.
  9320. * @returns {Array} Returns the slice of `array`.
  9321. * @example
  9322. *
  9323. * _.tail([1, 2, 3]);
  9324. * // => [2, 3]
  9325. */
  9326. function tail(array) {
  9327. var length = array == null ? 0 : array.length;
  9328. return length ? baseSlice(array, 1, length) : [];
  9329. }
  9330. /**
  9331. * Creates a slice of `array` with `n` elements taken from the beginning.
  9332. *
  9333. * @static
  9334. * @memberOf _
  9335. * @since 0.1.0
  9336. * @category Array
  9337. * @param {Array} array The array to query.
  9338. * @param {number} [n=1] The number of elements to take.
  9339. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9340. * @returns {Array} Returns the slice of `array`.
  9341. * @example
  9342. *
  9343. * _.take([1, 2, 3]);
  9344. * // => [1]
  9345. *
  9346. * _.take([1, 2, 3], 2);
  9347. * // => [1, 2]
  9348. *
  9349. * _.take([1, 2, 3], 5);
  9350. * // => [1, 2, 3]
  9351. *
  9352. * _.take([1, 2, 3], 0);
  9353. * // => []
  9354. */
  9355. function take(array, n, guard) {
  9356. if (!(array && array.length)) {
  9357. return [];
  9358. }
  9359. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  9360. return baseSlice(array, 0, n < 0 ? 0 : n);
  9361. }
  9362. /**
  9363. * Creates a slice of `array` with `n` elements taken from the end.
  9364. *
  9365. * @static
  9366. * @memberOf _
  9367. * @since 3.0.0
  9368. * @category Array
  9369. * @param {Array} array The array to query.
  9370. * @param {number} [n=1] The number of elements to take.
  9371. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9372. * @returns {Array} Returns the slice of `array`.
  9373. * @example
  9374. *
  9375. * _.takeRight([1, 2, 3]);
  9376. * // => [3]
  9377. *
  9378. * _.takeRight([1, 2, 3], 2);
  9379. * // => [2, 3]
  9380. *
  9381. * _.takeRight([1, 2, 3], 5);
  9382. * // => [1, 2, 3]
  9383. *
  9384. * _.takeRight([1, 2, 3], 0);
  9385. * // => []
  9386. */
  9387. function takeRight(array, n, guard) {
  9388. var length = array == null ? 0 : array.length;
  9389. if (!length) {
  9390. return [];
  9391. }
  9392. n = (guard || n === undefined$1) ? 1 : toInteger(n);
  9393. n = length - n;
  9394. return baseSlice(array, n < 0 ? 0 : n, length);
  9395. }
  9396. /**
  9397. * Creates a slice of `array` with elements taken from the end. Elements are
  9398. * taken until `predicate` returns falsey. The predicate is invoked with
  9399. * three arguments: (value, index, array).
  9400. *
  9401. * @static
  9402. * @memberOf _
  9403. * @since 3.0.0
  9404. * @category Array
  9405. * @param {Array} array The array to query.
  9406. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9407. * @returns {Array} Returns the slice of `array`.
  9408. * @example
  9409. *
  9410. * var users = [
  9411. * { 'user': 'barney', 'active': true },
  9412. * { 'user': 'fred', 'active': false },
  9413. * { 'user': 'pebbles', 'active': false }
  9414. * ];
  9415. *
  9416. * _.takeRightWhile(users, function(o) { return !o.active; });
  9417. * // => objects for ['fred', 'pebbles']
  9418. *
  9419. * // The `_.matches` iteratee shorthand.
  9420. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  9421. * // => objects for ['pebbles']
  9422. *
  9423. * // The `_.matchesProperty` iteratee shorthand.
  9424. * _.takeRightWhile(users, ['active', false]);
  9425. * // => objects for ['fred', 'pebbles']
  9426. *
  9427. * // The `_.property` iteratee shorthand.
  9428. * _.takeRightWhile(users, 'active');
  9429. * // => []
  9430. */
  9431. function takeRightWhile(array, predicate) {
  9432. return (array && array.length)
  9433. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  9434. : [];
  9435. }
  9436. /**
  9437. * Creates a slice of `array` with elements taken from the beginning. Elements
  9438. * are taken until `predicate` returns falsey. The predicate is invoked with
  9439. * three arguments: (value, index, array).
  9440. *
  9441. * @static
  9442. * @memberOf _
  9443. * @since 3.0.0
  9444. * @category Array
  9445. * @param {Array} array The array to query.
  9446. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9447. * @returns {Array} Returns the slice of `array`.
  9448. * @example
  9449. *
  9450. * var users = [
  9451. * { 'user': 'barney', 'active': false },
  9452. * { 'user': 'fred', 'active': false },
  9453. * { 'user': 'pebbles', 'active': true }
  9454. * ];
  9455. *
  9456. * _.takeWhile(users, function(o) { return !o.active; });
  9457. * // => objects for ['barney', 'fred']
  9458. *
  9459. * // The `_.matches` iteratee shorthand.
  9460. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  9461. * // => objects for ['barney']
  9462. *
  9463. * // The `_.matchesProperty` iteratee shorthand.
  9464. * _.takeWhile(users, ['active', false]);
  9465. * // => objects for ['barney', 'fred']
  9466. *
  9467. * // The `_.property` iteratee shorthand.
  9468. * _.takeWhile(users, 'active');
  9469. * // => []
  9470. */
  9471. function takeWhile(array, predicate) {
  9472. return (array && array.length)
  9473. ? baseWhile(array, getIteratee(predicate, 3))
  9474. : [];
  9475. }
  9476. /**
  9477. * Creates an array of unique values, in order, from all given arrays using
  9478. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9479. * for equality comparisons.
  9480. *
  9481. * @static
  9482. * @memberOf _
  9483. * @since 0.1.0
  9484. * @category Array
  9485. * @param {...Array} [arrays] The arrays to inspect.
  9486. * @returns {Array} Returns the new array of combined values.
  9487. * @example
  9488. *
  9489. * _.union([2], [1, 2]);
  9490. * // => [2, 1]
  9491. */
  9492. var union = baseRest(function(arrays) {
  9493. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  9494. });
  9495. /**
  9496. * This method is like `_.union` except that it accepts `iteratee` which is
  9497. * invoked for each element of each `arrays` to generate the criterion by
  9498. * which uniqueness is computed. Result values are chosen from the first
  9499. * array in which the value occurs. The iteratee is invoked with one argument:
  9500. * (value).
  9501. *
  9502. * @static
  9503. * @memberOf _
  9504. * @since 4.0.0
  9505. * @category Array
  9506. * @param {...Array} [arrays] The arrays to inspect.
  9507. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9508. * @returns {Array} Returns the new array of combined values.
  9509. * @example
  9510. *
  9511. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  9512. * // => [2.1, 1.2]
  9513. *
  9514. * // The `_.property` iteratee shorthand.
  9515. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9516. * // => [{ 'x': 1 }, { 'x': 2 }]
  9517. */
  9518. var unionBy = baseRest(function(arrays) {
  9519. var iteratee = last(arrays);
  9520. if (isArrayLikeObject(iteratee)) {
  9521. iteratee = undefined$1;
  9522. }
  9523. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  9524. });
  9525. /**
  9526. * This method is like `_.union` except that it accepts `comparator` which
  9527. * is invoked to compare elements of `arrays`. Result values are chosen from
  9528. * the first array in which the value occurs. The comparator is invoked
  9529. * with two arguments: (arrVal, othVal).
  9530. *
  9531. * @static
  9532. * @memberOf _
  9533. * @since 4.0.0
  9534. * @category Array
  9535. * @param {...Array} [arrays] The arrays to inspect.
  9536. * @param {Function} [comparator] The comparator invoked per element.
  9537. * @returns {Array} Returns the new array of combined values.
  9538. * @example
  9539. *
  9540. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9541. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9542. *
  9543. * _.unionWith(objects, others, _.isEqual);
  9544. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9545. */
  9546. var unionWith = baseRest(function(arrays) {
  9547. var comparator = last(arrays);
  9548. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  9549. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined$1, comparator);
  9550. });
  9551. /**
  9552. * Creates a duplicate-free version of an array, using
  9553. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9554. * for equality comparisons, in which only the first occurrence of each element
  9555. * is kept. The order of result values is determined by the order they occur
  9556. * in the array.
  9557. *
  9558. * @static
  9559. * @memberOf _
  9560. * @since 0.1.0
  9561. * @category Array
  9562. * @param {Array} array The array to inspect.
  9563. * @returns {Array} Returns the new duplicate free array.
  9564. * @example
  9565. *
  9566. * _.uniq([2, 1, 2]);
  9567. * // => [2, 1]
  9568. */
  9569. function uniq(array) {
  9570. return (array && array.length) ? baseUniq(array) : [];
  9571. }
  9572. /**
  9573. * This method is like `_.uniq` except that it accepts `iteratee` which is
  9574. * invoked for each element in `array` to generate the criterion by which
  9575. * uniqueness is computed. The order of result values is determined by the
  9576. * order they occur in the array. The iteratee is invoked with one argument:
  9577. * (value).
  9578. *
  9579. * @static
  9580. * @memberOf _
  9581. * @since 4.0.0
  9582. * @category Array
  9583. * @param {Array} array The array to inspect.
  9584. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9585. * @returns {Array} Returns the new duplicate free array.
  9586. * @example
  9587. *
  9588. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  9589. * // => [2.1, 1.2]
  9590. *
  9591. * // The `_.property` iteratee shorthand.
  9592. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  9593. * // => [{ 'x': 1 }, { 'x': 2 }]
  9594. */
  9595. function uniqBy(array, iteratee) {
  9596. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  9597. }
  9598. /**
  9599. * This method is like `_.uniq` except that it accepts `comparator` which
  9600. * is invoked to compare elements of `array`. The order of result values is
  9601. * determined by the order they occur in the array.The comparator is invoked
  9602. * with two arguments: (arrVal, othVal).
  9603. *
  9604. * @static
  9605. * @memberOf _
  9606. * @since 4.0.0
  9607. * @category Array
  9608. * @param {Array} array The array to inspect.
  9609. * @param {Function} [comparator] The comparator invoked per element.
  9610. * @returns {Array} Returns the new duplicate free array.
  9611. * @example
  9612. *
  9613. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9614. *
  9615. * _.uniqWith(objects, _.isEqual);
  9616. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  9617. */
  9618. function uniqWith(array, comparator) {
  9619. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  9620. return (array && array.length) ? baseUniq(array, undefined$1, comparator) : [];
  9621. }
  9622. /**
  9623. * This method is like `_.zip` except that it accepts an array of grouped
  9624. * elements and creates an array regrouping the elements to their pre-zip
  9625. * configuration.
  9626. *
  9627. * @static
  9628. * @memberOf _
  9629. * @since 1.2.0
  9630. * @category Array
  9631. * @param {Array} array The array of grouped elements to process.
  9632. * @returns {Array} Returns the new array of regrouped elements.
  9633. * @example
  9634. *
  9635. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  9636. * // => [['a', 1, true], ['b', 2, false]]
  9637. *
  9638. * _.unzip(zipped);
  9639. * // => [['a', 'b'], [1, 2], [true, false]]
  9640. */
  9641. function unzip(array) {
  9642. if (!(array && array.length)) {
  9643. return [];
  9644. }
  9645. var length = 0;
  9646. array = arrayFilter(array, function(group) {
  9647. if (isArrayLikeObject(group)) {
  9648. length = nativeMax(group.length, length);
  9649. return true;
  9650. }
  9651. });
  9652. return baseTimes(length, function(index) {
  9653. return arrayMap(array, baseProperty(index));
  9654. });
  9655. }
  9656. /**
  9657. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  9658. * how regrouped values should be combined. The iteratee is invoked with the
  9659. * elements of each group: (...group).
  9660. *
  9661. * @static
  9662. * @memberOf _
  9663. * @since 3.8.0
  9664. * @category Array
  9665. * @param {Array} array The array of grouped elements to process.
  9666. * @param {Function} [iteratee=_.identity] The function to combine
  9667. * regrouped values.
  9668. * @returns {Array} Returns the new array of regrouped elements.
  9669. * @example
  9670. *
  9671. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  9672. * // => [[1, 10, 100], [2, 20, 200]]
  9673. *
  9674. * _.unzipWith(zipped, _.add);
  9675. * // => [3, 30, 300]
  9676. */
  9677. function unzipWith(array, iteratee) {
  9678. if (!(array && array.length)) {
  9679. return [];
  9680. }
  9681. var result = unzip(array);
  9682. if (iteratee == null) {
  9683. return result;
  9684. }
  9685. return arrayMap(result, function(group) {
  9686. return apply(iteratee, undefined$1, group);
  9687. });
  9688. }
  9689. /**
  9690. * Creates an array excluding all given values using
  9691. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9692. * for equality comparisons.
  9693. *
  9694. * **Note:** Unlike `_.pull`, this method returns a new array.
  9695. *
  9696. * @static
  9697. * @memberOf _
  9698. * @since 0.1.0
  9699. * @category Array
  9700. * @param {Array} array The array to inspect.
  9701. * @param {...*} [values] The values to exclude.
  9702. * @returns {Array} Returns the new array of filtered values.
  9703. * @see _.difference, _.xor
  9704. * @example
  9705. *
  9706. * _.without([2, 1, 2, 3], 1, 2);
  9707. * // => [3]
  9708. */
  9709. var without = baseRest(function(array, values) {
  9710. return isArrayLikeObject(array)
  9711. ? baseDifference(array, values)
  9712. : [];
  9713. });
  9714. /**
  9715. * Creates an array of unique values that is the
  9716. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  9717. * of the given arrays. The order of result values is determined by the order
  9718. * they occur in the arrays.
  9719. *
  9720. * @static
  9721. * @memberOf _
  9722. * @since 2.4.0
  9723. * @category Array
  9724. * @param {...Array} [arrays] The arrays to inspect.
  9725. * @returns {Array} Returns the new array of filtered values.
  9726. * @see _.difference, _.without
  9727. * @example
  9728. *
  9729. * _.xor([2, 1], [2, 3]);
  9730. * // => [1, 3]
  9731. */
  9732. var xor = baseRest(function(arrays) {
  9733. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  9734. });
  9735. /**
  9736. * This method is like `_.xor` except that it accepts `iteratee` which is
  9737. * invoked for each element of each `arrays` to generate the criterion by
  9738. * which by which they're compared. The order of result values is determined
  9739. * by the order they occur in the arrays. The iteratee is invoked with one
  9740. * argument: (value).
  9741. *
  9742. * @static
  9743. * @memberOf _
  9744. * @since 4.0.0
  9745. * @category Array
  9746. * @param {...Array} [arrays] The arrays to inspect.
  9747. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9748. * @returns {Array} Returns the new array of filtered values.
  9749. * @example
  9750. *
  9751. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  9752. * // => [1.2, 3.4]
  9753. *
  9754. * // The `_.property` iteratee shorthand.
  9755. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9756. * // => [{ 'x': 2 }]
  9757. */
  9758. var xorBy = baseRest(function(arrays) {
  9759. var iteratee = last(arrays);
  9760. if (isArrayLikeObject(iteratee)) {
  9761. iteratee = undefined$1;
  9762. }
  9763. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  9764. });
  9765. /**
  9766. * This method is like `_.xor` except that it accepts `comparator` which is
  9767. * invoked to compare elements of `arrays`. The order of result values is
  9768. * determined by the order they occur in the arrays. The comparator is invoked
  9769. * with two arguments: (arrVal, othVal).
  9770. *
  9771. * @static
  9772. * @memberOf _
  9773. * @since 4.0.0
  9774. * @category Array
  9775. * @param {...Array} [arrays] The arrays to inspect.
  9776. * @param {Function} [comparator] The comparator invoked per element.
  9777. * @returns {Array} Returns the new array of filtered values.
  9778. * @example
  9779. *
  9780. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9781. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9782. *
  9783. * _.xorWith(objects, others, _.isEqual);
  9784. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9785. */
  9786. var xorWith = baseRest(function(arrays) {
  9787. var comparator = last(arrays);
  9788. comparator = typeof comparator == 'function' ? comparator : undefined$1;
  9789. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined$1, comparator);
  9790. });
  9791. /**
  9792. * Creates an array of grouped elements, the first of which contains the
  9793. * first elements of the given arrays, the second of which contains the
  9794. * second elements of the given arrays, and so on.
  9795. *
  9796. * @static
  9797. * @memberOf _
  9798. * @since 0.1.0
  9799. * @category Array
  9800. * @param {...Array} [arrays] The arrays to process.
  9801. * @returns {Array} Returns the new array of grouped elements.
  9802. * @example
  9803. *
  9804. * _.zip(['a', 'b'], [1, 2], [true, false]);
  9805. * // => [['a', 1, true], ['b', 2, false]]
  9806. */
  9807. var zip = baseRest(unzip);
  9808. /**
  9809. * This method is like `_.fromPairs` except that it accepts two arrays,
  9810. * one of property identifiers and one of corresponding values.
  9811. *
  9812. * @static
  9813. * @memberOf _
  9814. * @since 0.4.0
  9815. * @category Array
  9816. * @param {Array} [props=[]] The property identifiers.
  9817. * @param {Array} [values=[]] The property values.
  9818. * @returns {Object} Returns the new object.
  9819. * @example
  9820. *
  9821. * _.zipObject(['a', 'b'], [1, 2]);
  9822. * // => { 'a': 1, 'b': 2 }
  9823. */
  9824. function zipObject(props, values) {
  9825. return baseZipObject(props || [], values || [], assignValue);
  9826. }
  9827. /**
  9828. * This method is like `_.zipObject` except that it supports property paths.
  9829. *
  9830. * @static
  9831. * @memberOf _
  9832. * @since 4.1.0
  9833. * @category Array
  9834. * @param {Array} [props=[]] The property identifiers.
  9835. * @param {Array} [values=[]] The property values.
  9836. * @returns {Object} Returns the new object.
  9837. * @example
  9838. *
  9839. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  9840. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  9841. */
  9842. function zipObjectDeep(props, values) {
  9843. return baseZipObject(props || [], values || [], baseSet);
  9844. }
  9845. /**
  9846. * This method is like `_.zip` except that it accepts `iteratee` to specify
  9847. * how grouped values should be combined. The iteratee is invoked with the
  9848. * elements of each group: (...group).
  9849. *
  9850. * @static
  9851. * @memberOf _
  9852. * @since 3.8.0
  9853. * @category Array
  9854. * @param {...Array} [arrays] The arrays to process.
  9855. * @param {Function} [iteratee=_.identity] The function to combine
  9856. * grouped values.
  9857. * @returns {Array} Returns the new array of grouped elements.
  9858. * @example
  9859. *
  9860. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  9861. * return a + b + c;
  9862. * });
  9863. * // => [111, 222]
  9864. */
  9865. var zipWith = baseRest(function(arrays) {
  9866. var length = arrays.length,
  9867. iteratee = length > 1 ? arrays[length - 1] : undefined$1;
  9868. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined$1;
  9869. return unzipWith(arrays, iteratee);
  9870. });
  9871. /*------------------------------------------------------------------------*/
  9872. /**
  9873. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  9874. * chain sequences enabled. The result of such sequences must be unwrapped
  9875. * with `_#value`.
  9876. *
  9877. * @static
  9878. * @memberOf _
  9879. * @since 1.3.0
  9880. * @category Seq
  9881. * @param {*} value The value to wrap.
  9882. * @returns {Object} Returns the new `lodash` wrapper instance.
  9883. * @example
  9884. *
  9885. * var users = [
  9886. * { 'user': 'barney', 'age': 36 },
  9887. * { 'user': 'fred', 'age': 40 },
  9888. * { 'user': 'pebbles', 'age': 1 }
  9889. * ];
  9890. *
  9891. * var youngest = _
  9892. * .chain(users)
  9893. * .sortBy('age')
  9894. * .map(function(o) {
  9895. * return o.user + ' is ' + o.age;
  9896. * })
  9897. * .head()
  9898. * .value();
  9899. * // => 'pebbles is 1'
  9900. */
  9901. function chain(value) {
  9902. var result = lodash(value);
  9903. result.__chain__ = true;
  9904. return result;
  9905. }
  9906. /**
  9907. * This method invokes `interceptor` and returns `value`. The interceptor
  9908. * is invoked with one argument; (value). The purpose of this method is to
  9909. * "tap into" a method chain sequence in order to modify intermediate results.
  9910. *
  9911. * @static
  9912. * @memberOf _
  9913. * @since 0.1.0
  9914. * @category Seq
  9915. * @param {*} value The value to provide to `interceptor`.
  9916. * @param {Function} interceptor The function to invoke.
  9917. * @returns {*} Returns `value`.
  9918. * @example
  9919. *
  9920. * _([1, 2, 3])
  9921. * .tap(function(array) {
  9922. * // Mutate input array.
  9923. * array.pop();
  9924. * })
  9925. * .reverse()
  9926. * .value();
  9927. * // => [2, 1]
  9928. */
  9929. function tap(value, interceptor) {
  9930. interceptor(value);
  9931. return value;
  9932. }
  9933. /**
  9934. * This method is like `_.tap` except that it returns the result of `interceptor`.
  9935. * The purpose of this method is to "pass thru" values replacing intermediate
  9936. * results in a method chain sequence.
  9937. *
  9938. * @static
  9939. * @memberOf _
  9940. * @since 3.0.0
  9941. * @category Seq
  9942. * @param {*} value The value to provide to `interceptor`.
  9943. * @param {Function} interceptor The function to invoke.
  9944. * @returns {*} Returns the result of `interceptor`.
  9945. * @example
  9946. *
  9947. * _(' abc ')
  9948. * .chain()
  9949. * .trim()
  9950. * .thru(function(value) {
  9951. * return [value];
  9952. * })
  9953. * .value();
  9954. * // => ['abc']
  9955. */
  9956. function thru(value, interceptor) {
  9957. return interceptor(value);
  9958. }
  9959. /**
  9960. * This method is the wrapper version of `_.at`.
  9961. *
  9962. * @name at
  9963. * @memberOf _
  9964. * @since 1.0.0
  9965. * @category Seq
  9966. * @param {...(string|string[])} [paths] The property paths to pick.
  9967. * @returns {Object} Returns the new `lodash` wrapper instance.
  9968. * @example
  9969. *
  9970. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  9971. *
  9972. * _(object).at(['a[0].b.c', 'a[1]']).value();
  9973. * // => [3, 4]
  9974. */
  9975. var wrapperAt = flatRest(function(paths) {
  9976. var length = paths.length,
  9977. start = length ? paths[0] : 0,
  9978. value = this.__wrapped__,
  9979. interceptor = function(object) { return baseAt(object, paths); };
  9980. if (length > 1 || this.__actions__.length ||
  9981. !(value instanceof LazyWrapper) || !isIndex(start)) {
  9982. return this.thru(interceptor);
  9983. }
  9984. value = value.slice(start, +start + (length ? 1 : 0));
  9985. value.__actions__.push({
  9986. 'func': thru,
  9987. 'args': [interceptor],
  9988. 'thisArg': undefined$1
  9989. });
  9990. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9991. if (length && !array.length) {
  9992. array.push(undefined$1);
  9993. }
  9994. return array;
  9995. });
  9996. });
  9997. /**
  9998. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9999. *
  10000. * @name chain
  10001. * @memberOf _
  10002. * @since 0.1.0
  10003. * @category Seq
  10004. * @returns {Object} Returns the new `lodash` wrapper instance.
  10005. * @example
  10006. *
  10007. * var users = [
  10008. * { 'user': 'barney', 'age': 36 },
  10009. * { 'user': 'fred', 'age': 40 }
  10010. * ];
  10011. *
  10012. * // A sequence without explicit chaining.
  10013. * _(users).head();
  10014. * // => { 'user': 'barney', 'age': 36 }
  10015. *
  10016. * // A sequence with explicit chaining.
  10017. * _(users)
  10018. * .chain()
  10019. * .head()
  10020. * .pick('user')
  10021. * .value();
  10022. * // => { 'user': 'barney' }
  10023. */
  10024. function wrapperChain() {
  10025. return chain(this);
  10026. }
  10027. /**
  10028. * Executes the chain sequence and returns the wrapped result.
  10029. *
  10030. * @name commit
  10031. * @memberOf _
  10032. * @since 3.2.0
  10033. * @category Seq
  10034. * @returns {Object} Returns the new `lodash` wrapper instance.
  10035. * @example
  10036. *
  10037. * var array = [1, 2];
  10038. * var wrapped = _(array).push(3);
  10039. *
  10040. * console.log(array);
  10041. * // => [1, 2]
  10042. *
  10043. * wrapped = wrapped.commit();
  10044. * console.log(array);
  10045. * // => [1, 2, 3]
  10046. *
  10047. * wrapped.last();
  10048. * // => 3
  10049. *
  10050. * console.log(array);
  10051. * // => [1, 2, 3]
  10052. */
  10053. function wrapperCommit() {
  10054. return new LodashWrapper(this.value(), this.__chain__);
  10055. }
  10056. /**
  10057. * Gets the next value on a wrapped object following the
  10058. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  10059. *
  10060. * @name next
  10061. * @memberOf _
  10062. * @since 4.0.0
  10063. * @category Seq
  10064. * @returns {Object} Returns the next iterator value.
  10065. * @example
  10066. *
  10067. * var wrapped = _([1, 2]);
  10068. *
  10069. * wrapped.next();
  10070. * // => { 'done': false, 'value': 1 }
  10071. *
  10072. * wrapped.next();
  10073. * // => { 'done': false, 'value': 2 }
  10074. *
  10075. * wrapped.next();
  10076. * // => { 'done': true, 'value': undefined }
  10077. */
  10078. function wrapperNext() {
  10079. if (this.__values__ === undefined$1) {
  10080. this.__values__ = toArray(this.value());
  10081. }
  10082. var done = this.__index__ >= this.__values__.length,
  10083. value = done ? undefined$1 : this.__values__[this.__index__++];
  10084. return { 'done': done, 'value': value };
  10085. }
  10086. /**
  10087. * Enables the wrapper to be iterable.
  10088. *
  10089. * @name Symbol.iterator
  10090. * @memberOf _
  10091. * @since 4.0.0
  10092. * @category Seq
  10093. * @returns {Object} Returns the wrapper object.
  10094. * @example
  10095. *
  10096. * var wrapped = _([1, 2]);
  10097. *
  10098. * wrapped[Symbol.iterator]() === wrapped;
  10099. * // => true
  10100. *
  10101. * Array.from(wrapped);
  10102. * // => [1, 2]
  10103. */
  10104. function wrapperToIterator() {
  10105. return this;
  10106. }
  10107. /**
  10108. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  10109. *
  10110. * @name plant
  10111. * @memberOf _
  10112. * @since 3.2.0
  10113. * @category Seq
  10114. * @param {*} value The value to plant.
  10115. * @returns {Object} Returns the new `lodash` wrapper instance.
  10116. * @example
  10117. *
  10118. * function square(n) {
  10119. * return n * n;
  10120. * }
  10121. *
  10122. * var wrapped = _([1, 2]).map(square);
  10123. * var other = wrapped.plant([3, 4]);
  10124. *
  10125. * other.value();
  10126. * // => [9, 16]
  10127. *
  10128. * wrapped.value();
  10129. * // => [1, 4]
  10130. */
  10131. function wrapperPlant(value) {
  10132. var result,
  10133. parent = this;
  10134. while (parent instanceof baseLodash) {
  10135. var clone = wrapperClone(parent);
  10136. clone.__index__ = 0;
  10137. clone.__values__ = undefined$1;
  10138. if (result) {
  10139. previous.__wrapped__ = clone;
  10140. } else {
  10141. result = clone;
  10142. }
  10143. var previous = clone;
  10144. parent = parent.__wrapped__;
  10145. }
  10146. previous.__wrapped__ = value;
  10147. return result;
  10148. }
  10149. /**
  10150. * This method is the wrapper version of `_.reverse`.
  10151. *
  10152. * **Note:** This method mutates the wrapped array.
  10153. *
  10154. * @name reverse
  10155. * @memberOf _
  10156. * @since 0.1.0
  10157. * @category Seq
  10158. * @returns {Object} Returns the new `lodash` wrapper instance.
  10159. * @example
  10160. *
  10161. * var array = [1, 2, 3];
  10162. *
  10163. * _(array).reverse().value()
  10164. * // => [3, 2, 1]
  10165. *
  10166. * console.log(array);
  10167. * // => [3, 2, 1]
  10168. */
  10169. function wrapperReverse() {
  10170. var value = this.__wrapped__;
  10171. if (value instanceof LazyWrapper) {
  10172. var wrapped = value;
  10173. if (this.__actions__.length) {
  10174. wrapped = new LazyWrapper(this);
  10175. }
  10176. wrapped = wrapped.reverse();
  10177. wrapped.__actions__.push({
  10178. 'func': thru,
  10179. 'args': [reverse],
  10180. 'thisArg': undefined$1
  10181. });
  10182. return new LodashWrapper(wrapped, this.__chain__);
  10183. }
  10184. return this.thru(reverse);
  10185. }
  10186. /**
  10187. * Executes the chain sequence to resolve the unwrapped value.
  10188. *
  10189. * @name value
  10190. * @memberOf _
  10191. * @since 0.1.0
  10192. * @alias toJSON, valueOf
  10193. * @category Seq
  10194. * @returns {*} Returns the resolved unwrapped value.
  10195. * @example
  10196. *
  10197. * _([1, 2, 3]).value();
  10198. * // => [1, 2, 3]
  10199. */
  10200. function wrapperValue() {
  10201. return baseWrapperValue(this.__wrapped__, this.__actions__);
  10202. }
  10203. /*------------------------------------------------------------------------*/
  10204. /**
  10205. * Creates an object composed of keys generated from the results of running
  10206. * each element of `collection` thru `iteratee`. The corresponding value of
  10207. * each key is the number of times the key was returned by `iteratee`. The
  10208. * iteratee is invoked with one argument: (value).
  10209. *
  10210. * @static
  10211. * @memberOf _
  10212. * @since 0.5.0
  10213. * @category Collection
  10214. * @param {Array|Object} collection The collection to iterate over.
  10215. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10216. * @returns {Object} Returns the composed aggregate object.
  10217. * @example
  10218. *
  10219. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  10220. * // => { '4': 1, '6': 2 }
  10221. *
  10222. * // The `_.property` iteratee shorthand.
  10223. * _.countBy(['one', 'two', 'three'], 'length');
  10224. * // => { '3': 2, '5': 1 }
  10225. */
  10226. var countBy = createAggregator(function(result, value, key) {
  10227. if (hasOwnProperty.call(result, key)) {
  10228. ++result[key];
  10229. } else {
  10230. baseAssignValue(result, key, 1);
  10231. }
  10232. });
  10233. /**
  10234. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  10235. * Iteration is stopped once `predicate` returns falsey. The predicate is
  10236. * invoked with three arguments: (value, index|key, collection).
  10237. *
  10238. * **Note:** This method returns `true` for
  10239. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  10240. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  10241. * elements of empty collections.
  10242. *
  10243. * @static
  10244. * @memberOf _
  10245. * @since 0.1.0
  10246. * @category Collection
  10247. * @param {Array|Object} collection The collection to iterate over.
  10248. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10249. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10250. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  10251. * else `false`.
  10252. * @example
  10253. *
  10254. * _.every([true, 1, null, 'yes'], Boolean);
  10255. * // => false
  10256. *
  10257. * var users = [
  10258. * { 'user': 'barney', 'age': 36, 'active': false },
  10259. * { 'user': 'fred', 'age': 40, 'active': false }
  10260. * ];
  10261. *
  10262. * // The `_.matches` iteratee shorthand.
  10263. * _.every(users, { 'user': 'barney', 'active': false });
  10264. * // => false
  10265. *
  10266. * // The `_.matchesProperty` iteratee shorthand.
  10267. * _.every(users, ['active', false]);
  10268. * // => true
  10269. *
  10270. * // The `_.property` iteratee shorthand.
  10271. * _.every(users, 'active');
  10272. * // => false
  10273. */
  10274. function every(collection, predicate, guard) {
  10275. var func = isArray(collection) ? arrayEvery : baseEvery;
  10276. if (guard && isIterateeCall(collection, predicate, guard)) {
  10277. predicate = undefined$1;
  10278. }
  10279. return func(collection, getIteratee(predicate, 3));
  10280. }
  10281. /**
  10282. * Iterates over elements of `collection`, returning an array of all elements
  10283. * `predicate` returns truthy for. The predicate is invoked with three
  10284. * arguments: (value, index|key, collection).
  10285. *
  10286. * **Note:** Unlike `_.remove`, this method returns a new array.
  10287. *
  10288. * @static
  10289. * @memberOf _
  10290. * @since 0.1.0
  10291. * @category Collection
  10292. * @param {Array|Object} collection The collection to iterate over.
  10293. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10294. * @returns {Array} Returns the new filtered array.
  10295. * @see _.reject
  10296. * @example
  10297. *
  10298. * var users = [
  10299. * { 'user': 'barney', 'age': 36, 'active': true },
  10300. * { 'user': 'fred', 'age': 40, 'active': false }
  10301. * ];
  10302. *
  10303. * _.filter(users, function(o) { return !o.active; });
  10304. * // => objects for ['fred']
  10305. *
  10306. * // The `_.matches` iteratee shorthand.
  10307. * _.filter(users, { 'age': 36, 'active': true });
  10308. * // => objects for ['barney']
  10309. *
  10310. * // The `_.matchesProperty` iteratee shorthand.
  10311. * _.filter(users, ['active', false]);
  10312. * // => objects for ['fred']
  10313. *
  10314. * // The `_.property` iteratee shorthand.
  10315. * _.filter(users, 'active');
  10316. * // => objects for ['barney']
  10317. *
  10318. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  10319. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  10320. * // => objects for ['fred', 'barney']
  10321. */
  10322. function filter(collection, predicate) {
  10323. var func = isArray(collection) ? arrayFilter : baseFilter;
  10324. return func(collection, getIteratee(predicate, 3));
  10325. }
  10326. /**
  10327. * Iterates over elements of `collection`, returning the first element
  10328. * `predicate` returns truthy for. The predicate is invoked with three
  10329. * arguments: (value, index|key, collection).
  10330. *
  10331. * @static
  10332. * @memberOf _
  10333. * @since 0.1.0
  10334. * @category Collection
  10335. * @param {Array|Object} collection The collection to inspect.
  10336. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10337. * @param {number} [fromIndex=0] The index to search from.
  10338. * @returns {*} Returns the matched element, else `undefined`.
  10339. * @example
  10340. *
  10341. * var users = [
  10342. * { 'user': 'barney', 'age': 36, 'active': true },
  10343. * { 'user': 'fred', 'age': 40, 'active': false },
  10344. * { 'user': 'pebbles', 'age': 1, 'active': true }
  10345. * ];
  10346. *
  10347. * _.find(users, function(o) { return o.age < 40; });
  10348. * // => object for 'barney'
  10349. *
  10350. * // The `_.matches` iteratee shorthand.
  10351. * _.find(users, { 'age': 1, 'active': true });
  10352. * // => object for 'pebbles'
  10353. *
  10354. * // The `_.matchesProperty` iteratee shorthand.
  10355. * _.find(users, ['active', false]);
  10356. * // => object for 'fred'
  10357. *
  10358. * // The `_.property` iteratee shorthand.
  10359. * _.find(users, 'active');
  10360. * // => object for 'barney'
  10361. */
  10362. var find = createFind(findIndex);
  10363. /**
  10364. * This method is like `_.find` except that it iterates over elements of
  10365. * `collection` from right to left.
  10366. *
  10367. * @static
  10368. * @memberOf _
  10369. * @since 2.0.0
  10370. * @category Collection
  10371. * @param {Array|Object} collection The collection to inspect.
  10372. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10373. * @param {number} [fromIndex=collection.length-1] The index to search from.
  10374. * @returns {*} Returns the matched element, else `undefined`.
  10375. * @example
  10376. *
  10377. * _.findLast([1, 2, 3, 4], function(n) {
  10378. * return n % 2 == 1;
  10379. * });
  10380. * // => 3
  10381. */
  10382. var findLast = createFind(findLastIndex);
  10383. /**
  10384. * Creates a flattened array of values by running each element in `collection`
  10385. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  10386. * with three arguments: (value, index|key, collection).
  10387. *
  10388. * @static
  10389. * @memberOf _
  10390. * @since 4.0.0
  10391. * @category Collection
  10392. * @param {Array|Object} collection The collection to iterate over.
  10393. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10394. * @returns {Array} Returns the new flattened array.
  10395. * @example
  10396. *
  10397. * function duplicate(n) {
  10398. * return [n, n];
  10399. * }
  10400. *
  10401. * _.flatMap([1, 2], duplicate);
  10402. * // => [1, 1, 2, 2]
  10403. */
  10404. function flatMap(collection, iteratee) {
  10405. return baseFlatten(map(collection, iteratee), 1);
  10406. }
  10407. /**
  10408. * This method is like `_.flatMap` except that it recursively flattens the
  10409. * mapped results.
  10410. *
  10411. * @static
  10412. * @memberOf _
  10413. * @since 4.7.0
  10414. * @category Collection
  10415. * @param {Array|Object} collection The collection to iterate over.
  10416. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10417. * @returns {Array} Returns the new flattened array.
  10418. * @example
  10419. *
  10420. * function duplicate(n) {
  10421. * return [[[n, n]]];
  10422. * }
  10423. *
  10424. * _.flatMapDeep([1, 2], duplicate);
  10425. * // => [1, 1, 2, 2]
  10426. */
  10427. function flatMapDeep(collection, iteratee) {
  10428. return baseFlatten(map(collection, iteratee), INFINITY);
  10429. }
  10430. /**
  10431. * This method is like `_.flatMap` except that it recursively flattens the
  10432. * mapped results up to `depth` times.
  10433. *
  10434. * @static
  10435. * @memberOf _
  10436. * @since 4.7.0
  10437. * @category Collection
  10438. * @param {Array|Object} collection The collection to iterate over.
  10439. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10440. * @param {number} [depth=1] The maximum recursion depth.
  10441. * @returns {Array} Returns the new flattened array.
  10442. * @example
  10443. *
  10444. * function duplicate(n) {
  10445. * return [[[n, n]]];
  10446. * }
  10447. *
  10448. * _.flatMapDepth([1, 2], duplicate, 2);
  10449. * // => [[1, 1], [2, 2]]
  10450. */
  10451. function flatMapDepth(collection, iteratee, depth) {
  10452. depth = depth === undefined$1 ? 1 : toInteger(depth);
  10453. return baseFlatten(map(collection, iteratee), depth);
  10454. }
  10455. /**
  10456. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  10457. * The iteratee is invoked with three arguments: (value, index|key, collection).
  10458. * Iteratee functions may exit iteration early by explicitly returning `false`.
  10459. *
  10460. * **Note:** As with other "Collections" methods, objects with a "length"
  10461. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  10462. * or `_.forOwn` for object iteration.
  10463. *
  10464. * @static
  10465. * @memberOf _
  10466. * @since 0.1.0
  10467. * @alias each
  10468. * @category Collection
  10469. * @param {Array|Object} collection The collection to iterate over.
  10470. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10471. * @returns {Array|Object} Returns `collection`.
  10472. * @see _.forEachRight
  10473. * @example
  10474. *
  10475. * _.forEach([1, 2], function(value) {
  10476. * console.log(value);
  10477. * });
  10478. * // => Logs `1` then `2`.
  10479. *
  10480. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  10481. * console.log(key);
  10482. * });
  10483. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  10484. */
  10485. function forEach(collection, iteratee) {
  10486. var func = isArray(collection) ? arrayEach : baseEach;
  10487. return func(collection, getIteratee(iteratee, 3));
  10488. }
  10489. /**
  10490. * This method is like `_.forEach` except that it iterates over elements of
  10491. * `collection` from right to left.
  10492. *
  10493. * @static
  10494. * @memberOf _
  10495. * @since 2.0.0
  10496. * @alias eachRight
  10497. * @category Collection
  10498. * @param {Array|Object} collection The collection to iterate over.
  10499. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10500. * @returns {Array|Object} Returns `collection`.
  10501. * @see _.forEach
  10502. * @example
  10503. *
  10504. * _.forEachRight([1, 2], function(value) {
  10505. * console.log(value);
  10506. * });
  10507. * // => Logs `2` then `1`.
  10508. */
  10509. function forEachRight(collection, iteratee) {
  10510. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  10511. return func(collection, getIteratee(iteratee, 3));
  10512. }
  10513. /**
  10514. * Creates an object composed of keys generated from the results of running
  10515. * each element of `collection` thru `iteratee`. The order of grouped values
  10516. * is determined by the order they occur in `collection`. The corresponding
  10517. * value of each key is an array of elements responsible for generating the
  10518. * key. The iteratee is invoked with one argument: (value).
  10519. *
  10520. * @static
  10521. * @memberOf _
  10522. * @since 0.1.0
  10523. * @category Collection
  10524. * @param {Array|Object} collection The collection to iterate over.
  10525. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10526. * @returns {Object} Returns the composed aggregate object.
  10527. * @example
  10528. *
  10529. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  10530. * // => { '4': [4.2], '6': [6.1, 6.3] }
  10531. *
  10532. * // The `_.property` iteratee shorthand.
  10533. * _.groupBy(['one', 'two', 'three'], 'length');
  10534. * // => { '3': ['one', 'two'], '5': ['three'] }
  10535. */
  10536. var groupBy = createAggregator(function(result, value, key) {
  10537. if (hasOwnProperty.call(result, key)) {
  10538. result[key].push(value);
  10539. } else {
  10540. baseAssignValue(result, key, [value]);
  10541. }
  10542. });
  10543. /**
  10544. * Checks if `value` is in `collection`. If `collection` is a string, it's
  10545. * checked for a substring of `value`, otherwise
  10546. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10547. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  10548. * the offset from the end of `collection`.
  10549. *
  10550. * @static
  10551. * @memberOf _
  10552. * @since 0.1.0
  10553. * @category Collection
  10554. * @param {Array|Object|string} collection The collection to inspect.
  10555. * @param {*} value The value to search for.
  10556. * @param {number} [fromIndex=0] The index to search from.
  10557. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10558. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  10559. * @example
  10560. *
  10561. * _.includes([1, 2, 3], 1);
  10562. * // => true
  10563. *
  10564. * _.includes([1, 2, 3], 1, 2);
  10565. * // => false
  10566. *
  10567. * _.includes({ 'a': 1, 'b': 2 }, 1);
  10568. * // => true
  10569. *
  10570. * _.includes('abcd', 'bc');
  10571. * // => true
  10572. */
  10573. function includes(collection, value, fromIndex, guard) {
  10574. collection = isArrayLike(collection) ? collection : values(collection);
  10575. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  10576. var length = collection.length;
  10577. if (fromIndex < 0) {
  10578. fromIndex = nativeMax(length + fromIndex, 0);
  10579. }
  10580. return isString(collection)
  10581. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  10582. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  10583. }
  10584. /**
  10585. * Invokes the method at `path` of each element in `collection`, returning
  10586. * an array of the results of each invoked method. Any additional arguments
  10587. * are provided to each invoked method. If `path` is a function, it's invoked
  10588. * for, and `this` bound to, each element in `collection`.
  10589. *
  10590. * @static
  10591. * @memberOf _
  10592. * @since 4.0.0
  10593. * @category Collection
  10594. * @param {Array|Object} collection The collection to iterate over.
  10595. * @param {Array|Function|string} path The path of the method to invoke or
  10596. * the function invoked per iteration.
  10597. * @param {...*} [args] The arguments to invoke each method with.
  10598. * @returns {Array} Returns the array of results.
  10599. * @example
  10600. *
  10601. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  10602. * // => [[1, 5, 7], [1, 2, 3]]
  10603. *
  10604. * _.invokeMap([123, 456], String.prototype.split, '');
  10605. * // => [['1', '2', '3'], ['4', '5', '6']]
  10606. */
  10607. var invokeMap = baseRest(function(collection, path, args) {
  10608. var index = -1,
  10609. isFunc = typeof path == 'function',
  10610. result = isArrayLike(collection) ? Array(collection.length) : [];
  10611. baseEach(collection, function(value) {
  10612. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  10613. });
  10614. return result;
  10615. });
  10616. /**
  10617. * Creates an object composed of keys generated from the results of running
  10618. * each element of `collection` thru `iteratee`. The corresponding value of
  10619. * each key is the last element responsible for generating the key. The
  10620. * iteratee is invoked with one argument: (value).
  10621. *
  10622. * @static
  10623. * @memberOf _
  10624. * @since 4.0.0
  10625. * @category Collection
  10626. * @param {Array|Object} collection The collection to iterate over.
  10627. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10628. * @returns {Object} Returns the composed aggregate object.
  10629. * @example
  10630. *
  10631. * var array = [
  10632. * { 'dir': 'left', 'code': 97 },
  10633. * { 'dir': 'right', 'code': 100 }
  10634. * ];
  10635. *
  10636. * _.keyBy(array, function(o) {
  10637. * return String.fromCharCode(o.code);
  10638. * });
  10639. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  10640. *
  10641. * _.keyBy(array, 'dir');
  10642. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  10643. */
  10644. var keyBy = createAggregator(function(result, value, key) {
  10645. baseAssignValue(result, key, value);
  10646. });
  10647. /**
  10648. * Creates an array of values by running each element in `collection` thru
  10649. * `iteratee`. The iteratee is invoked with three arguments:
  10650. * (value, index|key, collection).
  10651. *
  10652. * Many lodash methods are guarded to work as iteratees for methods like
  10653. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  10654. *
  10655. * The guarded methods are:
  10656. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  10657. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  10658. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  10659. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  10660. *
  10661. * @static
  10662. * @memberOf _
  10663. * @since 0.1.0
  10664. * @category Collection
  10665. * @param {Array|Object} collection The collection to iterate over.
  10666. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10667. * @returns {Array} Returns the new mapped array.
  10668. * @example
  10669. *
  10670. * function square(n) {
  10671. * return n * n;
  10672. * }
  10673. *
  10674. * _.map([4, 8], square);
  10675. * // => [16, 64]
  10676. *
  10677. * _.map({ 'a': 4, 'b': 8 }, square);
  10678. * // => [16, 64] (iteration order is not guaranteed)
  10679. *
  10680. * var users = [
  10681. * { 'user': 'barney' },
  10682. * { 'user': 'fred' }
  10683. * ];
  10684. *
  10685. * // The `_.property` iteratee shorthand.
  10686. * _.map(users, 'user');
  10687. * // => ['barney', 'fred']
  10688. */
  10689. function map(collection, iteratee) {
  10690. var func = isArray(collection) ? arrayMap : baseMap;
  10691. return func(collection, getIteratee(iteratee, 3));
  10692. }
  10693. /**
  10694. * This method is like `_.sortBy` except that it allows specifying the sort
  10695. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  10696. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  10697. * descending or "asc" for ascending sort order of corresponding values.
  10698. *
  10699. * @static
  10700. * @memberOf _
  10701. * @since 4.0.0
  10702. * @category Collection
  10703. * @param {Array|Object} collection The collection to iterate over.
  10704. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  10705. * The iteratees to sort by.
  10706. * @param {string[]} [orders] The sort orders of `iteratees`.
  10707. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10708. * @returns {Array} Returns the new sorted array.
  10709. * @example
  10710. *
  10711. * var users = [
  10712. * { 'user': 'fred', 'age': 48 },
  10713. * { 'user': 'barney', 'age': 34 },
  10714. * { 'user': 'fred', 'age': 40 },
  10715. * { 'user': 'barney', 'age': 36 }
  10716. * ];
  10717. *
  10718. * // Sort by `user` in ascending order and by `age` in descending order.
  10719. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  10720. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10721. */
  10722. function orderBy(collection, iteratees, orders, guard) {
  10723. if (collection == null) {
  10724. return [];
  10725. }
  10726. if (!isArray(iteratees)) {
  10727. iteratees = iteratees == null ? [] : [iteratees];
  10728. }
  10729. orders = guard ? undefined$1 : orders;
  10730. if (!isArray(orders)) {
  10731. orders = orders == null ? [] : [orders];
  10732. }
  10733. return baseOrderBy(collection, iteratees, orders);
  10734. }
  10735. /**
  10736. * Creates an array of elements split into two groups, the first of which
  10737. * contains elements `predicate` returns truthy for, the second of which
  10738. * contains elements `predicate` returns falsey for. The predicate is
  10739. * invoked with one argument: (value).
  10740. *
  10741. * @static
  10742. * @memberOf _
  10743. * @since 3.0.0
  10744. * @category Collection
  10745. * @param {Array|Object} collection The collection to iterate over.
  10746. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10747. * @returns {Array} Returns the array of grouped elements.
  10748. * @example
  10749. *
  10750. * var users = [
  10751. * { 'user': 'barney', 'age': 36, 'active': false },
  10752. * { 'user': 'fred', 'age': 40, 'active': true },
  10753. * { 'user': 'pebbles', 'age': 1, 'active': false }
  10754. * ];
  10755. *
  10756. * _.partition(users, function(o) { return o.active; });
  10757. * // => objects for [['fred'], ['barney', 'pebbles']]
  10758. *
  10759. * // The `_.matches` iteratee shorthand.
  10760. * _.partition(users, { 'age': 1, 'active': false });
  10761. * // => objects for [['pebbles'], ['barney', 'fred']]
  10762. *
  10763. * // The `_.matchesProperty` iteratee shorthand.
  10764. * _.partition(users, ['active', false]);
  10765. * // => objects for [['barney', 'pebbles'], ['fred']]
  10766. *
  10767. * // The `_.property` iteratee shorthand.
  10768. * _.partition(users, 'active');
  10769. * // => objects for [['fred'], ['barney', 'pebbles']]
  10770. */
  10771. var partition = createAggregator(function(result, value, key) {
  10772. result[key ? 0 : 1].push(value);
  10773. }, function() { return [[], []]; });
  10774. /**
  10775. * Reduces `collection` to a value which is the accumulated result of running
  10776. * each element in `collection` thru `iteratee`, where each successive
  10777. * invocation is supplied the return value of the previous. If `accumulator`
  10778. * is not given, the first element of `collection` is used as the initial
  10779. * value. The iteratee is invoked with four arguments:
  10780. * (accumulator, value, index|key, collection).
  10781. *
  10782. * Many lodash methods are guarded to work as iteratees for methods like
  10783. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  10784. *
  10785. * The guarded methods are:
  10786. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  10787. * and `sortBy`
  10788. *
  10789. * @static
  10790. * @memberOf _
  10791. * @since 0.1.0
  10792. * @category Collection
  10793. * @param {Array|Object} collection The collection to iterate over.
  10794. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10795. * @param {*} [accumulator] The initial value.
  10796. * @returns {*} Returns the accumulated value.
  10797. * @see _.reduceRight
  10798. * @example
  10799. *
  10800. * _.reduce([1, 2], function(sum, n) {
  10801. * return sum + n;
  10802. * }, 0);
  10803. * // => 3
  10804. *
  10805. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  10806. * (result[value] || (result[value] = [])).push(key);
  10807. * return result;
  10808. * }, {});
  10809. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  10810. */
  10811. function reduce(collection, iteratee, accumulator) {
  10812. var func = isArray(collection) ? arrayReduce : baseReduce,
  10813. initAccum = arguments.length < 3;
  10814. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  10815. }
  10816. /**
  10817. * This method is like `_.reduce` except that it iterates over elements of
  10818. * `collection` from right to left.
  10819. *
  10820. * @static
  10821. * @memberOf _
  10822. * @since 0.1.0
  10823. * @category Collection
  10824. * @param {Array|Object} collection The collection to iterate over.
  10825. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10826. * @param {*} [accumulator] The initial value.
  10827. * @returns {*} Returns the accumulated value.
  10828. * @see _.reduce
  10829. * @example
  10830. *
  10831. * var array = [[0, 1], [2, 3], [4, 5]];
  10832. *
  10833. * _.reduceRight(array, function(flattened, other) {
  10834. * return flattened.concat(other);
  10835. * }, []);
  10836. * // => [4, 5, 2, 3, 0, 1]
  10837. */
  10838. function reduceRight(collection, iteratee, accumulator) {
  10839. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  10840. initAccum = arguments.length < 3;
  10841. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  10842. }
  10843. /**
  10844. * The opposite of `_.filter`; this method returns the elements of `collection`
  10845. * that `predicate` does **not** return truthy for.
  10846. *
  10847. * @static
  10848. * @memberOf _
  10849. * @since 0.1.0
  10850. * @category Collection
  10851. * @param {Array|Object} collection The collection to iterate over.
  10852. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10853. * @returns {Array} Returns the new filtered array.
  10854. * @see _.filter
  10855. * @example
  10856. *
  10857. * var users = [
  10858. * { 'user': 'barney', 'age': 36, 'active': false },
  10859. * { 'user': 'fred', 'age': 40, 'active': true }
  10860. * ];
  10861. *
  10862. * _.reject(users, function(o) { return !o.active; });
  10863. * // => objects for ['fred']
  10864. *
  10865. * // The `_.matches` iteratee shorthand.
  10866. * _.reject(users, { 'age': 40, 'active': true });
  10867. * // => objects for ['barney']
  10868. *
  10869. * // The `_.matchesProperty` iteratee shorthand.
  10870. * _.reject(users, ['active', false]);
  10871. * // => objects for ['fred']
  10872. *
  10873. * // The `_.property` iteratee shorthand.
  10874. * _.reject(users, 'active');
  10875. * // => objects for ['barney']
  10876. */
  10877. function reject(collection, predicate) {
  10878. var func = isArray(collection) ? arrayFilter : baseFilter;
  10879. return func(collection, negate(getIteratee(predicate, 3)));
  10880. }
  10881. /**
  10882. * Gets a random element from `collection`.
  10883. *
  10884. * @static
  10885. * @memberOf _
  10886. * @since 2.0.0
  10887. * @category Collection
  10888. * @param {Array|Object} collection The collection to sample.
  10889. * @returns {*} Returns the random element.
  10890. * @example
  10891. *
  10892. * _.sample([1, 2, 3, 4]);
  10893. * // => 2
  10894. */
  10895. function sample(collection) {
  10896. var func = isArray(collection) ? arraySample : baseSample;
  10897. return func(collection);
  10898. }
  10899. /**
  10900. * Gets `n` random elements at unique keys from `collection` up to the
  10901. * size of `collection`.
  10902. *
  10903. * @static
  10904. * @memberOf _
  10905. * @since 4.0.0
  10906. * @category Collection
  10907. * @param {Array|Object} collection The collection to sample.
  10908. * @param {number} [n=1] The number of elements to sample.
  10909. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10910. * @returns {Array} Returns the random elements.
  10911. * @example
  10912. *
  10913. * _.sampleSize([1, 2, 3], 2);
  10914. * // => [3, 1]
  10915. *
  10916. * _.sampleSize([1, 2, 3], 4);
  10917. * // => [2, 3, 1]
  10918. */
  10919. function sampleSize(collection, n, guard) {
  10920. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined$1)) {
  10921. n = 1;
  10922. } else {
  10923. n = toInteger(n);
  10924. }
  10925. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  10926. return func(collection, n);
  10927. }
  10928. /**
  10929. * Creates an array of shuffled values, using a version of the
  10930. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  10931. *
  10932. * @static
  10933. * @memberOf _
  10934. * @since 0.1.0
  10935. * @category Collection
  10936. * @param {Array|Object} collection The collection to shuffle.
  10937. * @returns {Array} Returns the new shuffled array.
  10938. * @example
  10939. *
  10940. * _.shuffle([1, 2, 3, 4]);
  10941. * // => [4, 1, 3, 2]
  10942. */
  10943. function shuffle(collection) {
  10944. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  10945. return func(collection);
  10946. }
  10947. /**
  10948. * Gets the size of `collection` by returning its length for array-like
  10949. * values or the number of own enumerable string keyed properties for objects.
  10950. *
  10951. * @static
  10952. * @memberOf _
  10953. * @since 0.1.0
  10954. * @category Collection
  10955. * @param {Array|Object|string} collection The collection to inspect.
  10956. * @returns {number} Returns the collection size.
  10957. * @example
  10958. *
  10959. * _.size([1, 2, 3]);
  10960. * // => 3
  10961. *
  10962. * _.size({ 'a': 1, 'b': 2 });
  10963. * // => 2
  10964. *
  10965. * _.size('pebbles');
  10966. * // => 7
  10967. */
  10968. function size(collection) {
  10969. if (collection == null) {
  10970. return 0;
  10971. }
  10972. if (isArrayLike(collection)) {
  10973. return isString(collection) ? stringSize(collection) : collection.length;
  10974. }
  10975. var tag = getTag(collection);
  10976. if (tag == mapTag || tag == setTag) {
  10977. return collection.size;
  10978. }
  10979. return baseKeys(collection).length;
  10980. }
  10981. /**
  10982. * Checks if `predicate` returns truthy for **any** element of `collection`.
  10983. * Iteration is stopped once `predicate` returns truthy. The predicate is
  10984. * invoked with three arguments: (value, index|key, collection).
  10985. *
  10986. * @static
  10987. * @memberOf _
  10988. * @since 0.1.0
  10989. * @category Collection
  10990. * @param {Array|Object} collection The collection to iterate over.
  10991. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10992. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10993. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10994. * else `false`.
  10995. * @example
  10996. *
  10997. * _.some([null, 0, 'yes', false], Boolean);
  10998. * // => true
  10999. *
  11000. * var users = [
  11001. * { 'user': 'barney', 'active': true },
  11002. * { 'user': 'fred', 'active': false }
  11003. * ];
  11004. *
  11005. * // The `_.matches` iteratee shorthand.
  11006. * _.some(users, { 'user': 'barney', 'active': false });
  11007. * // => false
  11008. *
  11009. * // The `_.matchesProperty` iteratee shorthand.
  11010. * _.some(users, ['active', false]);
  11011. * // => true
  11012. *
  11013. * // The `_.property` iteratee shorthand.
  11014. * _.some(users, 'active');
  11015. * // => true
  11016. */
  11017. function some(collection, predicate, guard) {
  11018. var func = isArray(collection) ? arraySome : baseSome;
  11019. if (guard && isIterateeCall(collection, predicate, guard)) {
  11020. predicate = undefined$1;
  11021. }
  11022. return func(collection, getIteratee(predicate, 3));
  11023. }
  11024. /**
  11025. * Creates an array of elements, sorted in ascending order by the results of
  11026. * running each element in a collection thru each iteratee. This method
  11027. * performs a stable sort, that is, it preserves the original sort order of
  11028. * equal elements. The iteratees are invoked with one argument: (value).
  11029. *
  11030. * @static
  11031. * @memberOf _
  11032. * @since 0.1.0
  11033. * @category Collection
  11034. * @param {Array|Object} collection The collection to iterate over.
  11035. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  11036. * The iteratees to sort by.
  11037. * @returns {Array} Returns the new sorted array.
  11038. * @example
  11039. *
  11040. * var users = [
  11041. * { 'user': 'fred', 'age': 48 },
  11042. * { 'user': 'barney', 'age': 36 },
  11043. * { 'user': 'fred', 'age': 30 },
  11044. * { 'user': 'barney', 'age': 34 }
  11045. * ];
  11046. *
  11047. * _.sortBy(users, [function(o) { return o.user; }]);
  11048. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  11049. *
  11050. * _.sortBy(users, ['user', 'age']);
  11051. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  11052. */
  11053. var sortBy = baseRest(function(collection, iteratees) {
  11054. if (collection == null) {
  11055. return [];
  11056. }
  11057. var length = iteratees.length;
  11058. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  11059. iteratees = [];
  11060. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  11061. iteratees = [iteratees[0]];
  11062. }
  11063. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  11064. });
  11065. /*------------------------------------------------------------------------*/
  11066. /**
  11067. * Gets the timestamp of the number of milliseconds that have elapsed since
  11068. * the Unix epoch (1 January 1970 00:00:00 UTC).
  11069. *
  11070. * @static
  11071. * @memberOf _
  11072. * @since 2.4.0
  11073. * @category Date
  11074. * @returns {number} Returns the timestamp.
  11075. * @example
  11076. *
  11077. * _.defer(function(stamp) {
  11078. * console.log(_.now() - stamp);
  11079. * }, _.now());
  11080. * // => Logs the number of milliseconds it took for the deferred invocation.
  11081. */
  11082. var now = ctxNow || function() {
  11083. return root.Date.now();
  11084. };
  11085. /*------------------------------------------------------------------------*/
  11086. /**
  11087. * The opposite of `_.before`; this method creates a function that invokes
  11088. * `func` once it's called `n` or more times.
  11089. *
  11090. * @static
  11091. * @memberOf _
  11092. * @since 0.1.0
  11093. * @category Function
  11094. * @param {number} n The number of calls before `func` is invoked.
  11095. * @param {Function} func The function to restrict.
  11096. * @returns {Function} Returns the new restricted function.
  11097. * @example
  11098. *
  11099. * var saves = ['profile', 'settings'];
  11100. *
  11101. * var done = _.after(saves.length, function() {
  11102. * console.log('done saving!');
  11103. * });
  11104. *
  11105. * _.forEach(saves, function(type) {
  11106. * asyncSave({ 'type': type, 'complete': done });
  11107. * });
  11108. * // => Logs 'done saving!' after the two async saves have completed.
  11109. */
  11110. function after(n, func) {
  11111. if (typeof func != 'function') {
  11112. throw new TypeError(FUNC_ERROR_TEXT);
  11113. }
  11114. n = toInteger(n);
  11115. return function() {
  11116. if (--n < 1) {
  11117. return func.apply(this, arguments);
  11118. }
  11119. };
  11120. }
  11121. /**
  11122. * Creates a function that invokes `func`, with up to `n` arguments,
  11123. * ignoring any additional arguments.
  11124. *
  11125. * @static
  11126. * @memberOf _
  11127. * @since 3.0.0
  11128. * @category Function
  11129. * @param {Function} func The function to cap arguments for.
  11130. * @param {number} [n=func.length] The arity cap.
  11131. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11132. * @returns {Function} Returns the new capped function.
  11133. * @example
  11134. *
  11135. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  11136. * // => [6, 8, 10]
  11137. */
  11138. function ary(func, n, guard) {
  11139. n = guard ? undefined$1 : n;
  11140. n = (func && n == null) ? func.length : n;
  11141. return createWrap(func, WRAP_ARY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, n);
  11142. }
  11143. /**
  11144. * Creates a function that invokes `func`, with the `this` binding and arguments
  11145. * of the created function, while it's called less than `n` times. Subsequent
  11146. * calls to the created function return the result of the last `func` invocation.
  11147. *
  11148. * @static
  11149. * @memberOf _
  11150. * @since 3.0.0
  11151. * @category Function
  11152. * @param {number} n The number of calls at which `func` is no longer invoked.
  11153. * @param {Function} func The function to restrict.
  11154. * @returns {Function} Returns the new restricted function.
  11155. * @example
  11156. *
  11157. * jQuery(element).on('click', _.before(5, addContactToList));
  11158. * // => Allows adding up to 4 contacts to the list.
  11159. */
  11160. function before(n, func) {
  11161. var result;
  11162. if (typeof func != 'function') {
  11163. throw new TypeError(FUNC_ERROR_TEXT);
  11164. }
  11165. n = toInteger(n);
  11166. return function() {
  11167. if (--n > 0) {
  11168. result = func.apply(this, arguments);
  11169. }
  11170. if (n <= 1) {
  11171. func = undefined$1;
  11172. }
  11173. return result;
  11174. };
  11175. }
  11176. /**
  11177. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  11178. * and `partials` prepended to the arguments it receives.
  11179. *
  11180. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  11181. * may be used as a placeholder for partially applied arguments.
  11182. *
  11183. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  11184. * property of bound functions.
  11185. *
  11186. * @static
  11187. * @memberOf _
  11188. * @since 0.1.0
  11189. * @category Function
  11190. * @param {Function} func The function to bind.
  11191. * @param {*} thisArg The `this` binding of `func`.
  11192. * @param {...*} [partials] The arguments to be partially applied.
  11193. * @returns {Function} Returns the new bound function.
  11194. * @example
  11195. *
  11196. * function greet(greeting, punctuation) {
  11197. * return greeting + ' ' + this.user + punctuation;
  11198. * }
  11199. *
  11200. * var object = { 'user': 'fred' };
  11201. *
  11202. * var bound = _.bind(greet, object, 'hi');
  11203. * bound('!');
  11204. * // => 'hi fred!'
  11205. *
  11206. * // Bound with placeholders.
  11207. * var bound = _.bind(greet, object, _, '!');
  11208. * bound('hi');
  11209. * // => 'hi fred!'
  11210. */
  11211. var bind = baseRest(function(func, thisArg, partials) {
  11212. var bitmask = WRAP_BIND_FLAG;
  11213. if (partials.length) {
  11214. var holders = replaceHolders(partials, getHolder(bind));
  11215. bitmask |= WRAP_PARTIAL_FLAG;
  11216. }
  11217. return createWrap(func, bitmask, thisArg, partials, holders);
  11218. });
  11219. /**
  11220. * Creates a function that invokes the method at `object[key]` with `partials`
  11221. * prepended to the arguments it receives.
  11222. *
  11223. * This method differs from `_.bind` by allowing bound functions to reference
  11224. * methods that may be redefined or don't yet exist. See
  11225. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  11226. * for more details.
  11227. *
  11228. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  11229. * builds, may be used as a placeholder for partially applied arguments.
  11230. *
  11231. * @static
  11232. * @memberOf _
  11233. * @since 0.10.0
  11234. * @category Function
  11235. * @param {Object} object The object to invoke the method on.
  11236. * @param {string} key The key of the method.
  11237. * @param {...*} [partials] The arguments to be partially applied.
  11238. * @returns {Function} Returns the new bound function.
  11239. * @example
  11240. *
  11241. * var object = {
  11242. * 'user': 'fred',
  11243. * 'greet': function(greeting, punctuation) {
  11244. * return greeting + ' ' + this.user + punctuation;
  11245. * }
  11246. * };
  11247. *
  11248. * var bound = _.bindKey(object, 'greet', 'hi');
  11249. * bound('!');
  11250. * // => 'hi fred!'
  11251. *
  11252. * object.greet = function(greeting, punctuation) {
  11253. * return greeting + 'ya ' + this.user + punctuation;
  11254. * };
  11255. *
  11256. * bound('!');
  11257. * // => 'hiya fred!'
  11258. *
  11259. * // Bound with placeholders.
  11260. * var bound = _.bindKey(object, 'greet', _, '!');
  11261. * bound('hi');
  11262. * // => 'hiya fred!'
  11263. */
  11264. var bindKey = baseRest(function(object, key, partials) {
  11265. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  11266. if (partials.length) {
  11267. var holders = replaceHolders(partials, getHolder(bindKey));
  11268. bitmask |= WRAP_PARTIAL_FLAG;
  11269. }
  11270. return createWrap(key, bitmask, object, partials, holders);
  11271. });
  11272. /**
  11273. * Creates a function that accepts arguments of `func` and either invokes
  11274. * `func` returning its result, if at least `arity` number of arguments have
  11275. * been provided, or returns a function that accepts the remaining `func`
  11276. * arguments, and so on. The arity of `func` may be specified if `func.length`
  11277. * is not sufficient.
  11278. *
  11279. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  11280. * may be used as a placeholder for provided arguments.
  11281. *
  11282. * **Note:** This method doesn't set the "length" property of curried functions.
  11283. *
  11284. * @static
  11285. * @memberOf _
  11286. * @since 2.0.0
  11287. * @category Function
  11288. * @param {Function} func The function to curry.
  11289. * @param {number} [arity=func.length] The arity of `func`.
  11290. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11291. * @returns {Function} Returns the new curried function.
  11292. * @example
  11293. *
  11294. * var abc = function(a, b, c) {
  11295. * return [a, b, c];
  11296. * };
  11297. *
  11298. * var curried = _.curry(abc);
  11299. *
  11300. * curried(1)(2)(3);
  11301. * // => [1, 2, 3]
  11302. *
  11303. * curried(1, 2)(3);
  11304. * // => [1, 2, 3]
  11305. *
  11306. * curried(1, 2, 3);
  11307. * // => [1, 2, 3]
  11308. *
  11309. * // Curried with placeholders.
  11310. * curried(1)(_, 3)(2);
  11311. * // => [1, 2, 3]
  11312. */
  11313. function curry(func, arity, guard) {
  11314. arity = guard ? undefined$1 : arity;
  11315. var result = createWrap(func, WRAP_CURRY_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
  11316. result.placeholder = curry.placeholder;
  11317. return result;
  11318. }
  11319. /**
  11320. * This method is like `_.curry` except that arguments are applied to `func`
  11321. * in the manner of `_.partialRight` instead of `_.partial`.
  11322. *
  11323. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  11324. * builds, may be used as a placeholder for provided arguments.
  11325. *
  11326. * **Note:** This method doesn't set the "length" property of curried functions.
  11327. *
  11328. * @static
  11329. * @memberOf _
  11330. * @since 3.0.0
  11331. * @category Function
  11332. * @param {Function} func The function to curry.
  11333. * @param {number} [arity=func.length] The arity of `func`.
  11334. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11335. * @returns {Function} Returns the new curried function.
  11336. * @example
  11337. *
  11338. * var abc = function(a, b, c) {
  11339. * return [a, b, c];
  11340. * };
  11341. *
  11342. * var curried = _.curryRight(abc);
  11343. *
  11344. * curried(3)(2)(1);
  11345. * // => [1, 2, 3]
  11346. *
  11347. * curried(2, 3)(1);
  11348. * // => [1, 2, 3]
  11349. *
  11350. * curried(1, 2, 3);
  11351. * // => [1, 2, 3]
  11352. *
  11353. * // Curried with placeholders.
  11354. * curried(3)(1, _)(2);
  11355. * // => [1, 2, 3]
  11356. */
  11357. function curryRight(func, arity, guard) {
  11358. arity = guard ? undefined$1 : arity;
  11359. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined$1, undefined$1, undefined$1, undefined$1, undefined$1, arity);
  11360. result.placeholder = curryRight.placeholder;
  11361. return result;
  11362. }
  11363. /**
  11364. * Creates a debounced function that delays invoking `func` until after `wait`
  11365. * milliseconds have elapsed since the last time the debounced function was
  11366. * invoked. The debounced function comes with a `cancel` method to cancel
  11367. * delayed `func` invocations and a `flush` method to immediately invoke them.
  11368. * Provide `options` to indicate whether `func` should be invoked on the
  11369. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  11370. * with the last arguments provided to the debounced function. Subsequent
  11371. * calls to the debounced function return the result of the last `func`
  11372. * invocation.
  11373. *
  11374. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11375. * invoked on the trailing edge of the timeout only if the debounced function
  11376. * is invoked more than once during the `wait` timeout.
  11377. *
  11378. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11379. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11380. *
  11381. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11382. * for details over the differences between `_.debounce` and `_.throttle`.
  11383. *
  11384. * @static
  11385. * @memberOf _
  11386. * @since 0.1.0
  11387. * @category Function
  11388. * @param {Function} func The function to debounce.
  11389. * @param {number} [wait=0] The number of milliseconds to delay.
  11390. * @param {Object} [options={}] The options object.
  11391. * @param {boolean} [options.leading=false]
  11392. * Specify invoking on the leading edge of the timeout.
  11393. * @param {number} [options.maxWait]
  11394. * The maximum time `func` is allowed to be delayed before it's invoked.
  11395. * @param {boolean} [options.trailing=true]
  11396. * Specify invoking on the trailing edge of the timeout.
  11397. * @returns {Function} Returns the new debounced function.
  11398. * @example
  11399. *
  11400. * // Avoid costly calculations while the window size is in flux.
  11401. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  11402. *
  11403. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  11404. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  11405. * 'leading': true,
  11406. * 'trailing': false
  11407. * }));
  11408. *
  11409. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  11410. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  11411. * var source = new EventSource('/stream');
  11412. * jQuery(source).on('message', debounced);
  11413. *
  11414. * // Cancel the trailing debounced invocation.
  11415. * jQuery(window).on('popstate', debounced.cancel);
  11416. */
  11417. function debounce(func, wait, options) {
  11418. var lastArgs,
  11419. lastThis,
  11420. maxWait,
  11421. result,
  11422. timerId,
  11423. lastCallTime,
  11424. lastInvokeTime = 0,
  11425. leading = false,
  11426. maxing = false,
  11427. trailing = true;
  11428. if (typeof func != 'function') {
  11429. throw new TypeError(FUNC_ERROR_TEXT);
  11430. }
  11431. wait = toNumber(wait) || 0;
  11432. if (isObject(options)) {
  11433. leading = !!options.leading;
  11434. maxing = 'maxWait' in options;
  11435. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  11436. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11437. }
  11438. function invokeFunc(time) {
  11439. var args = lastArgs,
  11440. thisArg = lastThis;
  11441. lastArgs = lastThis = undefined$1;
  11442. lastInvokeTime = time;
  11443. result = func.apply(thisArg, args);
  11444. return result;
  11445. }
  11446. function leadingEdge(time) {
  11447. // Reset any `maxWait` timer.
  11448. lastInvokeTime = time;
  11449. // Start the timer for the trailing edge.
  11450. timerId = setTimeout(timerExpired, wait);
  11451. // Invoke the leading edge.
  11452. return leading ? invokeFunc(time) : result;
  11453. }
  11454. function remainingWait(time) {
  11455. var timeSinceLastCall = time - lastCallTime,
  11456. timeSinceLastInvoke = time - lastInvokeTime,
  11457. timeWaiting = wait - timeSinceLastCall;
  11458. return maxing
  11459. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  11460. : timeWaiting;
  11461. }
  11462. function shouldInvoke(time) {
  11463. var timeSinceLastCall = time - lastCallTime,
  11464. timeSinceLastInvoke = time - lastInvokeTime;
  11465. // Either this is the first call, activity has stopped and we're at the
  11466. // trailing edge, the system time has gone backwards and we're treating
  11467. // it as the trailing edge, or we've hit the `maxWait` limit.
  11468. return (lastCallTime === undefined$1 || (timeSinceLastCall >= wait) ||
  11469. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  11470. }
  11471. function timerExpired() {
  11472. var time = now();
  11473. if (shouldInvoke(time)) {
  11474. return trailingEdge(time);
  11475. }
  11476. // Restart the timer.
  11477. timerId = setTimeout(timerExpired, remainingWait(time));
  11478. }
  11479. function trailingEdge(time) {
  11480. timerId = undefined$1;
  11481. // Only invoke if we have `lastArgs` which means `func` has been
  11482. // debounced at least once.
  11483. if (trailing && lastArgs) {
  11484. return invokeFunc(time);
  11485. }
  11486. lastArgs = lastThis = undefined$1;
  11487. return result;
  11488. }
  11489. function cancel() {
  11490. if (timerId !== undefined$1) {
  11491. clearTimeout(timerId);
  11492. }
  11493. lastInvokeTime = 0;
  11494. lastArgs = lastCallTime = lastThis = timerId = undefined$1;
  11495. }
  11496. function flush() {
  11497. return timerId === undefined$1 ? result : trailingEdge(now());
  11498. }
  11499. function debounced() {
  11500. var time = now(),
  11501. isInvoking = shouldInvoke(time);
  11502. lastArgs = arguments;
  11503. lastThis = this;
  11504. lastCallTime = time;
  11505. if (isInvoking) {
  11506. if (timerId === undefined$1) {
  11507. return leadingEdge(lastCallTime);
  11508. }
  11509. if (maxing) {
  11510. // Handle invocations in a tight loop.
  11511. clearTimeout(timerId);
  11512. timerId = setTimeout(timerExpired, wait);
  11513. return invokeFunc(lastCallTime);
  11514. }
  11515. }
  11516. if (timerId === undefined$1) {
  11517. timerId = setTimeout(timerExpired, wait);
  11518. }
  11519. return result;
  11520. }
  11521. debounced.cancel = cancel;
  11522. debounced.flush = flush;
  11523. return debounced;
  11524. }
  11525. /**
  11526. * Defers invoking the `func` until the current call stack has cleared. Any
  11527. * additional arguments are provided to `func` when it's invoked.
  11528. *
  11529. * @static
  11530. * @memberOf _
  11531. * @since 0.1.0
  11532. * @category Function
  11533. * @param {Function} func The function to defer.
  11534. * @param {...*} [args] The arguments to invoke `func` with.
  11535. * @returns {number} Returns the timer id.
  11536. * @example
  11537. *
  11538. * _.defer(function(text) {
  11539. * console.log(text);
  11540. * }, 'deferred');
  11541. * // => Logs 'deferred' after one millisecond.
  11542. */
  11543. var defer = baseRest(function(func, args) {
  11544. return baseDelay(func, 1, args);
  11545. });
  11546. /**
  11547. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  11548. * provided to `func` when it's invoked.
  11549. *
  11550. * @static
  11551. * @memberOf _
  11552. * @since 0.1.0
  11553. * @category Function
  11554. * @param {Function} func The function to delay.
  11555. * @param {number} wait The number of milliseconds to delay invocation.
  11556. * @param {...*} [args] The arguments to invoke `func` with.
  11557. * @returns {number} Returns the timer id.
  11558. * @example
  11559. *
  11560. * _.delay(function(text) {
  11561. * console.log(text);
  11562. * }, 1000, 'later');
  11563. * // => Logs 'later' after one second.
  11564. */
  11565. var delay = baseRest(function(func, wait, args) {
  11566. return baseDelay(func, toNumber(wait) || 0, args);
  11567. });
  11568. /**
  11569. * Creates a function that invokes `func` with arguments reversed.
  11570. *
  11571. * @static
  11572. * @memberOf _
  11573. * @since 4.0.0
  11574. * @category Function
  11575. * @param {Function} func The function to flip arguments for.
  11576. * @returns {Function} Returns the new flipped function.
  11577. * @example
  11578. *
  11579. * var flipped = _.flip(function() {
  11580. * return _.toArray(arguments);
  11581. * });
  11582. *
  11583. * flipped('a', 'b', 'c', 'd');
  11584. * // => ['d', 'c', 'b', 'a']
  11585. */
  11586. function flip(func) {
  11587. return createWrap(func, WRAP_FLIP_FLAG);
  11588. }
  11589. /**
  11590. * Creates a function that memoizes the result of `func`. If `resolver` is
  11591. * provided, it determines the cache key for storing the result based on the
  11592. * arguments provided to the memoized function. By default, the first argument
  11593. * provided to the memoized function is used as the map cache key. The `func`
  11594. * is invoked with the `this` binding of the memoized function.
  11595. *
  11596. * **Note:** The cache is exposed as the `cache` property on the memoized
  11597. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  11598. * constructor with one whose instances implement the
  11599. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  11600. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  11601. *
  11602. * @static
  11603. * @memberOf _
  11604. * @since 0.1.0
  11605. * @category Function
  11606. * @param {Function} func The function to have its output memoized.
  11607. * @param {Function} [resolver] The function to resolve the cache key.
  11608. * @returns {Function} Returns the new memoized function.
  11609. * @example
  11610. *
  11611. * var object = { 'a': 1, 'b': 2 };
  11612. * var other = { 'c': 3, 'd': 4 };
  11613. *
  11614. * var values = _.memoize(_.values);
  11615. * values(object);
  11616. * // => [1, 2]
  11617. *
  11618. * values(other);
  11619. * // => [3, 4]
  11620. *
  11621. * object.a = 2;
  11622. * values(object);
  11623. * // => [1, 2]
  11624. *
  11625. * // Modify the result cache.
  11626. * values.cache.set(object, ['a', 'b']);
  11627. * values(object);
  11628. * // => ['a', 'b']
  11629. *
  11630. * // Replace `_.memoize.Cache`.
  11631. * _.memoize.Cache = WeakMap;
  11632. */
  11633. function memoize(func, resolver) {
  11634. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  11635. throw new TypeError(FUNC_ERROR_TEXT);
  11636. }
  11637. var memoized = function() {
  11638. var args = arguments,
  11639. key = resolver ? resolver.apply(this, args) : args[0],
  11640. cache = memoized.cache;
  11641. if (cache.has(key)) {
  11642. return cache.get(key);
  11643. }
  11644. var result = func.apply(this, args);
  11645. memoized.cache = cache.set(key, result) || cache;
  11646. return result;
  11647. };
  11648. memoized.cache = new (memoize.Cache || MapCache);
  11649. return memoized;
  11650. }
  11651. // Expose `MapCache`.
  11652. memoize.Cache = MapCache;
  11653. /**
  11654. * Creates a function that negates the result of the predicate `func`. The
  11655. * `func` predicate is invoked with the `this` binding and arguments of the
  11656. * created function.
  11657. *
  11658. * @static
  11659. * @memberOf _
  11660. * @since 3.0.0
  11661. * @category Function
  11662. * @param {Function} predicate The predicate to negate.
  11663. * @returns {Function} Returns the new negated function.
  11664. * @example
  11665. *
  11666. * function isEven(n) {
  11667. * return n % 2 == 0;
  11668. * }
  11669. *
  11670. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  11671. * // => [1, 3, 5]
  11672. */
  11673. function negate(predicate) {
  11674. if (typeof predicate != 'function') {
  11675. throw new TypeError(FUNC_ERROR_TEXT);
  11676. }
  11677. return function() {
  11678. var args = arguments;
  11679. switch (args.length) {
  11680. case 0: return !predicate.call(this);
  11681. case 1: return !predicate.call(this, args[0]);
  11682. case 2: return !predicate.call(this, args[0], args[1]);
  11683. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  11684. }
  11685. return !predicate.apply(this, args);
  11686. };
  11687. }
  11688. /**
  11689. * Creates a function that is restricted to invoking `func` once. Repeat calls
  11690. * to the function return the value of the first invocation. The `func` is
  11691. * invoked with the `this` binding and arguments of the created function.
  11692. *
  11693. * @static
  11694. * @memberOf _
  11695. * @since 0.1.0
  11696. * @category Function
  11697. * @param {Function} func The function to restrict.
  11698. * @returns {Function} Returns the new restricted function.
  11699. * @example
  11700. *
  11701. * var initialize = _.once(createApplication);
  11702. * initialize();
  11703. * initialize();
  11704. * // => `createApplication` is invoked once
  11705. */
  11706. function once(func) {
  11707. return before(2, func);
  11708. }
  11709. /**
  11710. * Creates a function that invokes `func` with its arguments transformed.
  11711. *
  11712. * @static
  11713. * @since 4.0.0
  11714. * @memberOf _
  11715. * @category Function
  11716. * @param {Function} func The function to wrap.
  11717. * @param {...(Function|Function[])} [transforms=[_.identity]]
  11718. * The argument transforms.
  11719. * @returns {Function} Returns the new function.
  11720. * @example
  11721. *
  11722. * function doubled(n) {
  11723. * return n * 2;
  11724. * }
  11725. *
  11726. * function square(n) {
  11727. * return n * n;
  11728. * }
  11729. *
  11730. * var func = _.overArgs(function(x, y) {
  11731. * return [x, y];
  11732. * }, [square, doubled]);
  11733. *
  11734. * func(9, 3);
  11735. * // => [81, 6]
  11736. *
  11737. * func(10, 5);
  11738. * // => [100, 10]
  11739. */
  11740. var overArgs = castRest(function(func, transforms) {
  11741. transforms = (transforms.length == 1 && isArray(transforms[0]))
  11742. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  11743. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  11744. var funcsLength = transforms.length;
  11745. return baseRest(function(args) {
  11746. var index = -1,
  11747. length = nativeMin(args.length, funcsLength);
  11748. while (++index < length) {
  11749. args[index] = transforms[index].call(this, args[index]);
  11750. }
  11751. return apply(func, this, args);
  11752. });
  11753. });
  11754. /**
  11755. * Creates a function that invokes `func` with `partials` prepended to the
  11756. * arguments it receives. This method is like `_.bind` except it does **not**
  11757. * alter the `this` binding.
  11758. *
  11759. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  11760. * builds, may be used as a placeholder for partially applied arguments.
  11761. *
  11762. * **Note:** This method doesn't set the "length" property of partially
  11763. * applied functions.
  11764. *
  11765. * @static
  11766. * @memberOf _
  11767. * @since 0.2.0
  11768. * @category Function
  11769. * @param {Function} func The function to partially apply arguments to.
  11770. * @param {...*} [partials] The arguments to be partially applied.
  11771. * @returns {Function} Returns the new partially applied function.
  11772. * @example
  11773. *
  11774. * function greet(greeting, name) {
  11775. * return greeting + ' ' + name;
  11776. * }
  11777. *
  11778. * var sayHelloTo = _.partial(greet, 'hello');
  11779. * sayHelloTo('fred');
  11780. * // => 'hello fred'
  11781. *
  11782. * // Partially applied with placeholders.
  11783. * var greetFred = _.partial(greet, _, 'fred');
  11784. * greetFred('hi');
  11785. * // => 'hi fred'
  11786. */
  11787. var partial = baseRest(function(func, partials) {
  11788. var holders = replaceHolders(partials, getHolder(partial));
  11789. return createWrap(func, WRAP_PARTIAL_FLAG, undefined$1, partials, holders);
  11790. });
  11791. /**
  11792. * This method is like `_.partial` except that partially applied arguments
  11793. * are appended to the arguments it receives.
  11794. *
  11795. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  11796. * builds, may be used as a placeholder for partially applied arguments.
  11797. *
  11798. * **Note:** This method doesn't set the "length" property of partially
  11799. * applied functions.
  11800. *
  11801. * @static
  11802. * @memberOf _
  11803. * @since 1.0.0
  11804. * @category Function
  11805. * @param {Function} func The function to partially apply arguments to.
  11806. * @param {...*} [partials] The arguments to be partially applied.
  11807. * @returns {Function} Returns the new partially applied function.
  11808. * @example
  11809. *
  11810. * function greet(greeting, name) {
  11811. * return greeting + ' ' + name;
  11812. * }
  11813. *
  11814. * var greetFred = _.partialRight(greet, 'fred');
  11815. * greetFred('hi');
  11816. * // => 'hi fred'
  11817. *
  11818. * // Partially applied with placeholders.
  11819. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  11820. * sayHelloTo('fred');
  11821. * // => 'hello fred'
  11822. */
  11823. var partialRight = baseRest(function(func, partials) {
  11824. var holders = replaceHolders(partials, getHolder(partialRight));
  11825. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined$1, partials, holders);
  11826. });
  11827. /**
  11828. * Creates a function that invokes `func` with arguments arranged according
  11829. * to the specified `indexes` where the argument value at the first index is
  11830. * provided as the first argument, the argument value at the second index is
  11831. * provided as the second argument, and so on.
  11832. *
  11833. * @static
  11834. * @memberOf _
  11835. * @since 3.0.0
  11836. * @category Function
  11837. * @param {Function} func The function to rearrange arguments for.
  11838. * @param {...(number|number[])} indexes The arranged argument indexes.
  11839. * @returns {Function} Returns the new function.
  11840. * @example
  11841. *
  11842. * var rearged = _.rearg(function(a, b, c) {
  11843. * return [a, b, c];
  11844. * }, [2, 0, 1]);
  11845. *
  11846. * rearged('b', 'c', 'a')
  11847. * // => ['a', 'b', 'c']
  11848. */
  11849. var rearg = flatRest(function(func, indexes) {
  11850. return createWrap(func, WRAP_REARG_FLAG, undefined$1, undefined$1, undefined$1, indexes);
  11851. });
  11852. /**
  11853. * Creates a function that invokes `func` with the `this` binding of the
  11854. * created function and arguments from `start` and beyond provided as
  11855. * an array.
  11856. *
  11857. * **Note:** This method is based on the
  11858. * [rest parameter](https://mdn.io/rest_parameters).
  11859. *
  11860. * @static
  11861. * @memberOf _
  11862. * @since 4.0.0
  11863. * @category Function
  11864. * @param {Function} func The function to apply a rest parameter to.
  11865. * @param {number} [start=func.length-1] The start position of the rest parameter.
  11866. * @returns {Function} Returns the new function.
  11867. * @example
  11868. *
  11869. * var say = _.rest(function(what, names) {
  11870. * return what + ' ' + _.initial(names).join(', ') +
  11871. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  11872. * });
  11873. *
  11874. * say('hello', 'fred', 'barney', 'pebbles');
  11875. * // => 'hello fred, barney, & pebbles'
  11876. */
  11877. function rest(func, start) {
  11878. if (typeof func != 'function') {
  11879. throw new TypeError(FUNC_ERROR_TEXT);
  11880. }
  11881. start = start === undefined$1 ? start : toInteger(start);
  11882. return baseRest(func, start);
  11883. }
  11884. /**
  11885. * Creates a function that invokes `func` with the `this` binding of the
  11886. * create function and an array of arguments much like
  11887. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  11888. *
  11889. * **Note:** This method is based on the
  11890. * [spread operator](https://mdn.io/spread_operator).
  11891. *
  11892. * @static
  11893. * @memberOf _
  11894. * @since 3.2.0
  11895. * @category Function
  11896. * @param {Function} func The function to spread arguments over.
  11897. * @param {number} [start=0] The start position of the spread.
  11898. * @returns {Function} Returns the new function.
  11899. * @example
  11900. *
  11901. * var say = _.spread(function(who, what) {
  11902. * return who + ' says ' + what;
  11903. * });
  11904. *
  11905. * say(['fred', 'hello']);
  11906. * // => 'fred says hello'
  11907. *
  11908. * var numbers = Promise.all([
  11909. * Promise.resolve(40),
  11910. * Promise.resolve(36)
  11911. * ]);
  11912. *
  11913. * numbers.then(_.spread(function(x, y) {
  11914. * return x + y;
  11915. * }));
  11916. * // => a Promise of 76
  11917. */
  11918. function spread(func, start) {
  11919. if (typeof func != 'function') {
  11920. throw new TypeError(FUNC_ERROR_TEXT);
  11921. }
  11922. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  11923. return baseRest(function(args) {
  11924. var array = args[start],
  11925. otherArgs = castSlice(args, 0, start);
  11926. if (array) {
  11927. arrayPush(otherArgs, array);
  11928. }
  11929. return apply(func, this, otherArgs);
  11930. });
  11931. }
  11932. /**
  11933. * Creates a throttled function that only invokes `func` at most once per
  11934. * every `wait` milliseconds. The throttled function comes with a `cancel`
  11935. * method to cancel delayed `func` invocations and a `flush` method to
  11936. * immediately invoke them. Provide `options` to indicate whether `func`
  11937. * should be invoked on the leading and/or trailing edge of the `wait`
  11938. * timeout. The `func` is invoked with the last arguments provided to the
  11939. * throttled function. Subsequent calls to the throttled function return the
  11940. * result of the last `func` invocation.
  11941. *
  11942. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11943. * invoked on the trailing edge of the timeout only if the throttled function
  11944. * is invoked more than once during the `wait` timeout.
  11945. *
  11946. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11947. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11948. *
  11949. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11950. * for details over the differences between `_.throttle` and `_.debounce`.
  11951. *
  11952. * @static
  11953. * @memberOf _
  11954. * @since 0.1.0
  11955. * @category Function
  11956. * @param {Function} func The function to throttle.
  11957. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  11958. * @param {Object} [options={}] The options object.
  11959. * @param {boolean} [options.leading=true]
  11960. * Specify invoking on the leading edge of the timeout.
  11961. * @param {boolean} [options.trailing=true]
  11962. * Specify invoking on the trailing edge of the timeout.
  11963. * @returns {Function} Returns the new throttled function.
  11964. * @example
  11965. *
  11966. * // Avoid excessively updating the position while scrolling.
  11967. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  11968. *
  11969. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  11970. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  11971. * jQuery(element).on('click', throttled);
  11972. *
  11973. * // Cancel the trailing throttled invocation.
  11974. * jQuery(window).on('popstate', throttled.cancel);
  11975. */
  11976. function throttle(func, wait, options) {
  11977. var leading = true,
  11978. trailing = true;
  11979. if (typeof func != 'function') {
  11980. throw new TypeError(FUNC_ERROR_TEXT);
  11981. }
  11982. if (isObject(options)) {
  11983. leading = 'leading' in options ? !!options.leading : leading;
  11984. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11985. }
  11986. return debounce(func, wait, {
  11987. 'leading': leading,
  11988. 'maxWait': wait,
  11989. 'trailing': trailing
  11990. });
  11991. }
  11992. /**
  11993. * Creates a function that accepts up to one argument, ignoring any
  11994. * additional arguments.
  11995. *
  11996. * @static
  11997. * @memberOf _
  11998. * @since 4.0.0
  11999. * @category Function
  12000. * @param {Function} func The function to cap arguments for.
  12001. * @returns {Function} Returns the new capped function.
  12002. * @example
  12003. *
  12004. * _.map(['6', '8', '10'], _.unary(parseInt));
  12005. * // => [6, 8, 10]
  12006. */
  12007. function unary(func) {
  12008. return ary(func, 1);
  12009. }
  12010. /**
  12011. * Creates a function that provides `value` to `wrapper` as its first
  12012. * argument. Any additional arguments provided to the function are appended
  12013. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  12014. * binding of the created function.
  12015. *
  12016. * @static
  12017. * @memberOf _
  12018. * @since 0.1.0
  12019. * @category Function
  12020. * @param {*} value The value to wrap.
  12021. * @param {Function} [wrapper=identity] The wrapper function.
  12022. * @returns {Function} Returns the new function.
  12023. * @example
  12024. *
  12025. * var p = _.wrap(_.escape, function(func, text) {
  12026. * return '<p>' + func(text) + '</p>';
  12027. * });
  12028. *
  12029. * p('fred, barney, & pebbles');
  12030. * // => '<p>fred, barney, &amp; pebbles</p>'
  12031. */
  12032. function wrap(value, wrapper) {
  12033. return partial(castFunction(wrapper), value);
  12034. }
  12035. /*------------------------------------------------------------------------*/
  12036. /**
  12037. * Casts `value` as an array if it's not one.
  12038. *
  12039. * @static
  12040. * @memberOf _
  12041. * @since 4.4.0
  12042. * @category Lang
  12043. * @param {*} value The value to inspect.
  12044. * @returns {Array} Returns the cast array.
  12045. * @example
  12046. *
  12047. * _.castArray(1);
  12048. * // => [1]
  12049. *
  12050. * _.castArray({ 'a': 1 });
  12051. * // => [{ 'a': 1 }]
  12052. *
  12053. * _.castArray('abc');
  12054. * // => ['abc']
  12055. *
  12056. * _.castArray(null);
  12057. * // => [null]
  12058. *
  12059. * _.castArray(undefined);
  12060. * // => [undefined]
  12061. *
  12062. * _.castArray();
  12063. * // => []
  12064. *
  12065. * var array = [1, 2, 3];
  12066. * console.log(_.castArray(array) === array);
  12067. * // => true
  12068. */
  12069. function castArray() {
  12070. if (!arguments.length) {
  12071. return [];
  12072. }
  12073. var value = arguments[0];
  12074. return isArray(value) ? value : [value];
  12075. }
  12076. /**
  12077. * Creates a shallow clone of `value`.
  12078. *
  12079. * **Note:** This method is loosely based on the
  12080. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  12081. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  12082. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  12083. * arrays. The own enumerable properties of `arguments` objects are cloned
  12084. * as plain objects. An empty object is returned for uncloneable values such
  12085. * as error objects, functions, DOM nodes, and WeakMaps.
  12086. *
  12087. * @static
  12088. * @memberOf _
  12089. * @since 0.1.0
  12090. * @category Lang
  12091. * @param {*} value The value to clone.
  12092. * @returns {*} Returns the cloned value.
  12093. * @see _.cloneDeep
  12094. * @example
  12095. *
  12096. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  12097. *
  12098. * var shallow = _.clone(objects);
  12099. * console.log(shallow[0] === objects[0]);
  12100. * // => true
  12101. */
  12102. function clone(value) {
  12103. return baseClone(value, CLONE_SYMBOLS_FLAG);
  12104. }
  12105. /**
  12106. * This method is like `_.clone` except that it accepts `customizer` which
  12107. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  12108. * cloning is handled by the method instead. The `customizer` is invoked with
  12109. * up to four arguments; (value [, index|key, object, stack]).
  12110. *
  12111. * @static
  12112. * @memberOf _
  12113. * @since 4.0.0
  12114. * @category Lang
  12115. * @param {*} value The value to clone.
  12116. * @param {Function} [customizer] The function to customize cloning.
  12117. * @returns {*} Returns the cloned value.
  12118. * @see _.cloneDeepWith
  12119. * @example
  12120. *
  12121. * function customizer(value) {
  12122. * if (_.isElement(value)) {
  12123. * return value.cloneNode(false);
  12124. * }
  12125. * }
  12126. *
  12127. * var el = _.cloneWith(document.body, customizer);
  12128. *
  12129. * console.log(el === document.body);
  12130. * // => false
  12131. * console.log(el.nodeName);
  12132. * // => 'BODY'
  12133. * console.log(el.childNodes.length);
  12134. * // => 0
  12135. */
  12136. function cloneWith(value, customizer) {
  12137. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  12138. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  12139. }
  12140. /**
  12141. * This method is like `_.clone` except that it recursively clones `value`.
  12142. *
  12143. * @static
  12144. * @memberOf _
  12145. * @since 1.0.0
  12146. * @category Lang
  12147. * @param {*} value The value to recursively clone.
  12148. * @returns {*} Returns the deep cloned value.
  12149. * @see _.clone
  12150. * @example
  12151. *
  12152. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  12153. *
  12154. * var deep = _.cloneDeep(objects);
  12155. * console.log(deep[0] === objects[0]);
  12156. * // => false
  12157. */
  12158. function cloneDeep(value) {
  12159. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  12160. }
  12161. /**
  12162. * This method is like `_.cloneWith` except that it recursively clones `value`.
  12163. *
  12164. * @static
  12165. * @memberOf _
  12166. * @since 4.0.0
  12167. * @category Lang
  12168. * @param {*} value The value to recursively clone.
  12169. * @param {Function} [customizer] The function to customize cloning.
  12170. * @returns {*} Returns the deep cloned value.
  12171. * @see _.cloneWith
  12172. * @example
  12173. *
  12174. * function customizer(value) {
  12175. * if (_.isElement(value)) {
  12176. * return value.cloneNode(true);
  12177. * }
  12178. * }
  12179. *
  12180. * var el = _.cloneDeepWith(document.body, customizer);
  12181. *
  12182. * console.log(el === document.body);
  12183. * // => false
  12184. * console.log(el.nodeName);
  12185. * // => 'BODY'
  12186. * console.log(el.childNodes.length);
  12187. * // => 20
  12188. */
  12189. function cloneDeepWith(value, customizer) {
  12190. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  12191. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  12192. }
  12193. /**
  12194. * Checks if `object` conforms to `source` by invoking the predicate
  12195. * properties of `source` with the corresponding property values of `object`.
  12196. *
  12197. * **Note:** This method is equivalent to `_.conforms` when `source` is
  12198. * partially applied.
  12199. *
  12200. * @static
  12201. * @memberOf _
  12202. * @since 4.14.0
  12203. * @category Lang
  12204. * @param {Object} object The object to inspect.
  12205. * @param {Object} source The object of property predicates to conform to.
  12206. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  12207. * @example
  12208. *
  12209. * var object = { 'a': 1, 'b': 2 };
  12210. *
  12211. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  12212. * // => true
  12213. *
  12214. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  12215. * // => false
  12216. */
  12217. function conformsTo(object, source) {
  12218. return source == null || baseConformsTo(object, source, keys(source));
  12219. }
  12220. /**
  12221. * Performs a
  12222. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12223. * comparison between two values to determine if they are equivalent.
  12224. *
  12225. * @static
  12226. * @memberOf _
  12227. * @since 4.0.0
  12228. * @category Lang
  12229. * @param {*} value The value to compare.
  12230. * @param {*} other The other value to compare.
  12231. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12232. * @example
  12233. *
  12234. * var object = { 'a': 1 };
  12235. * var other = { 'a': 1 };
  12236. *
  12237. * _.eq(object, object);
  12238. * // => true
  12239. *
  12240. * _.eq(object, other);
  12241. * // => false
  12242. *
  12243. * _.eq('a', 'a');
  12244. * // => true
  12245. *
  12246. * _.eq('a', Object('a'));
  12247. * // => false
  12248. *
  12249. * _.eq(NaN, NaN);
  12250. * // => true
  12251. */
  12252. function eq(value, other) {
  12253. return value === other || (value !== value && other !== other);
  12254. }
  12255. /**
  12256. * Checks if `value` is greater than `other`.
  12257. *
  12258. * @static
  12259. * @memberOf _
  12260. * @since 3.9.0
  12261. * @category Lang
  12262. * @param {*} value The value to compare.
  12263. * @param {*} other The other value to compare.
  12264. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  12265. * else `false`.
  12266. * @see _.lt
  12267. * @example
  12268. *
  12269. * _.gt(3, 1);
  12270. * // => true
  12271. *
  12272. * _.gt(3, 3);
  12273. * // => false
  12274. *
  12275. * _.gt(1, 3);
  12276. * // => false
  12277. */
  12278. var gt = createRelationalOperation(baseGt);
  12279. /**
  12280. * Checks if `value` is greater than or equal to `other`.
  12281. *
  12282. * @static
  12283. * @memberOf _
  12284. * @since 3.9.0
  12285. * @category Lang
  12286. * @param {*} value The value to compare.
  12287. * @param {*} other The other value to compare.
  12288. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  12289. * `other`, else `false`.
  12290. * @see _.lte
  12291. * @example
  12292. *
  12293. * _.gte(3, 1);
  12294. * // => true
  12295. *
  12296. * _.gte(3, 3);
  12297. * // => true
  12298. *
  12299. * _.gte(1, 3);
  12300. * // => false
  12301. */
  12302. var gte = createRelationalOperation(function(value, other) {
  12303. return value >= other;
  12304. });
  12305. /**
  12306. * Checks if `value` is likely an `arguments` object.
  12307. *
  12308. * @static
  12309. * @memberOf _
  12310. * @since 0.1.0
  12311. * @category Lang
  12312. * @param {*} value The value to check.
  12313. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  12314. * else `false`.
  12315. * @example
  12316. *
  12317. * _.isArguments(function() { return arguments; }());
  12318. * // => true
  12319. *
  12320. * _.isArguments([1, 2, 3]);
  12321. * // => false
  12322. */
  12323. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  12324. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  12325. !propertyIsEnumerable.call(value, 'callee');
  12326. };
  12327. /**
  12328. * Checks if `value` is classified as an `Array` object.
  12329. *
  12330. * @static
  12331. * @memberOf _
  12332. * @since 0.1.0
  12333. * @category Lang
  12334. * @param {*} value The value to check.
  12335. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  12336. * @example
  12337. *
  12338. * _.isArray([1, 2, 3]);
  12339. * // => true
  12340. *
  12341. * _.isArray(document.body.children);
  12342. * // => false
  12343. *
  12344. * _.isArray('abc');
  12345. * // => false
  12346. *
  12347. * _.isArray(_.noop);
  12348. * // => false
  12349. */
  12350. var isArray = Array.isArray;
  12351. /**
  12352. * Checks if `value` is classified as an `ArrayBuffer` object.
  12353. *
  12354. * @static
  12355. * @memberOf _
  12356. * @since 4.3.0
  12357. * @category Lang
  12358. * @param {*} value The value to check.
  12359. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  12360. * @example
  12361. *
  12362. * _.isArrayBuffer(new ArrayBuffer(2));
  12363. * // => true
  12364. *
  12365. * _.isArrayBuffer(new Array(2));
  12366. * // => false
  12367. */
  12368. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  12369. /**
  12370. * Checks if `value` is array-like. A value is considered array-like if it's
  12371. * not a function and has a `value.length` that's an integer greater than or
  12372. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  12373. *
  12374. * @static
  12375. * @memberOf _
  12376. * @since 4.0.0
  12377. * @category Lang
  12378. * @param {*} value The value to check.
  12379. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  12380. * @example
  12381. *
  12382. * _.isArrayLike([1, 2, 3]);
  12383. * // => true
  12384. *
  12385. * _.isArrayLike(document.body.children);
  12386. * // => true
  12387. *
  12388. * _.isArrayLike('abc');
  12389. * // => true
  12390. *
  12391. * _.isArrayLike(_.noop);
  12392. * // => false
  12393. */
  12394. function isArrayLike(value) {
  12395. return value != null && isLength(value.length) && !isFunction(value);
  12396. }
  12397. /**
  12398. * This method is like `_.isArrayLike` except that it also checks if `value`
  12399. * is an object.
  12400. *
  12401. * @static
  12402. * @memberOf _
  12403. * @since 4.0.0
  12404. * @category Lang
  12405. * @param {*} value The value to check.
  12406. * @returns {boolean} Returns `true` if `value` is an array-like object,
  12407. * else `false`.
  12408. * @example
  12409. *
  12410. * _.isArrayLikeObject([1, 2, 3]);
  12411. * // => true
  12412. *
  12413. * _.isArrayLikeObject(document.body.children);
  12414. * // => true
  12415. *
  12416. * _.isArrayLikeObject('abc');
  12417. * // => false
  12418. *
  12419. * _.isArrayLikeObject(_.noop);
  12420. * // => false
  12421. */
  12422. function isArrayLikeObject(value) {
  12423. return isObjectLike(value) && isArrayLike(value);
  12424. }
  12425. /**
  12426. * Checks if `value` is classified as a boolean primitive or object.
  12427. *
  12428. * @static
  12429. * @memberOf _
  12430. * @since 0.1.0
  12431. * @category Lang
  12432. * @param {*} value The value to check.
  12433. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  12434. * @example
  12435. *
  12436. * _.isBoolean(false);
  12437. * // => true
  12438. *
  12439. * _.isBoolean(null);
  12440. * // => false
  12441. */
  12442. function isBoolean(value) {
  12443. return value === true || value === false ||
  12444. (isObjectLike(value) && baseGetTag(value) == boolTag);
  12445. }
  12446. /**
  12447. * Checks if `value` is a buffer.
  12448. *
  12449. * @static
  12450. * @memberOf _
  12451. * @since 4.3.0
  12452. * @category Lang
  12453. * @param {*} value The value to check.
  12454. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  12455. * @example
  12456. *
  12457. * _.isBuffer(new Buffer(2));
  12458. * // => true
  12459. *
  12460. * _.isBuffer(new Uint8Array(2));
  12461. * // => false
  12462. */
  12463. var isBuffer = nativeIsBuffer || stubFalse;
  12464. /**
  12465. * Checks if `value` is classified as a `Date` object.
  12466. *
  12467. * @static
  12468. * @memberOf _
  12469. * @since 0.1.0
  12470. * @category Lang
  12471. * @param {*} value The value to check.
  12472. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  12473. * @example
  12474. *
  12475. * _.isDate(new Date);
  12476. * // => true
  12477. *
  12478. * _.isDate('Mon April 23 2012');
  12479. * // => false
  12480. */
  12481. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  12482. /**
  12483. * Checks if `value` is likely a DOM element.
  12484. *
  12485. * @static
  12486. * @memberOf _
  12487. * @since 0.1.0
  12488. * @category Lang
  12489. * @param {*} value The value to check.
  12490. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  12491. * @example
  12492. *
  12493. * _.isElement(document.body);
  12494. * // => true
  12495. *
  12496. * _.isElement('<body>');
  12497. * // => false
  12498. */
  12499. function isElement(value) {
  12500. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  12501. }
  12502. /**
  12503. * Checks if `value` is an empty object, collection, map, or set.
  12504. *
  12505. * Objects are considered empty if they have no own enumerable string keyed
  12506. * properties.
  12507. *
  12508. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  12509. * jQuery-like collections are considered empty if they have a `length` of `0`.
  12510. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  12511. *
  12512. * @static
  12513. * @memberOf _
  12514. * @since 0.1.0
  12515. * @category Lang
  12516. * @param {*} value The value to check.
  12517. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  12518. * @example
  12519. *
  12520. * _.isEmpty(null);
  12521. * // => true
  12522. *
  12523. * _.isEmpty(true);
  12524. * // => true
  12525. *
  12526. * _.isEmpty(1);
  12527. * // => true
  12528. *
  12529. * _.isEmpty([1, 2, 3]);
  12530. * // => false
  12531. *
  12532. * _.isEmpty({ 'a': 1 });
  12533. * // => false
  12534. */
  12535. function isEmpty(value) {
  12536. if (value == null) {
  12537. return true;
  12538. }
  12539. if (isArrayLike(value) &&
  12540. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  12541. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  12542. return !value.length;
  12543. }
  12544. var tag = getTag(value);
  12545. if (tag == mapTag || tag == setTag) {
  12546. return !value.size;
  12547. }
  12548. if (isPrototype(value)) {
  12549. return !baseKeys(value).length;
  12550. }
  12551. for (var key in value) {
  12552. if (hasOwnProperty.call(value, key)) {
  12553. return false;
  12554. }
  12555. }
  12556. return true;
  12557. }
  12558. /**
  12559. * Performs a deep comparison between two values to determine if they are
  12560. * equivalent.
  12561. *
  12562. * **Note:** This method supports comparing arrays, array buffers, booleans,
  12563. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  12564. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  12565. * by their own, not inherited, enumerable properties. Functions and DOM
  12566. * nodes are compared by strict equality, i.e. `===`.
  12567. *
  12568. * @static
  12569. * @memberOf _
  12570. * @since 0.1.0
  12571. * @category Lang
  12572. * @param {*} value The value to compare.
  12573. * @param {*} other The other value to compare.
  12574. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12575. * @example
  12576. *
  12577. * var object = { 'a': 1 };
  12578. * var other = { 'a': 1 };
  12579. *
  12580. * _.isEqual(object, other);
  12581. * // => true
  12582. *
  12583. * object === other;
  12584. * // => false
  12585. */
  12586. function isEqual(value, other) {
  12587. return baseIsEqual(value, other);
  12588. }
  12589. /**
  12590. * This method is like `_.isEqual` except that it accepts `customizer` which
  12591. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12592. * are handled by the method instead. The `customizer` is invoked with up to
  12593. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  12594. *
  12595. * @static
  12596. * @memberOf _
  12597. * @since 4.0.0
  12598. * @category Lang
  12599. * @param {*} value The value to compare.
  12600. * @param {*} other The other value to compare.
  12601. * @param {Function} [customizer] The function to customize comparisons.
  12602. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12603. * @example
  12604. *
  12605. * function isGreeting(value) {
  12606. * return /^h(?:i|ello)$/.test(value);
  12607. * }
  12608. *
  12609. * function customizer(objValue, othValue) {
  12610. * if (isGreeting(objValue) && isGreeting(othValue)) {
  12611. * return true;
  12612. * }
  12613. * }
  12614. *
  12615. * var array = ['hello', 'goodbye'];
  12616. * var other = ['hi', 'goodbye'];
  12617. *
  12618. * _.isEqualWith(array, other, customizer);
  12619. * // => true
  12620. */
  12621. function isEqualWith(value, other, customizer) {
  12622. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  12623. var result = customizer ? customizer(value, other) : undefined$1;
  12624. return result === undefined$1 ? baseIsEqual(value, other, undefined$1, customizer) : !!result;
  12625. }
  12626. /**
  12627. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  12628. * `SyntaxError`, `TypeError`, or `URIError` object.
  12629. *
  12630. * @static
  12631. * @memberOf _
  12632. * @since 3.0.0
  12633. * @category Lang
  12634. * @param {*} value The value to check.
  12635. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  12636. * @example
  12637. *
  12638. * _.isError(new Error);
  12639. * // => true
  12640. *
  12641. * _.isError(Error);
  12642. * // => false
  12643. */
  12644. function isError(value) {
  12645. if (!isObjectLike(value)) {
  12646. return false;
  12647. }
  12648. var tag = baseGetTag(value);
  12649. return tag == errorTag || tag == domExcTag ||
  12650. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  12651. }
  12652. /**
  12653. * Checks if `value` is a finite primitive number.
  12654. *
  12655. * **Note:** This method is based on
  12656. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  12657. *
  12658. * @static
  12659. * @memberOf _
  12660. * @since 0.1.0
  12661. * @category Lang
  12662. * @param {*} value The value to check.
  12663. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  12664. * @example
  12665. *
  12666. * _.isFinite(3);
  12667. * // => true
  12668. *
  12669. * _.isFinite(Number.MIN_VALUE);
  12670. * // => true
  12671. *
  12672. * _.isFinite(Infinity);
  12673. * // => false
  12674. *
  12675. * _.isFinite('3');
  12676. * // => false
  12677. */
  12678. function isFinite(value) {
  12679. return typeof value == 'number' && nativeIsFinite(value);
  12680. }
  12681. /**
  12682. * Checks if `value` is classified as a `Function` object.
  12683. *
  12684. * @static
  12685. * @memberOf _
  12686. * @since 0.1.0
  12687. * @category Lang
  12688. * @param {*} value The value to check.
  12689. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  12690. * @example
  12691. *
  12692. * _.isFunction(_);
  12693. * // => true
  12694. *
  12695. * _.isFunction(/abc/);
  12696. * // => false
  12697. */
  12698. function isFunction(value) {
  12699. if (!isObject(value)) {
  12700. return false;
  12701. }
  12702. // The use of `Object#toString` avoids issues with the `typeof` operator
  12703. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  12704. var tag = baseGetTag(value);
  12705. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  12706. }
  12707. /**
  12708. * Checks if `value` is an integer.
  12709. *
  12710. * **Note:** This method is based on
  12711. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  12712. *
  12713. * @static
  12714. * @memberOf _
  12715. * @since 4.0.0
  12716. * @category Lang
  12717. * @param {*} value The value to check.
  12718. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  12719. * @example
  12720. *
  12721. * _.isInteger(3);
  12722. * // => true
  12723. *
  12724. * _.isInteger(Number.MIN_VALUE);
  12725. * // => false
  12726. *
  12727. * _.isInteger(Infinity);
  12728. * // => false
  12729. *
  12730. * _.isInteger('3');
  12731. * // => false
  12732. */
  12733. function isInteger(value) {
  12734. return typeof value == 'number' && value == toInteger(value);
  12735. }
  12736. /**
  12737. * Checks if `value` is a valid array-like length.
  12738. *
  12739. * **Note:** This method is loosely based on
  12740. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12741. *
  12742. * @static
  12743. * @memberOf _
  12744. * @since 4.0.0
  12745. * @category Lang
  12746. * @param {*} value The value to check.
  12747. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  12748. * @example
  12749. *
  12750. * _.isLength(3);
  12751. * // => true
  12752. *
  12753. * _.isLength(Number.MIN_VALUE);
  12754. * // => false
  12755. *
  12756. * _.isLength(Infinity);
  12757. * // => false
  12758. *
  12759. * _.isLength('3');
  12760. * // => false
  12761. */
  12762. function isLength(value) {
  12763. return typeof value == 'number' &&
  12764. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  12765. }
  12766. /**
  12767. * Checks if `value` is the
  12768. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  12769. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  12770. *
  12771. * @static
  12772. * @memberOf _
  12773. * @since 0.1.0
  12774. * @category Lang
  12775. * @param {*} value The value to check.
  12776. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  12777. * @example
  12778. *
  12779. * _.isObject({});
  12780. * // => true
  12781. *
  12782. * _.isObject([1, 2, 3]);
  12783. * // => true
  12784. *
  12785. * _.isObject(_.noop);
  12786. * // => true
  12787. *
  12788. * _.isObject(null);
  12789. * // => false
  12790. */
  12791. function isObject(value) {
  12792. var type = typeof value;
  12793. return value != null && (type == 'object' || type == 'function');
  12794. }
  12795. /**
  12796. * Checks if `value` is object-like. A value is object-like if it's not `null`
  12797. * and has a `typeof` result of "object".
  12798. *
  12799. * @static
  12800. * @memberOf _
  12801. * @since 4.0.0
  12802. * @category Lang
  12803. * @param {*} value The value to check.
  12804. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  12805. * @example
  12806. *
  12807. * _.isObjectLike({});
  12808. * // => true
  12809. *
  12810. * _.isObjectLike([1, 2, 3]);
  12811. * // => true
  12812. *
  12813. * _.isObjectLike(_.noop);
  12814. * // => false
  12815. *
  12816. * _.isObjectLike(null);
  12817. * // => false
  12818. */
  12819. function isObjectLike(value) {
  12820. return value != null && typeof value == 'object';
  12821. }
  12822. /**
  12823. * Checks if `value` is classified as a `Map` object.
  12824. *
  12825. * @static
  12826. * @memberOf _
  12827. * @since 4.3.0
  12828. * @category Lang
  12829. * @param {*} value The value to check.
  12830. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  12831. * @example
  12832. *
  12833. * _.isMap(new Map);
  12834. * // => true
  12835. *
  12836. * _.isMap(new WeakMap);
  12837. * // => false
  12838. */
  12839. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  12840. /**
  12841. * Performs a partial deep comparison between `object` and `source` to
  12842. * determine if `object` contains equivalent property values.
  12843. *
  12844. * **Note:** This method is equivalent to `_.matches` when `source` is
  12845. * partially applied.
  12846. *
  12847. * Partial comparisons will match empty array and empty object `source`
  12848. * values against any array or object value, respectively. See `_.isEqual`
  12849. * for a list of supported value comparisons.
  12850. *
  12851. * @static
  12852. * @memberOf _
  12853. * @since 3.0.0
  12854. * @category Lang
  12855. * @param {Object} object The object to inspect.
  12856. * @param {Object} source The object of property values to match.
  12857. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12858. * @example
  12859. *
  12860. * var object = { 'a': 1, 'b': 2 };
  12861. *
  12862. * _.isMatch(object, { 'b': 2 });
  12863. * // => true
  12864. *
  12865. * _.isMatch(object, { 'b': 1 });
  12866. * // => false
  12867. */
  12868. function isMatch(object, source) {
  12869. return object === source || baseIsMatch(object, source, getMatchData(source));
  12870. }
  12871. /**
  12872. * This method is like `_.isMatch` except that it accepts `customizer` which
  12873. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12874. * are handled by the method instead. The `customizer` is invoked with five
  12875. * arguments: (objValue, srcValue, index|key, object, source).
  12876. *
  12877. * @static
  12878. * @memberOf _
  12879. * @since 4.0.0
  12880. * @category Lang
  12881. * @param {Object} object The object to inspect.
  12882. * @param {Object} source The object of property values to match.
  12883. * @param {Function} [customizer] The function to customize comparisons.
  12884. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12885. * @example
  12886. *
  12887. * function isGreeting(value) {
  12888. * return /^h(?:i|ello)$/.test(value);
  12889. * }
  12890. *
  12891. * function customizer(objValue, srcValue) {
  12892. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  12893. * return true;
  12894. * }
  12895. * }
  12896. *
  12897. * var object = { 'greeting': 'hello' };
  12898. * var source = { 'greeting': 'hi' };
  12899. *
  12900. * _.isMatchWith(object, source, customizer);
  12901. * // => true
  12902. */
  12903. function isMatchWith(object, source, customizer) {
  12904. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  12905. return baseIsMatch(object, source, getMatchData(source), customizer);
  12906. }
  12907. /**
  12908. * Checks if `value` is `NaN`.
  12909. *
  12910. * **Note:** This method is based on
  12911. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  12912. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  12913. * `undefined` and other non-number values.
  12914. *
  12915. * @static
  12916. * @memberOf _
  12917. * @since 0.1.0
  12918. * @category Lang
  12919. * @param {*} value The value to check.
  12920. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12921. * @example
  12922. *
  12923. * _.isNaN(NaN);
  12924. * // => true
  12925. *
  12926. * _.isNaN(new Number(NaN));
  12927. * // => true
  12928. *
  12929. * isNaN(undefined);
  12930. * // => true
  12931. *
  12932. * _.isNaN(undefined);
  12933. * // => false
  12934. */
  12935. function isNaN(value) {
  12936. // An `NaN` primitive is the only value that is not equal to itself.
  12937. // Perform the `toStringTag` check first to avoid errors with some
  12938. // ActiveX objects in IE.
  12939. return isNumber(value) && value != +value;
  12940. }
  12941. /**
  12942. * Checks if `value` is a pristine native function.
  12943. *
  12944. * **Note:** This method can't reliably detect native functions in the presence
  12945. * of the core-js package because core-js circumvents this kind of detection.
  12946. * Despite multiple requests, the core-js maintainer has made it clear: any
  12947. * attempt to fix the detection will be obstructed. As a result, we're left
  12948. * with little choice but to throw an error. Unfortunately, this also affects
  12949. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  12950. * which rely on core-js.
  12951. *
  12952. * @static
  12953. * @memberOf _
  12954. * @since 3.0.0
  12955. * @category Lang
  12956. * @param {*} value The value to check.
  12957. * @returns {boolean} Returns `true` if `value` is a native function,
  12958. * else `false`.
  12959. * @example
  12960. *
  12961. * _.isNative(Array.prototype.push);
  12962. * // => true
  12963. *
  12964. * _.isNative(_);
  12965. * // => false
  12966. */
  12967. function isNative(value) {
  12968. if (isMaskable(value)) {
  12969. throw new Error(CORE_ERROR_TEXT);
  12970. }
  12971. return baseIsNative(value);
  12972. }
  12973. /**
  12974. * Checks if `value` is `null`.
  12975. *
  12976. * @static
  12977. * @memberOf _
  12978. * @since 0.1.0
  12979. * @category Lang
  12980. * @param {*} value The value to check.
  12981. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  12982. * @example
  12983. *
  12984. * _.isNull(null);
  12985. * // => true
  12986. *
  12987. * _.isNull(void 0);
  12988. * // => false
  12989. */
  12990. function isNull(value) {
  12991. return value === null;
  12992. }
  12993. /**
  12994. * Checks if `value` is `null` or `undefined`.
  12995. *
  12996. * @static
  12997. * @memberOf _
  12998. * @since 4.0.0
  12999. * @category Lang
  13000. * @param {*} value The value to check.
  13001. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  13002. * @example
  13003. *
  13004. * _.isNil(null);
  13005. * // => true
  13006. *
  13007. * _.isNil(void 0);
  13008. * // => true
  13009. *
  13010. * _.isNil(NaN);
  13011. * // => false
  13012. */
  13013. function isNil(value) {
  13014. return value == null;
  13015. }
  13016. /**
  13017. * Checks if `value` is classified as a `Number` primitive or object.
  13018. *
  13019. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  13020. * classified as numbers, use the `_.isFinite` method.
  13021. *
  13022. * @static
  13023. * @memberOf _
  13024. * @since 0.1.0
  13025. * @category Lang
  13026. * @param {*} value The value to check.
  13027. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  13028. * @example
  13029. *
  13030. * _.isNumber(3);
  13031. * // => true
  13032. *
  13033. * _.isNumber(Number.MIN_VALUE);
  13034. * // => true
  13035. *
  13036. * _.isNumber(Infinity);
  13037. * // => true
  13038. *
  13039. * _.isNumber('3');
  13040. * // => false
  13041. */
  13042. function isNumber(value) {
  13043. return typeof value == 'number' ||
  13044. (isObjectLike(value) && baseGetTag(value) == numberTag);
  13045. }
  13046. /**
  13047. * Checks if `value` is a plain object, that is, an object created by the
  13048. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  13049. *
  13050. * @static
  13051. * @memberOf _
  13052. * @since 0.8.0
  13053. * @category Lang
  13054. * @param {*} value The value to check.
  13055. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  13056. * @example
  13057. *
  13058. * function Foo() {
  13059. * this.a = 1;
  13060. * }
  13061. *
  13062. * _.isPlainObject(new Foo);
  13063. * // => false
  13064. *
  13065. * _.isPlainObject([1, 2, 3]);
  13066. * // => false
  13067. *
  13068. * _.isPlainObject({ 'x': 0, 'y': 0 });
  13069. * // => true
  13070. *
  13071. * _.isPlainObject(Object.create(null));
  13072. * // => true
  13073. */
  13074. function isPlainObject(value) {
  13075. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  13076. return false;
  13077. }
  13078. var proto = getPrototype(value);
  13079. if (proto === null) {
  13080. return true;
  13081. }
  13082. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  13083. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  13084. funcToString.call(Ctor) == objectCtorString;
  13085. }
  13086. /**
  13087. * Checks if `value` is classified as a `RegExp` object.
  13088. *
  13089. * @static
  13090. * @memberOf _
  13091. * @since 0.1.0
  13092. * @category Lang
  13093. * @param {*} value The value to check.
  13094. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  13095. * @example
  13096. *
  13097. * _.isRegExp(/abc/);
  13098. * // => true
  13099. *
  13100. * _.isRegExp('/abc/');
  13101. * // => false
  13102. */
  13103. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  13104. /**
  13105. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  13106. * double precision number which isn't the result of a rounded unsafe integer.
  13107. *
  13108. * **Note:** This method is based on
  13109. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  13110. *
  13111. * @static
  13112. * @memberOf _
  13113. * @since 4.0.0
  13114. * @category Lang
  13115. * @param {*} value The value to check.
  13116. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  13117. * @example
  13118. *
  13119. * _.isSafeInteger(3);
  13120. * // => true
  13121. *
  13122. * _.isSafeInteger(Number.MIN_VALUE);
  13123. * // => false
  13124. *
  13125. * _.isSafeInteger(Infinity);
  13126. * // => false
  13127. *
  13128. * _.isSafeInteger('3');
  13129. * // => false
  13130. */
  13131. function isSafeInteger(value) {
  13132. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  13133. }
  13134. /**
  13135. * Checks if `value` is classified as a `Set` object.
  13136. *
  13137. * @static
  13138. * @memberOf _
  13139. * @since 4.3.0
  13140. * @category Lang
  13141. * @param {*} value The value to check.
  13142. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  13143. * @example
  13144. *
  13145. * _.isSet(new Set);
  13146. * // => true
  13147. *
  13148. * _.isSet(new WeakSet);
  13149. * // => false
  13150. */
  13151. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  13152. /**
  13153. * Checks if `value` is classified as a `String` primitive or object.
  13154. *
  13155. * @static
  13156. * @since 0.1.0
  13157. * @memberOf _
  13158. * @category Lang
  13159. * @param {*} value The value to check.
  13160. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  13161. * @example
  13162. *
  13163. * _.isString('abc');
  13164. * // => true
  13165. *
  13166. * _.isString(1);
  13167. * // => false
  13168. */
  13169. function isString(value) {
  13170. return typeof value == 'string' ||
  13171. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  13172. }
  13173. /**
  13174. * Checks if `value` is classified as a `Symbol` primitive or object.
  13175. *
  13176. * @static
  13177. * @memberOf _
  13178. * @since 4.0.0
  13179. * @category Lang
  13180. * @param {*} value The value to check.
  13181. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  13182. * @example
  13183. *
  13184. * _.isSymbol(Symbol.iterator);
  13185. * // => true
  13186. *
  13187. * _.isSymbol('abc');
  13188. * // => false
  13189. */
  13190. function isSymbol(value) {
  13191. return typeof value == 'symbol' ||
  13192. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  13193. }
  13194. /**
  13195. * Checks if `value` is classified as a typed array.
  13196. *
  13197. * @static
  13198. * @memberOf _
  13199. * @since 3.0.0
  13200. * @category Lang
  13201. * @param {*} value The value to check.
  13202. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  13203. * @example
  13204. *
  13205. * _.isTypedArray(new Uint8Array);
  13206. * // => true
  13207. *
  13208. * _.isTypedArray([]);
  13209. * // => false
  13210. */
  13211. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  13212. /**
  13213. * Checks if `value` is `undefined`.
  13214. *
  13215. * @static
  13216. * @since 0.1.0
  13217. * @memberOf _
  13218. * @category Lang
  13219. * @param {*} value The value to check.
  13220. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  13221. * @example
  13222. *
  13223. * _.isUndefined(void 0);
  13224. * // => true
  13225. *
  13226. * _.isUndefined(null);
  13227. * // => false
  13228. */
  13229. function isUndefined(value) {
  13230. return value === undefined$1;
  13231. }
  13232. /**
  13233. * Checks if `value` is classified as a `WeakMap` object.
  13234. *
  13235. * @static
  13236. * @memberOf _
  13237. * @since 4.3.0
  13238. * @category Lang
  13239. * @param {*} value The value to check.
  13240. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  13241. * @example
  13242. *
  13243. * _.isWeakMap(new WeakMap);
  13244. * // => true
  13245. *
  13246. * _.isWeakMap(new Map);
  13247. * // => false
  13248. */
  13249. function isWeakMap(value) {
  13250. return isObjectLike(value) && getTag(value) == weakMapTag;
  13251. }
  13252. /**
  13253. * Checks if `value` is classified as a `WeakSet` object.
  13254. *
  13255. * @static
  13256. * @memberOf _
  13257. * @since 4.3.0
  13258. * @category Lang
  13259. * @param {*} value The value to check.
  13260. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  13261. * @example
  13262. *
  13263. * _.isWeakSet(new WeakSet);
  13264. * // => true
  13265. *
  13266. * _.isWeakSet(new Set);
  13267. * // => false
  13268. */
  13269. function isWeakSet(value) {
  13270. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  13271. }
  13272. /**
  13273. * Checks if `value` is less than `other`.
  13274. *
  13275. * @static
  13276. * @memberOf _
  13277. * @since 3.9.0
  13278. * @category Lang
  13279. * @param {*} value The value to compare.
  13280. * @param {*} other The other value to compare.
  13281. * @returns {boolean} Returns `true` if `value` is less than `other`,
  13282. * else `false`.
  13283. * @see _.gt
  13284. * @example
  13285. *
  13286. * _.lt(1, 3);
  13287. * // => true
  13288. *
  13289. * _.lt(3, 3);
  13290. * // => false
  13291. *
  13292. * _.lt(3, 1);
  13293. * // => false
  13294. */
  13295. var lt = createRelationalOperation(baseLt);
  13296. /**
  13297. * Checks if `value` is less than or equal to `other`.
  13298. *
  13299. * @static
  13300. * @memberOf _
  13301. * @since 3.9.0
  13302. * @category Lang
  13303. * @param {*} value The value to compare.
  13304. * @param {*} other The other value to compare.
  13305. * @returns {boolean} Returns `true` if `value` is less than or equal to
  13306. * `other`, else `false`.
  13307. * @see _.gte
  13308. * @example
  13309. *
  13310. * _.lte(1, 3);
  13311. * // => true
  13312. *
  13313. * _.lte(3, 3);
  13314. * // => true
  13315. *
  13316. * _.lte(3, 1);
  13317. * // => false
  13318. */
  13319. var lte = createRelationalOperation(function(value, other) {
  13320. return value <= other;
  13321. });
  13322. /**
  13323. * Converts `value` to an array.
  13324. *
  13325. * @static
  13326. * @since 0.1.0
  13327. * @memberOf _
  13328. * @category Lang
  13329. * @param {*} value The value to convert.
  13330. * @returns {Array} Returns the converted array.
  13331. * @example
  13332. *
  13333. * _.toArray({ 'a': 1, 'b': 2 });
  13334. * // => [1, 2]
  13335. *
  13336. * _.toArray('abc');
  13337. * // => ['a', 'b', 'c']
  13338. *
  13339. * _.toArray(1);
  13340. * // => []
  13341. *
  13342. * _.toArray(null);
  13343. * // => []
  13344. */
  13345. function toArray(value) {
  13346. if (!value) {
  13347. return [];
  13348. }
  13349. if (isArrayLike(value)) {
  13350. return isString(value) ? stringToArray(value) : copyArray(value);
  13351. }
  13352. if (symIterator && value[symIterator]) {
  13353. return iteratorToArray(value[symIterator]());
  13354. }
  13355. var tag = getTag(value),
  13356. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  13357. return func(value);
  13358. }
  13359. /**
  13360. * Converts `value` to a finite number.
  13361. *
  13362. * @static
  13363. * @memberOf _
  13364. * @since 4.12.0
  13365. * @category Lang
  13366. * @param {*} value The value to convert.
  13367. * @returns {number} Returns the converted number.
  13368. * @example
  13369. *
  13370. * _.toFinite(3.2);
  13371. * // => 3.2
  13372. *
  13373. * _.toFinite(Number.MIN_VALUE);
  13374. * // => 5e-324
  13375. *
  13376. * _.toFinite(Infinity);
  13377. * // => 1.7976931348623157e+308
  13378. *
  13379. * _.toFinite('3.2');
  13380. * // => 3.2
  13381. */
  13382. function toFinite(value) {
  13383. if (!value) {
  13384. return value === 0 ? value : 0;
  13385. }
  13386. value = toNumber(value);
  13387. if (value === INFINITY || value === -INFINITY) {
  13388. var sign = (value < 0 ? -1 : 1);
  13389. return sign * MAX_INTEGER;
  13390. }
  13391. return value === value ? value : 0;
  13392. }
  13393. /**
  13394. * Converts `value` to an integer.
  13395. *
  13396. * **Note:** This method is loosely based on
  13397. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  13398. *
  13399. * @static
  13400. * @memberOf _
  13401. * @since 4.0.0
  13402. * @category Lang
  13403. * @param {*} value The value to convert.
  13404. * @returns {number} Returns the converted integer.
  13405. * @example
  13406. *
  13407. * _.toInteger(3.2);
  13408. * // => 3
  13409. *
  13410. * _.toInteger(Number.MIN_VALUE);
  13411. * // => 0
  13412. *
  13413. * _.toInteger(Infinity);
  13414. * // => 1.7976931348623157e+308
  13415. *
  13416. * _.toInteger('3.2');
  13417. * // => 3
  13418. */
  13419. function toInteger(value) {
  13420. var result = toFinite(value),
  13421. remainder = result % 1;
  13422. return result === result ? (remainder ? result - remainder : result) : 0;
  13423. }
  13424. /**
  13425. * Converts `value` to an integer suitable for use as the length of an
  13426. * array-like object.
  13427. *
  13428. * **Note:** This method is based on
  13429. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  13430. *
  13431. * @static
  13432. * @memberOf _
  13433. * @since 4.0.0
  13434. * @category Lang
  13435. * @param {*} value The value to convert.
  13436. * @returns {number} Returns the converted integer.
  13437. * @example
  13438. *
  13439. * _.toLength(3.2);
  13440. * // => 3
  13441. *
  13442. * _.toLength(Number.MIN_VALUE);
  13443. * // => 0
  13444. *
  13445. * _.toLength(Infinity);
  13446. * // => 4294967295
  13447. *
  13448. * _.toLength('3.2');
  13449. * // => 3
  13450. */
  13451. function toLength(value) {
  13452. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  13453. }
  13454. /**
  13455. * Converts `value` to a number.
  13456. *
  13457. * @static
  13458. * @memberOf _
  13459. * @since 4.0.0
  13460. * @category Lang
  13461. * @param {*} value The value to process.
  13462. * @returns {number} Returns the number.
  13463. * @example
  13464. *
  13465. * _.toNumber(3.2);
  13466. * // => 3.2
  13467. *
  13468. * _.toNumber(Number.MIN_VALUE);
  13469. * // => 5e-324
  13470. *
  13471. * _.toNumber(Infinity);
  13472. * // => Infinity
  13473. *
  13474. * _.toNumber('3.2');
  13475. * // => 3.2
  13476. */
  13477. function toNumber(value) {
  13478. if (typeof value == 'number') {
  13479. return value;
  13480. }
  13481. if (isSymbol(value)) {
  13482. return NAN;
  13483. }
  13484. if (isObject(value)) {
  13485. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  13486. value = isObject(other) ? (other + '') : other;
  13487. }
  13488. if (typeof value != 'string') {
  13489. return value === 0 ? value : +value;
  13490. }
  13491. value = baseTrim(value);
  13492. var isBinary = reIsBinary.test(value);
  13493. return (isBinary || reIsOctal.test(value))
  13494. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  13495. : (reIsBadHex.test(value) ? NAN : +value);
  13496. }
  13497. /**
  13498. * Converts `value` to a plain object flattening inherited enumerable string
  13499. * keyed properties of `value` to own properties of the plain object.
  13500. *
  13501. * @static
  13502. * @memberOf _
  13503. * @since 3.0.0
  13504. * @category Lang
  13505. * @param {*} value The value to convert.
  13506. * @returns {Object} Returns the converted plain object.
  13507. * @example
  13508. *
  13509. * function Foo() {
  13510. * this.b = 2;
  13511. * }
  13512. *
  13513. * Foo.prototype.c = 3;
  13514. *
  13515. * _.assign({ 'a': 1 }, new Foo);
  13516. * // => { 'a': 1, 'b': 2 }
  13517. *
  13518. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  13519. * // => { 'a': 1, 'b': 2, 'c': 3 }
  13520. */
  13521. function toPlainObject(value) {
  13522. return copyObject(value, keysIn(value));
  13523. }
  13524. /**
  13525. * Converts `value` to a safe integer. A safe integer can be compared and
  13526. * represented correctly.
  13527. *
  13528. * @static
  13529. * @memberOf _
  13530. * @since 4.0.0
  13531. * @category Lang
  13532. * @param {*} value The value to convert.
  13533. * @returns {number} Returns the converted integer.
  13534. * @example
  13535. *
  13536. * _.toSafeInteger(3.2);
  13537. * // => 3
  13538. *
  13539. * _.toSafeInteger(Number.MIN_VALUE);
  13540. * // => 0
  13541. *
  13542. * _.toSafeInteger(Infinity);
  13543. * // => 9007199254740991
  13544. *
  13545. * _.toSafeInteger('3.2');
  13546. * // => 3
  13547. */
  13548. function toSafeInteger(value) {
  13549. return value
  13550. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  13551. : (value === 0 ? value : 0);
  13552. }
  13553. /**
  13554. * Converts `value` to a string. An empty string is returned for `null`
  13555. * and `undefined` values. The sign of `-0` is preserved.
  13556. *
  13557. * @static
  13558. * @memberOf _
  13559. * @since 4.0.0
  13560. * @category Lang
  13561. * @param {*} value The value to convert.
  13562. * @returns {string} Returns the converted string.
  13563. * @example
  13564. *
  13565. * _.toString(null);
  13566. * // => ''
  13567. *
  13568. * _.toString(-0);
  13569. * // => '-0'
  13570. *
  13571. * _.toString([1, 2, 3]);
  13572. * // => '1,2,3'
  13573. */
  13574. function toString(value) {
  13575. return value == null ? '' : baseToString(value);
  13576. }
  13577. /*------------------------------------------------------------------------*/
  13578. /**
  13579. * Assigns own enumerable string keyed properties of source objects to the
  13580. * destination object. Source objects are applied from left to right.
  13581. * Subsequent sources overwrite property assignments of previous sources.
  13582. *
  13583. * **Note:** This method mutates `object` and is loosely based on
  13584. * [`Object.assign`](https://mdn.io/Object/assign).
  13585. *
  13586. * @static
  13587. * @memberOf _
  13588. * @since 0.10.0
  13589. * @category Object
  13590. * @param {Object} object The destination object.
  13591. * @param {...Object} [sources] The source objects.
  13592. * @returns {Object} Returns `object`.
  13593. * @see _.assignIn
  13594. * @example
  13595. *
  13596. * function Foo() {
  13597. * this.a = 1;
  13598. * }
  13599. *
  13600. * function Bar() {
  13601. * this.c = 3;
  13602. * }
  13603. *
  13604. * Foo.prototype.b = 2;
  13605. * Bar.prototype.d = 4;
  13606. *
  13607. * _.assign({ 'a': 0 }, new Foo, new Bar);
  13608. * // => { 'a': 1, 'c': 3 }
  13609. */
  13610. var assign = createAssigner(function(object, source) {
  13611. if (isPrototype(source) || isArrayLike(source)) {
  13612. copyObject(source, keys(source), object);
  13613. return;
  13614. }
  13615. for (var key in source) {
  13616. if (hasOwnProperty.call(source, key)) {
  13617. assignValue(object, key, source[key]);
  13618. }
  13619. }
  13620. });
  13621. /**
  13622. * This method is like `_.assign` except that it iterates over own and
  13623. * inherited source properties.
  13624. *
  13625. * **Note:** This method mutates `object`.
  13626. *
  13627. * @static
  13628. * @memberOf _
  13629. * @since 4.0.0
  13630. * @alias extend
  13631. * @category Object
  13632. * @param {Object} object The destination object.
  13633. * @param {...Object} [sources] The source objects.
  13634. * @returns {Object} Returns `object`.
  13635. * @see _.assign
  13636. * @example
  13637. *
  13638. * function Foo() {
  13639. * this.a = 1;
  13640. * }
  13641. *
  13642. * function Bar() {
  13643. * this.c = 3;
  13644. * }
  13645. *
  13646. * Foo.prototype.b = 2;
  13647. * Bar.prototype.d = 4;
  13648. *
  13649. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  13650. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  13651. */
  13652. var assignIn = createAssigner(function(object, source) {
  13653. copyObject(source, keysIn(source), object);
  13654. });
  13655. /**
  13656. * This method is like `_.assignIn` except that it accepts `customizer`
  13657. * which is invoked to produce the assigned values. If `customizer` returns
  13658. * `undefined`, assignment is handled by the method instead. The `customizer`
  13659. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13660. *
  13661. * **Note:** This method mutates `object`.
  13662. *
  13663. * @static
  13664. * @memberOf _
  13665. * @since 4.0.0
  13666. * @alias extendWith
  13667. * @category Object
  13668. * @param {Object} object The destination object.
  13669. * @param {...Object} sources The source objects.
  13670. * @param {Function} [customizer] The function to customize assigned values.
  13671. * @returns {Object} Returns `object`.
  13672. * @see _.assignWith
  13673. * @example
  13674. *
  13675. * function customizer(objValue, srcValue) {
  13676. * return _.isUndefined(objValue) ? srcValue : objValue;
  13677. * }
  13678. *
  13679. * var defaults = _.partialRight(_.assignInWith, customizer);
  13680. *
  13681. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13682. * // => { 'a': 1, 'b': 2 }
  13683. */
  13684. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  13685. copyObject(source, keysIn(source), object, customizer);
  13686. });
  13687. /**
  13688. * This method is like `_.assign` except that it accepts `customizer`
  13689. * which is invoked to produce the assigned values. If `customizer` returns
  13690. * `undefined`, assignment is handled by the method instead. The `customizer`
  13691. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13692. *
  13693. * **Note:** This method mutates `object`.
  13694. *
  13695. * @static
  13696. * @memberOf _
  13697. * @since 4.0.0
  13698. * @category Object
  13699. * @param {Object} object The destination object.
  13700. * @param {...Object} sources The source objects.
  13701. * @param {Function} [customizer] The function to customize assigned values.
  13702. * @returns {Object} Returns `object`.
  13703. * @see _.assignInWith
  13704. * @example
  13705. *
  13706. * function customizer(objValue, srcValue) {
  13707. * return _.isUndefined(objValue) ? srcValue : objValue;
  13708. * }
  13709. *
  13710. * var defaults = _.partialRight(_.assignWith, customizer);
  13711. *
  13712. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13713. * // => { 'a': 1, 'b': 2 }
  13714. */
  13715. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  13716. copyObject(source, keys(source), object, customizer);
  13717. });
  13718. /**
  13719. * Creates an array of values corresponding to `paths` of `object`.
  13720. *
  13721. * @static
  13722. * @memberOf _
  13723. * @since 1.0.0
  13724. * @category Object
  13725. * @param {Object} object The object to iterate over.
  13726. * @param {...(string|string[])} [paths] The property paths to pick.
  13727. * @returns {Array} Returns the picked values.
  13728. * @example
  13729. *
  13730. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13731. *
  13732. * _.at(object, ['a[0].b.c', 'a[1]']);
  13733. * // => [3, 4]
  13734. */
  13735. var at = flatRest(baseAt);
  13736. /**
  13737. * Creates an object that inherits from the `prototype` object. If a
  13738. * `properties` object is given, its own enumerable string keyed properties
  13739. * are assigned to the created object.
  13740. *
  13741. * @static
  13742. * @memberOf _
  13743. * @since 2.3.0
  13744. * @category Object
  13745. * @param {Object} prototype The object to inherit from.
  13746. * @param {Object} [properties] The properties to assign to the object.
  13747. * @returns {Object} Returns the new object.
  13748. * @example
  13749. *
  13750. * function Shape() {
  13751. * this.x = 0;
  13752. * this.y = 0;
  13753. * }
  13754. *
  13755. * function Circle() {
  13756. * Shape.call(this);
  13757. * }
  13758. *
  13759. * Circle.prototype = _.create(Shape.prototype, {
  13760. * 'constructor': Circle
  13761. * });
  13762. *
  13763. * var circle = new Circle;
  13764. * circle instanceof Circle;
  13765. * // => true
  13766. *
  13767. * circle instanceof Shape;
  13768. * // => true
  13769. */
  13770. function create(prototype, properties) {
  13771. var result = baseCreate(prototype);
  13772. return properties == null ? result : baseAssign(result, properties);
  13773. }
  13774. /**
  13775. * Assigns own and inherited enumerable string keyed properties of source
  13776. * objects to the destination object for all destination properties that
  13777. * resolve to `undefined`. Source objects are applied from left to right.
  13778. * Once a property is set, additional values of the same property are ignored.
  13779. *
  13780. * **Note:** This method mutates `object`.
  13781. *
  13782. * @static
  13783. * @since 0.1.0
  13784. * @memberOf _
  13785. * @category Object
  13786. * @param {Object} object The destination object.
  13787. * @param {...Object} [sources] The source objects.
  13788. * @returns {Object} Returns `object`.
  13789. * @see _.defaultsDeep
  13790. * @example
  13791. *
  13792. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13793. * // => { 'a': 1, 'b': 2 }
  13794. */
  13795. var defaults = baseRest(function(object, sources) {
  13796. object = Object(object);
  13797. var index = -1;
  13798. var length = sources.length;
  13799. var guard = length > 2 ? sources[2] : undefined$1;
  13800. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  13801. length = 1;
  13802. }
  13803. while (++index < length) {
  13804. var source = sources[index];
  13805. var props = keysIn(source);
  13806. var propsIndex = -1;
  13807. var propsLength = props.length;
  13808. while (++propsIndex < propsLength) {
  13809. var key = props[propsIndex];
  13810. var value = object[key];
  13811. if (value === undefined$1 ||
  13812. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  13813. object[key] = source[key];
  13814. }
  13815. }
  13816. }
  13817. return object;
  13818. });
  13819. /**
  13820. * This method is like `_.defaults` except that it recursively assigns
  13821. * default properties.
  13822. *
  13823. * **Note:** This method mutates `object`.
  13824. *
  13825. * @static
  13826. * @memberOf _
  13827. * @since 3.10.0
  13828. * @category Object
  13829. * @param {Object} object The destination object.
  13830. * @param {...Object} [sources] The source objects.
  13831. * @returns {Object} Returns `object`.
  13832. * @see _.defaults
  13833. * @example
  13834. *
  13835. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  13836. * // => { 'a': { 'b': 2, 'c': 3 } }
  13837. */
  13838. var defaultsDeep = baseRest(function(args) {
  13839. args.push(undefined$1, customDefaultsMerge);
  13840. return apply(mergeWith, undefined$1, args);
  13841. });
  13842. /**
  13843. * This method is like `_.find` except that it returns the key of the first
  13844. * element `predicate` returns truthy for instead of the element itself.
  13845. *
  13846. * @static
  13847. * @memberOf _
  13848. * @since 1.1.0
  13849. * @category Object
  13850. * @param {Object} object The object to inspect.
  13851. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13852. * @returns {string|undefined} Returns the key of the matched element,
  13853. * else `undefined`.
  13854. * @example
  13855. *
  13856. * var users = {
  13857. * 'barney': { 'age': 36, 'active': true },
  13858. * 'fred': { 'age': 40, 'active': false },
  13859. * 'pebbles': { 'age': 1, 'active': true }
  13860. * };
  13861. *
  13862. * _.findKey(users, function(o) { return o.age < 40; });
  13863. * // => 'barney' (iteration order is not guaranteed)
  13864. *
  13865. * // The `_.matches` iteratee shorthand.
  13866. * _.findKey(users, { 'age': 1, 'active': true });
  13867. * // => 'pebbles'
  13868. *
  13869. * // The `_.matchesProperty` iteratee shorthand.
  13870. * _.findKey(users, ['active', false]);
  13871. * // => 'fred'
  13872. *
  13873. * // The `_.property` iteratee shorthand.
  13874. * _.findKey(users, 'active');
  13875. * // => 'barney'
  13876. */
  13877. function findKey(object, predicate) {
  13878. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  13879. }
  13880. /**
  13881. * This method is like `_.findKey` except that it iterates over elements of
  13882. * a collection in the opposite order.
  13883. *
  13884. * @static
  13885. * @memberOf _
  13886. * @since 2.0.0
  13887. * @category Object
  13888. * @param {Object} object The object to inspect.
  13889. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13890. * @returns {string|undefined} Returns the key of the matched element,
  13891. * else `undefined`.
  13892. * @example
  13893. *
  13894. * var users = {
  13895. * 'barney': { 'age': 36, 'active': true },
  13896. * 'fred': { 'age': 40, 'active': false },
  13897. * 'pebbles': { 'age': 1, 'active': true }
  13898. * };
  13899. *
  13900. * _.findLastKey(users, function(o) { return o.age < 40; });
  13901. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  13902. *
  13903. * // The `_.matches` iteratee shorthand.
  13904. * _.findLastKey(users, { 'age': 36, 'active': true });
  13905. * // => 'barney'
  13906. *
  13907. * // The `_.matchesProperty` iteratee shorthand.
  13908. * _.findLastKey(users, ['active', false]);
  13909. * // => 'fred'
  13910. *
  13911. * // The `_.property` iteratee shorthand.
  13912. * _.findLastKey(users, 'active');
  13913. * // => 'pebbles'
  13914. */
  13915. function findLastKey(object, predicate) {
  13916. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  13917. }
  13918. /**
  13919. * Iterates over own and inherited enumerable string keyed properties of an
  13920. * object and invokes `iteratee` for each property. The iteratee is invoked
  13921. * with three arguments: (value, key, object). Iteratee functions may exit
  13922. * iteration early by explicitly returning `false`.
  13923. *
  13924. * @static
  13925. * @memberOf _
  13926. * @since 0.3.0
  13927. * @category Object
  13928. * @param {Object} object The object to iterate over.
  13929. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13930. * @returns {Object} Returns `object`.
  13931. * @see _.forInRight
  13932. * @example
  13933. *
  13934. * function Foo() {
  13935. * this.a = 1;
  13936. * this.b = 2;
  13937. * }
  13938. *
  13939. * Foo.prototype.c = 3;
  13940. *
  13941. * _.forIn(new Foo, function(value, key) {
  13942. * console.log(key);
  13943. * });
  13944. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  13945. */
  13946. function forIn(object, iteratee) {
  13947. return object == null
  13948. ? object
  13949. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  13950. }
  13951. /**
  13952. * This method is like `_.forIn` except that it iterates over properties of
  13953. * `object` in the opposite order.
  13954. *
  13955. * @static
  13956. * @memberOf _
  13957. * @since 2.0.0
  13958. * @category Object
  13959. * @param {Object} object The object to iterate over.
  13960. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13961. * @returns {Object} Returns `object`.
  13962. * @see _.forIn
  13963. * @example
  13964. *
  13965. * function Foo() {
  13966. * this.a = 1;
  13967. * this.b = 2;
  13968. * }
  13969. *
  13970. * Foo.prototype.c = 3;
  13971. *
  13972. * _.forInRight(new Foo, function(value, key) {
  13973. * console.log(key);
  13974. * });
  13975. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  13976. */
  13977. function forInRight(object, iteratee) {
  13978. return object == null
  13979. ? object
  13980. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  13981. }
  13982. /**
  13983. * Iterates over own enumerable string keyed properties of an object and
  13984. * invokes `iteratee` for each property. The iteratee is invoked with three
  13985. * arguments: (value, key, object). Iteratee functions may exit iteration
  13986. * early by explicitly returning `false`.
  13987. *
  13988. * @static
  13989. * @memberOf _
  13990. * @since 0.3.0
  13991. * @category Object
  13992. * @param {Object} object The object to iterate over.
  13993. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13994. * @returns {Object} Returns `object`.
  13995. * @see _.forOwnRight
  13996. * @example
  13997. *
  13998. * function Foo() {
  13999. * this.a = 1;
  14000. * this.b = 2;
  14001. * }
  14002. *
  14003. * Foo.prototype.c = 3;
  14004. *
  14005. * _.forOwn(new Foo, function(value, key) {
  14006. * console.log(key);
  14007. * });
  14008. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  14009. */
  14010. function forOwn(object, iteratee) {
  14011. return object && baseForOwn(object, getIteratee(iteratee, 3));
  14012. }
  14013. /**
  14014. * This method is like `_.forOwn` except that it iterates over properties of
  14015. * `object` in the opposite order.
  14016. *
  14017. * @static
  14018. * @memberOf _
  14019. * @since 2.0.0
  14020. * @category Object
  14021. * @param {Object} object The object to iterate over.
  14022. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14023. * @returns {Object} Returns `object`.
  14024. * @see _.forOwn
  14025. * @example
  14026. *
  14027. * function Foo() {
  14028. * this.a = 1;
  14029. * this.b = 2;
  14030. * }
  14031. *
  14032. * Foo.prototype.c = 3;
  14033. *
  14034. * _.forOwnRight(new Foo, function(value, key) {
  14035. * console.log(key);
  14036. * });
  14037. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  14038. */
  14039. function forOwnRight(object, iteratee) {
  14040. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  14041. }
  14042. /**
  14043. * Creates an array of function property names from own enumerable properties
  14044. * of `object`.
  14045. *
  14046. * @static
  14047. * @since 0.1.0
  14048. * @memberOf _
  14049. * @category Object
  14050. * @param {Object} object The object to inspect.
  14051. * @returns {Array} Returns the function names.
  14052. * @see _.functionsIn
  14053. * @example
  14054. *
  14055. * function Foo() {
  14056. * this.a = _.constant('a');
  14057. * this.b = _.constant('b');
  14058. * }
  14059. *
  14060. * Foo.prototype.c = _.constant('c');
  14061. *
  14062. * _.functions(new Foo);
  14063. * // => ['a', 'b']
  14064. */
  14065. function functions(object) {
  14066. return object == null ? [] : baseFunctions(object, keys(object));
  14067. }
  14068. /**
  14069. * Creates an array of function property names from own and inherited
  14070. * enumerable properties of `object`.
  14071. *
  14072. * @static
  14073. * @memberOf _
  14074. * @since 4.0.0
  14075. * @category Object
  14076. * @param {Object} object The object to inspect.
  14077. * @returns {Array} Returns the function names.
  14078. * @see _.functions
  14079. * @example
  14080. *
  14081. * function Foo() {
  14082. * this.a = _.constant('a');
  14083. * this.b = _.constant('b');
  14084. * }
  14085. *
  14086. * Foo.prototype.c = _.constant('c');
  14087. *
  14088. * _.functionsIn(new Foo);
  14089. * // => ['a', 'b', 'c']
  14090. */
  14091. function functionsIn(object) {
  14092. return object == null ? [] : baseFunctions(object, keysIn(object));
  14093. }
  14094. /**
  14095. * Gets the value at `path` of `object`. If the resolved value is
  14096. * `undefined`, the `defaultValue` is returned in its place.
  14097. *
  14098. * @static
  14099. * @memberOf _
  14100. * @since 3.7.0
  14101. * @category Object
  14102. * @param {Object} object The object to query.
  14103. * @param {Array|string} path The path of the property to get.
  14104. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14105. * @returns {*} Returns the resolved value.
  14106. * @example
  14107. *
  14108. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14109. *
  14110. * _.get(object, 'a[0].b.c');
  14111. * // => 3
  14112. *
  14113. * _.get(object, ['a', '0', 'b', 'c']);
  14114. * // => 3
  14115. *
  14116. * _.get(object, 'a.b.c', 'default');
  14117. * // => 'default'
  14118. */
  14119. function get(object, path, defaultValue) {
  14120. var result = object == null ? undefined$1 : baseGet(object, path);
  14121. return result === undefined$1 ? defaultValue : result;
  14122. }
  14123. /**
  14124. * Checks if `path` is a direct property of `object`.
  14125. *
  14126. * @static
  14127. * @since 0.1.0
  14128. * @memberOf _
  14129. * @category Object
  14130. * @param {Object} object The object to query.
  14131. * @param {Array|string} path The path to check.
  14132. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14133. * @example
  14134. *
  14135. * var object = { 'a': { 'b': 2 } };
  14136. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  14137. *
  14138. * _.has(object, 'a');
  14139. * // => true
  14140. *
  14141. * _.has(object, 'a.b');
  14142. * // => true
  14143. *
  14144. * _.has(object, ['a', 'b']);
  14145. * // => true
  14146. *
  14147. * _.has(other, 'a');
  14148. * // => false
  14149. */
  14150. function has(object, path) {
  14151. return object != null && hasPath(object, path, baseHas);
  14152. }
  14153. /**
  14154. * Checks if `path` is a direct or inherited property of `object`.
  14155. *
  14156. * @static
  14157. * @memberOf _
  14158. * @since 4.0.0
  14159. * @category Object
  14160. * @param {Object} object The object to query.
  14161. * @param {Array|string} path The path to check.
  14162. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14163. * @example
  14164. *
  14165. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  14166. *
  14167. * _.hasIn(object, 'a');
  14168. * // => true
  14169. *
  14170. * _.hasIn(object, 'a.b');
  14171. * // => true
  14172. *
  14173. * _.hasIn(object, ['a', 'b']);
  14174. * // => true
  14175. *
  14176. * _.hasIn(object, 'b');
  14177. * // => false
  14178. */
  14179. function hasIn(object, path) {
  14180. return object != null && hasPath(object, path, baseHasIn);
  14181. }
  14182. /**
  14183. * Creates an object composed of the inverted keys and values of `object`.
  14184. * If `object` contains duplicate values, subsequent values overwrite
  14185. * property assignments of previous values.
  14186. *
  14187. * @static
  14188. * @memberOf _
  14189. * @since 0.7.0
  14190. * @category Object
  14191. * @param {Object} object The object to invert.
  14192. * @returns {Object} Returns the new inverted object.
  14193. * @example
  14194. *
  14195. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  14196. *
  14197. * _.invert(object);
  14198. * // => { '1': 'c', '2': 'b' }
  14199. */
  14200. var invert = createInverter(function(result, value, key) {
  14201. if (value != null &&
  14202. typeof value.toString != 'function') {
  14203. value = nativeObjectToString.call(value);
  14204. }
  14205. result[value] = key;
  14206. }, constant(identity));
  14207. /**
  14208. * This method is like `_.invert` except that the inverted object is generated
  14209. * from the results of running each element of `object` thru `iteratee`. The
  14210. * corresponding inverted value of each inverted key is an array of keys
  14211. * responsible for generating the inverted value. The iteratee is invoked
  14212. * with one argument: (value).
  14213. *
  14214. * @static
  14215. * @memberOf _
  14216. * @since 4.1.0
  14217. * @category Object
  14218. * @param {Object} object The object to invert.
  14219. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  14220. * @returns {Object} Returns the new inverted object.
  14221. * @example
  14222. *
  14223. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  14224. *
  14225. * _.invertBy(object);
  14226. * // => { '1': ['a', 'c'], '2': ['b'] }
  14227. *
  14228. * _.invertBy(object, function(value) {
  14229. * return 'group' + value;
  14230. * });
  14231. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  14232. */
  14233. var invertBy = createInverter(function(result, value, key) {
  14234. if (value != null &&
  14235. typeof value.toString != 'function') {
  14236. value = nativeObjectToString.call(value);
  14237. }
  14238. if (hasOwnProperty.call(result, value)) {
  14239. result[value].push(key);
  14240. } else {
  14241. result[value] = [key];
  14242. }
  14243. }, getIteratee);
  14244. /**
  14245. * Invokes the method at `path` of `object`.
  14246. *
  14247. * @static
  14248. * @memberOf _
  14249. * @since 4.0.0
  14250. * @category Object
  14251. * @param {Object} object The object to query.
  14252. * @param {Array|string} path The path of the method to invoke.
  14253. * @param {...*} [args] The arguments to invoke the method with.
  14254. * @returns {*} Returns the result of the invoked method.
  14255. * @example
  14256. *
  14257. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  14258. *
  14259. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  14260. * // => [2, 3]
  14261. */
  14262. var invoke = baseRest(baseInvoke);
  14263. /**
  14264. * Creates an array of the own enumerable property names of `object`.
  14265. *
  14266. * **Note:** Non-object values are coerced to objects. See the
  14267. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  14268. * for more details.
  14269. *
  14270. * @static
  14271. * @since 0.1.0
  14272. * @memberOf _
  14273. * @category Object
  14274. * @param {Object} object The object to query.
  14275. * @returns {Array} Returns the array of property names.
  14276. * @example
  14277. *
  14278. * function Foo() {
  14279. * this.a = 1;
  14280. * this.b = 2;
  14281. * }
  14282. *
  14283. * Foo.prototype.c = 3;
  14284. *
  14285. * _.keys(new Foo);
  14286. * // => ['a', 'b'] (iteration order is not guaranteed)
  14287. *
  14288. * _.keys('hi');
  14289. * // => ['0', '1']
  14290. */
  14291. function keys(object) {
  14292. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  14293. }
  14294. /**
  14295. * Creates an array of the own and inherited enumerable property names of `object`.
  14296. *
  14297. * **Note:** Non-object values are coerced to objects.
  14298. *
  14299. * @static
  14300. * @memberOf _
  14301. * @since 3.0.0
  14302. * @category Object
  14303. * @param {Object} object The object to query.
  14304. * @returns {Array} Returns the array of property names.
  14305. * @example
  14306. *
  14307. * function Foo() {
  14308. * this.a = 1;
  14309. * this.b = 2;
  14310. * }
  14311. *
  14312. * Foo.prototype.c = 3;
  14313. *
  14314. * _.keysIn(new Foo);
  14315. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  14316. */
  14317. function keysIn(object) {
  14318. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  14319. }
  14320. /**
  14321. * The opposite of `_.mapValues`; this method creates an object with the
  14322. * same values as `object` and keys generated by running each own enumerable
  14323. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  14324. * with three arguments: (value, key, object).
  14325. *
  14326. * @static
  14327. * @memberOf _
  14328. * @since 3.8.0
  14329. * @category Object
  14330. * @param {Object} object The object to iterate over.
  14331. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14332. * @returns {Object} Returns the new mapped object.
  14333. * @see _.mapValues
  14334. * @example
  14335. *
  14336. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  14337. * return key + value;
  14338. * });
  14339. * // => { 'a1': 1, 'b2': 2 }
  14340. */
  14341. function mapKeys(object, iteratee) {
  14342. var result = {};
  14343. iteratee = getIteratee(iteratee, 3);
  14344. baseForOwn(object, function(value, key, object) {
  14345. baseAssignValue(result, iteratee(value, key, object), value);
  14346. });
  14347. return result;
  14348. }
  14349. /**
  14350. * Creates an object with the same keys as `object` and values generated
  14351. * by running each own enumerable string keyed property of `object` thru
  14352. * `iteratee`. The iteratee is invoked with three arguments:
  14353. * (value, key, object).
  14354. *
  14355. * @static
  14356. * @memberOf _
  14357. * @since 2.4.0
  14358. * @category Object
  14359. * @param {Object} object The object to iterate over.
  14360. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14361. * @returns {Object} Returns the new mapped object.
  14362. * @see _.mapKeys
  14363. * @example
  14364. *
  14365. * var users = {
  14366. * 'fred': { 'user': 'fred', 'age': 40 },
  14367. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  14368. * };
  14369. *
  14370. * _.mapValues(users, function(o) { return o.age; });
  14371. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14372. *
  14373. * // The `_.property` iteratee shorthand.
  14374. * _.mapValues(users, 'age');
  14375. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14376. */
  14377. function mapValues(object, iteratee) {
  14378. var result = {};
  14379. iteratee = getIteratee(iteratee, 3);
  14380. baseForOwn(object, function(value, key, object) {
  14381. baseAssignValue(result, key, iteratee(value, key, object));
  14382. });
  14383. return result;
  14384. }
  14385. /**
  14386. * This method is like `_.assign` except that it recursively merges own and
  14387. * inherited enumerable string keyed properties of source objects into the
  14388. * destination object. Source properties that resolve to `undefined` are
  14389. * skipped if a destination value exists. Array and plain object properties
  14390. * are merged recursively. Other objects and value types are overridden by
  14391. * assignment. Source objects are applied from left to right. Subsequent
  14392. * sources overwrite property assignments of previous sources.
  14393. *
  14394. * **Note:** This method mutates `object`.
  14395. *
  14396. * @static
  14397. * @memberOf _
  14398. * @since 0.5.0
  14399. * @category Object
  14400. * @param {Object} object The destination object.
  14401. * @param {...Object} [sources] The source objects.
  14402. * @returns {Object} Returns `object`.
  14403. * @example
  14404. *
  14405. * var object = {
  14406. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  14407. * };
  14408. *
  14409. * var other = {
  14410. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  14411. * };
  14412. *
  14413. * _.merge(object, other);
  14414. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  14415. */
  14416. var merge = createAssigner(function(object, source, srcIndex) {
  14417. baseMerge(object, source, srcIndex);
  14418. });
  14419. /**
  14420. * This method is like `_.merge` except that it accepts `customizer` which
  14421. * is invoked to produce the merged values of the destination and source
  14422. * properties. If `customizer` returns `undefined`, merging is handled by the
  14423. * method instead. The `customizer` is invoked with six arguments:
  14424. * (objValue, srcValue, key, object, source, stack).
  14425. *
  14426. * **Note:** This method mutates `object`.
  14427. *
  14428. * @static
  14429. * @memberOf _
  14430. * @since 4.0.0
  14431. * @category Object
  14432. * @param {Object} object The destination object.
  14433. * @param {...Object} sources The source objects.
  14434. * @param {Function} customizer The function to customize assigned values.
  14435. * @returns {Object} Returns `object`.
  14436. * @example
  14437. *
  14438. * function customizer(objValue, srcValue) {
  14439. * if (_.isArray(objValue)) {
  14440. * return objValue.concat(srcValue);
  14441. * }
  14442. * }
  14443. *
  14444. * var object = { 'a': [1], 'b': [2] };
  14445. * var other = { 'a': [3], 'b': [4] };
  14446. *
  14447. * _.mergeWith(object, other, customizer);
  14448. * // => { 'a': [1, 3], 'b': [2, 4] }
  14449. */
  14450. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  14451. baseMerge(object, source, srcIndex, customizer);
  14452. });
  14453. /**
  14454. * The opposite of `_.pick`; this method creates an object composed of the
  14455. * own and inherited enumerable property paths of `object` that are not omitted.
  14456. *
  14457. * **Note:** This method is considerably slower than `_.pick`.
  14458. *
  14459. * @static
  14460. * @since 0.1.0
  14461. * @memberOf _
  14462. * @category Object
  14463. * @param {Object} object The source object.
  14464. * @param {...(string|string[])} [paths] The property paths to omit.
  14465. * @returns {Object} Returns the new object.
  14466. * @example
  14467. *
  14468. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14469. *
  14470. * _.omit(object, ['a', 'c']);
  14471. * // => { 'b': '2' }
  14472. */
  14473. var omit = flatRest(function(object, paths) {
  14474. var result = {};
  14475. if (object == null) {
  14476. return result;
  14477. }
  14478. var isDeep = false;
  14479. paths = arrayMap(paths, function(path) {
  14480. path = castPath(path, object);
  14481. isDeep || (isDeep = path.length > 1);
  14482. return path;
  14483. });
  14484. copyObject(object, getAllKeysIn(object), result);
  14485. if (isDeep) {
  14486. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  14487. }
  14488. var length = paths.length;
  14489. while (length--) {
  14490. baseUnset(result, paths[length]);
  14491. }
  14492. return result;
  14493. });
  14494. /**
  14495. * The opposite of `_.pickBy`; this method creates an object composed of
  14496. * the own and inherited enumerable string keyed properties of `object` that
  14497. * `predicate` doesn't return truthy for. The predicate is invoked with two
  14498. * arguments: (value, key).
  14499. *
  14500. * @static
  14501. * @memberOf _
  14502. * @since 4.0.0
  14503. * @category Object
  14504. * @param {Object} object The source object.
  14505. * @param {Function} [predicate=_.identity] The function invoked per property.
  14506. * @returns {Object} Returns the new object.
  14507. * @example
  14508. *
  14509. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14510. *
  14511. * _.omitBy(object, _.isNumber);
  14512. * // => { 'b': '2' }
  14513. */
  14514. function omitBy(object, predicate) {
  14515. return pickBy(object, negate(getIteratee(predicate)));
  14516. }
  14517. /**
  14518. * Creates an object composed of the picked `object` properties.
  14519. *
  14520. * @static
  14521. * @since 0.1.0
  14522. * @memberOf _
  14523. * @category Object
  14524. * @param {Object} object The source object.
  14525. * @param {...(string|string[])} [paths] The property paths to pick.
  14526. * @returns {Object} Returns the new object.
  14527. * @example
  14528. *
  14529. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14530. *
  14531. * _.pick(object, ['a', 'c']);
  14532. * // => { 'a': 1, 'c': 3 }
  14533. */
  14534. var pick = flatRest(function(object, paths) {
  14535. return object == null ? {} : basePick(object, paths);
  14536. });
  14537. /**
  14538. * Creates an object composed of the `object` properties `predicate` returns
  14539. * truthy for. The predicate is invoked with two arguments: (value, key).
  14540. *
  14541. * @static
  14542. * @memberOf _
  14543. * @since 4.0.0
  14544. * @category Object
  14545. * @param {Object} object The source object.
  14546. * @param {Function} [predicate=_.identity] The function invoked per property.
  14547. * @returns {Object} Returns the new object.
  14548. * @example
  14549. *
  14550. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14551. *
  14552. * _.pickBy(object, _.isNumber);
  14553. * // => { 'a': 1, 'c': 3 }
  14554. */
  14555. function pickBy(object, predicate) {
  14556. if (object == null) {
  14557. return {};
  14558. }
  14559. var props = arrayMap(getAllKeysIn(object), function(prop) {
  14560. return [prop];
  14561. });
  14562. predicate = getIteratee(predicate);
  14563. return basePickBy(object, props, function(value, path) {
  14564. return predicate(value, path[0]);
  14565. });
  14566. }
  14567. /**
  14568. * This method is like `_.get` except that if the resolved value is a
  14569. * function it's invoked with the `this` binding of its parent object and
  14570. * its result is returned.
  14571. *
  14572. * @static
  14573. * @since 0.1.0
  14574. * @memberOf _
  14575. * @category Object
  14576. * @param {Object} object The object to query.
  14577. * @param {Array|string} path The path of the property to resolve.
  14578. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14579. * @returns {*} Returns the resolved value.
  14580. * @example
  14581. *
  14582. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  14583. *
  14584. * _.result(object, 'a[0].b.c1');
  14585. * // => 3
  14586. *
  14587. * _.result(object, 'a[0].b.c2');
  14588. * // => 4
  14589. *
  14590. * _.result(object, 'a[0].b.c3', 'default');
  14591. * // => 'default'
  14592. *
  14593. * _.result(object, 'a[0].b.c3', _.constant('default'));
  14594. * // => 'default'
  14595. */
  14596. function result(object, path, defaultValue) {
  14597. path = castPath(path, object);
  14598. var index = -1,
  14599. length = path.length;
  14600. // Ensure the loop is entered when path is empty.
  14601. if (!length) {
  14602. length = 1;
  14603. object = undefined$1;
  14604. }
  14605. while (++index < length) {
  14606. var value = object == null ? undefined$1 : object[toKey(path[index])];
  14607. if (value === undefined$1) {
  14608. index = length;
  14609. value = defaultValue;
  14610. }
  14611. object = isFunction(value) ? value.call(object) : value;
  14612. }
  14613. return object;
  14614. }
  14615. /**
  14616. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  14617. * it's created. Arrays are created for missing index properties while objects
  14618. * are created for all other missing properties. Use `_.setWith` to customize
  14619. * `path` creation.
  14620. *
  14621. * **Note:** This method mutates `object`.
  14622. *
  14623. * @static
  14624. * @memberOf _
  14625. * @since 3.7.0
  14626. * @category Object
  14627. * @param {Object} object The object to modify.
  14628. * @param {Array|string} path The path of the property to set.
  14629. * @param {*} value The value to set.
  14630. * @returns {Object} Returns `object`.
  14631. * @example
  14632. *
  14633. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14634. *
  14635. * _.set(object, 'a[0].b.c', 4);
  14636. * console.log(object.a[0].b.c);
  14637. * // => 4
  14638. *
  14639. * _.set(object, ['x', '0', 'y', 'z'], 5);
  14640. * console.log(object.x[0].y.z);
  14641. * // => 5
  14642. */
  14643. function set(object, path, value) {
  14644. return object == null ? object : baseSet(object, path, value);
  14645. }
  14646. /**
  14647. * This method is like `_.set` except that it accepts `customizer` which is
  14648. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14649. * path creation is handled by the method instead. The `customizer` is invoked
  14650. * with three arguments: (nsValue, key, nsObject).
  14651. *
  14652. * **Note:** This method mutates `object`.
  14653. *
  14654. * @static
  14655. * @memberOf _
  14656. * @since 4.0.0
  14657. * @category Object
  14658. * @param {Object} object The object to modify.
  14659. * @param {Array|string} path The path of the property to set.
  14660. * @param {*} value The value to set.
  14661. * @param {Function} [customizer] The function to customize assigned values.
  14662. * @returns {Object} Returns `object`.
  14663. * @example
  14664. *
  14665. * var object = {};
  14666. *
  14667. * _.setWith(object, '[0][1]', 'a', Object);
  14668. * // => { '0': { '1': 'a' } }
  14669. */
  14670. function setWith(object, path, value, customizer) {
  14671. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  14672. return object == null ? object : baseSet(object, path, value, customizer);
  14673. }
  14674. /**
  14675. * Creates an array of own enumerable string keyed-value pairs for `object`
  14676. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  14677. * entries are returned.
  14678. *
  14679. * @static
  14680. * @memberOf _
  14681. * @since 4.0.0
  14682. * @alias entries
  14683. * @category Object
  14684. * @param {Object} object The object to query.
  14685. * @returns {Array} Returns the key-value pairs.
  14686. * @example
  14687. *
  14688. * function Foo() {
  14689. * this.a = 1;
  14690. * this.b = 2;
  14691. * }
  14692. *
  14693. * Foo.prototype.c = 3;
  14694. *
  14695. * _.toPairs(new Foo);
  14696. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  14697. */
  14698. var toPairs = createToPairs(keys);
  14699. /**
  14700. * Creates an array of own and inherited enumerable string keyed-value pairs
  14701. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  14702. * or set, its entries are returned.
  14703. *
  14704. * @static
  14705. * @memberOf _
  14706. * @since 4.0.0
  14707. * @alias entriesIn
  14708. * @category Object
  14709. * @param {Object} object The object to query.
  14710. * @returns {Array} Returns the key-value pairs.
  14711. * @example
  14712. *
  14713. * function Foo() {
  14714. * this.a = 1;
  14715. * this.b = 2;
  14716. * }
  14717. *
  14718. * Foo.prototype.c = 3;
  14719. *
  14720. * _.toPairsIn(new Foo);
  14721. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  14722. */
  14723. var toPairsIn = createToPairs(keysIn);
  14724. /**
  14725. * An alternative to `_.reduce`; this method transforms `object` to a new
  14726. * `accumulator` object which is the result of running each of its own
  14727. * enumerable string keyed properties thru `iteratee`, with each invocation
  14728. * potentially mutating the `accumulator` object. If `accumulator` is not
  14729. * provided, a new object with the same `[[Prototype]]` will be used. The
  14730. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  14731. * Iteratee functions may exit iteration early by explicitly returning `false`.
  14732. *
  14733. * @static
  14734. * @memberOf _
  14735. * @since 1.3.0
  14736. * @category Object
  14737. * @param {Object} object The object to iterate over.
  14738. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14739. * @param {*} [accumulator] The custom accumulator value.
  14740. * @returns {*} Returns the accumulated value.
  14741. * @example
  14742. *
  14743. * _.transform([2, 3, 4], function(result, n) {
  14744. * result.push(n *= n);
  14745. * return n % 2 == 0;
  14746. * }, []);
  14747. * // => [4, 9]
  14748. *
  14749. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  14750. * (result[value] || (result[value] = [])).push(key);
  14751. * }, {});
  14752. * // => { '1': ['a', 'c'], '2': ['b'] }
  14753. */
  14754. function transform(object, iteratee, accumulator) {
  14755. var isArr = isArray(object),
  14756. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  14757. iteratee = getIteratee(iteratee, 4);
  14758. if (accumulator == null) {
  14759. var Ctor = object && object.constructor;
  14760. if (isArrLike) {
  14761. accumulator = isArr ? new Ctor : [];
  14762. }
  14763. else if (isObject(object)) {
  14764. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  14765. }
  14766. else {
  14767. accumulator = {};
  14768. }
  14769. }
  14770. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  14771. return iteratee(accumulator, value, index, object);
  14772. });
  14773. return accumulator;
  14774. }
  14775. /**
  14776. * Removes the property at `path` of `object`.
  14777. *
  14778. * **Note:** This method mutates `object`.
  14779. *
  14780. * @static
  14781. * @memberOf _
  14782. * @since 4.0.0
  14783. * @category Object
  14784. * @param {Object} object The object to modify.
  14785. * @param {Array|string} path The path of the property to unset.
  14786. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  14787. * @example
  14788. *
  14789. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  14790. * _.unset(object, 'a[0].b.c');
  14791. * // => true
  14792. *
  14793. * console.log(object);
  14794. * // => { 'a': [{ 'b': {} }] };
  14795. *
  14796. * _.unset(object, ['a', '0', 'b', 'c']);
  14797. * // => true
  14798. *
  14799. * console.log(object);
  14800. * // => { 'a': [{ 'b': {} }] };
  14801. */
  14802. function unset(object, path) {
  14803. return object == null ? true : baseUnset(object, path);
  14804. }
  14805. /**
  14806. * This method is like `_.set` except that accepts `updater` to produce the
  14807. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  14808. * is invoked with one argument: (value).
  14809. *
  14810. * **Note:** This method mutates `object`.
  14811. *
  14812. * @static
  14813. * @memberOf _
  14814. * @since 4.6.0
  14815. * @category Object
  14816. * @param {Object} object The object to modify.
  14817. * @param {Array|string} path The path of the property to set.
  14818. * @param {Function} updater The function to produce the updated value.
  14819. * @returns {Object} Returns `object`.
  14820. * @example
  14821. *
  14822. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14823. *
  14824. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  14825. * console.log(object.a[0].b.c);
  14826. * // => 9
  14827. *
  14828. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  14829. * console.log(object.x[0].y.z);
  14830. * // => 0
  14831. */
  14832. function update(object, path, updater) {
  14833. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  14834. }
  14835. /**
  14836. * This method is like `_.update` except that it accepts `customizer` which is
  14837. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14838. * path creation is handled by the method instead. The `customizer` is invoked
  14839. * with three arguments: (nsValue, key, nsObject).
  14840. *
  14841. * **Note:** This method mutates `object`.
  14842. *
  14843. * @static
  14844. * @memberOf _
  14845. * @since 4.6.0
  14846. * @category Object
  14847. * @param {Object} object The object to modify.
  14848. * @param {Array|string} path The path of the property to set.
  14849. * @param {Function} updater The function to produce the updated value.
  14850. * @param {Function} [customizer] The function to customize assigned values.
  14851. * @returns {Object} Returns `object`.
  14852. * @example
  14853. *
  14854. * var object = {};
  14855. *
  14856. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  14857. * // => { '0': { '1': 'a' } }
  14858. */
  14859. function updateWith(object, path, updater, customizer) {
  14860. customizer = typeof customizer == 'function' ? customizer : undefined$1;
  14861. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  14862. }
  14863. /**
  14864. * Creates an array of the own enumerable string keyed property values of `object`.
  14865. *
  14866. * **Note:** Non-object values are coerced to objects.
  14867. *
  14868. * @static
  14869. * @since 0.1.0
  14870. * @memberOf _
  14871. * @category Object
  14872. * @param {Object} object The object to query.
  14873. * @returns {Array} Returns the array of property values.
  14874. * @example
  14875. *
  14876. * function Foo() {
  14877. * this.a = 1;
  14878. * this.b = 2;
  14879. * }
  14880. *
  14881. * Foo.prototype.c = 3;
  14882. *
  14883. * _.values(new Foo);
  14884. * // => [1, 2] (iteration order is not guaranteed)
  14885. *
  14886. * _.values('hi');
  14887. * // => ['h', 'i']
  14888. */
  14889. function values(object) {
  14890. return object == null ? [] : baseValues(object, keys(object));
  14891. }
  14892. /**
  14893. * Creates an array of the own and inherited enumerable string keyed property
  14894. * values of `object`.
  14895. *
  14896. * **Note:** Non-object values are coerced to objects.
  14897. *
  14898. * @static
  14899. * @memberOf _
  14900. * @since 3.0.0
  14901. * @category Object
  14902. * @param {Object} object The object to query.
  14903. * @returns {Array} Returns the array of property values.
  14904. * @example
  14905. *
  14906. * function Foo() {
  14907. * this.a = 1;
  14908. * this.b = 2;
  14909. * }
  14910. *
  14911. * Foo.prototype.c = 3;
  14912. *
  14913. * _.valuesIn(new Foo);
  14914. * // => [1, 2, 3] (iteration order is not guaranteed)
  14915. */
  14916. function valuesIn(object) {
  14917. return object == null ? [] : baseValues(object, keysIn(object));
  14918. }
  14919. /*------------------------------------------------------------------------*/
  14920. /**
  14921. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  14922. *
  14923. * @static
  14924. * @memberOf _
  14925. * @since 4.0.0
  14926. * @category Number
  14927. * @param {number} number The number to clamp.
  14928. * @param {number} [lower] The lower bound.
  14929. * @param {number} upper The upper bound.
  14930. * @returns {number} Returns the clamped number.
  14931. * @example
  14932. *
  14933. * _.clamp(-10, -5, 5);
  14934. * // => -5
  14935. *
  14936. * _.clamp(10, -5, 5);
  14937. * // => 5
  14938. */
  14939. function clamp(number, lower, upper) {
  14940. if (upper === undefined$1) {
  14941. upper = lower;
  14942. lower = undefined$1;
  14943. }
  14944. if (upper !== undefined$1) {
  14945. upper = toNumber(upper);
  14946. upper = upper === upper ? upper : 0;
  14947. }
  14948. if (lower !== undefined$1) {
  14949. lower = toNumber(lower);
  14950. lower = lower === lower ? lower : 0;
  14951. }
  14952. return baseClamp(toNumber(number), lower, upper);
  14953. }
  14954. /**
  14955. * Checks if `n` is between `start` and up to, but not including, `end`. If
  14956. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  14957. * If `start` is greater than `end` the params are swapped to support
  14958. * negative ranges.
  14959. *
  14960. * @static
  14961. * @memberOf _
  14962. * @since 3.3.0
  14963. * @category Number
  14964. * @param {number} number The number to check.
  14965. * @param {number} [start=0] The start of the range.
  14966. * @param {number} end The end of the range.
  14967. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  14968. * @see _.range, _.rangeRight
  14969. * @example
  14970. *
  14971. * _.inRange(3, 2, 4);
  14972. * // => true
  14973. *
  14974. * _.inRange(4, 8);
  14975. * // => true
  14976. *
  14977. * _.inRange(4, 2);
  14978. * // => false
  14979. *
  14980. * _.inRange(2, 2);
  14981. * // => false
  14982. *
  14983. * _.inRange(1.2, 2);
  14984. * // => true
  14985. *
  14986. * _.inRange(5.2, 4);
  14987. * // => false
  14988. *
  14989. * _.inRange(-3, -2, -6);
  14990. * // => true
  14991. */
  14992. function inRange(number, start, end) {
  14993. start = toFinite(start);
  14994. if (end === undefined$1) {
  14995. end = start;
  14996. start = 0;
  14997. } else {
  14998. end = toFinite(end);
  14999. }
  15000. number = toNumber(number);
  15001. return baseInRange(number, start, end);
  15002. }
  15003. /**
  15004. * Produces a random number between the inclusive `lower` and `upper` bounds.
  15005. * If only one argument is provided a number between `0` and the given number
  15006. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  15007. * floats, a floating-point number is returned instead of an integer.
  15008. *
  15009. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  15010. * floating-point values which can produce unexpected results.
  15011. *
  15012. * @static
  15013. * @memberOf _
  15014. * @since 0.7.0
  15015. * @category Number
  15016. * @param {number} [lower=0] The lower bound.
  15017. * @param {number} [upper=1] The upper bound.
  15018. * @param {boolean} [floating] Specify returning a floating-point number.
  15019. * @returns {number} Returns the random number.
  15020. * @example
  15021. *
  15022. * _.random(0, 5);
  15023. * // => an integer between 0 and 5
  15024. *
  15025. * _.random(5);
  15026. * // => also an integer between 0 and 5
  15027. *
  15028. * _.random(5, true);
  15029. * // => a floating-point number between 0 and 5
  15030. *
  15031. * _.random(1.2, 5.2);
  15032. * // => a floating-point number between 1.2 and 5.2
  15033. */
  15034. function random(lower, upper, floating) {
  15035. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  15036. upper = floating = undefined$1;
  15037. }
  15038. if (floating === undefined$1) {
  15039. if (typeof upper == 'boolean') {
  15040. floating = upper;
  15041. upper = undefined$1;
  15042. }
  15043. else if (typeof lower == 'boolean') {
  15044. floating = lower;
  15045. lower = undefined$1;
  15046. }
  15047. }
  15048. if (lower === undefined$1 && upper === undefined$1) {
  15049. lower = 0;
  15050. upper = 1;
  15051. }
  15052. else {
  15053. lower = toFinite(lower);
  15054. if (upper === undefined$1) {
  15055. upper = lower;
  15056. lower = 0;
  15057. } else {
  15058. upper = toFinite(upper);
  15059. }
  15060. }
  15061. if (lower > upper) {
  15062. var temp = lower;
  15063. lower = upper;
  15064. upper = temp;
  15065. }
  15066. if (floating || lower % 1 || upper % 1) {
  15067. var rand = nativeRandom();
  15068. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  15069. }
  15070. return baseRandom(lower, upper);
  15071. }
  15072. /*------------------------------------------------------------------------*/
  15073. /**
  15074. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  15075. *
  15076. * @static
  15077. * @memberOf _
  15078. * @since 3.0.0
  15079. * @category String
  15080. * @param {string} [string=''] The string to convert.
  15081. * @returns {string} Returns the camel cased string.
  15082. * @example
  15083. *
  15084. * _.camelCase('Foo Bar');
  15085. * // => 'fooBar'
  15086. *
  15087. * _.camelCase('--foo-bar--');
  15088. * // => 'fooBar'
  15089. *
  15090. * _.camelCase('__FOO_BAR__');
  15091. * // => 'fooBar'
  15092. */
  15093. var camelCase = createCompounder(function(result, word, index) {
  15094. word = word.toLowerCase();
  15095. return result + (index ? capitalize(word) : word);
  15096. });
  15097. /**
  15098. * Converts the first character of `string` to upper case and the remaining
  15099. * to lower case.
  15100. *
  15101. * @static
  15102. * @memberOf _
  15103. * @since 3.0.0
  15104. * @category String
  15105. * @param {string} [string=''] The string to capitalize.
  15106. * @returns {string} Returns the capitalized string.
  15107. * @example
  15108. *
  15109. * _.capitalize('FRED');
  15110. * // => 'Fred'
  15111. */
  15112. function capitalize(string) {
  15113. return upperFirst(toString(string).toLowerCase());
  15114. }
  15115. /**
  15116. * Deburrs `string` by converting
  15117. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  15118. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  15119. * letters to basic Latin letters and removing
  15120. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  15121. *
  15122. * @static
  15123. * @memberOf _
  15124. * @since 3.0.0
  15125. * @category String
  15126. * @param {string} [string=''] The string to deburr.
  15127. * @returns {string} Returns the deburred string.
  15128. * @example
  15129. *
  15130. * _.deburr('déjà vu');
  15131. * // => 'deja vu'
  15132. */
  15133. function deburr(string) {
  15134. string = toString(string);
  15135. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  15136. }
  15137. /**
  15138. * Checks if `string` ends with the given target string.
  15139. *
  15140. * @static
  15141. * @memberOf _
  15142. * @since 3.0.0
  15143. * @category String
  15144. * @param {string} [string=''] The string to inspect.
  15145. * @param {string} [target] The string to search for.
  15146. * @param {number} [position=string.length] The position to search up to.
  15147. * @returns {boolean} Returns `true` if `string` ends with `target`,
  15148. * else `false`.
  15149. * @example
  15150. *
  15151. * _.endsWith('abc', 'c');
  15152. * // => true
  15153. *
  15154. * _.endsWith('abc', 'b');
  15155. * // => false
  15156. *
  15157. * _.endsWith('abc', 'b', 2);
  15158. * // => true
  15159. */
  15160. function endsWith(string, target, position) {
  15161. string = toString(string);
  15162. target = baseToString(target);
  15163. var length = string.length;
  15164. position = position === undefined$1
  15165. ? length
  15166. : baseClamp(toInteger(position), 0, length);
  15167. var end = position;
  15168. position -= target.length;
  15169. return position >= 0 && string.slice(position, end) == target;
  15170. }
  15171. /**
  15172. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  15173. * corresponding HTML entities.
  15174. *
  15175. * **Note:** No other characters are escaped. To escape additional
  15176. * characters use a third-party library like [_he_](https://mths.be/he).
  15177. *
  15178. * Though the ">" character is escaped for symmetry, characters like
  15179. * ">" and "/" don't need escaping in HTML and have no special meaning
  15180. * unless they're part of a tag or unquoted attribute value. See
  15181. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  15182. * (under "semi-related fun fact") for more details.
  15183. *
  15184. * When working with HTML you should always
  15185. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  15186. * XSS vectors.
  15187. *
  15188. * @static
  15189. * @since 0.1.0
  15190. * @memberOf _
  15191. * @category String
  15192. * @param {string} [string=''] The string to escape.
  15193. * @returns {string} Returns the escaped string.
  15194. * @example
  15195. *
  15196. * _.escape('fred, barney, & pebbles');
  15197. * // => 'fred, barney, &amp; pebbles'
  15198. */
  15199. function escape(string) {
  15200. string = toString(string);
  15201. return (string && reHasUnescapedHtml.test(string))
  15202. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  15203. : string;
  15204. }
  15205. /**
  15206. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  15207. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  15208. *
  15209. * @static
  15210. * @memberOf _
  15211. * @since 3.0.0
  15212. * @category String
  15213. * @param {string} [string=''] The string to escape.
  15214. * @returns {string} Returns the escaped string.
  15215. * @example
  15216. *
  15217. * _.escapeRegExp('[lodash](https://lodash.com/)');
  15218. * // => '\[lodash\]\(https://lodash\.com/\)'
  15219. */
  15220. function escapeRegExp(string) {
  15221. string = toString(string);
  15222. return (string && reHasRegExpChar.test(string))
  15223. ? string.replace(reRegExpChar, '\\$&')
  15224. : string;
  15225. }
  15226. /**
  15227. * Converts `string` to
  15228. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  15229. *
  15230. * @static
  15231. * @memberOf _
  15232. * @since 3.0.0
  15233. * @category String
  15234. * @param {string} [string=''] The string to convert.
  15235. * @returns {string} Returns the kebab cased string.
  15236. * @example
  15237. *
  15238. * _.kebabCase('Foo Bar');
  15239. * // => 'foo-bar'
  15240. *
  15241. * _.kebabCase('fooBar');
  15242. * // => 'foo-bar'
  15243. *
  15244. * _.kebabCase('__FOO_BAR__');
  15245. * // => 'foo-bar'
  15246. */
  15247. var kebabCase = createCompounder(function(result, word, index) {
  15248. return result + (index ? '-' : '') + word.toLowerCase();
  15249. });
  15250. /**
  15251. * Converts `string`, as space separated words, to lower case.
  15252. *
  15253. * @static
  15254. * @memberOf _
  15255. * @since 4.0.0
  15256. * @category String
  15257. * @param {string} [string=''] The string to convert.
  15258. * @returns {string} Returns the lower cased string.
  15259. * @example
  15260. *
  15261. * _.lowerCase('--Foo-Bar--');
  15262. * // => 'foo bar'
  15263. *
  15264. * _.lowerCase('fooBar');
  15265. * // => 'foo bar'
  15266. *
  15267. * _.lowerCase('__FOO_BAR__');
  15268. * // => 'foo bar'
  15269. */
  15270. var lowerCase = createCompounder(function(result, word, index) {
  15271. return result + (index ? ' ' : '') + word.toLowerCase();
  15272. });
  15273. /**
  15274. * Converts the first character of `string` to lower case.
  15275. *
  15276. * @static
  15277. * @memberOf _
  15278. * @since 4.0.0
  15279. * @category String
  15280. * @param {string} [string=''] The string to convert.
  15281. * @returns {string} Returns the converted string.
  15282. * @example
  15283. *
  15284. * _.lowerFirst('Fred');
  15285. * // => 'fred'
  15286. *
  15287. * _.lowerFirst('FRED');
  15288. * // => 'fRED'
  15289. */
  15290. var lowerFirst = createCaseFirst('toLowerCase');
  15291. /**
  15292. * Pads `string` on the left and right sides if it's shorter than `length`.
  15293. * Padding characters are truncated if they can't be evenly divided by `length`.
  15294. *
  15295. * @static
  15296. * @memberOf _
  15297. * @since 3.0.0
  15298. * @category String
  15299. * @param {string} [string=''] The string to pad.
  15300. * @param {number} [length=0] The padding length.
  15301. * @param {string} [chars=' '] The string used as padding.
  15302. * @returns {string} Returns the padded string.
  15303. * @example
  15304. *
  15305. * _.pad('abc', 8);
  15306. * // => ' abc '
  15307. *
  15308. * _.pad('abc', 8, '_-');
  15309. * // => '_-abc_-_'
  15310. *
  15311. * _.pad('abc', 3);
  15312. * // => 'abc'
  15313. */
  15314. function pad(string, length, chars) {
  15315. string = toString(string);
  15316. length = toInteger(length);
  15317. var strLength = length ? stringSize(string) : 0;
  15318. if (!length || strLength >= length) {
  15319. return string;
  15320. }
  15321. var mid = (length - strLength) / 2;
  15322. return (
  15323. createPadding(nativeFloor(mid), chars) +
  15324. string +
  15325. createPadding(nativeCeil(mid), chars)
  15326. );
  15327. }
  15328. /**
  15329. * Pads `string` on the right side if it's shorter than `length`. Padding
  15330. * characters are truncated if they exceed `length`.
  15331. *
  15332. * @static
  15333. * @memberOf _
  15334. * @since 4.0.0
  15335. * @category String
  15336. * @param {string} [string=''] The string to pad.
  15337. * @param {number} [length=0] The padding length.
  15338. * @param {string} [chars=' '] The string used as padding.
  15339. * @returns {string} Returns the padded string.
  15340. * @example
  15341. *
  15342. * _.padEnd('abc', 6);
  15343. * // => 'abc '
  15344. *
  15345. * _.padEnd('abc', 6, '_-');
  15346. * // => 'abc_-_'
  15347. *
  15348. * _.padEnd('abc', 3);
  15349. * // => 'abc'
  15350. */
  15351. function padEnd(string, length, chars) {
  15352. string = toString(string);
  15353. length = toInteger(length);
  15354. var strLength = length ? stringSize(string) : 0;
  15355. return (length && strLength < length)
  15356. ? (string + createPadding(length - strLength, chars))
  15357. : string;
  15358. }
  15359. /**
  15360. * Pads `string` on the left side if it's shorter than `length`. Padding
  15361. * characters are truncated if they exceed `length`.
  15362. *
  15363. * @static
  15364. * @memberOf _
  15365. * @since 4.0.0
  15366. * @category String
  15367. * @param {string} [string=''] The string to pad.
  15368. * @param {number} [length=0] The padding length.
  15369. * @param {string} [chars=' '] The string used as padding.
  15370. * @returns {string} Returns the padded string.
  15371. * @example
  15372. *
  15373. * _.padStart('abc', 6);
  15374. * // => ' abc'
  15375. *
  15376. * _.padStart('abc', 6, '_-');
  15377. * // => '_-_abc'
  15378. *
  15379. * _.padStart('abc', 3);
  15380. * // => 'abc'
  15381. */
  15382. function padStart(string, length, chars) {
  15383. string = toString(string);
  15384. length = toInteger(length);
  15385. var strLength = length ? stringSize(string) : 0;
  15386. return (length && strLength < length)
  15387. ? (createPadding(length - strLength, chars) + string)
  15388. : string;
  15389. }
  15390. /**
  15391. * Converts `string` to an integer of the specified radix. If `radix` is
  15392. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  15393. * hexadecimal, in which case a `radix` of `16` is used.
  15394. *
  15395. * **Note:** This method aligns with the
  15396. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  15397. *
  15398. * @static
  15399. * @memberOf _
  15400. * @since 1.1.0
  15401. * @category String
  15402. * @param {string} string The string to convert.
  15403. * @param {number} [radix=10] The radix to interpret `value` by.
  15404. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15405. * @returns {number} Returns the converted integer.
  15406. * @example
  15407. *
  15408. * _.parseInt('08');
  15409. * // => 8
  15410. *
  15411. * _.map(['6', '08', '10'], _.parseInt);
  15412. * // => [6, 8, 10]
  15413. */
  15414. function parseInt(string, radix, guard) {
  15415. if (guard || radix == null) {
  15416. radix = 0;
  15417. } else if (radix) {
  15418. radix = +radix;
  15419. }
  15420. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  15421. }
  15422. /**
  15423. * Repeats the given string `n` times.
  15424. *
  15425. * @static
  15426. * @memberOf _
  15427. * @since 3.0.0
  15428. * @category String
  15429. * @param {string} [string=''] The string to repeat.
  15430. * @param {number} [n=1] The number of times to repeat the string.
  15431. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15432. * @returns {string} Returns the repeated string.
  15433. * @example
  15434. *
  15435. * _.repeat('*', 3);
  15436. * // => '***'
  15437. *
  15438. * _.repeat('abc', 2);
  15439. * // => 'abcabc'
  15440. *
  15441. * _.repeat('abc', 0);
  15442. * // => ''
  15443. */
  15444. function repeat(string, n, guard) {
  15445. if ((guard ? isIterateeCall(string, n, guard) : n === undefined$1)) {
  15446. n = 1;
  15447. } else {
  15448. n = toInteger(n);
  15449. }
  15450. return baseRepeat(toString(string), n);
  15451. }
  15452. /**
  15453. * Replaces matches for `pattern` in `string` with `replacement`.
  15454. *
  15455. * **Note:** This method is based on
  15456. * [`String#replace`](https://mdn.io/String/replace).
  15457. *
  15458. * @static
  15459. * @memberOf _
  15460. * @since 4.0.0
  15461. * @category String
  15462. * @param {string} [string=''] The string to modify.
  15463. * @param {RegExp|string} pattern The pattern to replace.
  15464. * @param {Function|string} replacement The match replacement.
  15465. * @returns {string} Returns the modified string.
  15466. * @example
  15467. *
  15468. * _.replace('Hi Fred', 'Fred', 'Barney');
  15469. * // => 'Hi Barney'
  15470. */
  15471. function replace() {
  15472. var args = arguments,
  15473. string = toString(args[0]);
  15474. return args.length < 3 ? string : string.replace(args[1], args[2]);
  15475. }
  15476. /**
  15477. * Converts `string` to
  15478. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  15479. *
  15480. * @static
  15481. * @memberOf _
  15482. * @since 3.0.0
  15483. * @category String
  15484. * @param {string} [string=''] The string to convert.
  15485. * @returns {string} Returns the snake cased string.
  15486. * @example
  15487. *
  15488. * _.snakeCase('Foo Bar');
  15489. * // => 'foo_bar'
  15490. *
  15491. * _.snakeCase('fooBar');
  15492. * // => 'foo_bar'
  15493. *
  15494. * _.snakeCase('--FOO-BAR--');
  15495. * // => 'foo_bar'
  15496. */
  15497. var snakeCase = createCompounder(function(result, word, index) {
  15498. return result + (index ? '_' : '') + word.toLowerCase();
  15499. });
  15500. /**
  15501. * Splits `string` by `separator`.
  15502. *
  15503. * **Note:** This method is based on
  15504. * [`String#split`](https://mdn.io/String/split).
  15505. *
  15506. * @static
  15507. * @memberOf _
  15508. * @since 4.0.0
  15509. * @category String
  15510. * @param {string} [string=''] The string to split.
  15511. * @param {RegExp|string} separator The separator pattern to split by.
  15512. * @param {number} [limit] The length to truncate results to.
  15513. * @returns {Array} Returns the string segments.
  15514. * @example
  15515. *
  15516. * _.split('a-b-c', '-', 2);
  15517. * // => ['a', 'b']
  15518. */
  15519. function split(string, separator, limit) {
  15520. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  15521. separator = limit = undefined$1;
  15522. }
  15523. limit = limit === undefined$1 ? MAX_ARRAY_LENGTH : limit >>> 0;
  15524. if (!limit) {
  15525. return [];
  15526. }
  15527. string = toString(string);
  15528. if (string && (
  15529. typeof separator == 'string' ||
  15530. (separator != null && !isRegExp(separator))
  15531. )) {
  15532. separator = baseToString(separator);
  15533. if (!separator && hasUnicode(string)) {
  15534. return castSlice(stringToArray(string), 0, limit);
  15535. }
  15536. }
  15537. return string.split(separator, limit);
  15538. }
  15539. /**
  15540. * Converts `string` to
  15541. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  15542. *
  15543. * @static
  15544. * @memberOf _
  15545. * @since 3.1.0
  15546. * @category String
  15547. * @param {string} [string=''] The string to convert.
  15548. * @returns {string} Returns the start cased string.
  15549. * @example
  15550. *
  15551. * _.startCase('--foo-bar--');
  15552. * // => 'Foo Bar'
  15553. *
  15554. * _.startCase('fooBar');
  15555. * // => 'Foo Bar'
  15556. *
  15557. * _.startCase('__FOO_BAR__');
  15558. * // => 'FOO BAR'
  15559. */
  15560. var startCase = createCompounder(function(result, word, index) {
  15561. return result + (index ? ' ' : '') + upperFirst(word);
  15562. });
  15563. /**
  15564. * Checks if `string` starts with the given target string.
  15565. *
  15566. * @static
  15567. * @memberOf _
  15568. * @since 3.0.0
  15569. * @category String
  15570. * @param {string} [string=''] The string to inspect.
  15571. * @param {string} [target] The string to search for.
  15572. * @param {number} [position=0] The position to search from.
  15573. * @returns {boolean} Returns `true` if `string` starts with `target`,
  15574. * else `false`.
  15575. * @example
  15576. *
  15577. * _.startsWith('abc', 'a');
  15578. * // => true
  15579. *
  15580. * _.startsWith('abc', 'b');
  15581. * // => false
  15582. *
  15583. * _.startsWith('abc', 'b', 1);
  15584. * // => true
  15585. */
  15586. function startsWith(string, target, position) {
  15587. string = toString(string);
  15588. position = position == null
  15589. ? 0
  15590. : baseClamp(toInteger(position), 0, string.length);
  15591. target = baseToString(target);
  15592. return string.slice(position, position + target.length) == target;
  15593. }
  15594. /**
  15595. * Creates a compiled template function that can interpolate data properties
  15596. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  15597. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  15598. * properties may be accessed as free variables in the template. If a setting
  15599. * object is given, it takes precedence over `_.templateSettings` values.
  15600. *
  15601. * **Note:** In the development build `_.template` utilizes
  15602. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  15603. * for easier debugging.
  15604. *
  15605. * For more information on precompiling templates see
  15606. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  15607. *
  15608. * For more information on Chrome extension sandboxes see
  15609. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  15610. *
  15611. * @static
  15612. * @since 0.1.0
  15613. * @memberOf _
  15614. * @category String
  15615. * @param {string} [string=''] The template string.
  15616. * @param {Object} [options={}] The options object.
  15617. * @param {RegExp} [options.escape=_.templateSettings.escape]
  15618. * The HTML "escape" delimiter.
  15619. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  15620. * The "evaluate" delimiter.
  15621. * @param {Object} [options.imports=_.templateSettings.imports]
  15622. * An object to import into the template as free variables.
  15623. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  15624. * The "interpolate" delimiter.
  15625. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  15626. * The sourceURL of the compiled template.
  15627. * @param {string} [options.variable='obj']
  15628. * The data object variable name.
  15629. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15630. * @returns {Function} Returns the compiled template function.
  15631. * @example
  15632. *
  15633. * // Use the "interpolate" delimiter to create a compiled template.
  15634. * var compiled = _.template('hello <%= user %>!');
  15635. * compiled({ 'user': 'fred' });
  15636. * // => 'hello fred!'
  15637. *
  15638. * // Use the HTML "escape" delimiter to escape data property values.
  15639. * var compiled = _.template('<b><%- value %></b>');
  15640. * compiled({ 'value': '<script>' });
  15641. * // => '<b>&lt;script&gt;</b>'
  15642. *
  15643. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  15644. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  15645. * compiled({ 'users': ['fred', 'barney'] });
  15646. * // => '<li>fred</li><li>barney</li>'
  15647. *
  15648. * // Use the internal `print` function in "evaluate" delimiters.
  15649. * var compiled = _.template('<% print("hello " + user); %>!');
  15650. * compiled({ 'user': 'barney' });
  15651. * // => 'hello barney!'
  15652. *
  15653. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  15654. * // Disable support by replacing the "interpolate" delimiter.
  15655. * var compiled = _.template('hello ${ user }!');
  15656. * compiled({ 'user': 'pebbles' });
  15657. * // => 'hello pebbles!'
  15658. *
  15659. * // Use backslashes to treat delimiters as plain text.
  15660. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  15661. * compiled({ 'value': 'ignored' });
  15662. * // => '<%- value %>'
  15663. *
  15664. * // Use the `imports` option to import `jQuery` as `jq`.
  15665. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  15666. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  15667. * compiled({ 'users': ['fred', 'barney'] });
  15668. * // => '<li>fred</li><li>barney</li>'
  15669. *
  15670. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  15671. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  15672. * compiled(data);
  15673. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  15674. *
  15675. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  15676. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  15677. * compiled.source;
  15678. * // => function(data) {
  15679. * // var __t, __p = '';
  15680. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  15681. * // return __p;
  15682. * // }
  15683. *
  15684. * // Use custom template delimiters.
  15685. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  15686. * var compiled = _.template('hello {{ user }}!');
  15687. * compiled({ 'user': 'mustache' });
  15688. * // => 'hello mustache!'
  15689. *
  15690. * // Use the `source` property to inline compiled templates for meaningful
  15691. * // line numbers in error messages and stack traces.
  15692. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  15693. * var JST = {\
  15694. * "main": ' + _.template(mainText).source + '\
  15695. * };\
  15696. * ');
  15697. */
  15698. function template(string, options, guard) {
  15699. // Based on John Resig's `tmpl` implementation
  15700. // (http://ejohn.org/blog/javascript-micro-templating/)
  15701. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  15702. var settings = lodash.templateSettings;
  15703. if (guard && isIterateeCall(string, options, guard)) {
  15704. options = undefined$1;
  15705. }
  15706. string = toString(string);
  15707. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  15708. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  15709. importsKeys = keys(imports),
  15710. importsValues = baseValues(imports, importsKeys);
  15711. var isEscaping,
  15712. isEvaluating,
  15713. index = 0,
  15714. interpolate = options.interpolate || reNoMatch,
  15715. source = "__p += '";
  15716. // Compile the regexp to match each delimiter.
  15717. var reDelimiters = RegExp(
  15718. (options.escape || reNoMatch).source + '|' +
  15719. interpolate.source + '|' +
  15720. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  15721. (options.evaluate || reNoMatch).source + '|$'
  15722. , 'g');
  15723. // Use a sourceURL for easier debugging.
  15724. // The sourceURL gets injected into the source that's eval-ed, so be careful
  15725. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  15726. // and escape the comment, thus injecting code that gets evaled.
  15727. var sourceURL = '//# sourceURL=' +
  15728. (hasOwnProperty.call(options, 'sourceURL')
  15729. ? (options.sourceURL + '').replace(/\s/g, ' ')
  15730. : ('lodash.templateSources[' + (++templateCounter) + ']')
  15731. ) + '\n';
  15732. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  15733. interpolateValue || (interpolateValue = esTemplateValue);
  15734. // Escape characters that can't be included in string literals.
  15735. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  15736. // Replace delimiters with snippets.
  15737. if (escapeValue) {
  15738. isEscaping = true;
  15739. source += "' +\n__e(" + escapeValue + ") +\n'";
  15740. }
  15741. if (evaluateValue) {
  15742. isEvaluating = true;
  15743. source += "';\n" + evaluateValue + ";\n__p += '";
  15744. }
  15745. if (interpolateValue) {
  15746. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  15747. }
  15748. index = offset + match.length;
  15749. // The JS engine embedded in Adobe products needs `match` returned in
  15750. // order to produce the correct `offset` value.
  15751. return match;
  15752. });
  15753. source += "';\n";
  15754. // If `variable` is not specified wrap a with-statement around the generated
  15755. // code to add the data object to the top of the scope chain.
  15756. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  15757. if (!variable) {
  15758. source = 'with (obj) {\n' + source + '\n}\n';
  15759. }
  15760. // Throw an error if a forbidden character was found in `variable`, to prevent
  15761. // potential command injection attacks.
  15762. else if (reForbiddenIdentifierChars.test(variable)) {
  15763. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  15764. }
  15765. // Cleanup code by stripping empty strings.
  15766. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  15767. .replace(reEmptyStringMiddle, '$1')
  15768. .replace(reEmptyStringTrailing, '$1;');
  15769. // Frame code as the function body.
  15770. source = 'function(' + (variable || 'obj') + ') {\n' +
  15771. (variable
  15772. ? ''
  15773. : 'obj || (obj = {});\n'
  15774. ) +
  15775. "var __t, __p = ''" +
  15776. (isEscaping
  15777. ? ', __e = _.escape'
  15778. : ''
  15779. ) +
  15780. (isEvaluating
  15781. ? ', __j = Array.prototype.join;\n' +
  15782. "function print() { __p += __j.call(arguments, '') }\n"
  15783. : ';\n'
  15784. ) +
  15785. source +
  15786. 'return __p\n}';
  15787. var result = attempt(function() {
  15788. return Function(importsKeys, sourceURL + 'return ' + source)
  15789. .apply(undefined$1, importsValues);
  15790. });
  15791. // Provide the compiled function's source by its `toString` method or
  15792. // the `source` property as a convenience for inlining compiled templates.
  15793. result.source = source;
  15794. if (isError(result)) {
  15795. throw result;
  15796. }
  15797. return result;
  15798. }
  15799. /**
  15800. * Converts `string`, as a whole, to lower case just like
  15801. * [String#toLowerCase](https://mdn.io/toLowerCase).
  15802. *
  15803. * @static
  15804. * @memberOf _
  15805. * @since 4.0.0
  15806. * @category String
  15807. * @param {string} [string=''] The string to convert.
  15808. * @returns {string} Returns the lower cased string.
  15809. * @example
  15810. *
  15811. * _.toLower('--Foo-Bar--');
  15812. * // => '--foo-bar--'
  15813. *
  15814. * _.toLower('fooBar');
  15815. * // => 'foobar'
  15816. *
  15817. * _.toLower('__FOO_BAR__');
  15818. * // => '__foo_bar__'
  15819. */
  15820. function toLower(value) {
  15821. return toString(value).toLowerCase();
  15822. }
  15823. /**
  15824. * Converts `string`, as a whole, to upper case just like
  15825. * [String#toUpperCase](https://mdn.io/toUpperCase).
  15826. *
  15827. * @static
  15828. * @memberOf _
  15829. * @since 4.0.0
  15830. * @category String
  15831. * @param {string} [string=''] The string to convert.
  15832. * @returns {string} Returns the upper cased string.
  15833. * @example
  15834. *
  15835. * _.toUpper('--foo-bar--');
  15836. * // => '--FOO-BAR--'
  15837. *
  15838. * _.toUpper('fooBar');
  15839. * // => 'FOOBAR'
  15840. *
  15841. * _.toUpper('__foo_bar__');
  15842. * // => '__FOO_BAR__'
  15843. */
  15844. function toUpper(value) {
  15845. return toString(value).toUpperCase();
  15846. }
  15847. /**
  15848. * Removes leading and trailing whitespace or specified characters from `string`.
  15849. *
  15850. * @static
  15851. * @memberOf _
  15852. * @since 3.0.0
  15853. * @category String
  15854. * @param {string} [string=''] The string to trim.
  15855. * @param {string} [chars=whitespace] The characters to trim.
  15856. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15857. * @returns {string} Returns the trimmed string.
  15858. * @example
  15859. *
  15860. * _.trim(' abc ');
  15861. * // => 'abc'
  15862. *
  15863. * _.trim('-_-abc-_-', '_-');
  15864. * // => 'abc'
  15865. *
  15866. * _.map([' foo ', ' bar '], _.trim);
  15867. * // => ['foo', 'bar']
  15868. */
  15869. function trim(string, chars, guard) {
  15870. string = toString(string);
  15871. if (string && (guard || chars === undefined$1)) {
  15872. return baseTrim(string);
  15873. }
  15874. if (!string || !(chars = baseToString(chars))) {
  15875. return string;
  15876. }
  15877. var strSymbols = stringToArray(string),
  15878. chrSymbols = stringToArray(chars),
  15879. start = charsStartIndex(strSymbols, chrSymbols),
  15880. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  15881. return castSlice(strSymbols, start, end).join('');
  15882. }
  15883. /**
  15884. * Removes trailing whitespace or specified characters from `string`.
  15885. *
  15886. * @static
  15887. * @memberOf _
  15888. * @since 4.0.0
  15889. * @category String
  15890. * @param {string} [string=''] The string to trim.
  15891. * @param {string} [chars=whitespace] The characters to trim.
  15892. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15893. * @returns {string} Returns the trimmed string.
  15894. * @example
  15895. *
  15896. * _.trimEnd(' abc ');
  15897. * // => ' abc'
  15898. *
  15899. * _.trimEnd('-_-abc-_-', '_-');
  15900. * // => '-_-abc'
  15901. */
  15902. function trimEnd(string, chars, guard) {
  15903. string = toString(string);
  15904. if (string && (guard || chars === undefined$1)) {
  15905. return string.slice(0, trimmedEndIndex(string) + 1);
  15906. }
  15907. if (!string || !(chars = baseToString(chars))) {
  15908. return string;
  15909. }
  15910. var strSymbols = stringToArray(string),
  15911. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  15912. return castSlice(strSymbols, 0, end).join('');
  15913. }
  15914. /**
  15915. * Removes leading whitespace or specified characters from `string`.
  15916. *
  15917. * @static
  15918. * @memberOf _
  15919. * @since 4.0.0
  15920. * @category String
  15921. * @param {string} [string=''] The string to trim.
  15922. * @param {string} [chars=whitespace] The characters to trim.
  15923. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15924. * @returns {string} Returns the trimmed string.
  15925. * @example
  15926. *
  15927. * _.trimStart(' abc ');
  15928. * // => 'abc '
  15929. *
  15930. * _.trimStart('-_-abc-_-', '_-');
  15931. * // => 'abc-_-'
  15932. */
  15933. function trimStart(string, chars, guard) {
  15934. string = toString(string);
  15935. if (string && (guard || chars === undefined$1)) {
  15936. return string.replace(reTrimStart, '');
  15937. }
  15938. if (!string || !(chars = baseToString(chars))) {
  15939. return string;
  15940. }
  15941. var strSymbols = stringToArray(string),
  15942. start = charsStartIndex(strSymbols, stringToArray(chars));
  15943. return castSlice(strSymbols, start).join('');
  15944. }
  15945. /**
  15946. * Truncates `string` if it's longer than the given maximum string length.
  15947. * The last characters of the truncated string are replaced with the omission
  15948. * string which defaults to "...".
  15949. *
  15950. * @static
  15951. * @memberOf _
  15952. * @since 4.0.0
  15953. * @category String
  15954. * @param {string} [string=''] The string to truncate.
  15955. * @param {Object} [options={}] The options object.
  15956. * @param {number} [options.length=30] The maximum string length.
  15957. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  15958. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  15959. * @returns {string} Returns the truncated string.
  15960. * @example
  15961. *
  15962. * _.truncate('hi-diddly-ho there, neighborino');
  15963. * // => 'hi-diddly-ho there, neighbo...'
  15964. *
  15965. * _.truncate('hi-diddly-ho there, neighborino', {
  15966. * 'length': 24,
  15967. * 'separator': ' '
  15968. * });
  15969. * // => 'hi-diddly-ho there,...'
  15970. *
  15971. * _.truncate('hi-diddly-ho there, neighborino', {
  15972. * 'length': 24,
  15973. * 'separator': /,? +/
  15974. * });
  15975. * // => 'hi-diddly-ho there...'
  15976. *
  15977. * _.truncate('hi-diddly-ho there, neighborino', {
  15978. * 'omission': ' [...]'
  15979. * });
  15980. * // => 'hi-diddly-ho there, neig [...]'
  15981. */
  15982. function truncate(string, options) {
  15983. var length = DEFAULT_TRUNC_LENGTH,
  15984. omission = DEFAULT_TRUNC_OMISSION;
  15985. if (isObject(options)) {
  15986. var separator = 'separator' in options ? options.separator : separator;
  15987. length = 'length' in options ? toInteger(options.length) : length;
  15988. omission = 'omission' in options ? baseToString(options.omission) : omission;
  15989. }
  15990. string = toString(string);
  15991. var strLength = string.length;
  15992. if (hasUnicode(string)) {
  15993. var strSymbols = stringToArray(string);
  15994. strLength = strSymbols.length;
  15995. }
  15996. if (length >= strLength) {
  15997. return string;
  15998. }
  15999. var end = length - stringSize(omission);
  16000. if (end < 1) {
  16001. return omission;
  16002. }
  16003. var result = strSymbols
  16004. ? castSlice(strSymbols, 0, end).join('')
  16005. : string.slice(0, end);
  16006. if (separator === undefined$1) {
  16007. return result + omission;
  16008. }
  16009. if (strSymbols) {
  16010. end += (result.length - end);
  16011. }
  16012. if (isRegExp(separator)) {
  16013. if (string.slice(end).search(separator)) {
  16014. var match,
  16015. substring = result;
  16016. if (!separator.global) {
  16017. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  16018. }
  16019. separator.lastIndex = 0;
  16020. while ((match = separator.exec(substring))) {
  16021. var newEnd = match.index;
  16022. }
  16023. result = result.slice(0, newEnd === undefined$1 ? end : newEnd);
  16024. }
  16025. } else if (string.indexOf(baseToString(separator), end) != end) {
  16026. var index = result.lastIndexOf(separator);
  16027. if (index > -1) {
  16028. result = result.slice(0, index);
  16029. }
  16030. }
  16031. return result + omission;
  16032. }
  16033. /**
  16034. * The inverse of `_.escape`; this method converts the HTML entities
  16035. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  16036. * their corresponding characters.
  16037. *
  16038. * **Note:** No other HTML entities are unescaped. To unescape additional
  16039. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  16040. *
  16041. * @static
  16042. * @memberOf _
  16043. * @since 0.6.0
  16044. * @category String
  16045. * @param {string} [string=''] The string to unescape.
  16046. * @returns {string} Returns the unescaped string.
  16047. * @example
  16048. *
  16049. * _.unescape('fred, barney, &amp; pebbles');
  16050. * // => 'fred, barney, & pebbles'
  16051. */
  16052. function unescape(string) {
  16053. string = toString(string);
  16054. return (string && reHasEscapedHtml.test(string))
  16055. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  16056. : string;
  16057. }
  16058. /**
  16059. * Converts `string`, as space separated words, to upper case.
  16060. *
  16061. * @static
  16062. * @memberOf _
  16063. * @since 4.0.0
  16064. * @category String
  16065. * @param {string} [string=''] The string to convert.
  16066. * @returns {string} Returns the upper cased string.
  16067. * @example
  16068. *
  16069. * _.upperCase('--foo-bar');
  16070. * // => 'FOO BAR'
  16071. *
  16072. * _.upperCase('fooBar');
  16073. * // => 'FOO BAR'
  16074. *
  16075. * _.upperCase('__foo_bar__');
  16076. * // => 'FOO BAR'
  16077. */
  16078. var upperCase = createCompounder(function(result, word, index) {
  16079. return result + (index ? ' ' : '') + word.toUpperCase();
  16080. });
  16081. /**
  16082. * Converts the first character of `string` to upper case.
  16083. *
  16084. * @static
  16085. * @memberOf _
  16086. * @since 4.0.0
  16087. * @category String
  16088. * @param {string} [string=''] The string to convert.
  16089. * @returns {string} Returns the converted string.
  16090. * @example
  16091. *
  16092. * _.upperFirst('fred');
  16093. * // => 'Fred'
  16094. *
  16095. * _.upperFirst('FRED');
  16096. * // => 'FRED'
  16097. */
  16098. var upperFirst = createCaseFirst('toUpperCase');
  16099. /**
  16100. * Splits `string` into an array of its words.
  16101. *
  16102. * @static
  16103. * @memberOf _
  16104. * @since 3.0.0
  16105. * @category String
  16106. * @param {string} [string=''] The string to inspect.
  16107. * @param {RegExp|string} [pattern] The pattern to match words.
  16108. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  16109. * @returns {Array} Returns the words of `string`.
  16110. * @example
  16111. *
  16112. * _.words('fred, barney, & pebbles');
  16113. * // => ['fred', 'barney', 'pebbles']
  16114. *
  16115. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  16116. * // => ['fred', 'barney', '&', 'pebbles']
  16117. */
  16118. function words(string, pattern, guard) {
  16119. string = toString(string);
  16120. pattern = guard ? undefined$1 : pattern;
  16121. if (pattern === undefined$1) {
  16122. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  16123. }
  16124. return string.match(pattern) || [];
  16125. }
  16126. /*------------------------------------------------------------------------*/
  16127. /**
  16128. * Attempts to invoke `func`, returning either the result or the caught error
  16129. * object. Any additional arguments are provided to `func` when it's invoked.
  16130. *
  16131. * @static
  16132. * @memberOf _
  16133. * @since 3.0.0
  16134. * @category Util
  16135. * @param {Function} func The function to attempt.
  16136. * @param {...*} [args] The arguments to invoke `func` with.
  16137. * @returns {*} Returns the `func` result or error object.
  16138. * @example
  16139. *
  16140. * // Avoid throwing errors for invalid selectors.
  16141. * var elements = _.attempt(function(selector) {
  16142. * return document.querySelectorAll(selector);
  16143. * }, '>_>');
  16144. *
  16145. * if (_.isError(elements)) {
  16146. * elements = [];
  16147. * }
  16148. */
  16149. var attempt = baseRest(function(func, args) {
  16150. try {
  16151. return apply(func, undefined$1, args);
  16152. } catch (e) {
  16153. return isError(e) ? e : new Error(e);
  16154. }
  16155. });
  16156. /**
  16157. * Binds methods of an object to the object itself, overwriting the existing
  16158. * method.
  16159. *
  16160. * **Note:** This method doesn't set the "length" property of bound functions.
  16161. *
  16162. * @static
  16163. * @since 0.1.0
  16164. * @memberOf _
  16165. * @category Util
  16166. * @param {Object} object The object to bind and assign the bound methods to.
  16167. * @param {...(string|string[])} methodNames The object method names to bind.
  16168. * @returns {Object} Returns `object`.
  16169. * @example
  16170. *
  16171. * var view = {
  16172. * 'label': 'docs',
  16173. * 'click': function() {
  16174. * console.log('clicked ' + this.label);
  16175. * }
  16176. * };
  16177. *
  16178. * _.bindAll(view, ['click']);
  16179. * jQuery(element).on('click', view.click);
  16180. * // => Logs 'clicked docs' when clicked.
  16181. */
  16182. var bindAll = flatRest(function(object, methodNames) {
  16183. arrayEach(methodNames, function(key) {
  16184. key = toKey(key);
  16185. baseAssignValue(object, key, bind(object[key], object));
  16186. });
  16187. return object;
  16188. });
  16189. /**
  16190. * Creates a function that iterates over `pairs` and invokes the corresponding
  16191. * function of the first predicate to return truthy. The predicate-function
  16192. * pairs are invoked with the `this` binding and arguments of the created
  16193. * function.
  16194. *
  16195. * @static
  16196. * @memberOf _
  16197. * @since 4.0.0
  16198. * @category Util
  16199. * @param {Array} pairs The predicate-function pairs.
  16200. * @returns {Function} Returns the new composite function.
  16201. * @example
  16202. *
  16203. * var func = _.cond([
  16204. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  16205. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  16206. * [_.stubTrue, _.constant('no match')]
  16207. * ]);
  16208. *
  16209. * func({ 'a': 1, 'b': 2 });
  16210. * // => 'matches A'
  16211. *
  16212. * func({ 'a': 0, 'b': 1 });
  16213. * // => 'matches B'
  16214. *
  16215. * func({ 'a': '1', 'b': '2' });
  16216. * // => 'no match'
  16217. */
  16218. function cond(pairs) {
  16219. var length = pairs == null ? 0 : pairs.length,
  16220. toIteratee = getIteratee();
  16221. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  16222. if (typeof pair[1] != 'function') {
  16223. throw new TypeError(FUNC_ERROR_TEXT);
  16224. }
  16225. return [toIteratee(pair[0]), pair[1]];
  16226. });
  16227. return baseRest(function(args) {
  16228. var index = -1;
  16229. while (++index < length) {
  16230. var pair = pairs[index];
  16231. if (apply(pair[0], this, args)) {
  16232. return apply(pair[1], this, args);
  16233. }
  16234. }
  16235. });
  16236. }
  16237. /**
  16238. * Creates a function that invokes the predicate properties of `source` with
  16239. * the corresponding property values of a given object, returning `true` if
  16240. * all predicates return truthy, else `false`.
  16241. *
  16242. * **Note:** The created function is equivalent to `_.conformsTo` with
  16243. * `source` partially applied.
  16244. *
  16245. * @static
  16246. * @memberOf _
  16247. * @since 4.0.0
  16248. * @category Util
  16249. * @param {Object} source The object of property predicates to conform to.
  16250. * @returns {Function} Returns the new spec function.
  16251. * @example
  16252. *
  16253. * var objects = [
  16254. * { 'a': 2, 'b': 1 },
  16255. * { 'a': 1, 'b': 2 }
  16256. * ];
  16257. *
  16258. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  16259. * // => [{ 'a': 1, 'b': 2 }]
  16260. */
  16261. function conforms(source) {
  16262. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  16263. }
  16264. /**
  16265. * Creates a function that returns `value`.
  16266. *
  16267. * @static
  16268. * @memberOf _
  16269. * @since 2.4.0
  16270. * @category Util
  16271. * @param {*} value The value to return from the new function.
  16272. * @returns {Function} Returns the new constant function.
  16273. * @example
  16274. *
  16275. * var objects = _.times(2, _.constant({ 'a': 1 }));
  16276. *
  16277. * console.log(objects);
  16278. * // => [{ 'a': 1 }, { 'a': 1 }]
  16279. *
  16280. * console.log(objects[0] === objects[1]);
  16281. * // => true
  16282. */
  16283. function constant(value) {
  16284. return function() {
  16285. return value;
  16286. };
  16287. }
  16288. /**
  16289. * Checks `value` to determine whether a default value should be returned in
  16290. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  16291. * or `undefined`.
  16292. *
  16293. * @static
  16294. * @memberOf _
  16295. * @since 4.14.0
  16296. * @category Util
  16297. * @param {*} value The value to check.
  16298. * @param {*} defaultValue The default value.
  16299. * @returns {*} Returns the resolved value.
  16300. * @example
  16301. *
  16302. * _.defaultTo(1, 10);
  16303. * // => 1
  16304. *
  16305. * _.defaultTo(undefined, 10);
  16306. * // => 10
  16307. */
  16308. function defaultTo(value, defaultValue) {
  16309. return (value == null || value !== value) ? defaultValue : value;
  16310. }
  16311. /**
  16312. * Creates a function that returns the result of invoking the given functions
  16313. * with the `this` binding of the created function, where each successive
  16314. * invocation is supplied the return value of the previous.
  16315. *
  16316. * @static
  16317. * @memberOf _
  16318. * @since 3.0.0
  16319. * @category Util
  16320. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16321. * @returns {Function} Returns the new composite function.
  16322. * @see _.flowRight
  16323. * @example
  16324. *
  16325. * function square(n) {
  16326. * return n * n;
  16327. * }
  16328. *
  16329. * var addSquare = _.flow([_.add, square]);
  16330. * addSquare(1, 2);
  16331. * // => 9
  16332. */
  16333. var flow = createFlow();
  16334. /**
  16335. * This method is like `_.flow` except that it creates a function that
  16336. * invokes the given functions from right to left.
  16337. *
  16338. * @static
  16339. * @since 3.0.0
  16340. * @memberOf _
  16341. * @category Util
  16342. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16343. * @returns {Function} Returns the new composite function.
  16344. * @see _.flow
  16345. * @example
  16346. *
  16347. * function square(n) {
  16348. * return n * n;
  16349. * }
  16350. *
  16351. * var addSquare = _.flowRight([square, _.add]);
  16352. * addSquare(1, 2);
  16353. * // => 9
  16354. */
  16355. var flowRight = createFlow(true);
  16356. /**
  16357. * This method returns the first argument it receives.
  16358. *
  16359. * @static
  16360. * @since 0.1.0
  16361. * @memberOf _
  16362. * @category Util
  16363. * @param {*} value Any value.
  16364. * @returns {*} Returns `value`.
  16365. * @example
  16366. *
  16367. * var object = { 'a': 1 };
  16368. *
  16369. * console.log(_.identity(object) === object);
  16370. * // => true
  16371. */
  16372. function identity(value) {
  16373. return value;
  16374. }
  16375. /**
  16376. * Creates a function that invokes `func` with the arguments of the created
  16377. * function. If `func` is a property name, the created function returns the
  16378. * property value for a given element. If `func` is an array or object, the
  16379. * created function returns `true` for elements that contain the equivalent
  16380. * source properties, otherwise it returns `false`.
  16381. *
  16382. * @static
  16383. * @since 4.0.0
  16384. * @memberOf _
  16385. * @category Util
  16386. * @param {*} [func=_.identity] The value to convert to a callback.
  16387. * @returns {Function} Returns the callback.
  16388. * @example
  16389. *
  16390. * var users = [
  16391. * { 'user': 'barney', 'age': 36, 'active': true },
  16392. * { 'user': 'fred', 'age': 40, 'active': false }
  16393. * ];
  16394. *
  16395. * // The `_.matches` iteratee shorthand.
  16396. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  16397. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  16398. *
  16399. * // The `_.matchesProperty` iteratee shorthand.
  16400. * _.filter(users, _.iteratee(['user', 'fred']));
  16401. * // => [{ 'user': 'fred', 'age': 40 }]
  16402. *
  16403. * // The `_.property` iteratee shorthand.
  16404. * _.map(users, _.iteratee('user'));
  16405. * // => ['barney', 'fred']
  16406. *
  16407. * // Create custom iteratee shorthands.
  16408. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  16409. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  16410. * return func.test(string);
  16411. * };
  16412. * });
  16413. *
  16414. * _.filter(['abc', 'def'], /ef/);
  16415. * // => ['def']
  16416. */
  16417. function iteratee(func) {
  16418. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  16419. }
  16420. /**
  16421. * Creates a function that performs a partial deep comparison between a given
  16422. * object and `source`, returning `true` if the given object has equivalent
  16423. * property values, else `false`.
  16424. *
  16425. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  16426. * partially applied.
  16427. *
  16428. * Partial comparisons will match empty array and empty object `source`
  16429. * values against any array or object value, respectively. See `_.isEqual`
  16430. * for a list of supported value comparisons.
  16431. *
  16432. * **Note:** Multiple values can be checked by combining several matchers
  16433. * using `_.overSome`
  16434. *
  16435. * @static
  16436. * @memberOf _
  16437. * @since 3.0.0
  16438. * @category Util
  16439. * @param {Object} source The object of property values to match.
  16440. * @returns {Function} Returns the new spec function.
  16441. * @example
  16442. *
  16443. * var objects = [
  16444. * { 'a': 1, 'b': 2, 'c': 3 },
  16445. * { 'a': 4, 'b': 5, 'c': 6 }
  16446. * ];
  16447. *
  16448. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  16449. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  16450. *
  16451. * // Checking for several possible values
  16452. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  16453. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16454. */
  16455. function matches(source) {
  16456. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  16457. }
  16458. /**
  16459. * Creates a function that performs a partial deep comparison between the
  16460. * value at `path` of a given object to `srcValue`, returning `true` if the
  16461. * object value is equivalent, else `false`.
  16462. *
  16463. * **Note:** Partial comparisons will match empty array and empty object
  16464. * `srcValue` values against any array or object value, respectively. See
  16465. * `_.isEqual` for a list of supported value comparisons.
  16466. *
  16467. * **Note:** Multiple values can be checked by combining several matchers
  16468. * using `_.overSome`
  16469. *
  16470. * @static
  16471. * @memberOf _
  16472. * @since 3.2.0
  16473. * @category Util
  16474. * @param {Array|string} path The path of the property to get.
  16475. * @param {*} srcValue The value to match.
  16476. * @returns {Function} Returns the new spec function.
  16477. * @example
  16478. *
  16479. * var objects = [
  16480. * { 'a': 1, 'b': 2, 'c': 3 },
  16481. * { 'a': 4, 'b': 5, 'c': 6 }
  16482. * ];
  16483. *
  16484. * _.find(objects, _.matchesProperty('a', 4));
  16485. * // => { 'a': 4, 'b': 5, 'c': 6 }
  16486. *
  16487. * // Checking for several possible values
  16488. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  16489. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16490. */
  16491. function matchesProperty(path, srcValue) {
  16492. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  16493. }
  16494. /**
  16495. * Creates a function that invokes the method at `path` of a given object.
  16496. * Any additional arguments are provided to the invoked method.
  16497. *
  16498. * @static
  16499. * @memberOf _
  16500. * @since 3.7.0
  16501. * @category Util
  16502. * @param {Array|string} path The path of the method to invoke.
  16503. * @param {...*} [args] The arguments to invoke the method with.
  16504. * @returns {Function} Returns the new invoker function.
  16505. * @example
  16506. *
  16507. * var objects = [
  16508. * { 'a': { 'b': _.constant(2) } },
  16509. * { 'a': { 'b': _.constant(1) } }
  16510. * ];
  16511. *
  16512. * _.map(objects, _.method('a.b'));
  16513. * // => [2, 1]
  16514. *
  16515. * _.map(objects, _.method(['a', 'b']));
  16516. * // => [2, 1]
  16517. */
  16518. var method = baseRest(function(path, args) {
  16519. return function(object) {
  16520. return baseInvoke(object, path, args);
  16521. };
  16522. });
  16523. /**
  16524. * The opposite of `_.method`; this method creates a function that invokes
  16525. * the method at a given path of `object`. Any additional arguments are
  16526. * provided to the invoked method.
  16527. *
  16528. * @static
  16529. * @memberOf _
  16530. * @since 3.7.0
  16531. * @category Util
  16532. * @param {Object} object The object to query.
  16533. * @param {...*} [args] The arguments to invoke the method with.
  16534. * @returns {Function} Returns the new invoker function.
  16535. * @example
  16536. *
  16537. * var array = _.times(3, _.constant),
  16538. * object = { 'a': array, 'b': array, 'c': array };
  16539. *
  16540. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  16541. * // => [2, 0]
  16542. *
  16543. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  16544. * // => [2, 0]
  16545. */
  16546. var methodOf = baseRest(function(object, args) {
  16547. return function(path) {
  16548. return baseInvoke(object, path, args);
  16549. };
  16550. });
  16551. /**
  16552. * Adds all own enumerable string keyed function properties of a source
  16553. * object to the destination object. If `object` is a function, then methods
  16554. * are added to its prototype as well.
  16555. *
  16556. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  16557. * avoid conflicts caused by modifying the original.
  16558. *
  16559. * @static
  16560. * @since 0.1.0
  16561. * @memberOf _
  16562. * @category Util
  16563. * @param {Function|Object} [object=lodash] The destination object.
  16564. * @param {Object} source The object of functions to add.
  16565. * @param {Object} [options={}] The options object.
  16566. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  16567. * @returns {Function|Object} Returns `object`.
  16568. * @example
  16569. *
  16570. * function vowels(string) {
  16571. * return _.filter(string, function(v) {
  16572. * return /[aeiou]/i.test(v);
  16573. * });
  16574. * }
  16575. *
  16576. * _.mixin({ 'vowels': vowels });
  16577. * _.vowels('fred');
  16578. * // => ['e']
  16579. *
  16580. * _('fred').vowels().value();
  16581. * // => ['e']
  16582. *
  16583. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  16584. * _('fred').vowels();
  16585. * // => ['e']
  16586. */
  16587. function mixin(object, source, options) {
  16588. var props = keys(source),
  16589. methodNames = baseFunctions(source, props);
  16590. if (options == null &&
  16591. !(isObject(source) && (methodNames.length || !props.length))) {
  16592. options = source;
  16593. source = object;
  16594. object = this;
  16595. methodNames = baseFunctions(source, keys(source));
  16596. }
  16597. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  16598. isFunc = isFunction(object);
  16599. arrayEach(methodNames, function(methodName) {
  16600. var func = source[methodName];
  16601. object[methodName] = func;
  16602. if (isFunc) {
  16603. object.prototype[methodName] = function() {
  16604. var chainAll = this.__chain__;
  16605. if (chain || chainAll) {
  16606. var result = object(this.__wrapped__),
  16607. actions = result.__actions__ = copyArray(this.__actions__);
  16608. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  16609. result.__chain__ = chainAll;
  16610. return result;
  16611. }
  16612. return func.apply(object, arrayPush([this.value()], arguments));
  16613. };
  16614. }
  16615. });
  16616. return object;
  16617. }
  16618. /**
  16619. * Reverts the `_` variable to its previous value and returns a reference to
  16620. * the `lodash` function.
  16621. *
  16622. * @static
  16623. * @since 0.1.0
  16624. * @memberOf _
  16625. * @category Util
  16626. * @returns {Function} Returns the `lodash` function.
  16627. * @example
  16628. *
  16629. * var lodash = _.noConflict();
  16630. */
  16631. function noConflict() {
  16632. if (root._ === this) {
  16633. root._ = oldDash;
  16634. }
  16635. return this;
  16636. }
  16637. /**
  16638. * This method returns `undefined`.
  16639. *
  16640. * @static
  16641. * @memberOf _
  16642. * @since 2.3.0
  16643. * @category Util
  16644. * @example
  16645. *
  16646. * _.times(2, _.noop);
  16647. * // => [undefined, undefined]
  16648. */
  16649. function noop() {
  16650. // No operation performed.
  16651. }
  16652. /**
  16653. * Creates a function that gets the argument at index `n`. If `n` is negative,
  16654. * the nth argument from the end is returned.
  16655. *
  16656. * @static
  16657. * @memberOf _
  16658. * @since 4.0.0
  16659. * @category Util
  16660. * @param {number} [n=0] The index of the argument to return.
  16661. * @returns {Function} Returns the new pass-thru function.
  16662. * @example
  16663. *
  16664. * var func = _.nthArg(1);
  16665. * func('a', 'b', 'c', 'd');
  16666. * // => 'b'
  16667. *
  16668. * var func = _.nthArg(-2);
  16669. * func('a', 'b', 'c', 'd');
  16670. * // => 'c'
  16671. */
  16672. function nthArg(n) {
  16673. n = toInteger(n);
  16674. return baseRest(function(args) {
  16675. return baseNth(args, n);
  16676. });
  16677. }
  16678. /**
  16679. * Creates a function that invokes `iteratees` with the arguments it receives
  16680. * and returns their results.
  16681. *
  16682. * @static
  16683. * @memberOf _
  16684. * @since 4.0.0
  16685. * @category Util
  16686. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  16687. * The iteratees to invoke.
  16688. * @returns {Function} Returns the new function.
  16689. * @example
  16690. *
  16691. * var func = _.over([Math.max, Math.min]);
  16692. *
  16693. * func(1, 2, 3, 4);
  16694. * // => [4, 1]
  16695. */
  16696. var over = createOver(arrayMap);
  16697. /**
  16698. * Creates a function that checks if **all** of the `predicates` return
  16699. * truthy when invoked with the arguments it receives.
  16700. *
  16701. * Following shorthands are possible for providing predicates.
  16702. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16703. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16704. *
  16705. * @static
  16706. * @memberOf _
  16707. * @since 4.0.0
  16708. * @category Util
  16709. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16710. * The predicates to check.
  16711. * @returns {Function} Returns the new function.
  16712. * @example
  16713. *
  16714. * var func = _.overEvery([Boolean, isFinite]);
  16715. *
  16716. * func('1');
  16717. * // => true
  16718. *
  16719. * func(null);
  16720. * // => false
  16721. *
  16722. * func(NaN);
  16723. * // => false
  16724. */
  16725. var overEvery = createOver(arrayEvery);
  16726. /**
  16727. * Creates a function that checks if **any** of the `predicates` return
  16728. * truthy when invoked with the arguments it receives.
  16729. *
  16730. * Following shorthands are possible for providing predicates.
  16731. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16732. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16733. *
  16734. * @static
  16735. * @memberOf _
  16736. * @since 4.0.0
  16737. * @category Util
  16738. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16739. * The predicates to check.
  16740. * @returns {Function} Returns the new function.
  16741. * @example
  16742. *
  16743. * var func = _.overSome([Boolean, isFinite]);
  16744. *
  16745. * func('1');
  16746. * // => true
  16747. *
  16748. * func(null);
  16749. * // => true
  16750. *
  16751. * func(NaN);
  16752. * // => false
  16753. *
  16754. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  16755. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  16756. */
  16757. var overSome = createOver(arraySome);
  16758. /**
  16759. * Creates a function that returns the value at `path` of a given object.
  16760. *
  16761. * @static
  16762. * @memberOf _
  16763. * @since 2.4.0
  16764. * @category Util
  16765. * @param {Array|string} path The path of the property to get.
  16766. * @returns {Function} Returns the new accessor function.
  16767. * @example
  16768. *
  16769. * var objects = [
  16770. * { 'a': { 'b': 2 } },
  16771. * { 'a': { 'b': 1 } }
  16772. * ];
  16773. *
  16774. * _.map(objects, _.property('a.b'));
  16775. * // => [2, 1]
  16776. *
  16777. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  16778. * // => [1, 2]
  16779. */
  16780. function property(path) {
  16781. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  16782. }
  16783. /**
  16784. * The opposite of `_.property`; this method creates a function that returns
  16785. * the value at a given path of `object`.
  16786. *
  16787. * @static
  16788. * @memberOf _
  16789. * @since 3.0.0
  16790. * @category Util
  16791. * @param {Object} object The object to query.
  16792. * @returns {Function} Returns the new accessor function.
  16793. * @example
  16794. *
  16795. * var array = [0, 1, 2],
  16796. * object = { 'a': array, 'b': array, 'c': array };
  16797. *
  16798. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  16799. * // => [2, 0]
  16800. *
  16801. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  16802. * // => [2, 0]
  16803. */
  16804. function propertyOf(object) {
  16805. return function(path) {
  16806. return object == null ? undefined$1 : baseGet(object, path);
  16807. };
  16808. }
  16809. /**
  16810. * Creates an array of numbers (positive and/or negative) progressing from
  16811. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  16812. * `start` is specified without an `end` or `step`. If `end` is not specified,
  16813. * it's set to `start` with `start` then set to `0`.
  16814. *
  16815. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  16816. * floating-point values which can produce unexpected results.
  16817. *
  16818. * @static
  16819. * @since 0.1.0
  16820. * @memberOf _
  16821. * @category Util
  16822. * @param {number} [start=0] The start of the range.
  16823. * @param {number} end The end of the range.
  16824. * @param {number} [step=1] The value to increment or decrement by.
  16825. * @returns {Array} Returns the range of numbers.
  16826. * @see _.inRange, _.rangeRight
  16827. * @example
  16828. *
  16829. * _.range(4);
  16830. * // => [0, 1, 2, 3]
  16831. *
  16832. * _.range(-4);
  16833. * // => [0, -1, -2, -3]
  16834. *
  16835. * _.range(1, 5);
  16836. * // => [1, 2, 3, 4]
  16837. *
  16838. * _.range(0, 20, 5);
  16839. * // => [0, 5, 10, 15]
  16840. *
  16841. * _.range(0, -4, -1);
  16842. * // => [0, -1, -2, -3]
  16843. *
  16844. * _.range(1, 4, 0);
  16845. * // => [1, 1, 1]
  16846. *
  16847. * _.range(0);
  16848. * // => []
  16849. */
  16850. var range = createRange();
  16851. /**
  16852. * This method is like `_.range` except that it populates values in
  16853. * descending order.
  16854. *
  16855. * @static
  16856. * @memberOf _
  16857. * @since 4.0.0
  16858. * @category Util
  16859. * @param {number} [start=0] The start of the range.
  16860. * @param {number} end The end of the range.
  16861. * @param {number} [step=1] The value to increment or decrement by.
  16862. * @returns {Array} Returns the range of numbers.
  16863. * @see _.inRange, _.range
  16864. * @example
  16865. *
  16866. * _.rangeRight(4);
  16867. * // => [3, 2, 1, 0]
  16868. *
  16869. * _.rangeRight(-4);
  16870. * // => [-3, -2, -1, 0]
  16871. *
  16872. * _.rangeRight(1, 5);
  16873. * // => [4, 3, 2, 1]
  16874. *
  16875. * _.rangeRight(0, 20, 5);
  16876. * // => [15, 10, 5, 0]
  16877. *
  16878. * _.rangeRight(0, -4, -1);
  16879. * // => [-3, -2, -1, 0]
  16880. *
  16881. * _.rangeRight(1, 4, 0);
  16882. * // => [1, 1, 1]
  16883. *
  16884. * _.rangeRight(0);
  16885. * // => []
  16886. */
  16887. var rangeRight = createRange(true);
  16888. /**
  16889. * This method returns a new empty array.
  16890. *
  16891. * @static
  16892. * @memberOf _
  16893. * @since 4.13.0
  16894. * @category Util
  16895. * @returns {Array} Returns the new empty array.
  16896. * @example
  16897. *
  16898. * var arrays = _.times(2, _.stubArray);
  16899. *
  16900. * console.log(arrays);
  16901. * // => [[], []]
  16902. *
  16903. * console.log(arrays[0] === arrays[1]);
  16904. * // => false
  16905. */
  16906. function stubArray() {
  16907. return [];
  16908. }
  16909. /**
  16910. * This method returns `false`.
  16911. *
  16912. * @static
  16913. * @memberOf _
  16914. * @since 4.13.0
  16915. * @category Util
  16916. * @returns {boolean} Returns `false`.
  16917. * @example
  16918. *
  16919. * _.times(2, _.stubFalse);
  16920. * // => [false, false]
  16921. */
  16922. function stubFalse() {
  16923. return false;
  16924. }
  16925. /**
  16926. * This method returns a new empty object.
  16927. *
  16928. * @static
  16929. * @memberOf _
  16930. * @since 4.13.0
  16931. * @category Util
  16932. * @returns {Object} Returns the new empty object.
  16933. * @example
  16934. *
  16935. * var objects = _.times(2, _.stubObject);
  16936. *
  16937. * console.log(objects);
  16938. * // => [{}, {}]
  16939. *
  16940. * console.log(objects[0] === objects[1]);
  16941. * // => false
  16942. */
  16943. function stubObject() {
  16944. return {};
  16945. }
  16946. /**
  16947. * This method returns an empty string.
  16948. *
  16949. * @static
  16950. * @memberOf _
  16951. * @since 4.13.0
  16952. * @category Util
  16953. * @returns {string} Returns the empty string.
  16954. * @example
  16955. *
  16956. * _.times(2, _.stubString);
  16957. * // => ['', '']
  16958. */
  16959. function stubString() {
  16960. return '';
  16961. }
  16962. /**
  16963. * This method returns `true`.
  16964. *
  16965. * @static
  16966. * @memberOf _
  16967. * @since 4.13.0
  16968. * @category Util
  16969. * @returns {boolean} Returns `true`.
  16970. * @example
  16971. *
  16972. * _.times(2, _.stubTrue);
  16973. * // => [true, true]
  16974. */
  16975. function stubTrue() {
  16976. return true;
  16977. }
  16978. /**
  16979. * Invokes the iteratee `n` times, returning an array of the results of
  16980. * each invocation. The iteratee is invoked with one argument; (index).
  16981. *
  16982. * @static
  16983. * @since 0.1.0
  16984. * @memberOf _
  16985. * @category Util
  16986. * @param {number} n The number of times to invoke `iteratee`.
  16987. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16988. * @returns {Array} Returns the array of results.
  16989. * @example
  16990. *
  16991. * _.times(3, String);
  16992. * // => ['0', '1', '2']
  16993. *
  16994. * _.times(4, _.constant(0));
  16995. * // => [0, 0, 0, 0]
  16996. */
  16997. function times(n, iteratee) {
  16998. n = toInteger(n);
  16999. if (n < 1 || n > MAX_SAFE_INTEGER) {
  17000. return [];
  17001. }
  17002. var index = MAX_ARRAY_LENGTH,
  17003. length = nativeMin(n, MAX_ARRAY_LENGTH);
  17004. iteratee = getIteratee(iteratee);
  17005. n -= MAX_ARRAY_LENGTH;
  17006. var result = baseTimes(length, iteratee);
  17007. while (++index < n) {
  17008. iteratee(index);
  17009. }
  17010. return result;
  17011. }
  17012. /**
  17013. * Converts `value` to a property path array.
  17014. *
  17015. * @static
  17016. * @memberOf _
  17017. * @since 4.0.0
  17018. * @category Util
  17019. * @param {*} value The value to convert.
  17020. * @returns {Array} Returns the new property path array.
  17021. * @example
  17022. *
  17023. * _.toPath('a.b.c');
  17024. * // => ['a', 'b', 'c']
  17025. *
  17026. * _.toPath('a[0].b.c');
  17027. * // => ['a', '0', 'b', 'c']
  17028. */
  17029. function toPath(value) {
  17030. if (isArray(value)) {
  17031. return arrayMap(value, toKey);
  17032. }
  17033. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  17034. }
  17035. /**
  17036. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  17037. *
  17038. * @static
  17039. * @since 0.1.0
  17040. * @memberOf _
  17041. * @category Util
  17042. * @param {string} [prefix=''] The value to prefix the ID with.
  17043. * @returns {string} Returns the unique ID.
  17044. * @example
  17045. *
  17046. * _.uniqueId('contact_');
  17047. * // => 'contact_104'
  17048. *
  17049. * _.uniqueId();
  17050. * // => '105'
  17051. */
  17052. function uniqueId(prefix) {
  17053. var id = ++idCounter;
  17054. return toString(prefix) + id;
  17055. }
  17056. /*------------------------------------------------------------------------*/
  17057. /**
  17058. * Adds two numbers.
  17059. *
  17060. * @static
  17061. * @memberOf _
  17062. * @since 3.4.0
  17063. * @category Math
  17064. * @param {number} augend The first number in an addition.
  17065. * @param {number} addend The second number in an addition.
  17066. * @returns {number} Returns the total.
  17067. * @example
  17068. *
  17069. * _.add(6, 4);
  17070. * // => 10
  17071. */
  17072. var add = createMathOperation(function(augend, addend) {
  17073. return augend + addend;
  17074. }, 0);
  17075. /**
  17076. * Computes `number` rounded up to `precision`.
  17077. *
  17078. * @static
  17079. * @memberOf _
  17080. * @since 3.10.0
  17081. * @category Math
  17082. * @param {number} number The number to round up.
  17083. * @param {number} [precision=0] The precision to round up to.
  17084. * @returns {number} Returns the rounded up number.
  17085. * @example
  17086. *
  17087. * _.ceil(4.006);
  17088. * // => 5
  17089. *
  17090. * _.ceil(6.004, 2);
  17091. * // => 6.01
  17092. *
  17093. * _.ceil(6040, -2);
  17094. * // => 6100
  17095. */
  17096. var ceil = createRound('ceil');
  17097. /**
  17098. * Divide two numbers.
  17099. *
  17100. * @static
  17101. * @memberOf _
  17102. * @since 4.7.0
  17103. * @category Math
  17104. * @param {number} dividend The first number in a division.
  17105. * @param {number} divisor The second number in a division.
  17106. * @returns {number} Returns the quotient.
  17107. * @example
  17108. *
  17109. * _.divide(6, 4);
  17110. * // => 1.5
  17111. */
  17112. var divide = createMathOperation(function(dividend, divisor) {
  17113. return dividend / divisor;
  17114. }, 1);
  17115. /**
  17116. * Computes `number` rounded down to `precision`.
  17117. *
  17118. * @static
  17119. * @memberOf _
  17120. * @since 3.10.0
  17121. * @category Math
  17122. * @param {number} number The number to round down.
  17123. * @param {number} [precision=0] The precision to round down to.
  17124. * @returns {number} Returns the rounded down number.
  17125. * @example
  17126. *
  17127. * _.floor(4.006);
  17128. * // => 4
  17129. *
  17130. * _.floor(0.046, 2);
  17131. * // => 0.04
  17132. *
  17133. * _.floor(4060, -2);
  17134. * // => 4000
  17135. */
  17136. var floor = createRound('floor');
  17137. /**
  17138. * Computes the maximum value of `array`. If `array` is empty or falsey,
  17139. * `undefined` is returned.
  17140. *
  17141. * @static
  17142. * @since 0.1.0
  17143. * @memberOf _
  17144. * @category Math
  17145. * @param {Array} array The array to iterate over.
  17146. * @returns {*} Returns the maximum value.
  17147. * @example
  17148. *
  17149. * _.max([4, 2, 8, 6]);
  17150. * // => 8
  17151. *
  17152. * _.max([]);
  17153. * // => undefined
  17154. */
  17155. function max(array) {
  17156. return (array && array.length)
  17157. ? baseExtremum(array, identity, baseGt)
  17158. : undefined$1;
  17159. }
  17160. /**
  17161. * This method is like `_.max` except that it accepts `iteratee` which is
  17162. * invoked for each element in `array` to generate the criterion by which
  17163. * the value is ranked. The iteratee is invoked with one argument: (value).
  17164. *
  17165. * @static
  17166. * @memberOf _
  17167. * @since 4.0.0
  17168. * @category Math
  17169. * @param {Array} array The array to iterate over.
  17170. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17171. * @returns {*} Returns the maximum value.
  17172. * @example
  17173. *
  17174. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  17175. *
  17176. * _.maxBy(objects, function(o) { return o.n; });
  17177. * // => { 'n': 2 }
  17178. *
  17179. * // The `_.property` iteratee shorthand.
  17180. * _.maxBy(objects, 'n');
  17181. * // => { 'n': 2 }
  17182. */
  17183. function maxBy(array, iteratee) {
  17184. return (array && array.length)
  17185. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  17186. : undefined$1;
  17187. }
  17188. /**
  17189. * Computes the mean of the values in `array`.
  17190. *
  17191. * @static
  17192. * @memberOf _
  17193. * @since 4.0.0
  17194. * @category Math
  17195. * @param {Array} array The array to iterate over.
  17196. * @returns {number} Returns the mean.
  17197. * @example
  17198. *
  17199. * _.mean([4, 2, 8, 6]);
  17200. * // => 5
  17201. */
  17202. function mean(array) {
  17203. return baseMean(array, identity);
  17204. }
  17205. /**
  17206. * This method is like `_.mean` except that it accepts `iteratee` which is
  17207. * invoked for each element in `array` to generate the value to be averaged.
  17208. * The iteratee is invoked with one argument: (value).
  17209. *
  17210. * @static
  17211. * @memberOf _
  17212. * @since 4.7.0
  17213. * @category Math
  17214. * @param {Array} array The array to iterate over.
  17215. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17216. * @returns {number} Returns the mean.
  17217. * @example
  17218. *
  17219. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  17220. *
  17221. * _.meanBy(objects, function(o) { return o.n; });
  17222. * // => 5
  17223. *
  17224. * // The `_.property` iteratee shorthand.
  17225. * _.meanBy(objects, 'n');
  17226. * // => 5
  17227. */
  17228. function meanBy(array, iteratee) {
  17229. return baseMean(array, getIteratee(iteratee, 2));
  17230. }
  17231. /**
  17232. * Computes the minimum value of `array`. If `array` is empty or falsey,
  17233. * `undefined` is returned.
  17234. *
  17235. * @static
  17236. * @since 0.1.0
  17237. * @memberOf _
  17238. * @category Math
  17239. * @param {Array} array The array to iterate over.
  17240. * @returns {*} Returns the minimum value.
  17241. * @example
  17242. *
  17243. * _.min([4, 2, 8, 6]);
  17244. * // => 2
  17245. *
  17246. * _.min([]);
  17247. * // => undefined
  17248. */
  17249. function min(array) {
  17250. return (array && array.length)
  17251. ? baseExtremum(array, identity, baseLt)
  17252. : undefined$1;
  17253. }
  17254. /**
  17255. * This method is like `_.min` except that it accepts `iteratee` which is
  17256. * invoked for each element in `array` to generate the criterion by which
  17257. * the value is ranked. The iteratee is invoked with one argument: (value).
  17258. *
  17259. * @static
  17260. * @memberOf _
  17261. * @since 4.0.0
  17262. * @category Math
  17263. * @param {Array} array The array to iterate over.
  17264. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17265. * @returns {*} Returns the minimum value.
  17266. * @example
  17267. *
  17268. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  17269. *
  17270. * _.minBy(objects, function(o) { return o.n; });
  17271. * // => { 'n': 1 }
  17272. *
  17273. * // The `_.property` iteratee shorthand.
  17274. * _.minBy(objects, 'n');
  17275. * // => { 'n': 1 }
  17276. */
  17277. function minBy(array, iteratee) {
  17278. return (array && array.length)
  17279. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  17280. : undefined$1;
  17281. }
  17282. /**
  17283. * Multiply two numbers.
  17284. *
  17285. * @static
  17286. * @memberOf _
  17287. * @since 4.7.0
  17288. * @category Math
  17289. * @param {number} multiplier The first number in a multiplication.
  17290. * @param {number} multiplicand The second number in a multiplication.
  17291. * @returns {number} Returns the product.
  17292. * @example
  17293. *
  17294. * _.multiply(6, 4);
  17295. * // => 24
  17296. */
  17297. var multiply = createMathOperation(function(multiplier, multiplicand) {
  17298. return multiplier * multiplicand;
  17299. }, 1);
  17300. /**
  17301. * Computes `number` rounded to `precision`.
  17302. *
  17303. * @static
  17304. * @memberOf _
  17305. * @since 3.10.0
  17306. * @category Math
  17307. * @param {number} number The number to round.
  17308. * @param {number} [precision=0] The precision to round to.
  17309. * @returns {number} Returns the rounded number.
  17310. * @example
  17311. *
  17312. * _.round(4.006);
  17313. * // => 4
  17314. *
  17315. * _.round(4.006, 2);
  17316. * // => 4.01
  17317. *
  17318. * _.round(4060, -2);
  17319. * // => 4100
  17320. */
  17321. var round = createRound('round');
  17322. /**
  17323. * Subtract two numbers.
  17324. *
  17325. * @static
  17326. * @memberOf _
  17327. * @since 4.0.0
  17328. * @category Math
  17329. * @param {number} minuend The first number in a subtraction.
  17330. * @param {number} subtrahend The second number in a subtraction.
  17331. * @returns {number} Returns the difference.
  17332. * @example
  17333. *
  17334. * _.subtract(6, 4);
  17335. * // => 2
  17336. */
  17337. var subtract = createMathOperation(function(minuend, subtrahend) {
  17338. return minuend - subtrahend;
  17339. }, 0);
  17340. /**
  17341. * Computes the sum of the values in `array`.
  17342. *
  17343. * @static
  17344. * @memberOf _
  17345. * @since 3.4.0
  17346. * @category Math
  17347. * @param {Array} array The array to iterate over.
  17348. * @returns {number} Returns the sum.
  17349. * @example
  17350. *
  17351. * _.sum([4, 2, 8, 6]);
  17352. * // => 20
  17353. */
  17354. function sum(array) {
  17355. return (array && array.length)
  17356. ? baseSum(array, identity)
  17357. : 0;
  17358. }
  17359. /**
  17360. * This method is like `_.sum` except that it accepts `iteratee` which is
  17361. * invoked for each element in `array` to generate the value to be summed.
  17362. * The iteratee is invoked with one argument: (value).
  17363. *
  17364. * @static
  17365. * @memberOf _
  17366. * @since 4.0.0
  17367. * @category Math
  17368. * @param {Array} array The array to iterate over.
  17369. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17370. * @returns {number} Returns the sum.
  17371. * @example
  17372. *
  17373. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  17374. *
  17375. * _.sumBy(objects, function(o) { return o.n; });
  17376. * // => 20
  17377. *
  17378. * // The `_.property` iteratee shorthand.
  17379. * _.sumBy(objects, 'n');
  17380. * // => 20
  17381. */
  17382. function sumBy(array, iteratee) {
  17383. return (array && array.length)
  17384. ? baseSum(array, getIteratee(iteratee, 2))
  17385. : 0;
  17386. }
  17387. /*------------------------------------------------------------------------*/
  17388. // Add methods that return wrapped values in chain sequences.
  17389. lodash.after = after;
  17390. lodash.ary = ary;
  17391. lodash.assign = assign;
  17392. lodash.assignIn = assignIn;
  17393. lodash.assignInWith = assignInWith;
  17394. lodash.assignWith = assignWith;
  17395. lodash.at = at;
  17396. lodash.before = before;
  17397. lodash.bind = bind;
  17398. lodash.bindAll = bindAll;
  17399. lodash.bindKey = bindKey;
  17400. lodash.castArray = castArray;
  17401. lodash.chain = chain;
  17402. lodash.chunk = chunk;
  17403. lodash.compact = compact;
  17404. lodash.concat = concat;
  17405. lodash.cond = cond;
  17406. lodash.conforms = conforms;
  17407. lodash.constant = constant;
  17408. lodash.countBy = countBy;
  17409. lodash.create = create;
  17410. lodash.curry = curry;
  17411. lodash.curryRight = curryRight;
  17412. lodash.debounce = debounce;
  17413. lodash.defaults = defaults;
  17414. lodash.defaultsDeep = defaultsDeep;
  17415. lodash.defer = defer;
  17416. lodash.delay = delay;
  17417. lodash.difference = difference;
  17418. lodash.differenceBy = differenceBy;
  17419. lodash.differenceWith = differenceWith;
  17420. lodash.drop = drop;
  17421. lodash.dropRight = dropRight;
  17422. lodash.dropRightWhile = dropRightWhile;
  17423. lodash.dropWhile = dropWhile;
  17424. lodash.fill = fill;
  17425. lodash.filter = filter;
  17426. lodash.flatMap = flatMap;
  17427. lodash.flatMapDeep = flatMapDeep;
  17428. lodash.flatMapDepth = flatMapDepth;
  17429. lodash.flatten = flatten;
  17430. lodash.flattenDeep = flattenDeep;
  17431. lodash.flattenDepth = flattenDepth;
  17432. lodash.flip = flip;
  17433. lodash.flow = flow;
  17434. lodash.flowRight = flowRight;
  17435. lodash.fromPairs = fromPairs;
  17436. lodash.functions = functions;
  17437. lodash.functionsIn = functionsIn;
  17438. lodash.groupBy = groupBy;
  17439. lodash.initial = initial;
  17440. lodash.intersection = intersection;
  17441. lodash.intersectionBy = intersectionBy;
  17442. lodash.intersectionWith = intersectionWith;
  17443. lodash.invert = invert;
  17444. lodash.invertBy = invertBy;
  17445. lodash.invokeMap = invokeMap;
  17446. lodash.iteratee = iteratee;
  17447. lodash.keyBy = keyBy;
  17448. lodash.keys = keys;
  17449. lodash.keysIn = keysIn;
  17450. lodash.map = map;
  17451. lodash.mapKeys = mapKeys;
  17452. lodash.mapValues = mapValues;
  17453. lodash.matches = matches;
  17454. lodash.matchesProperty = matchesProperty;
  17455. lodash.memoize = memoize;
  17456. lodash.merge = merge;
  17457. lodash.mergeWith = mergeWith;
  17458. lodash.method = method;
  17459. lodash.methodOf = methodOf;
  17460. lodash.mixin = mixin;
  17461. lodash.negate = negate;
  17462. lodash.nthArg = nthArg;
  17463. lodash.omit = omit;
  17464. lodash.omitBy = omitBy;
  17465. lodash.once = once;
  17466. lodash.orderBy = orderBy;
  17467. lodash.over = over;
  17468. lodash.overArgs = overArgs;
  17469. lodash.overEvery = overEvery;
  17470. lodash.overSome = overSome;
  17471. lodash.partial = partial;
  17472. lodash.partialRight = partialRight;
  17473. lodash.partition = partition;
  17474. lodash.pick = pick;
  17475. lodash.pickBy = pickBy;
  17476. lodash.property = property;
  17477. lodash.propertyOf = propertyOf;
  17478. lodash.pull = pull;
  17479. lodash.pullAll = pullAll;
  17480. lodash.pullAllBy = pullAllBy;
  17481. lodash.pullAllWith = pullAllWith;
  17482. lodash.pullAt = pullAt;
  17483. lodash.range = range;
  17484. lodash.rangeRight = rangeRight;
  17485. lodash.rearg = rearg;
  17486. lodash.reject = reject;
  17487. lodash.remove = remove;
  17488. lodash.rest = rest;
  17489. lodash.reverse = reverse;
  17490. lodash.sampleSize = sampleSize;
  17491. lodash.set = set;
  17492. lodash.setWith = setWith;
  17493. lodash.shuffle = shuffle;
  17494. lodash.slice = slice;
  17495. lodash.sortBy = sortBy;
  17496. lodash.sortedUniq = sortedUniq;
  17497. lodash.sortedUniqBy = sortedUniqBy;
  17498. lodash.split = split;
  17499. lodash.spread = spread;
  17500. lodash.tail = tail;
  17501. lodash.take = take;
  17502. lodash.takeRight = takeRight;
  17503. lodash.takeRightWhile = takeRightWhile;
  17504. lodash.takeWhile = takeWhile;
  17505. lodash.tap = tap;
  17506. lodash.throttle = throttle;
  17507. lodash.thru = thru;
  17508. lodash.toArray = toArray;
  17509. lodash.toPairs = toPairs;
  17510. lodash.toPairsIn = toPairsIn;
  17511. lodash.toPath = toPath;
  17512. lodash.toPlainObject = toPlainObject;
  17513. lodash.transform = transform;
  17514. lodash.unary = unary;
  17515. lodash.union = union;
  17516. lodash.unionBy = unionBy;
  17517. lodash.unionWith = unionWith;
  17518. lodash.uniq = uniq;
  17519. lodash.uniqBy = uniqBy;
  17520. lodash.uniqWith = uniqWith;
  17521. lodash.unset = unset;
  17522. lodash.unzip = unzip;
  17523. lodash.unzipWith = unzipWith;
  17524. lodash.update = update;
  17525. lodash.updateWith = updateWith;
  17526. lodash.values = values;
  17527. lodash.valuesIn = valuesIn;
  17528. lodash.without = without;
  17529. lodash.words = words;
  17530. lodash.wrap = wrap;
  17531. lodash.xor = xor;
  17532. lodash.xorBy = xorBy;
  17533. lodash.xorWith = xorWith;
  17534. lodash.zip = zip;
  17535. lodash.zipObject = zipObject;
  17536. lodash.zipObjectDeep = zipObjectDeep;
  17537. lodash.zipWith = zipWith;
  17538. // Add aliases.
  17539. lodash.entries = toPairs;
  17540. lodash.entriesIn = toPairsIn;
  17541. lodash.extend = assignIn;
  17542. lodash.extendWith = assignInWith;
  17543. // Add methods to `lodash.prototype`.
  17544. mixin(lodash, lodash);
  17545. /*------------------------------------------------------------------------*/
  17546. // Add methods that return unwrapped values in chain sequences.
  17547. lodash.add = add;
  17548. lodash.attempt = attempt;
  17549. lodash.camelCase = camelCase;
  17550. lodash.capitalize = capitalize;
  17551. lodash.ceil = ceil;
  17552. lodash.clamp = clamp;
  17553. lodash.clone = clone;
  17554. lodash.cloneDeep = cloneDeep;
  17555. lodash.cloneDeepWith = cloneDeepWith;
  17556. lodash.cloneWith = cloneWith;
  17557. lodash.conformsTo = conformsTo;
  17558. lodash.deburr = deburr;
  17559. lodash.defaultTo = defaultTo;
  17560. lodash.divide = divide;
  17561. lodash.endsWith = endsWith;
  17562. lodash.eq = eq;
  17563. lodash.escape = escape;
  17564. lodash.escapeRegExp = escapeRegExp;
  17565. lodash.every = every;
  17566. lodash.find = find;
  17567. lodash.findIndex = findIndex;
  17568. lodash.findKey = findKey;
  17569. lodash.findLast = findLast;
  17570. lodash.findLastIndex = findLastIndex;
  17571. lodash.findLastKey = findLastKey;
  17572. lodash.floor = floor;
  17573. lodash.forEach = forEach;
  17574. lodash.forEachRight = forEachRight;
  17575. lodash.forIn = forIn;
  17576. lodash.forInRight = forInRight;
  17577. lodash.forOwn = forOwn;
  17578. lodash.forOwnRight = forOwnRight;
  17579. lodash.get = get;
  17580. lodash.gt = gt;
  17581. lodash.gte = gte;
  17582. lodash.has = has;
  17583. lodash.hasIn = hasIn;
  17584. lodash.head = head;
  17585. lodash.identity = identity;
  17586. lodash.includes = includes;
  17587. lodash.indexOf = indexOf;
  17588. lodash.inRange = inRange;
  17589. lodash.invoke = invoke;
  17590. lodash.isArguments = isArguments;
  17591. lodash.isArray = isArray;
  17592. lodash.isArrayBuffer = isArrayBuffer;
  17593. lodash.isArrayLike = isArrayLike;
  17594. lodash.isArrayLikeObject = isArrayLikeObject;
  17595. lodash.isBoolean = isBoolean;
  17596. lodash.isBuffer = isBuffer;
  17597. lodash.isDate = isDate;
  17598. lodash.isElement = isElement;
  17599. lodash.isEmpty = isEmpty;
  17600. lodash.isEqual = isEqual;
  17601. lodash.isEqualWith = isEqualWith;
  17602. lodash.isError = isError;
  17603. lodash.isFinite = isFinite;
  17604. lodash.isFunction = isFunction;
  17605. lodash.isInteger = isInteger;
  17606. lodash.isLength = isLength;
  17607. lodash.isMap = isMap;
  17608. lodash.isMatch = isMatch;
  17609. lodash.isMatchWith = isMatchWith;
  17610. lodash.isNaN = isNaN;
  17611. lodash.isNative = isNative;
  17612. lodash.isNil = isNil;
  17613. lodash.isNull = isNull;
  17614. lodash.isNumber = isNumber;
  17615. lodash.isObject = isObject;
  17616. lodash.isObjectLike = isObjectLike;
  17617. lodash.isPlainObject = isPlainObject;
  17618. lodash.isRegExp = isRegExp;
  17619. lodash.isSafeInteger = isSafeInteger;
  17620. lodash.isSet = isSet;
  17621. lodash.isString = isString;
  17622. lodash.isSymbol = isSymbol;
  17623. lodash.isTypedArray = isTypedArray;
  17624. lodash.isUndefined = isUndefined;
  17625. lodash.isWeakMap = isWeakMap;
  17626. lodash.isWeakSet = isWeakSet;
  17627. lodash.join = join;
  17628. lodash.kebabCase = kebabCase;
  17629. lodash.last = last;
  17630. lodash.lastIndexOf = lastIndexOf;
  17631. lodash.lowerCase = lowerCase;
  17632. lodash.lowerFirst = lowerFirst;
  17633. lodash.lt = lt;
  17634. lodash.lte = lte;
  17635. lodash.max = max;
  17636. lodash.maxBy = maxBy;
  17637. lodash.mean = mean;
  17638. lodash.meanBy = meanBy;
  17639. lodash.min = min;
  17640. lodash.minBy = minBy;
  17641. lodash.stubArray = stubArray;
  17642. lodash.stubFalse = stubFalse;
  17643. lodash.stubObject = stubObject;
  17644. lodash.stubString = stubString;
  17645. lodash.stubTrue = stubTrue;
  17646. lodash.multiply = multiply;
  17647. lodash.nth = nth;
  17648. lodash.noConflict = noConflict;
  17649. lodash.noop = noop;
  17650. lodash.now = now;
  17651. lodash.pad = pad;
  17652. lodash.padEnd = padEnd;
  17653. lodash.padStart = padStart;
  17654. lodash.parseInt = parseInt;
  17655. lodash.random = random;
  17656. lodash.reduce = reduce;
  17657. lodash.reduceRight = reduceRight;
  17658. lodash.repeat = repeat;
  17659. lodash.replace = replace;
  17660. lodash.result = result;
  17661. lodash.round = round;
  17662. lodash.runInContext = runInContext;
  17663. lodash.sample = sample;
  17664. lodash.size = size;
  17665. lodash.snakeCase = snakeCase;
  17666. lodash.some = some;
  17667. lodash.sortedIndex = sortedIndex;
  17668. lodash.sortedIndexBy = sortedIndexBy;
  17669. lodash.sortedIndexOf = sortedIndexOf;
  17670. lodash.sortedLastIndex = sortedLastIndex;
  17671. lodash.sortedLastIndexBy = sortedLastIndexBy;
  17672. lodash.sortedLastIndexOf = sortedLastIndexOf;
  17673. lodash.startCase = startCase;
  17674. lodash.startsWith = startsWith;
  17675. lodash.subtract = subtract;
  17676. lodash.sum = sum;
  17677. lodash.sumBy = sumBy;
  17678. lodash.template = template;
  17679. lodash.times = times;
  17680. lodash.toFinite = toFinite;
  17681. lodash.toInteger = toInteger;
  17682. lodash.toLength = toLength;
  17683. lodash.toLower = toLower;
  17684. lodash.toNumber = toNumber;
  17685. lodash.toSafeInteger = toSafeInteger;
  17686. lodash.toString = toString;
  17687. lodash.toUpper = toUpper;
  17688. lodash.trim = trim;
  17689. lodash.trimEnd = trimEnd;
  17690. lodash.trimStart = trimStart;
  17691. lodash.truncate = truncate;
  17692. lodash.unescape = unescape;
  17693. lodash.uniqueId = uniqueId;
  17694. lodash.upperCase = upperCase;
  17695. lodash.upperFirst = upperFirst;
  17696. // Add aliases.
  17697. lodash.each = forEach;
  17698. lodash.eachRight = forEachRight;
  17699. lodash.first = head;
  17700. mixin(lodash, (function() {
  17701. var source = {};
  17702. baseForOwn(lodash, function(func, methodName) {
  17703. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  17704. source[methodName] = func;
  17705. }
  17706. });
  17707. return source;
  17708. }()), { 'chain': false });
  17709. /*------------------------------------------------------------------------*/
  17710. /**
  17711. * The semantic version number.
  17712. *
  17713. * @static
  17714. * @memberOf _
  17715. * @type {string}
  17716. */
  17717. lodash.VERSION = VERSION;
  17718. // Assign default placeholders.
  17719. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  17720. lodash[methodName].placeholder = lodash;
  17721. });
  17722. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  17723. arrayEach(['drop', 'take'], function(methodName, index) {
  17724. LazyWrapper.prototype[methodName] = function(n) {
  17725. n = n === undefined$1 ? 1 : nativeMax(toInteger(n), 0);
  17726. var result = (this.__filtered__ && !index)
  17727. ? new LazyWrapper(this)
  17728. : this.clone();
  17729. if (result.__filtered__) {
  17730. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  17731. } else {
  17732. result.__views__.push({
  17733. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  17734. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  17735. });
  17736. }
  17737. return result;
  17738. };
  17739. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  17740. return this.reverse()[methodName](n).reverse();
  17741. };
  17742. });
  17743. // Add `LazyWrapper` methods that accept an `iteratee` value.
  17744. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  17745. var type = index + 1,
  17746. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  17747. LazyWrapper.prototype[methodName] = function(iteratee) {
  17748. var result = this.clone();
  17749. result.__iteratees__.push({
  17750. 'iteratee': getIteratee(iteratee, 3),
  17751. 'type': type
  17752. });
  17753. result.__filtered__ = result.__filtered__ || isFilter;
  17754. return result;
  17755. };
  17756. });
  17757. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  17758. arrayEach(['head', 'last'], function(methodName, index) {
  17759. var takeName = 'take' + (index ? 'Right' : '');
  17760. LazyWrapper.prototype[methodName] = function() {
  17761. return this[takeName](1).value()[0];
  17762. };
  17763. });
  17764. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  17765. arrayEach(['initial', 'tail'], function(methodName, index) {
  17766. var dropName = 'drop' + (index ? '' : 'Right');
  17767. LazyWrapper.prototype[methodName] = function() {
  17768. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  17769. };
  17770. });
  17771. LazyWrapper.prototype.compact = function() {
  17772. return this.filter(identity);
  17773. };
  17774. LazyWrapper.prototype.find = function(predicate) {
  17775. return this.filter(predicate).head();
  17776. };
  17777. LazyWrapper.prototype.findLast = function(predicate) {
  17778. return this.reverse().find(predicate);
  17779. };
  17780. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  17781. if (typeof path == 'function') {
  17782. return new LazyWrapper(this);
  17783. }
  17784. return this.map(function(value) {
  17785. return baseInvoke(value, path, args);
  17786. });
  17787. });
  17788. LazyWrapper.prototype.reject = function(predicate) {
  17789. return this.filter(negate(getIteratee(predicate)));
  17790. };
  17791. LazyWrapper.prototype.slice = function(start, end) {
  17792. start = toInteger(start);
  17793. var result = this;
  17794. if (result.__filtered__ && (start > 0 || end < 0)) {
  17795. return new LazyWrapper(result);
  17796. }
  17797. if (start < 0) {
  17798. result = result.takeRight(-start);
  17799. } else if (start) {
  17800. result = result.drop(start);
  17801. }
  17802. if (end !== undefined$1) {
  17803. end = toInteger(end);
  17804. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  17805. }
  17806. return result;
  17807. };
  17808. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  17809. return this.reverse().takeWhile(predicate).reverse();
  17810. };
  17811. LazyWrapper.prototype.toArray = function() {
  17812. return this.take(MAX_ARRAY_LENGTH);
  17813. };
  17814. // Add `LazyWrapper` methods to `lodash.prototype`.
  17815. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17816. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  17817. isTaker = /^(?:head|last)$/.test(methodName),
  17818. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  17819. retUnwrapped = isTaker || /^find/.test(methodName);
  17820. if (!lodashFunc) {
  17821. return;
  17822. }
  17823. lodash.prototype[methodName] = function() {
  17824. var value = this.__wrapped__,
  17825. args = isTaker ? [1] : arguments,
  17826. isLazy = value instanceof LazyWrapper,
  17827. iteratee = args[0],
  17828. useLazy = isLazy || isArray(value);
  17829. var interceptor = function(value) {
  17830. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  17831. return (isTaker && chainAll) ? result[0] : result;
  17832. };
  17833. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  17834. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  17835. isLazy = useLazy = false;
  17836. }
  17837. var chainAll = this.__chain__,
  17838. isHybrid = !!this.__actions__.length,
  17839. isUnwrapped = retUnwrapped && !chainAll,
  17840. onlyLazy = isLazy && !isHybrid;
  17841. if (!retUnwrapped && useLazy) {
  17842. value = onlyLazy ? value : new LazyWrapper(this);
  17843. var result = func.apply(value, args);
  17844. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined$1 });
  17845. return new LodashWrapper(result, chainAll);
  17846. }
  17847. if (isUnwrapped && onlyLazy) {
  17848. return func.apply(this, args);
  17849. }
  17850. result = this.thru(interceptor);
  17851. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  17852. };
  17853. });
  17854. // Add `Array` methods to `lodash.prototype`.
  17855. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  17856. var func = arrayProto[methodName],
  17857. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  17858. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  17859. lodash.prototype[methodName] = function() {
  17860. var args = arguments;
  17861. if (retUnwrapped && !this.__chain__) {
  17862. var value = this.value();
  17863. return func.apply(isArray(value) ? value : [], args);
  17864. }
  17865. return this[chainName](function(value) {
  17866. return func.apply(isArray(value) ? value : [], args);
  17867. });
  17868. };
  17869. });
  17870. // Map minified method names to their real names.
  17871. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17872. var lodashFunc = lodash[methodName];
  17873. if (lodashFunc) {
  17874. var key = lodashFunc.name + '';
  17875. if (!hasOwnProperty.call(realNames, key)) {
  17876. realNames[key] = [];
  17877. }
  17878. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  17879. }
  17880. });
  17881. realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
  17882. 'name': 'wrapper',
  17883. 'func': undefined$1
  17884. }];
  17885. // Add methods to `LazyWrapper`.
  17886. LazyWrapper.prototype.clone = lazyClone;
  17887. LazyWrapper.prototype.reverse = lazyReverse;
  17888. LazyWrapper.prototype.value = lazyValue;
  17889. // Add chain sequence methods to the `lodash` wrapper.
  17890. lodash.prototype.at = wrapperAt;
  17891. lodash.prototype.chain = wrapperChain;
  17892. lodash.prototype.commit = wrapperCommit;
  17893. lodash.prototype.next = wrapperNext;
  17894. lodash.prototype.plant = wrapperPlant;
  17895. lodash.prototype.reverse = wrapperReverse;
  17896. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  17897. // Add lazy aliases.
  17898. lodash.prototype.first = lodash.prototype.head;
  17899. if (symIterator) {
  17900. lodash.prototype[symIterator] = wrapperToIterator;
  17901. }
  17902. return lodash;
  17903. });
  17904. /*--------------------------------------------------------------------------*/
  17905. // Export lodash.
  17906. var _ = runInContext();
  17907. // Some AMD build optimizers, like r.js, check for condition patterns like:
  17908. if (freeModule) {
  17909. // Export for Node.js.
  17910. (freeModule.exports = _)._ = _;
  17911. // Export for CommonJS support.
  17912. freeExports._ = _;
  17913. }
  17914. else {
  17915. // Export to the global object.
  17916. root._ = _;
  17917. }
  17918. }.call(commonjsGlobal));
  17919. });
  17920. var jquery = createCommonjsModule(function (module) {
  17921. /*!
  17922. * jQuery JavaScript Library v3.6.0
  17923. * https://jquery.com/
  17924. *
  17925. * Includes Sizzle.js
  17926. * https://sizzlejs.com/
  17927. *
  17928. * Copyright OpenJS Foundation and other contributors
  17929. * Released under the MIT license
  17930. * https://jquery.org/license
  17931. *
  17932. * Date: 2021-03-02T17:08Z
  17933. */
  17934. ( function( global, factory ) {
  17935. {
  17936. // For CommonJS and CommonJS-like environments where a proper `window`
  17937. // is present, execute the factory and get jQuery.
  17938. // For environments that do not have a `window` with a `document`
  17939. // (such as Node.js), expose a factory as module.exports.
  17940. // This accentuates the need for the creation of a real `window`.
  17941. // e.g. var jQuery = require("jquery")(window);
  17942. // See ticket #14549 for more info.
  17943. module.exports = global.document ?
  17944. factory( global, true ) :
  17945. function( w ) {
  17946. if ( !w.document ) {
  17947. throw new Error( "jQuery requires a window with a document" );
  17948. }
  17949. return factory( w );
  17950. };
  17951. }
  17952. // Pass this if window is not defined yet
  17953. } )( typeof window !== "undefined" ? window : commonjsGlobal, function( window, noGlobal ) {
  17954. var arr = [];
  17955. var getProto = Object.getPrototypeOf;
  17956. var slice = arr.slice;
  17957. var flat = arr.flat ? function( array ) {
  17958. return arr.flat.call( array );
  17959. } : function( array ) {
  17960. return arr.concat.apply( [], array );
  17961. };
  17962. var push = arr.push;
  17963. var indexOf = arr.indexOf;
  17964. var class2type = {};
  17965. var toString = class2type.toString;
  17966. var hasOwn = class2type.hasOwnProperty;
  17967. var fnToString = hasOwn.toString;
  17968. var ObjectFunctionString = fnToString.call( Object );
  17969. var support = {};
  17970. var isFunction = function isFunction( obj ) {
  17971. // Support: Chrome <=57, Firefox <=52
  17972. // In some browsers, typeof returns "function" for HTML <object> elements
  17973. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  17974. // We don't want to classify *any* DOM node as a function.
  17975. // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
  17976. // Plus for old WebKit, typeof returns "function" for HTML collections
  17977. // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
  17978. return typeof obj === "function" && typeof obj.nodeType !== "number" &&
  17979. typeof obj.item !== "function";
  17980. };
  17981. var isWindow = function isWindow( obj ) {
  17982. return obj != null && obj === obj.window;
  17983. };
  17984. var document = window.document;
  17985. var preservedScriptAttributes = {
  17986. type: true,
  17987. src: true,
  17988. nonce: true,
  17989. noModule: true
  17990. };
  17991. function DOMEval( code, node, doc ) {
  17992. doc = doc || document;
  17993. var i, val,
  17994. script = doc.createElement( "script" );
  17995. script.text = code;
  17996. if ( node ) {
  17997. for ( i in preservedScriptAttributes ) {
  17998. // Support: Firefox 64+, Edge 18+
  17999. // Some browsers don't support the "nonce" property on scripts.
  18000. // On the other hand, just using `getAttribute` is not enough as
  18001. // the `nonce` attribute is reset to an empty string whenever it
  18002. // becomes browsing-context connected.
  18003. // See https://github.com/whatwg/html/issues/2369
  18004. // See https://html.spec.whatwg.org/#nonce-attributes
  18005. // The `node.getAttribute` check was added for the sake of
  18006. // `jQuery.globalEval` so that it can fake a nonce-containing node
  18007. // via an object.
  18008. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  18009. if ( val ) {
  18010. script.setAttribute( i, val );
  18011. }
  18012. }
  18013. }
  18014. doc.head.appendChild( script ).parentNode.removeChild( script );
  18015. }
  18016. function toType( obj ) {
  18017. if ( obj == null ) {
  18018. return obj + "";
  18019. }
  18020. // Support: Android <=2.3 only (functionish RegExp)
  18021. return typeof obj === "object" || typeof obj === "function" ?
  18022. class2type[ toString.call( obj ) ] || "object" :
  18023. typeof obj;
  18024. }
  18025. /* global Symbol */
  18026. // Defining this global in .eslintrc.json would create a danger of using the global
  18027. // unguarded in another place, it seems safer to define global only for this module
  18028. var
  18029. version = "3.6.0",
  18030. // Define a local copy of jQuery
  18031. jQuery = function( selector, context ) {
  18032. // The jQuery object is actually just the init constructor 'enhanced'
  18033. // Need init if jQuery is called (just allow error to be thrown if not included)
  18034. return new jQuery.fn.init( selector, context );
  18035. };
  18036. jQuery.fn = jQuery.prototype = {
  18037. // The current version of jQuery being used
  18038. jquery: version,
  18039. constructor: jQuery,
  18040. // The default length of a jQuery object is 0
  18041. length: 0,
  18042. toArray: function() {
  18043. return slice.call( this );
  18044. },
  18045. // Get the Nth element in the matched element set OR
  18046. // Get the whole matched element set as a clean array
  18047. get: function( num ) {
  18048. // Return all the elements in a clean array
  18049. if ( num == null ) {
  18050. return slice.call( this );
  18051. }
  18052. // Return just the one element from the set
  18053. return num < 0 ? this[ num + this.length ] : this[ num ];
  18054. },
  18055. // Take an array of elements and push it onto the stack
  18056. // (returning the new matched element set)
  18057. pushStack: function( elems ) {
  18058. // Build a new jQuery matched element set
  18059. var ret = jQuery.merge( this.constructor(), elems );
  18060. // Add the old object onto the stack (as a reference)
  18061. ret.prevObject = this;
  18062. // Return the newly-formed element set
  18063. return ret;
  18064. },
  18065. // Execute a callback for every element in the matched set.
  18066. each: function( callback ) {
  18067. return jQuery.each( this, callback );
  18068. },
  18069. map: function( callback ) {
  18070. return this.pushStack( jQuery.map( this, function( elem, i ) {
  18071. return callback.call( elem, i, elem );
  18072. } ) );
  18073. },
  18074. slice: function() {
  18075. return this.pushStack( slice.apply( this, arguments ) );
  18076. },
  18077. first: function() {
  18078. return this.eq( 0 );
  18079. },
  18080. last: function() {
  18081. return this.eq( -1 );
  18082. },
  18083. even: function() {
  18084. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  18085. return ( i + 1 ) % 2;
  18086. } ) );
  18087. },
  18088. odd: function() {
  18089. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  18090. return i % 2;
  18091. } ) );
  18092. },
  18093. eq: function( i ) {
  18094. var len = this.length,
  18095. j = +i + ( i < 0 ? len : 0 );
  18096. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  18097. },
  18098. end: function() {
  18099. return this.prevObject || this.constructor();
  18100. },
  18101. // For internal use only.
  18102. // Behaves like an Array's method, not like a jQuery method.
  18103. push: push,
  18104. sort: arr.sort,
  18105. splice: arr.splice
  18106. };
  18107. jQuery.extend = jQuery.fn.extend = function() {
  18108. var options, name, src, copy, copyIsArray, clone,
  18109. target = arguments[ 0 ] || {},
  18110. i = 1,
  18111. length = arguments.length,
  18112. deep = false;
  18113. // Handle a deep copy situation
  18114. if ( typeof target === "boolean" ) {
  18115. deep = target;
  18116. // Skip the boolean and the target
  18117. target = arguments[ i ] || {};
  18118. i++;
  18119. }
  18120. // Handle case when target is a string or something (possible in deep copy)
  18121. if ( typeof target !== "object" && !isFunction( target ) ) {
  18122. target = {};
  18123. }
  18124. // Extend jQuery itself if only one argument is passed
  18125. if ( i === length ) {
  18126. target = this;
  18127. i--;
  18128. }
  18129. for ( ; i < length; i++ ) {
  18130. // Only deal with non-null/undefined values
  18131. if ( ( options = arguments[ i ] ) != null ) {
  18132. // Extend the base object
  18133. for ( name in options ) {
  18134. copy = options[ name ];
  18135. // Prevent Object.prototype pollution
  18136. // Prevent never-ending loop
  18137. if ( name === "__proto__" || target === copy ) {
  18138. continue;
  18139. }
  18140. // Recurse if we're merging plain objects or arrays
  18141. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  18142. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  18143. src = target[ name ];
  18144. // Ensure proper type for the source value
  18145. if ( copyIsArray && !Array.isArray( src ) ) {
  18146. clone = [];
  18147. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  18148. clone = {};
  18149. } else {
  18150. clone = src;
  18151. }
  18152. copyIsArray = false;
  18153. // Never move original objects, clone them
  18154. target[ name ] = jQuery.extend( deep, clone, copy );
  18155. // Don't bring in undefined values
  18156. } else if ( copy !== undefined ) {
  18157. target[ name ] = copy;
  18158. }
  18159. }
  18160. }
  18161. }
  18162. // Return the modified object
  18163. return target;
  18164. };
  18165. jQuery.extend( {
  18166. // Unique for each copy of jQuery on the page
  18167. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  18168. // Assume jQuery is ready without the ready module
  18169. isReady: true,
  18170. error: function( msg ) {
  18171. throw new Error( msg );
  18172. },
  18173. noop: function() {},
  18174. isPlainObject: function( obj ) {
  18175. var proto, Ctor;
  18176. // Detect obvious negatives
  18177. // Use toString instead of jQuery.type to catch host objects
  18178. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  18179. return false;
  18180. }
  18181. proto = getProto( obj );
  18182. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  18183. if ( !proto ) {
  18184. return true;
  18185. }
  18186. // Objects with prototype are plain iff they were constructed by a global Object function
  18187. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  18188. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  18189. },
  18190. isEmptyObject: function( obj ) {
  18191. var name;
  18192. for ( name in obj ) {
  18193. return false;
  18194. }
  18195. return true;
  18196. },
  18197. // Evaluates a script in a provided context; falls back to the global one
  18198. // if not specified.
  18199. globalEval: function( code, options, doc ) {
  18200. DOMEval( code, { nonce: options && options.nonce }, doc );
  18201. },
  18202. each: function( obj, callback ) {
  18203. var length, i = 0;
  18204. if ( isArrayLike( obj ) ) {
  18205. length = obj.length;
  18206. for ( ; i < length; i++ ) {
  18207. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  18208. break;
  18209. }
  18210. }
  18211. } else {
  18212. for ( i in obj ) {
  18213. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  18214. break;
  18215. }
  18216. }
  18217. }
  18218. return obj;
  18219. },
  18220. // results is for internal usage only
  18221. makeArray: function( arr, results ) {
  18222. var ret = results || [];
  18223. if ( arr != null ) {
  18224. if ( isArrayLike( Object( arr ) ) ) {
  18225. jQuery.merge( ret,
  18226. typeof arr === "string" ?
  18227. [ arr ] : arr
  18228. );
  18229. } else {
  18230. push.call( ret, arr );
  18231. }
  18232. }
  18233. return ret;
  18234. },
  18235. inArray: function( elem, arr, i ) {
  18236. return arr == null ? -1 : indexOf.call( arr, elem, i );
  18237. },
  18238. // Support: Android <=4.0 only, PhantomJS 1 only
  18239. // push.apply(_, arraylike) throws on ancient WebKit
  18240. merge: function( first, second ) {
  18241. var len = +second.length,
  18242. j = 0,
  18243. i = first.length;
  18244. for ( ; j < len; j++ ) {
  18245. first[ i++ ] = second[ j ];
  18246. }
  18247. first.length = i;
  18248. return first;
  18249. },
  18250. grep: function( elems, callback, invert ) {
  18251. var callbackInverse,
  18252. matches = [],
  18253. i = 0,
  18254. length = elems.length,
  18255. callbackExpect = !invert;
  18256. // Go through the array, only saving the items
  18257. // that pass the validator function
  18258. for ( ; i < length; i++ ) {
  18259. callbackInverse = !callback( elems[ i ], i );
  18260. if ( callbackInverse !== callbackExpect ) {
  18261. matches.push( elems[ i ] );
  18262. }
  18263. }
  18264. return matches;
  18265. },
  18266. // arg is for internal usage only
  18267. map: function( elems, callback, arg ) {
  18268. var length, value,
  18269. i = 0,
  18270. ret = [];
  18271. // Go through the array, translating each of the items to their new values
  18272. if ( isArrayLike( elems ) ) {
  18273. length = elems.length;
  18274. for ( ; i < length; i++ ) {
  18275. value = callback( elems[ i ], i, arg );
  18276. if ( value != null ) {
  18277. ret.push( value );
  18278. }
  18279. }
  18280. // Go through every key on the object,
  18281. } else {
  18282. for ( i in elems ) {
  18283. value = callback( elems[ i ], i, arg );
  18284. if ( value != null ) {
  18285. ret.push( value );
  18286. }
  18287. }
  18288. }
  18289. // Flatten any nested arrays
  18290. return flat( ret );
  18291. },
  18292. // A global GUID counter for objects
  18293. guid: 1,
  18294. // jQuery.support is not used in Core but other projects attach their
  18295. // properties to it so it needs to exist.
  18296. support: support
  18297. } );
  18298. if ( typeof Symbol === "function" ) {
  18299. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  18300. }
  18301. // Populate the class2type map
  18302. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  18303. function( _i, name ) {
  18304. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  18305. } );
  18306. function isArrayLike( obj ) {
  18307. // Support: real iOS 8.2 only (not reproducible in simulator)
  18308. // `in` check used to prevent JIT error (gh-2145)
  18309. // hasOwn isn't used here due to false negatives
  18310. // regarding Nodelist length in IE
  18311. var length = !!obj && "length" in obj && obj.length,
  18312. type = toType( obj );
  18313. if ( isFunction( obj ) || isWindow( obj ) ) {
  18314. return false;
  18315. }
  18316. return type === "array" || length === 0 ||
  18317. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  18318. }
  18319. var Sizzle =
  18320. /*!
  18321. * Sizzle CSS Selector Engine v2.3.6
  18322. * https://sizzlejs.com/
  18323. *
  18324. * Copyright JS Foundation and other contributors
  18325. * Released under the MIT license
  18326. * https://js.foundation/
  18327. *
  18328. * Date: 2021-02-16
  18329. */
  18330. ( function( window ) {
  18331. var i,
  18332. support,
  18333. Expr,
  18334. getText,
  18335. isXML,
  18336. tokenize,
  18337. compile,
  18338. select,
  18339. outermostContext,
  18340. sortInput,
  18341. hasDuplicate,
  18342. // Local document vars
  18343. setDocument,
  18344. document,
  18345. docElem,
  18346. documentIsHTML,
  18347. rbuggyQSA,
  18348. rbuggyMatches,
  18349. matches,
  18350. contains,
  18351. // Instance-specific data
  18352. expando = "sizzle" + 1 * new Date(),
  18353. preferredDoc = window.document,
  18354. dirruns = 0,
  18355. done = 0,
  18356. classCache = createCache(),
  18357. tokenCache = createCache(),
  18358. compilerCache = createCache(),
  18359. nonnativeSelectorCache = createCache(),
  18360. sortOrder = function( a, b ) {
  18361. if ( a === b ) {
  18362. hasDuplicate = true;
  18363. }
  18364. return 0;
  18365. },
  18366. // Instance methods
  18367. hasOwn = ( {} ).hasOwnProperty,
  18368. arr = [],
  18369. pop = arr.pop,
  18370. pushNative = arr.push,
  18371. push = arr.push,
  18372. slice = arr.slice,
  18373. // Use a stripped-down indexOf as it's faster than native
  18374. // https://jsperf.com/thor-indexof-vs-for/5
  18375. indexOf = function( list, elem ) {
  18376. var i = 0,
  18377. len = list.length;
  18378. for ( ; i < len; i++ ) {
  18379. if ( list[ i ] === elem ) {
  18380. return i;
  18381. }
  18382. }
  18383. return -1;
  18384. },
  18385. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
  18386. "ismap|loop|multiple|open|readonly|required|scoped",
  18387. // Regular expressions
  18388. // http://www.w3.org/TR/css3-selectors/#whitespace
  18389. whitespace = "[\\x20\\t\\r\\n\\f]",
  18390. // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
  18391. identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
  18392. "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
  18393. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  18394. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  18395. // Operator (capture 2)
  18396. "*([*^$|!~]?=)" + whitespace +
  18397. // "Attribute values must be CSS identifiers [capture 5]
  18398. // or strings [capture 3 or capture 4]"
  18399. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
  18400. whitespace + "*\\]",
  18401. pseudos = ":(" + identifier + ")(?:\\((" +
  18402. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  18403. // 1. quoted (capture 3; capture 4 or capture 5)
  18404. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  18405. // 2. simple (capture 6)
  18406. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  18407. // 3. anything else (capture 2)
  18408. ".*" +
  18409. ")\\)|)",
  18410. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  18411. rwhitespace = new RegExp( whitespace + "+", "g" ),
  18412. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
  18413. whitespace + "+$", "g" ),
  18414. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  18415. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
  18416. "*" ),
  18417. rdescend = new RegExp( whitespace + "|>" ),
  18418. rpseudo = new RegExp( pseudos ),
  18419. ridentifier = new RegExp( "^" + identifier + "$" ),
  18420. matchExpr = {
  18421. "ID": new RegExp( "^#(" + identifier + ")" ),
  18422. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  18423. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  18424. "ATTR": new RegExp( "^" + attributes ),
  18425. "PSEUDO": new RegExp( "^" + pseudos ),
  18426. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
  18427. whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
  18428. whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  18429. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  18430. // For use in libraries implementing .is()
  18431. // We use this for POS matching in `select`
  18432. "needsContext": new RegExp( "^" + whitespace +
  18433. "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  18434. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  18435. },
  18436. rhtml = /HTML$/i,
  18437. rinputs = /^(?:input|select|textarea|button)$/i,
  18438. rheader = /^h\d$/i,
  18439. rnative = /^[^{]+\{\s*\[native \w/,
  18440. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  18441. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  18442. rsibling = /[+~]/,
  18443. // CSS escapes
  18444. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  18445. runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
  18446. funescape = function( escape, nonHex ) {
  18447. var high = "0x" + escape.slice( 1 ) - 0x10000;
  18448. return nonHex ?
  18449. // Strip the backslash prefix from a non-hex escape sequence
  18450. nonHex :
  18451. // Replace a hexadecimal escape sequence with the encoded Unicode code point
  18452. // Support: IE <=11+
  18453. // For values outside the Basic Multilingual Plane (BMP), manually construct a
  18454. // surrogate pair
  18455. high < 0 ?
  18456. String.fromCharCode( high + 0x10000 ) :
  18457. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  18458. },
  18459. // CSS string/identifier serialization
  18460. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  18461. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  18462. fcssescape = function( ch, asCodePoint ) {
  18463. if ( asCodePoint ) {
  18464. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  18465. if ( ch === "\0" ) {
  18466. return "\uFFFD";
  18467. }
  18468. // Control characters and (dependent upon position) numbers get escaped as code points
  18469. return ch.slice( 0, -1 ) + "\\" +
  18470. ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  18471. }
  18472. // Other potentially-special ASCII characters get backslash-escaped
  18473. return "\\" + ch;
  18474. },
  18475. // Used for iframes
  18476. // See setDocument()
  18477. // Removing the function wrapper causes a "Permission Denied"
  18478. // error in IE
  18479. unloadHandler = function() {
  18480. setDocument();
  18481. },
  18482. inDisabledFieldset = addCombinator(
  18483. function( elem ) {
  18484. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  18485. },
  18486. { dir: "parentNode", next: "legend" }
  18487. );
  18488. // Optimize for push.apply( _, NodeList )
  18489. try {
  18490. push.apply(
  18491. ( arr = slice.call( preferredDoc.childNodes ) ),
  18492. preferredDoc.childNodes
  18493. );
  18494. // Support: Android<4.0
  18495. // Detect silently failing push.apply
  18496. // eslint-disable-next-line no-unused-expressions
  18497. arr[ preferredDoc.childNodes.length ].nodeType;
  18498. } catch ( e ) {
  18499. push = { apply: arr.length ?
  18500. // Leverage slice if possible
  18501. function( target, els ) {
  18502. pushNative.apply( target, slice.call( els ) );
  18503. } :
  18504. // Support: IE<9
  18505. // Otherwise append directly
  18506. function( target, els ) {
  18507. var j = target.length,
  18508. i = 0;
  18509. // Can't trust NodeList.length
  18510. while ( ( target[ j++ ] = els[ i++ ] ) ) {}
  18511. target.length = j - 1;
  18512. }
  18513. };
  18514. }
  18515. function Sizzle( selector, context, results, seed ) {
  18516. var m, i, elem, nid, match, groups, newSelector,
  18517. newContext = context && context.ownerDocument,
  18518. // nodeType defaults to 9, since context defaults to document
  18519. nodeType = context ? context.nodeType : 9;
  18520. results = results || [];
  18521. // Return early from calls with invalid selector or context
  18522. if ( typeof selector !== "string" || !selector ||
  18523. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  18524. return results;
  18525. }
  18526. // Try to shortcut find operations (as opposed to filters) in HTML documents
  18527. if ( !seed ) {
  18528. setDocument( context );
  18529. context = context || document;
  18530. if ( documentIsHTML ) {
  18531. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  18532. // (excepting DocumentFragment context, where the methods don't exist)
  18533. if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
  18534. // ID selector
  18535. if ( ( m = match[ 1 ] ) ) {
  18536. // Document context
  18537. if ( nodeType === 9 ) {
  18538. if ( ( elem = context.getElementById( m ) ) ) {
  18539. // Support: IE, Opera, Webkit
  18540. // TODO: identify versions
  18541. // getElementById can match elements by name instead of ID
  18542. if ( elem.id === m ) {
  18543. results.push( elem );
  18544. return results;
  18545. }
  18546. } else {
  18547. return results;
  18548. }
  18549. // Element context
  18550. } else {
  18551. // Support: IE, Opera, Webkit
  18552. // TODO: identify versions
  18553. // getElementById can match elements by name instead of ID
  18554. if ( newContext && ( elem = newContext.getElementById( m ) ) &&
  18555. contains( context, elem ) &&
  18556. elem.id === m ) {
  18557. results.push( elem );
  18558. return results;
  18559. }
  18560. }
  18561. // Type selector
  18562. } else if ( match[ 2 ] ) {
  18563. push.apply( results, context.getElementsByTagName( selector ) );
  18564. return results;
  18565. // Class selector
  18566. } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
  18567. context.getElementsByClassName ) {
  18568. push.apply( results, context.getElementsByClassName( m ) );
  18569. return results;
  18570. }
  18571. }
  18572. // Take advantage of querySelectorAll
  18573. if ( support.qsa &&
  18574. !nonnativeSelectorCache[ selector + " " ] &&
  18575. ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
  18576. // Support: IE 8 only
  18577. // Exclude object elements
  18578. ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
  18579. newSelector = selector;
  18580. newContext = context;
  18581. // qSA considers elements outside a scoping root when evaluating child or
  18582. // descendant combinators, which is not what we want.
  18583. // In such cases, we work around the behavior by prefixing every selector in the
  18584. // list with an ID selector referencing the scope context.
  18585. // The technique has to be used as well when a leading combinator is used
  18586. // as such selectors are not recognized by querySelectorAll.
  18587. // Thanks to Andrew Dupont for this technique.
  18588. if ( nodeType === 1 &&
  18589. ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
  18590. // Expand context for sibling selectors
  18591. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  18592. context;
  18593. // We can use :scope instead of the ID hack if the browser
  18594. // supports it & if we're not changing the context.
  18595. if ( newContext !== context || !support.scope ) {
  18596. // Capture the context ID, setting it first if necessary
  18597. if ( ( nid = context.getAttribute( "id" ) ) ) {
  18598. nid = nid.replace( rcssescape, fcssescape );
  18599. } else {
  18600. context.setAttribute( "id", ( nid = expando ) );
  18601. }
  18602. }
  18603. // Prefix every selector in the list
  18604. groups = tokenize( selector );
  18605. i = groups.length;
  18606. while ( i-- ) {
  18607. groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
  18608. toSelector( groups[ i ] );
  18609. }
  18610. newSelector = groups.join( "," );
  18611. }
  18612. try {
  18613. push.apply( results,
  18614. newContext.querySelectorAll( newSelector )
  18615. );
  18616. return results;
  18617. } catch ( qsaError ) {
  18618. nonnativeSelectorCache( selector, true );
  18619. } finally {
  18620. if ( nid === expando ) {
  18621. context.removeAttribute( "id" );
  18622. }
  18623. }
  18624. }
  18625. }
  18626. }
  18627. // All others
  18628. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  18629. }
  18630. /**
  18631. * Create key-value caches of limited size
  18632. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  18633. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  18634. * deleting the oldest entry
  18635. */
  18636. function createCache() {
  18637. var keys = [];
  18638. function cache( key, value ) {
  18639. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  18640. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  18641. // Only keep the most recent entries
  18642. delete cache[ keys.shift() ];
  18643. }
  18644. return ( cache[ key + " " ] = value );
  18645. }
  18646. return cache;
  18647. }
  18648. /**
  18649. * Mark a function for special use by Sizzle
  18650. * @param {Function} fn The function to mark
  18651. */
  18652. function markFunction( fn ) {
  18653. fn[ expando ] = true;
  18654. return fn;
  18655. }
  18656. /**
  18657. * Support testing using an element
  18658. * @param {Function} fn Passed the created element and returns a boolean result
  18659. */
  18660. function assert( fn ) {
  18661. var el = document.createElement( "fieldset" );
  18662. try {
  18663. return !!fn( el );
  18664. } catch ( e ) {
  18665. return false;
  18666. } finally {
  18667. // Remove from its parent by default
  18668. if ( el.parentNode ) {
  18669. el.parentNode.removeChild( el );
  18670. }
  18671. // release memory in IE
  18672. el = null;
  18673. }
  18674. }
  18675. /**
  18676. * Adds the same handler for all of the specified attrs
  18677. * @param {String} attrs Pipe-separated list of attributes
  18678. * @param {Function} handler The method that will be applied
  18679. */
  18680. function addHandle( attrs, handler ) {
  18681. var arr = attrs.split( "|" ),
  18682. i = arr.length;
  18683. while ( i-- ) {
  18684. Expr.attrHandle[ arr[ i ] ] = handler;
  18685. }
  18686. }
  18687. /**
  18688. * Checks document order of two siblings
  18689. * @param {Element} a
  18690. * @param {Element} b
  18691. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  18692. */
  18693. function siblingCheck( a, b ) {
  18694. var cur = b && a,
  18695. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  18696. a.sourceIndex - b.sourceIndex;
  18697. // Use IE sourceIndex if available on both nodes
  18698. if ( diff ) {
  18699. return diff;
  18700. }
  18701. // Check if b follows a
  18702. if ( cur ) {
  18703. while ( ( cur = cur.nextSibling ) ) {
  18704. if ( cur === b ) {
  18705. return -1;
  18706. }
  18707. }
  18708. }
  18709. return a ? 1 : -1;
  18710. }
  18711. /**
  18712. * Returns a function to use in pseudos for input types
  18713. * @param {String} type
  18714. */
  18715. function createInputPseudo( type ) {
  18716. return function( elem ) {
  18717. var name = elem.nodeName.toLowerCase();
  18718. return name === "input" && elem.type === type;
  18719. };
  18720. }
  18721. /**
  18722. * Returns a function to use in pseudos for buttons
  18723. * @param {String} type
  18724. */
  18725. function createButtonPseudo( type ) {
  18726. return function( elem ) {
  18727. var name = elem.nodeName.toLowerCase();
  18728. return ( name === "input" || name === "button" ) && elem.type === type;
  18729. };
  18730. }
  18731. /**
  18732. * Returns a function to use in pseudos for :enabled/:disabled
  18733. * @param {Boolean} disabled true for :disabled; false for :enabled
  18734. */
  18735. function createDisabledPseudo( disabled ) {
  18736. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  18737. return function( elem ) {
  18738. // Only certain elements can match :enabled or :disabled
  18739. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  18740. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  18741. if ( "form" in elem ) {
  18742. // Check for inherited disabledness on relevant non-disabled elements:
  18743. // * listed form-associated elements in a disabled fieldset
  18744. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  18745. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  18746. // * option elements in a disabled optgroup
  18747. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  18748. // All such elements have a "form" property.
  18749. if ( elem.parentNode && elem.disabled === false ) {
  18750. // Option elements defer to a parent optgroup if present
  18751. if ( "label" in elem ) {
  18752. if ( "label" in elem.parentNode ) {
  18753. return elem.parentNode.disabled === disabled;
  18754. } else {
  18755. return elem.disabled === disabled;
  18756. }
  18757. }
  18758. // Support: IE 6 - 11
  18759. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  18760. return elem.isDisabled === disabled ||
  18761. // Where there is no isDisabled, check manually
  18762. /* jshint -W018 */
  18763. elem.isDisabled !== !disabled &&
  18764. inDisabledFieldset( elem ) === disabled;
  18765. }
  18766. return elem.disabled === disabled;
  18767. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  18768. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  18769. // even exist on them, let alone have a boolean value.
  18770. } else if ( "label" in elem ) {
  18771. return elem.disabled === disabled;
  18772. }
  18773. // Remaining elements are neither :enabled nor :disabled
  18774. return false;
  18775. };
  18776. }
  18777. /**
  18778. * Returns a function to use in pseudos for positionals
  18779. * @param {Function} fn
  18780. */
  18781. function createPositionalPseudo( fn ) {
  18782. return markFunction( function( argument ) {
  18783. argument = +argument;
  18784. return markFunction( function( seed, matches ) {
  18785. var j,
  18786. matchIndexes = fn( [], seed.length, argument ),
  18787. i = matchIndexes.length;
  18788. // Match elements found at the specified indexes
  18789. while ( i-- ) {
  18790. if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
  18791. seed[ j ] = !( matches[ j ] = seed[ j ] );
  18792. }
  18793. }
  18794. } );
  18795. } );
  18796. }
  18797. /**
  18798. * Checks a node for validity as a Sizzle context
  18799. * @param {Element|Object=} context
  18800. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  18801. */
  18802. function testContext( context ) {
  18803. return context && typeof context.getElementsByTagName !== "undefined" && context;
  18804. }
  18805. // Expose support vars for convenience
  18806. support = Sizzle.support = {};
  18807. /**
  18808. * Detects XML nodes
  18809. * @param {Element|Object} elem An element or a document
  18810. * @returns {Boolean} True iff elem is a non-HTML XML node
  18811. */
  18812. isXML = Sizzle.isXML = function( elem ) {
  18813. var namespace = elem && elem.namespaceURI,
  18814. docElem = elem && ( elem.ownerDocument || elem ).documentElement;
  18815. // Support: IE <=8
  18816. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  18817. // https://bugs.jquery.com/ticket/4833
  18818. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  18819. };
  18820. /**
  18821. * Sets document-related variables once based on the current document
  18822. * @param {Element|Object} [doc] An element or document object to use to set the document
  18823. * @returns {Object} Returns the current document
  18824. */
  18825. setDocument = Sizzle.setDocument = function( node ) {
  18826. var hasCompare, subWindow,
  18827. doc = node ? node.ownerDocument || node : preferredDoc;
  18828. // Return early if doc is invalid or already selected
  18829. // Support: IE 11+, Edge 17 - 18+
  18830. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  18831. // two documents; shallow comparisons work.
  18832. // eslint-disable-next-line eqeqeq
  18833. if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
  18834. return document;
  18835. }
  18836. // Update global variables
  18837. document = doc;
  18838. docElem = document.documentElement;
  18839. documentIsHTML = !isXML( document );
  18840. // Support: IE 9 - 11+, Edge 12 - 18+
  18841. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  18842. // Support: IE 11+, Edge 17 - 18+
  18843. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  18844. // two documents; shallow comparisons work.
  18845. // eslint-disable-next-line eqeqeq
  18846. if ( preferredDoc != document &&
  18847. ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
  18848. // Support: IE 11, Edge
  18849. if ( subWindow.addEventListener ) {
  18850. subWindow.addEventListener( "unload", unloadHandler, false );
  18851. // Support: IE 9 - 10 only
  18852. } else if ( subWindow.attachEvent ) {
  18853. subWindow.attachEvent( "onunload", unloadHandler );
  18854. }
  18855. }
  18856. // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
  18857. // Safari 4 - 5 only, Opera <=11.6 - 12.x only
  18858. // IE/Edge & older browsers don't support the :scope pseudo-class.
  18859. // Support: Safari 6.0 only
  18860. // Safari 6.0 supports :scope but it's an alias of :root there.
  18861. support.scope = assert( function( el ) {
  18862. docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
  18863. return typeof el.querySelectorAll !== "undefined" &&
  18864. !el.querySelectorAll( ":scope fieldset div" ).length;
  18865. } );
  18866. /* Attributes
  18867. ---------------------------------------------------------------------- */
  18868. // Support: IE<8
  18869. // Verify that getAttribute really returns attributes and not properties
  18870. // (excepting IE8 booleans)
  18871. support.attributes = assert( function( el ) {
  18872. el.className = "i";
  18873. return !el.getAttribute( "className" );
  18874. } );
  18875. /* getElement(s)By*
  18876. ---------------------------------------------------------------------- */
  18877. // Check if getElementsByTagName("*") returns only elements
  18878. support.getElementsByTagName = assert( function( el ) {
  18879. el.appendChild( document.createComment( "" ) );
  18880. return !el.getElementsByTagName( "*" ).length;
  18881. } );
  18882. // Support: IE<9
  18883. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  18884. // Support: IE<10
  18885. // Check if getElementById returns elements by name
  18886. // The broken getElementById methods don't pick up programmatically-set names,
  18887. // so use a roundabout getElementsByName test
  18888. support.getById = assert( function( el ) {
  18889. docElem.appendChild( el ).id = expando;
  18890. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  18891. } );
  18892. // ID filter and find
  18893. if ( support.getById ) {
  18894. Expr.filter[ "ID" ] = function( id ) {
  18895. var attrId = id.replace( runescape, funescape );
  18896. return function( elem ) {
  18897. return elem.getAttribute( "id" ) === attrId;
  18898. };
  18899. };
  18900. Expr.find[ "ID" ] = function( id, context ) {
  18901. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  18902. var elem = context.getElementById( id );
  18903. return elem ? [ elem ] : [];
  18904. }
  18905. };
  18906. } else {
  18907. Expr.filter[ "ID" ] = function( id ) {
  18908. var attrId = id.replace( runescape, funescape );
  18909. return function( elem ) {
  18910. var node = typeof elem.getAttributeNode !== "undefined" &&
  18911. elem.getAttributeNode( "id" );
  18912. return node && node.value === attrId;
  18913. };
  18914. };
  18915. // Support: IE 6 - 7 only
  18916. // getElementById is not reliable as a find shortcut
  18917. Expr.find[ "ID" ] = function( id, context ) {
  18918. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  18919. var node, i, elems,
  18920. elem = context.getElementById( id );
  18921. if ( elem ) {
  18922. // Verify the id attribute
  18923. node = elem.getAttributeNode( "id" );
  18924. if ( node && node.value === id ) {
  18925. return [ elem ];
  18926. }
  18927. // Fall back on getElementsByName
  18928. elems = context.getElementsByName( id );
  18929. i = 0;
  18930. while ( ( elem = elems[ i++ ] ) ) {
  18931. node = elem.getAttributeNode( "id" );
  18932. if ( node && node.value === id ) {
  18933. return [ elem ];
  18934. }
  18935. }
  18936. }
  18937. return [];
  18938. }
  18939. };
  18940. }
  18941. // Tag
  18942. Expr.find[ "TAG" ] = support.getElementsByTagName ?
  18943. function( tag, context ) {
  18944. if ( typeof context.getElementsByTagName !== "undefined" ) {
  18945. return context.getElementsByTagName( tag );
  18946. // DocumentFragment nodes don't have gEBTN
  18947. } else if ( support.qsa ) {
  18948. return context.querySelectorAll( tag );
  18949. }
  18950. } :
  18951. function( tag, context ) {
  18952. var elem,
  18953. tmp = [],
  18954. i = 0,
  18955. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  18956. results = context.getElementsByTagName( tag );
  18957. // Filter out possible comments
  18958. if ( tag === "*" ) {
  18959. while ( ( elem = results[ i++ ] ) ) {
  18960. if ( elem.nodeType === 1 ) {
  18961. tmp.push( elem );
  18962. }
  18963. }
  18964. return tmp;
  18965. }
  18966. return results;
  18967. };
  18968. // Class
  18969. Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
  18970. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  18971. return context.getElementsByClassName( className );
  18972. }
  18973. };
  18974. /* QSA/matchesSelector
  18975. ---------------------------------------------------------------------- */
  18976. // QSA and matchesSelector support
  18977. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  18978. rbuggyMatches = [];
  18979. // qSa(:focus) reports false when true (Chrome 21)
  18980. // We allow this because of a bug in IE8/9 that throws an error
  18981. // whenever `document.activeElement` is accessed on an iframe
  18982. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  18983. // See https://bugs.jquery.com/ticket/13378
  18984. rbuggyQSA = [];
  18985. if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
  18986. // Build QSA regex
  18987. // Regex strategy adopted from Diego Perini
  18988. assert( function( el ) {
  18989. var input;
  18990. // Select is set to empty string on purpose
  18991. // This is to test IE's treatment of not explicitly
  18992. // setting a boolean content attribute,
  18993. // since its presence should be enough
  18994. // https://bugs.jquery.com/ticket/12359
  18995. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  18996. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  18997. "<option selected=''></option></select>";
  18998. // Support: IE8, Opera 11-12.16
  18999. // Nothing should be selected when empty strings follow ^= or $= or *=
  19000. // The test attribute must be unknown in Opera but "safe" for WinRT
  19001. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  19002. if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
  19003. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  19004. }
  19005. // Support: IE8
  19006. // Boolean attributes and "value" are not treated correctly
  19007. if ( !el.querySelectorAll( "[selected]" ).length ) {
  19008. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  19009. }
  19010. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  19011. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  19012. rbuggyQSA.push( "~=" );
  19013. }
  19014. // Support: IE 11+, Edge 15 - 18+
  19015. // IE 11/Edge don't find elements on a `[name='']` query in some cases.
  19016. // Adding a temporary attribute to the document before the selection works
  19017. // around the issue.
  19018. // Interestingly, IE 10 & older don't seem to have the issue.
  19019. input = document.createElement( "input" );
  19020. input.setAttribute( "name", "" );
  19021. el.appendChild( input );
  19022. if ( !el.querySelectorAll( "[name='']" ).length ) {
  19023. rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
  19024. whitespace + "*(?:''|\"\")" );
  19025. }
  19026. // Webkit/Opera - :checked should return selected option elements
  19027. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  19028. // IE8 throws error here and will not see later tests
  19029. if ( !el.querySelectorAll( ":checked" ).length ) {
  19030. rbuggyQSA.push( ":checked" );
  19031. }
  19032. // Support: Safari 8+, iOS 8+
  19033. // https://bugs.webkit.org/show_bug.cgi?id=136851
  19034. // In-page `selector#id sibling-combinator selector` fails
  19035. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  19036. rbuggyQSA.push( ".#.+[+~]" );
  19037. }
  19038. // Support: Firefox <=3.6 - 5 only
  19039. // Old Firefox doesn't throw on a badly-escaped identifier.
  19040. el.querySelectorAll( "\\\f" );
  19041. rbuggyQSA.push( "[\\r\\n\\f]" );
  19042. } );
  19043. assert( function( el ) {
  19044. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  19045. "<select disabled='disabled'><option/></select>";
  19046. // Support: Windows 8 Native Apps
  19047. // The type and name attributes are restricted during .innerHTML assignment
  19048. var input = document.createElement( "input" );
  19049. input.setAttribute( "type", "hidden" );
  19050. el.appendChild( input ).setAttribute( "name", "D" );
  19051. // Support: IE8
  19052. // Enforce case-sensitivity of name attribute
  19053. if ( el.querySelectorAll( "[name=d]" ).length ) {
  19054. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  19055. }
  19056. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  19057. // IE8 throws error here and will not see later tests
  19058. if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
  19059. rbuggyQSA.push( ":enabled", ":disabled" );
  19060. }
  19061. // Support: IE9-11+
  19062. // IE's :disabled selector does not pick up the children of disabled fieldsets
  19063. docElem.appendChild( el ).disabled = true;
  19064. if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
  19065. rbuggyQSA.push( ":enabled", ":disabled" );
  19066. }
  19067. // Support: Opera 10 - 11 only
  19068. // Opera 10-11 does not throw on post-comma invalid pseudos
  19069. el.querySelectorAll( "*,:x" );
  19070. rbuggyQSA.push( ",.*:" );
  19071. } );
  19072. }
  19073. if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
  19074. docElem.webkitMatchesSelector ||
  19075. docElem.mozMatchesSelector ||
  19076. docElem.oMatchesSelector ||
  19077. docElem.msMatchesSelector ) ) ) ) {
  19078. assert( function( el ) {
  19079. // Check to see if it's possible to do matchesSelector
  19080. // on a disconnected node (IE 9)
  19081. support.disconnectedMatch = matches.call( el, "*" );
  19082. // This should fail with an exception
  19083. // Gecko does not error, returns false instead
  19084. matches.call( el, "[s!='']:x" );
  19085. rbuggyMatches.push( "!=", pseudos );
  19086. } );
  19087. }
  19088. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
  19089. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
  19090. /* Contains
  19091. ---------------------------------------------------------------------- */
  19092. hasCompare = rnative.test( docElem.compareDocumentPosition );
  19093. // Element contains another
  19094. // Purposefully self-exclusive
  19095. // As in, an element does not contain itself
  19096. contains = hasCompare || rnative.test( docElem.contains ) ?
  19097. function( a, b ) {
  19098. var adown = a.nodeType === 9 ? a.documentElement : a,
  19099. bup = b && b.parentNode;
  19100. return a === bup || !!( bup && bup.nodeType === 1 && (
  19101. adown.contains ?
  19102. adown.contains( bup ) :
  19103. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  19104. ) );
  19105. } :
  19106. function( a, b ) {
  19107. if ( b ) {
  19108. while ( ( b = b.parentNode ) ) {
  19109. if ( b === a ) {
  19110. return true;
  19111. }
  19112. }
  19113. }
  19114. return false;
  19115. };
  19116. /* Sorting
  19117. ---------------------------------------------------------------------- */
  19118. // Document order sorting
  19119. sortOrder = hasCompare ?
  19120. function( a, b ) {
  19121. // Flag for duplicate removal
  19122. if ( a === b ) {
  19123. hasDuplicate = true;
  19124. return 0;
  19125. }
  19126. // Sort on method existence if only one input has compareDocumentPosition
  19127. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  19128. if ( compare ) {
  19129. return compare;
  19130. }
  19131. // Calculate position if both inputs belong to the same document
  19132. // Support: IE 11+, Edge 17 - 18+
  19133. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19134. // two documents; shallow comparisons work.
  19135. // eslint-disable-next-line eqeqeq
  19136. compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
  19137. a.compareDocumentPosition( b ) :
  19138. // Otherwise we know they are disconnected
  19139. 1;
  19140. // Disconnected nodes
  19141. if ( compare & 1 ||
  19142. ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
  19143. // Choose the first element that is related to our preferred document
  19144. // Support: IE 11+, Edge 17 - 18+
  19145. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19146. // two documents; shallow comparisons work.
  19147. // eslint-disable-next-line eqeqeq
  19148. if ( a == document || a.ownerDocument == preferredDoc &&
  19149. contains( preferredDoc, a ) ) {
  19150. return -1;
  19151. }
  19152. // Support: IE 11+, Edge 17 - 18+
  19153. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19154. // two documents; shallow comparisons work.
  19155. // eslint-disable-next-line eqeqeq
  19156. if ( b == document || b.ownerDocument == preferredDoc &&
  19157. contains( preferredDoc, b ) ) {
  19158. return 1;
  19159. }
  19160. // Maintain original order
  19161. return sortInput ?
  19162. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  19163. 0;
  19164. }
  19165. return compare & 4 ? -1 : 1;
  19166. } :
  19167. function( a, b ) {
  19168. // Exit early if the nodes are identical
  19169. if ( a === b ) {
  19170. hasDuplicate = true;
  19171. return 0;
  19172. }
  19173. var cur,
  19174. i = 0,
  19175. aup = a.parentNode,
  19176. bup = b.parentNode,
  19177. ap = [ a ],
  19178. bp = [ b ];
  19179. // Parentless nodes are either documents or disconnected
  19180. if ( !aup || !bup ) {
  19181. // Support: IE 11+, Edge 17 - 18+
  19182. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19183. // two documents; shallow comparisons work.
  19184. /* eslint-disable eqeqeq */
  19185. return a == document ? -1 :
  19186. b == document ? 1 :
  19187. /* eslint-enable eqeqeq */
  19188. aup ? -1 :
  19189. bup ? 1 :
  19190. sortInput ?
  19191. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  19192. 0;
  19193. // If the nodes are siblings, we can do a quick check
  19194. } else if ( aup === bup ) {
  19195. return siblingCheck( a, b );
  19196. }
  19197. // Otherwise we need full lists of their ancestors for comparison
  19198. cur = a;
  19199. while ( ( cur = cur.parentNode ) ) {
  19200. ap.unshift( cur );
  19201. }
  19202. cur = b;
  19203. while ( ( cur = cur.parentNode ) ) {
  19204. bp.unshift( cur );
  19205. }
  19206. // Walk down the tree looking for a discrepancy
  19207. while ( ap[ i ] === bp[ i ] ) {
  19208. i++;
  19209. }
  19210. return i ?
  19211. // Do a sibling check if the nodes have a common ancestor
  19212. siblingCheck( ap[ i ], bp[ i ] ) :
  19213. // Otherwise nodes in our document sort first
  19214. // Support: IE 11+, Edge 17 - 18+
  19215. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19216. // two documents; shallow comparisons work.
  19217. /* eslint-disable eqeqeq */
  19218. ap[ i ] == preferredDoc ? -1 :
  19219. bp[ i ] == preferredDoc ? 1 :
  19220. /* eslint-enable eqeqeq */
  19221. 0;
  19222. };
  19223. return document;
  19224. };
  19225. Sizzle.matches = function( expr, elements ) {
  19226. return Sizzle( expr, null, null, elements );
  19227. };
  19228. Sizzle.matchesSelector = function( elem, expr ) {
  19229. setDocument( elem );
  19230. if ( support.matchesSelector && documentIsHTML &&
  19231. !nonnativeSelectorCache[ expr + " " ] &&
  19232. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  19233. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  19234. try {
  19235. var ret = matches.call( elem, expr );
  19236. // IE 9's matchesSelector returns false on disconnected nodes
  19237. if ( ret || support.disconnectedMatch ||
  19238. // As well, disconnected nodes are said to be in a document
  19239. // fragment in IE 9
  19240. elem.document && elem.document.nodeType !== 11 ) {
  19241. return ret;
  19242. }
  19243. } catch ( e ) {
  19244. nonnativeSelectorCache( expr, true );
  19245. }
  19246. }
  19247. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  19248. };
  19249. Sizzle.contains = function( context, elem ) {
  19250. // Set document vars if needed
  19251. // Support: IE 11+, Edge 17 - 18+
  19252. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19253. // two documents; shallow comparisons work.
  19254. // eslint-disable-next-line eqeqeq
  19255. if ( ( context.ownerDocument || context ) != document ) {
  19256. setDocument( context );
  19257. }
  19258. return contains( context, elem );
  19259. };
  19260. Sizzle.attr = function( elem, name ) {
  19261. // Set document vars if needed
  19262. // Support: IE 11+, Edge 17 - 18+
  19263. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  19264. // two documents; shallow comparisons work.
  19265. // eslint-disable-next-line eqeqeq
  19266. if ( ( elem.ownerDocument || elem ) != document ) {
  19267. setDocument( elem );
  19268. }
  19269. var fn = Expr.attrHandle[ name.toLowerCase() ],
  19270. // Don't get fooled by Object.prototype properties (jQuery #13807)
  19271. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  19272. fn( elem, name, !documentIsHTML ) :
  19273. undefined;
  19274. return val !== undefined ?
  19275. val :
  19276. support.attributes || !documentIsHTML ?
  19277. elem.getAttribute( name ) :
  19278. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  19279. val.value :
  19280. null;
  19281. };
  19282. Sizzle.escape = function( sel ) {
  19283. return ( sel + "" ).replace( rcssescape, fcssescape );
  19284. };
  19285. Sizzle.error = function( msg ) {
  19286. throw new Error( "Syntax error, unrecognized expression: " + msg );
  19287. };
  19288. /**
  19289. * Document sorting and removing duplicates
  19290. * @param {ArrayLike} results
  19291. */
  19292. Sizzle.uniqueSort = function( results ) {
  19293. var elem,
  19294. duplicates = [],
  19295. j = 0,
  19296. i = 0;
  19297. // Unless we *know* we can detect duplicates, assume their presence
  19298. hasDuplicate = !support.detectDuplicates;
  19299. sortInput = !support.sortStable && results.slice( 0 );
  19300. results.sort( sortOrder );
  19301. if ( hasDuplicate ) {
  19302. while ( ( elem = results[ i++ ] ) ) {
  19303. if ( elem === results[ i ] ) {
  19304. j = duplicates.push( i );
  19305. }
  19306. }
  19307. while ( j-- ) {
  19308. results.splice( duplicates[ j ], 1 );
  19309. }
  19310. }
  19311. // Clear input after sorting to release objects
  19312. // See https://github.com/jquery/sizzle/pull/225
  19313. sortInput = null;
  19314. return results;
  19315. };
  19316. /**
  19317. * Utility function for retrieving the text value of an array of DOM nodes
  19318. * @param {Array|Element} elem
  19319. */
  19320. getText = Sizzle.getText = function( elem ) {
  19321. var node,
  19322. ret = "",
  19323. i = 0,
  19324. nodeType = elem.nodeType;
  19325. if ( !nodeType ) {
  19326. // If no nodeType, this is expected to be an array
  19327. while ( ( node = elem[ i++ ] ) ) {
  19328. // Do not traverse comment nodes
  19329. ret += getText( node );
  19330. }
  19331. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  19332. // Use textContent for elements
  19333. // innerText usage removed for consistency of new lines (jQuery #11153)
  19334. if ( typeof elem.textContent === "string" ) {
  19335. return elem.textContent;
  19336. } else {
  19337. // Traverse its children
  19338. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  19339. ret += getText( elem );
  19340. }
  19341. }
  19342. } else if ( nodeType === 3 || nodeType === 4 ) {
  19343. return elem.nodeValue;
  19344. }
  19345. // Do not include comment or processing instruction nodes
  19346. return ret;
  19347. };
  19348. Expr = Sizzle.selectors = {
  19349. // Can be adjusted by the user
  19350. cacheLength: 50,
  19351. createPseudo: markFunction,
  19352. match: matchExpr,
  19353. attrHandle: {},
  19354. find: {},
  19355. relative: {
  19356. ">": { dir: "parentNode", first: true },
  19357. " ": { dir: "parentNode" },
  19358. "+": { dir: "previousSibling", first: true },
  19359. "~": { dir: "previousSibling" }
  19360. },
  19361. preFilter: {
  19362. "ATTR": function( match ) {
  19363. match[ 1 ] = match[ 1 ].replace( runescape, funescape );
  19364. // Move the given value to match[3] whether quoted or unquoted
  19365. match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
  19366. match[ 5 ] || "" ).replace( runescape, funescape );
  19367. if ( match[ 2 ] === "~=" ) {
  19368. match[ 3 ] = " " + match[ 3 ] + " ";
  19369. }
  19370. return match.slice( 0, 4 );
  19371. },
  19372. "CHILD": function( match ) {
  19373. /* matches from matchExpr["CHILD"]
  19374. 1 type (only|nth|...)
  19375. 2 what (child|of-type)
  19376. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  19377. 4 xn-component of xn+y argument ([+-]?\d*n|)
  19378. 5 sign of xn-component
  19379. 6 x of xn-component
  19380. 7 sign of y-component
  19381. 8 y of y-component
  19382. */
  19383. match[ 1 ] = match[ 1 ].toLowerCase();
  19384. if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
  19385. // nth-* requires argument
  19386. if ( !match[ 3 ] ) {
  19387. Sizzle.error( match[ 0 ] );
  19388. }
  19389. // numeric x and y parameters for Expr.filter.CHILD
  19390. // remember that false/true cast respectively to 0/1
  19391. match[ 4 ] = +( match[ 4 ] ?
  19392. match[ 5 ] + ( match[ 6 ] || 1 ) :
  19393. 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
  19394. match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
  19395. // other types prohibit arguments
  19396. } else if ( match[ 3 ] ) {
  19397. Sizzle.error( match[ 0 ] );
  19398. }
  19399. return match;
  19400. },
  19401. "PSEUDO": function( match ) {
  19402. var excess,
  19403. unquoted = !match[ 6 ] && match[ 2 ];
  19404. if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
  19405. return null;
  19406. }
  19407. // Accept quoted arguments as-is
  19408. if ( match[ 3 ] ) {
  19409. match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
  19410. // Strip excess characters from unquoted arguments
  19411. } else if ( unquoted && rpseudo.test( unquoted ) &&
  19412. // Get excess from tokenize (recursively)
  19413. ( excess = tokenize( unquoted, true ) ) &&
  19414. // advance to the next closing parenthesis
  19415. ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
  19416. // excess is a negative index
  19417. match[ 0 ] = match[ 0 ].slice( 0, excess );
  19418. match[ 2 ] = unquoted.slice( 0, excess );
  19419. }
  19420. // Return only captures needed by the pseudo filter method (type and argument)
  19421. return match.slice( 0, 3 );
  19422. }
  19423. },
  19424. filter: {
  19425. "TAG": function( nodeNameSelector ) {
  19426. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  19427. return nodeNameSelector === "*" ?
  19428. function() {
  19429. return true;
  19430. } :
  19431. function( elem ) {
  19432. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  19433. };
  19434. },
  19435. "CLASS": function( className ) {
  19436. var pattern = classCache[ className + " " ];
  19437. return pattern ||
  19438. ( pattern = new RegExp( "(^|" + whitespace +
  19439. ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
  19440. className, function( elem ) {
  19441. return pattern.test(
  19442. typeof elem.className === "string" && elem.className ||
  19443. typeof elem.getAttribute !== "undefined" &&
  19444. elem.getAttribute( "class" ) ||
  19445. ""
  19446. );
  19447. } );
  19448. },
  19449. "ATTR": function( name, operator, check ) {
  19450. return function( elem ) {
  19451. var result = Sizzle.attr( elem, name );
  19452. if ( result == null ) {
  19453. return operator === "!=";
  19454. }
  19455. if ( !operator ) {
  19456. return true;
  19457. }
  19458. result += "";
  19459. /* eslint-disable max-len */
  19460. return operator === "=" ? result === check :
  19461. operator === "!=" ? result !== check :
  19462. operator === "^=" ? check && result.indexOf( check ) === 0 :
  19463. operator === "*=" ? check && result.indexOf( check ) > -1 :
  19464. operator === "$=" ? check && result.slice( -check.length ) === check :
  19465. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  19466. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  19467. false;
  19468. /* eslint-enable max-len */
  19469. };
  19470. },
  19471. "CHILD": function( type, what, _argument, first, last ) {
  19472. var simple = type.slice( 0, 3 ) !== "nth",
  19473. forward = type.slice( -4 ) !== "last",
  19474. ofType = what === "of-type";
  19475. return first === 1 && last === 0 ?
  19476. // Shortcut for :nth-*(n)
  19477. function( elem ) {
  19478. return !!elem.parentNode;
  19479. } :
  19480. function( elem, _context, xml ) {
  19481. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  19482. dir = simple !== forward ? "nextSibling" : "previousSibling",
  19483. parent = elem.parentNode,
  19484. name = ofType && elem.nodeName.toLowerCase(),
  19485. useCache = !xml && !ofType,
  19486. diff = false;
  19487. if ( parent ) {
  19488. // :(first|last|only)-(child|of-type)
  19489. if ( simple ) {
  19490. while ( dir ) {
  19491. node = elem;
  19492. while ( ( node = node[ dir ] ) ) {
  19493. if ( ofType ?
  19494. node.nodeName.toLowerCase() === name :
  19495. node.nodeType === 1 ) {
  19496. return false;
  19497. }
  19498. }
  19499. // Reverse direction for :only-* (if we haven't yet done so)
  19500. start = dir = type === "only" && !start && "nextSibling";
  19501. }
  19502. return true;
  19503. }
  19504. start = [ forward ? parent.firstChild : parent.lastChild ];
  19505. // non-xml :nth-child(...) stores cache data on `parent`
  19506. if ( forward && useCache ) {
  19507. // Seek `elem` from a previously-cached index
  19508. // ...in a gzip-friendly way
  19509. node = parent;
  19510. outerCache = node[ expando ] || ( node[ expando ] = {} );
  19511. // Support: IE <9 only
  19512. // Defend against cloned attroperties (jQuery gh-1709)
  19513. uniqueCache = outerCache[ node.uniqueID ] ||
  19514. ( outerCache[ node.uniqueID ] = {} );
  19515. cache = uniqueCache[ type ] || [];
  19516. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  19517. diff = nodeIndex && cache[ 2 ];
  19518. node = nodeIndex && parent.childNodes[ nodeIndex ];
  19519. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  19520. // Fallback to seeking `elem` from the start
  19521. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  19522. // When found, cache indexes on `parent` and break
  19523. if ( node.nodeType === 1 && ++diff && node === elem ) {
  19524. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  19525. break;
  19526. }
  19527. }
  19528. } else {
  19529. // Use previously-cached element index if available
  19530. if ( useCache ) {
  19531. // ...in a gzip-friendly way
  19532. node = elem;
  19533. outerCache = node[ expando ] || ( node[ expando ] = {} );
  19534. // Support: IE <9 only
  19535. // Defend against cloned attroperties (jQuery gh-1709)
  19536. uniqueCache = outerCache[ node.uniqueID ] ||
  19537. ( outerCache[ node.uniqueID ] = {} );
  19538. cache = uniqueCache[ type ] || [];
  19539. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  19540. diff = nodeIndex;
  19541. }
  19542. // xml :nth-child(...)
  19543. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  19544. if ( diff === false ) {
  19545. // Use the same loop as above to seek `elem` from the start
  19546. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  19547. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  19548. if ( ( ofType ?
  19549. node.nodeName.toLowerCase() === name :
  19550. node.nodeType === 1 ) &&
  19551. ++diff ) {
  19552. // Cache the index of each encountered element
  19553. if ( useCache ) {
  19554. outerCache = node[ expando ] ||
  19555. ( node[ expando ] = {} );
  19556. // Support: IE <9 only
  19557. // Defend against cloned attroperties (jQuery gh-1709)
  19558. uniqueCache = outerCache[ node.uniqueID ] ||
  19559. ( outerCache[ node.uniqueID ] = {} );
  19560. uniqueCache[ type ] = [ dirruns, diff ];
  19561. }
  19562. if ( node === elem ) {
  19563. break;
  19564. }
  19565. }
  19566. }
  19567. }
  19568. }
  19569. // Incorporate the offset, then check against cycle size
  19570. diff -= last;
  19571. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  19572. }
  19573. };
  19574. },
  19575. "PSEUDO": function( pseudo, argument ) {
  19576. // pseudo-class names are case-insensitive
  19577. // http://www.w3.org/TR/selectors/#pseudo-classes
  19578. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  19579. // Remember that setFilters inherits from pseudos
  19580. var args,
  19581. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  19582. Sizzle.error( "unsupported pseudo: " + pseudo );
  19583. // The user may use createPseudo to indicate that
  19584. // arguments are needed to create the filter function
  19585. // just as Sizzle does
  19586. if ( fn[ expando ] ) {
  19587. return fn( argument );
  19588. }
  19589. // But maintain support for old signatures
  19590. if ( fn.length > 1 ) {
  19591. args = [ pseudo, pseudo, "", argument ];
  19592. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  19593. markFunction( function( seed, matches ) {
  19594. var idx,
  19595. matched = fn( seed, argument ),
  19596. i = matched.length;
  19597. while ( i-- ) {
  19598. idx = indexOf( seed, matched[ i ] );
  19599. seed[ idx ] = !( matches[ idx ] = matched[ i ] );
  19600. }
  19601. } ) :
  19602. function( elem ) {
  19603. return fn( elem, 0, args );
  19604. };
  19605. }
  19606. return fn;
  19607. }
  19608. },
  19609. pseudos: {
  19610. // Potentially complex pseudos
  19611. "not": markFunction( function( selector ) {
  19612. // Trim the selector passed to compile
  19613. // to avoid treating leading and trailing
  19614. // spaces as combinators
  19615. var input = [],
  19616. results = [],
  19617. matcher = compile( selector.replace( rtrim, "$1" ) );
  19618. return matcher[ expando ] ?
  19619. markFunction( function( seed, matches, _context, xml ) {
  19620. var elem,
  19621. unmatched = matcher( seed, null, xml, [] ),
  19622. i = seed.length;
  19623. // Match elements unmatched by `matcher`
  19624. while ( i-- ) {
  19625. if ( ( elem = unmatched[ i ] ) ) {
  19626. seed[ i ] = !( matches[ i ] = elem );
  19627. }
  19628. }
  19629. } ) :
  19630. function( elem, _context, xml ) {
  19631. input[ 0 ] = elem;
  19632. matcher( input, null, xml, results );
  19633. // Don't keep the element (issue #299)
  19634. input[ 0 ] = null;
  19635. return !results.pop();
  19636. };
  19637. } ),
  19638. "has": markFunction( function( selector ) {
  19639. return function( elem ) {
  19640. return Sizzle( selector, elem ).length > 0;
  19641. };
  19642. } ),
  19643. "contains": markFunction( function( text ) {
  19644. text = text.replace( runescape, funescape );
  19645. return function( elem ) {
  19646. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  19647. };
  19648. } ),
  19649. // "Whether an element is represented by a :lang() selector
  19650. // is based solely on the element's language value
  19651. // being equal to the identifier C,
  19652. // or beginning with the identifier C immediately followed by "-".
  19653. // The matching of C against the element's language value is performed case-insensitively.
  19654. // The identifier C does not have to be a valid language name."
  19655. // http://www.w3.org/TR/selectors/#lang-pseudo
  19656. "lang": markFunction( function( lang ) {
  19657. // lang value must be a valid identifier
  19658. if ( !ridentifier.test( lang || "" ) ) {
  19659. Sizzle.error( "unsupported lang: " + lang );
  19660. }
  19661. lang = lang.replace( runescape, funescape ).toLowerCase();
  19662. return function( elem ) {
  19663. var elemLang;
  19664. do {
  19665. if ( ( elemLang = documentIsHTML ?
  19666. elem.lang :
  19667. elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
  19668. elemLang = elemLang.toLowerCase();
  19669. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  19670. }
  19671. } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
  19672. return false;
  19673. };
  19674. } ),
  19675. // Miscellaneous
  19676. "target": function( elem ) {
  19677. var hash = window.location && window.location.hash;
  19678. return hash && hash.slice( 1 ) === elem.id;
  19679. },
  19680. "root": function( elem ) {
  19681. return elem === docElem;
  19682. },
  19683. "focus": function( elem ) {
  19684. return elem === document.activeElement &&
  19685. ( !document.hasFocus || document.hasFocus() ) &&
  19686. !!( elem.type || elem.href || ~elem.tabIndex );
  19687. },
  19688. // Boolean properties
  19689. "enabled": createDisabledPseudo( false ),
  19690. "disabled": createDisabledPseudo( true ),
  19691. "checked": function( elem ) {
  19692. // In CSS3, :checked should return both checked and selected elements
  19693. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  19694. var nodeName = elem.nodeName.toLowerCase();
  19695. return ( nodeName === "input" && !!elem.checked ) ||
  19696. ( nodeName === "option" && !!elem.selected );
  19697. },
  19698. "selected": function( elem ) {
  19699. // Accessing this property makes selected-by-default
  19700. // options in Safari work properly
  19701. if ( elem.parentNode ) {
  19702. // eslint-disable-next-line no-unused-expressions
  19703. elem.parentNode.selectedIndex;
  19704. }
  19705. return elem.selected === true;
  19706. },
  19707. // Contents
  19708. "empty": function( elem ) {
  19709. // http://www.w3.org/TR/selectors/#empty-pseudo
  19710. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  19711. // but not by others (comment: 8; processing instruction: 7; etc.)
  19712. // nodeType < 6 works because attributes (2) do not appear as children
  19713. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  19714. if ( elem.nodeType < 6 ) {
  19715. return false;
  19716. }
  19717. }
  19718. return true;
  19719. },
  19720. "parent": function( elem ) {
  19721. return !Expr.pseudos[ "empty" ]( elem );
  19722. },
  19723. // Element/input types
  19724. "header": function( elem ) {
  19725. return rheader.test( elem.nodeName );
  19726. },
  19727. "input": function( elem ) {
  19728. return rinputs.test( elem.nodeName );
  19729. },
  19730. "button": function( elem ) {
  19731. var name = elem.nodeName.toLowerCase();
  19732. return name === "input" && elem.type === "button" || name === "button";
  19733. },
  19734. "text": function( elem ) {
  19735. var attr;
  19736. return elem.nodeName.toLowerCase() === "input" &&
  19737. elem.type === "text" &&
  19738. // Support: IE<8
  19739. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  19740. ( ( attr = elem.getAttribute( "type" ) ) == null ||
  19741. attr.toLowerCase() === "text" );
  19742. },
  19743. // Position-in-collection
  19744. "first": createPositionalPseudo( function() {
  19745. return [ 0 ];
  19746. } ),
  19747. "last": createPositionalPseudo( function( _matchIndexes, length ) {
  19748. return [ length - 1 ];
  19749. } ),
  19750. "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
  19751. return [ argument < 0 ? argument + length : argument ];
  19752. } ),
  19753. "even": createPositionalPseudo( function( matchIndexes, length ) {
  19754. var i = 0;
  19755. for ( ; i < length; i += 2 ) {
  19756. matchIndexes.push( i );
  19757. }
  19758. return matchIndexes;
  19759. } ),
  19760. "odd": createPositionalPseudo( function( matchIndexes, length ) {
  19761. var i = 1;
  19762. for ( ; i < length; i += 2 ) {
  19763. matchIndexes.push( i );
  19764. }
  19765. return matchIndexes;
  19766. } ),
  19767. "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  19768. var i = argument < 0 ?
  19769. argument + length :
  19770. argument > length ?
  19771. length :
  19772. argument;
  19773. for ( ; --i >= 0; ) {
  19774. matchIndexes.push( i );
  19775. }
  19776. return matchIndexes;
  19777. } ),
  19778. "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  19779. var i = argument < 0 ? argument + length : argument;
  19780. for ( ; ++i < length; ) {
  19781. matchIndexes.push( i );
  19782. }
  19783. return matchIndexes;
  19784. } )
  19785. }
  19786. };
  19787. Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
  19788. // Add button/input type pseudos
  19789. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  19790. Expr.pseudos[ i ] = createInputPseudo( i );
  19791. }
  19792. for ( i in { submit: true, reset: true } ) {
  19793. Expr.pseudos[ i ] = createButtonPseudo( i );
  19794. }
  19795. // Easy API for creating new setFilters
  19796. function setFilters() {}
  19797. setFilters.prototype = Expr.filters = Expr.pseudos;
  19798. Expr.setFilters = new setFilters();
  19799. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  19800. var matched, match, tokens, type,
  19801. soFar, groups, preFilters,
  19802. cached = tokenCache[ selector + " " ];
  19803. if ( cached ) {
  19804. return parseOnly ? 0 : cached.slice( 0 );
  19805. }
  19806. soFar = selector;
  19807. groups = [];
  19808. preFilters = Expr.preFilter;
  19809. while ( soFar ) {
  19810. // Comma and first run
  19811. if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
  19812. if ( match ) {
  19813. // Don't consume trailing commas as valid
  19814. soFar = soFar.slice( match[ 0 ].length ) || soFar;
  19815. }
  19816. groups.push( ( tokens = [] ) );
  19817. }
  19818. matched = false;
  19819. // Combinators
  19820. if ( ( match = rcombinators.exec( soFar ) ) ) {
  19821. matched = match.shift();
  19822. tokens.push( {
  19823. value: matched,
  19824. // Cast descendant combinators to space
  19825. type: match[ 0 ].replace( rtrim, " " )
  19826. } );
  19827. soFar = soFar.slice( matched.length );
  19828. }
  19829. // Filters
  19830. for ( type in Expr.filter ) {
  19831. if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
  19832. ( match = preFilters[ type ]( match ) ) ) ) {
  19833. matched = match.shift();
  19834. tokens.push( {
  19835. value: matched,
  19836. type: type,
  19837. matches: match
  19838. } );
  19839. soFar = soFar.slice( matched.length );
  19840. }
  19841. }
  19842. if ( !matched ) {
  19843. break;
  19844. }
  19845. }
  19846. // Return the length of the invalid excess
  19847. // if we're just parsing
  19848. // Otherwise, throw an error or return tokens
  19849. return parseOnly ?
  19850. soFar.length :
  19851. soFar ?
  19852. Sizzle.error( selector ) :
  19853. // Cache the tokens
  19854. tokenCache( selector, groups ).slice( 0 );
  19855. };
  19856. function toSelector( tokens ) {
  19857. var i = 0,
  19858. len = tokens.length,
  19859. selector = "";
  19860. for ( ; i < len; i++ ) {
  19861. selector += tokens[ i ].value;
  19862. }
  19863. return selector;
  19864. }
  19865. function addCombinator( matcher, combinator, base ) {
  19866. var dir = combinator.dir,
  19867. skip = combinator.next,
  19868. key = skip || dir,
  19869. checkNonElements = base && key === "parentNode",
  19870. doneName = done++;
  19871. return combinator.first ?
  19872. // Check against closest ancestor/preceding element
  19873. function( elem, context, xml ) {
  19874. while ( ( elem = elem[ dir ] ) ) {
  19875. if ( elem.nodeType === 1 || checkNonElements ) {
  19876. return matcher( elem, context, xml );
  19877. }
  19878. }
  19879. return false;
  19880. } :
  19881. // Check against all ancestor/preceding elements
  19882. function( elem, context, xml ) {
  19883. var oldCache, uniqueCache, outerCache,
  19884. newCache = [ dirruns, doneName ];
  19885. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  19886. if ( xml ) {
  19887. while ( ( elem = elem[ dir ] ) ) {
  19888. if ( elem.nodeType === 1 || checkNonElements ) {
  19889. if ( matcher( elem, context, xml ) ) {
  19890. return true;
  19891. }
  19892. }
  19893. }
  19894. } else {
  19895. while ( ( elem = elem[ dir ] ) ) {
  19896. if ( elem.nodeType === 1 || checkNonElements ) {
  19897. outerCache = elem[ expando ] || ( elem[ expando ] = {} );
  19898. // Support: IE <9 only
  19899. // Defend against cloned attroperties (jQuery gh-1709)
  19900. uniqueCache = outerCache[ elem.uniqueID ] ||
  19901. ( outerCache[ elem.uniqueID ] = {} );
  19902. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  19903. elem = elem[ dir ] || elem;
  19904. } else if ( ( oldCache = uniqueCache[ key ] ) &&
  19905. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  19906. // Assign to newCache so results back-propagate to previous elements
  19907. return ( newCache[ 2 ] = oldCache[ 2 ] );
  19908. } else {
  19909. // Reuse newcache so results back-propagate to previous elements
  19910. uniqueCache[ key ] = newCache;
  19911. // A match means we're done; a fail means we have to keep checking
  19912. if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
  19913. return true;
  19914. }
  19915. }
  19916. }
  19917. }
  19918. }
  19919. return false;
  19920. };
  19921. }
  19922. function elementMatcher( matchers ) {
  19923. return matchers.length > 1 ?
  19924. function( elem, context, xml ) {
  19925. var i = matchers.length;
  19926. while ( i-- ) {
  19927. if ( !matchers[ i ]( elem, context, xml ) ) {
  19928. return false;
  19929. }
  19930. }
  19931. return true;
  19932. } :
  19933. matchers[ 0 ];
  19934. }
  19935. function multipleContexts( selector, contexts, results ) {
  19936. var i = 0,
  19937. len = contexts.length;
  19938. for ( ; i < len; i++ ) {
  19939. Sizzle( selector, contexts[ i ], results );
  19940. }
  19941. return results;
  19942. }
  19943. function condense( unmatched, map, filter, context, xml ) {
  19944. var elem,
  19945. newUnmatched = [],
  19946. i = 0,
  19947. len = unmatched.length,
  19948. mapped = map != null;
  19949. for ( ; i < len; i++ ) {
  19950. if ( ( elem = unmatched[ i ] ) ) {
  19951. if ( !filter || filter( elem, context, xml ) ) {
  19952. newUnmatched.push( elem );
  19953. if ( mapped ) {
  19954. map.push( i );
  19955. }
  19956. }
  19957. }
  19958. }
  19959. return newUnmatched;
  19960. }
  19961. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  19962. if ( postFilter && !postFilter[ expando ] ) {
  19963. postFilter = setMatcher( postFilter );
  19964. }
  19965. if ( postFinder && !postFinder[ expando ] ) {
  19966. postFinder = setMatcher( postFinder, postSelector );
  19967. }
  19968. return markFunction( function( seed, results, context, xml ) {
  19969. var temp, i, elem,
  19970. preMap = [],
  19971. postMap = [],
  19972. preexisting = results.length,
  19973. // Get initial elements from seed or context
  19974. elems = seed || multipleContexts(
  19975. selector || "*",
  19976. context.nodeType ? [ context ] : context,
  19977. []
  19978. ),
  19979. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  19980. matcherIn = preFilter && ( seed || !selector ) ?
  19981. condense( elems, preMap, preFilter, context, xml ) :
  19982. elems,
  19983. matcherOut = matcher ?
  19984. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  19985. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  19986. // ...intermediate processing is necessary
  19987. [] :
  19988. // ...otherwise use results directly
  19989. results :
  19990. matcherIn;
  19991. // Find primary matches
  19992. if ( matcher ) {
  19993. matcher( matcherIn, matcherOut, context, xml );
  19994. }
  19995. // Apply postFilter
  19996. if ( postFilter ) {
  19997. temp = condense( matcherOut, postMap );
  19998. postFilter( temp, [], context, xml );
  19999. // Un-match failing elements by moving them back to matcherIn
  20000. i = temp.length;
  20001. while ( i-- ) {
  20002. if ( ( elem = temp[ i ] ) ) {
  20003. matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
  20004. }
  20005. }
  20006. }
  20007. if ( seed ) {
  20008. if ( postFinder || preFilter ) {
  20009. if ( postFinder ) {
  20010. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  20011. temp = [];
  20012. i = matcherOut.length;
  20013. while ( i-- ) {
  20014. if ( ( elem = matcherOut[ i ] ) ) {
  20015. // Restore matcherIn since elem is not yet a final match
  20016. temp.push( ( matcherIn[ i ] = elem ) );
  20017. }
  20018. }
  20019. postFinder( null, ( matcherOut = [] ), temp, xml );
  20020. }
  20021. // Move matched elements from seed to results to keep them synchronized
  20022. i = matcherOut.length;
  20023. while ( i-- ) {
  20024. if ( ( elem = matcherOut[ i ] ) &&
  20025. ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
  20026. seed[ temp ] = !( results[ temp ] = elem );
  20027. }
  20028. }
  20029. }
  20030. // Add elements to results, through postFinder if defined
  20031. } else {
  20032. matcherOut = condense(
  20033. matcherOut === results ?
  20034. matcherOut.splice( preexisting, matcherOut.length ) :
  20035. matcherOut
  20036. );
  20037. if ( postFinder ) {
  20038. postFinder( null, results, matcherOut, xml );
  20039. } else {
  20040. push.apply( results, matcherOut );
  20041. }
  20042. }
  20043. } );
  20044. }
  20045. function matcherFromTokens( tokens ) {
  20046. var checkContext, matcher, j,
  20047. len = tokens.length,
  20048. leadingRelative = Expr.relative[ tokens[ 0 ].type ],
  20049. implicitRelative = leadingRelative || Expr.relative[ " " ],
  20050. i = leadingRelative ? 1 : 0,
  20051. // The foundational matcher ensures that elements are reachable from top-level context(s)
  20052. matchContext = addCombinator( function( elem ) {
  20053. return elem === checkContext;
  20054. }, implicitRelative, true ),
  20055. matchAnyContext = addCombinator( function( elem ) {
  20056. return indexOf( checkContext, elem ) > -1;
  20057. }, implicitRelative, true ),
  20058. matchers = [ function( elem, context, xml ) {
  20059. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  20060. ( checkContext = context ).nodeType ?
  20061. matchContext( elem, context, xml ) :
  20062. matchAnyContext( elem, context, xml ) );
  20063. // Avoid hanging onto element (issue #299)
  20064. checkContext = null;
  20065. return ret;
  20066. } ];
  20067. for ( ; i < len; i++ ) {
  20068. if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
  20069. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  20070. } else {
  20071. matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
  20072. // Return special upon seeing a positional matcher
  20073. if ( matcher[ expando ] ) {
  20074. // Find the next relative operator (if any) for proper handling
  20075. j = ++i;
  20076. for ( ; j < len; j++ ) {
  20077. if ( Expr.relative[ tokens[ j ].type ] ) {
  20078. break;
  20079. }
  20080. }
  20081. return setMatcher(
  20082. i > 1 && elementMatcher( matchers ),
  20083. i > 1 && toSelector(
  20084. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  20085. tokens
  20086. .slice( 0, i - 1 )
  20087. .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
  20088. ).replace( rtrim, "$1" ),
  20089. matcher,
  20090. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  20091. j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
  20092. j < len && toSelector( tokens )
  20093. );
  20094. }
  20095. matchers.push( matcher );
  20096. }
  20097. }
  20098. return elementMatcher( matchers );
  20099. }
  20100. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  20101. var bySet = setMatchers.length > 0,
  20102. byElement = elementMatchers.length > 0,
  20103. superMatcher = function( seed, context, xml, results, outermost ) {
  20104. var elem, j, matcher,
  20105. matchedCount = 0,
  20106. i = "0",
  20107. unmatched = seed && [],
  20108. setMatched = [],
  20109. contextBackup = outermostContext,
  20110. // We must always have either seed elements or outermost context
  20111. elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
  20112. // Use integer dirruns iff this is the outermost matcher
  20113. dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
  20114. len = elems.length;
  20115. if ( outermost ) {
  20116. // Support: IE 11+, Edge 17 - 18+
  20117. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  20118. // two documents; shallow comparisons work.
  20119. // eslint-disable-next-line eqeqeq
  20120. outermostContext = context == document || context || outermost;
  20121. }
  20122. // Add elements passing elementMatchers directly to results
  20123. // Support: IE<9, Safari
  20124. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  20125. for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
  20126. if ( byElement && elem ) {
  20127. j = 0;
  20128. // Support: IE 11+, Edge 17 - 18+
  20129. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  20130. // two documents; shallow comparisons work.
  20131. // eslint-disable-next-line eqeqeq
  20132. if ( !context && elem.ownerDocument != document ) {
  20133. setDocument( elem );
  20134. xml = !documentIsHTML;
  20135. }
  20136. while ( ( matcher = elementMatchers[ j++ ] ) ) {
  20137. if ( matcher( elem, context || document, xml ) ) {
  20138. results.push( elem );
  20139. break;
  20140. }
  20141. }
  20142. if ( outermost ) {
  20143. dirruns = dirrunsUnique;
  20144. }
  20145. }
  20146. // Track unmatched elements for set filters
  20147. if ( bySet ) {
  20148. // They will have gone through all possible matchers
  20149. if ( ( elem = !matcher && elem ) ) {
  20150. matchedCount--;
  20151. }
  20152. // Lengthen the array for every element, matched or not
  20153. if ( seed ) {
  20154. unmatched.push( elem );
  20155. }
  20156. }
  20157. }
  20158. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  20159. // makes the latter nonnegative.
  20160. matchedCount += i;
  20161. // Apply set filters to unmatched elements
  20162. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  20163. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  20164. // no element matchers and no seed.
  20165. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  20166. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  20167. // numerically zero.
  20168. if ( bySet && i !== matchedCount ) {
  20169. j = 0;
  20170. while ( ( matcher = setMatchers[ j++ ] ) ) {
  20171. matcher( unmatched, setMatched, context, xml );
  20172. }
  20173. if ( seed ) {
  20174. // Reintegrate element matches to eliminate the need for sorting
  20175. if ( matchedCount > 0 ) {
  20176. while ( i-- ) {
  20177. if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
  20178. setMatched[ i ] = pop.call( results );
  20179. }
  20180. }
  20181. }
  20182. // Discard index placeholder values to get only actual matches
  20183. setMatched = condense( setMatched );
  20184. }
  20185. // Add matches to results
  20186. push.apply( results, setMatched );
  20187. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  20188. if ( outermost && !seed && setMatched.length > 0 &&
  20189. ( matchedCount + setMatchers.length ) > 1 ) {
  20190. Sizzle.uniqueSort( results );
  20191. }
  20192. }
  20193. // Override manipulation of globals by nested matchers
  20194. if ( outermost ) {
  20195. dirruns = dirrunsUnique;
  20196. outermostContext = contextBackup;
  20197. }
  20198. return unmatched;
  20199. };
  20200. return bySet ?
  20201. markFunction( superMatcher ) :
  20202. superMatcher;
  20203. }
  20204. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  20205. var i,
  20206. setMatchers = [],
  20207. elementMatchers = [],
  20208. cached = compilerCache[ selector + " " ];
  20209. if ( !cached ) {
  20210. // Generate a function of recursive functions that can be used to check each element
  20211. if ( !match ) {
  20212. match = tokenize( selector );
  20213. }
  20214. i = match.length;
  20215. while ( i-- ) {
  20216. cached = matcherFromTokens( match[ i ] );
  20217. if ( cached[ expando ] ) {
  20218. setMatchers.push( cached );
  20219. } else {
  20220. elementMatchers.push( cached );
  20221. }
  20222. }
  20223. // Cache the compiled function
  20224. cached = compilerCache(
  20225. selector,
  20226. matcherFromGroupMatchers( elementMatchers, setMatchers )
  20227. );
  20228. // Save selector and tokenization
  20229. cached.selector = selector;
  20230. }
  20231. return cached;
  20232. };
  20233. /**
  20234. * A low-level selection function that works with Sizzle's compiled
  20235. * selector functions
  20236. * @param {String|Function} selector A selector or a pre-compiled
  20237. * selector function built with Sizzle.compile
  20238. * @param {Element} context
  20239. * @param {Array} [results]
  20240. * @param {Array} [seed] A set of elements to match against
  20241. */
  20242. select = Sizzle.select = function( selector, context, results, seed ) {
  20243. var i, tokens, token, type, find,
  20244. compiled = typeof selector === "function" && selector,
  20245. match = !seed && tokenize( ( selector = compiled.selector || selector ) );
  20246. results = results || [];
  20247. // Try to minimize operations if there is only one selector in the list and no seed
  20248. // (the latter of which guarantees us context)
  20249. if ( match.length === 1 ) {
  20250. // Reduce context if the leading compound selector is an ID
  20251. tokens = match[ 0 ] = match[ 0 ].slice( 0 );
  20252. if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
  20253. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
  20254. context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
  20255. .replace( runescape, funescape ), context ) || [] )[ 0 ];
  20256. if ( !context ) {
  20257. return results;
  20258. // Precompiled matchers will still verify ancestry, so step up a level
  20259. } else if ( compiled ) {
  20260. context = context.parentNode;
  20261. }
  20262. selector = selector.slice( tokens.shift().value.length );
  20263. }
  20264. // Fetch a seed set for right-to-left matching
  20265. i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
  20266. while ( i-- ) {
  20267. token = tokens[ i ];
  20268. // Abort if we hit a combinator
  20269. if ( Expr.relative[ ( type = token.type ) ] ) {
  20270. break;
  20271. }
  20272. if ( ( find = Expr.find[ type ] ) ) {
  20273. // Search, expanding context for leading sibling combinators
  20274. if ( ( seed = find(
  20275. token.matches[ 0 ].replace( runescape, funescape ),
  20276. rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
  20277. context
  20278. ) ) ) {
  20279. // If seed is empty or no tokens remain, we can return early
  20280. tokens.splice( i, 1 );
  20281. selector = seed.length && toSelector( tokens );
  20282. if ( !selector ) {
  20283. push.apply( results, seed );
  20284. return results;
  20285. }
  20286. break;
  20287. }
  20288. }
  20289. }
  20290. }
  20291. // Compile and execute a filtering function if one is not provided
  20292. // Provide `match` to avoid retokenization if we modified the selector above
  20293. ( compiled || compile( selector, match ) )(
  20294. seed,
  20295. context,
  20296. !documentIsHTML,
  20297. results,
  20298. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  20299. );
  20300. return results;
  20301. };
  20302. // One-time assignments
  20303. // Sort stability
  20304. support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
  20305. // Support: Chrome 14-35+
  20306. // Always assume duplicates if they aren't passed to the comparison function
  20307. support.detectDuplicates = !!hasDuplicate;
  20308. // Initialize against the default document
  20309. setDocument();
  20310. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  20311. // Detached nodes confoundingly follow *each other*
  20312. support.sortDetached = assert( function( el ) {
  20313. // Should return 1, but returns 4 (following)
  20314. return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
  20315. } );
  20316. // Support: IE<8
  20317. // Prevent attribute/property "interpolation"
  20318. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  20319. if ( !assert( function( el ) {
  20320. el.innerHTML = "<a href='#'></a>";
  20321. return el.firstChild.getAttribute( "href" ) === "#";
  20322. } ) ) {
  20323. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  20324. if ( !isXML ) {
  20325. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  20326. }
  20327. } );
  20328. }
  20329. // Support: IE<9
  20330. // Use defaultValue in place of getAttribute("value")
  20331. if ( !support.attributes || !assert( function( el ) {
  20332. el.innerHTML = "<input/>";
  20333. el.firstChild.setAttribute( "value", "" );
  20334. return el.firstChild.getAttribute( "value" ) === "";
  20335. } ) ) {
  20336. addHandle( "value", function( elem, _name, isXML ) {
  20337. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  20338. return elem.defaultValue;
  20339. }
  20340. } );
  20341. }
  20342. // Support: IE<9
  20343. // Use getAttributeNode to fetch booleans when getAttribute lies
  20344. if ( !assert( function( el ) {
  20345. return el.getAttribute( "disabled" ) == null;
  20346. } ) ) {
  20347. addHandle( booleans, function( elem, name, isXML ) {
  20348. var val;
  20349. if ( !isXML ) {
  20350. return elem[ name ] === true ? name.toLowerCase() :
  20351. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  20352. val.value :
  20353. null;
  20354. }
  20355. } );
  20356. }
  20357. return Sizzle;
  20358. } )( window );
  20359. jQuery.find = Sizzle;
  20360. jQuery.expr = Sizzle.selectors;
  20361. // Deprecated
  20362. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  20363. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  20364. jQuery.text = Sizzle.getText;
  20365. jQuery.isXMLDoc = Sizzle.isXML;
  20366. jQuery.contains = Sizzle.contains;
  20367. jQuery.escapeSelector = Sizzle.escape;
  20368. var dir = function( elem, dir, until ) {
  20369. var matched = [],
  20370. truncate = until !== undefined;
  20371. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  20372. if ( elem.nodeType === 1 ) {
  20373. if ( truncate && jQuery( elem ).is( until ) ) {
  20374. break;
  20375. }
  20376. matched.push( elem );
  20377. }
  20378. }
  20379. return matched;
  20380. };
  20381. var siblings = function( n, elem ) {
  20382. var matched = [];
  20383. for ( ; n; n = n.nextSibling ) {
  20384. if ( n.nodeType === 1 && n !== elem ) {
  20385. matched.push( n );
  20386. }
  20387. }
  20388. return matched;
  20389. };
  20390. var rneedsContext = jQuery.expr.match.needsContext;
  20391. function nodeName( elem, name ) {
  20392. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  20393. }
  20394. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  20395. // Implement the identical functionality for filter and not
  20396. function winnow( elements, qualifier, not ) {
  20397. if ( isFunction( qualifier ) ) {
  20398. return jQuery.grep( elements, function( elem, i ) {
  20399. return !!qualifier.call( elem, i, elem ) !== not;
  20400. } );
  20401. }
  20402. // Single element
  20403. if ( qualifier.nodeType ) {
  20404. return jQuery.grep( elements, function( elem ) {
  20405. return ( elem === qualifier ) !== not;
  20406. } );
  20407. }
  20408. // Arraylike of elements (jQuery, arguments, Array)
  20409. if ( typeof qualifier !== "string" ) {
  20410. return jQuery.grep( elements, function( elem ) {
  20411. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  20412. } );
  20413. }
  20414. // Filtered directly for both simple and complex selectors
  20415. return jQuery.filter( qualifier, elements, not );
  20416. }
  20417. jQuery.filter = function( expr, elems, not ) {
  20418. var elem = elems[ 0 ];
  20419. if ( not ) {
  20420. expr = ":not(" + expr + ")";
  20421. }
  20422. if ( elems.length === 1 && elem.nodeType === 1 ) {
  20423. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  20424. }
  20425. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  20426. return elem.nodeType === 1;
  20427. } ) );
  20428. };
  20429. jQuery.fn.extend( {
  20430. find: function( selector ) {
  20431. var i, ret,
  20432. len = this.length,
  20433. self = this;
  20434. if ( typeof selector !== "string" ) {
  20435. return this.pushStack( jQuery( selector ).filter( function() {
  20436. for ( i = 0; i < len; i++ ) {
  20437. if ( jQuery.contains( self[ i ], this ) ) {
  20438. return true;
  20439. }
  20440. }
  20441. } ) );
  20442. }
  20443. ret = this.pushStack( [] );
  20444. for ( i = 0; i < len; i++ ) {
  20445. jQuery.find( selector, self[ i ], ret );
  20446. }
  20447. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  20448. },
  20449. filter: function( selector ) {
  20450. return this.pushStack( winnow( this, selector || [], false ) );
  20451. },
  20452. not: function( selector ) {
  20453. return this.pushStack( winnow( this, selector || [], true ) );
  20454. },
  20455. is: function( selector ) {
  20456. return !!winnow(
  20457. this,
  20458. // If this is a positional/relative selector, check membership in the returned set
  20459. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  20460. typeof selector === "string" && rneedsContext.test( selector ) ?
  20461. jQuery( selector ) :
  20462. selector || [],
  20463. false
  20464. ).length;
  20465. }
  20466. } );
  20467. // Initialize a jQuery object
  20468. // A central reference to the root jQuery(document)
  20469. var rootjQuery,
  20470. // A simple way to check for HTML strings
  20471. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  20472. // Strict HTML recognition (#11290: must start with <)
  20473. // Shortcut simple #id case for speed
  20474. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  20475. init = jQuery.fn.init = function( selector, context, root ) {
  20476. var match, elem;
  20477. // HANDLE: $(""), $(null), $(undefined), $(false)
  20478. if ( !selector ) {
  20479. return this;
  20480. }
  20481. // Method init() accepts an alternate rootjQuery
  20482. // so migrate can support jQuery.sub (gh-2101)
  20483. root = root || rootjQuery;
  20484. // Handle HTML strings
  20485. if ( typeof selector === "string" ) {
  20486. if ( selector[ 0 ] === "<" &&
  20487. selector[ selector.length - 1 ] === ">" &&
  20488. selector.length >= 3 ) {
  20489. // Assume that strings that start and end with <> are HTML and skip the regex check
  20490. match = [ null, selector, null ];
  20491. } else {
  20492. match = rquickExpr.exec( selector );
  20493. }
  20494. // Match html or make sure no context is specified for #id
  20495. if ( match && ( match[ 1 ] || !context ) ) {
  20496. // HANDLE: $(html) -> $(array)
  20497. if ( match[ 1 ] ) {
  20498. context = context instanceof jQuery ? context[ 0 ] : context;
  20499. // Option to run scripts is true for back-compat
  20500. // Intentionally let the error be thrown if parseHTML is not present
  20501. jQuery.merge( this, jQuery.parseHTML(
  20502. match[ 1 ],
  20503. context && context.nodeType ? context.ownerDocument || context : document,
  20504. true
  20505. ) );
  20506. // HANDLE: $(html, props)
  20507. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  20508. for ( match in context ) {
  20509. // Properties of context are called as methods if possible
  20510. if ( isFunction( this[ match ] ) ) {
  20511. this[ match ]( context[ match ] );
  20512. // ...and otherwise set as attributes
  20513. } else {
  20514. this.attr( match, context[ match ] );
  20515. }
  20516. }
  20517. }
  20518. return this;
  20519. // HANDLE: $(#id)
  20520. } else {
  20521. elem = document.getElementById( match[ 2 ] );
  20522. if ( elem ) {
  20523. // Inject the element directly into the jQuery object
  20524. this[ 0 ] = elem;
  20525. this.length = 1;
  20526. }
  20527. return this;
  20528. }
  20529. // HANDLE: $(expr, $(...))
  20530. } else if ( !context || context.jquery ) {
  20531. return ( context || root ).find( selector );
  20532. // HANDLE: $(expr, context)
  20533. // (which is just equivalent to: $(context).find(expr)
  20534. } else {
  20535. return this.constructor( context ).find( selector );
  20536. }
  20537. // HANDLE: $(DOMElement)
  20538. } else if ( selector.nodeType ) {
  20539. this[ 0 ] = selector;
  20540. this.length = 1;
  20541. return this;
  20542. // HANDLE: $(function)
  20543. // Shortcut for document ready
  20544. } else if ( isFunction( selector ) ) {
  20545. return root.ready !== undefined ?
  20546. root.ready( selector ) :
  20547. // Execute immediately if ready is not present
  20548. selector( jQuery );
  20549. }
  20550. return jQuery.makeArray( selector, this );
  20551. };
  20552. // Give the init function the jQuery prototype for later instantiation
  20553. init.prototype = jQuery.fn;
  20554. // Initialize central reference
  20555. rootjQuery = jQuery( document );
  20556. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  20557. // Methods guaranteed to produce a unique set when starting from a unique set
  20558. guaranteedUnique = {
  20559. children: true,
  20560. contents: true,
  20561. next: true,
  20562. prev: true
  20563. };
  20564. jQuery.fn.extend( {
  20565. has: function( target ) {
  20566. var targets = jQuery( target, this ),
  20567. l = targets.length;
  20568. return this.filter( function() {
  20569. var i = 0;
  20570. for ( ; i < l; i++ ) {
  20571. if ( jQuery.contains( this, targets[ i ] ) ) {
  20572. return true;
  20573. }
  20574. }
  20575. } );
  20576. },
  20577. closest: function( selectors, context ) {
  20578. var cur,
  20579. i = 0,
  20580. l = this.length,
  20581. matched = [],
  20582. targets = typeof selectors !== "string" && jQuery( selectors );
  20583. // Positional selectors never match, since there's no _selection_ context
  20584. if ( !rneedsContext.test( selectors ) ) {
  20585. for ( ; i < l; i++ ) {
  20586. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  20587. // Always skip document fragments
  20588. if ( cur.nodeType < 11 && ( targets ?
  20589. targets.index( cur ) > -1 :
  20590. // Don't pass non-elements to Sizzle
  20591. cur.nodeType === 1 &&
  20592. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  20593. matched.push( cur );
  20594. break;
  20595. }
  20596. }
  20597. }
  20598. }
  20599. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  20600. },
  20601. // Determine the position of an element within the set
  20602. index: function( elem ) {
  20603. // No argument, return index in parent
  20604. if ( !elem ) {
  20605. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  20606. }
  20607. // Index in selector
  20608. if ( typeof elem === "string" ) {
  20609. return indexOf.call( jQuery( elem ), this[ 0 ] );
  20610. }
  20611. // Locate the position of the desired element
  20612. return indexOf.call( this,
  20613. // If it receives a jQuery object, the first element is used
  20614. elem.jquery ? elem[ 0 ] : elem
  20615. );
  20616. },
  20617. add: function( selector, context ) {
  20618. return this.pushStack(
  20619. jQuery.uniqueSort(
  20620. jQuery.merge( this.get(), jQuery( selector, context ) )
  20621. )
  20622. );
  20623. },
  20624. addBack: function( selector ) {
  20625. return this.add( selector == null ?
  20626. this.prevObject : this.prevObject.filter( selector )
  20627. );
  20628. }
  20629. } );
  20630. function sibling( cur, dir ) {
  20631. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  20632. return cur;
  20633. }
  20634. jQuery.each( {
  20635. parent: function( elem ) {
  20636. var parent = elem.parentNode;
  20637. return parent && parent.nodeType !== 11 ? parent : null;
  20638. },
  20639. parents: function( elem ) {
  20640. return dir( elem, "parentNode" );
  20641. },
  20642. parentsUntil: function( elem, _i, until ) {
  20643. return dir( elem, "parentNode", until );
  20644. },
  20645. next: function( elem ) {
  20646. return sibling( elem, "nextSibling" );
  20647. },
  20648. prev: function( elem ) {
  20649. return sibling( elem, "previousSibling" );
  20650. },
  20651. nextAll: function( elem ) {
  20652. return dir( elem, "nextSibling" );
  20653. },
  20654. prevAll: function( elem ) {
  20655. return dir( elem, "previousSibling" );
  20656. },
  20657. nextUntil: function( elem, _i, until ) {
  20658. return dir( elem, "nextSibling", until );
  20659. },
  20660. prevUntil: function( elem, _i, until ) {
  20661. return dir( elem, "previousSibling", until );
  20662. },
  20663. siblings: function( elem ) {
  20664. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  20665. },
  20666. children: function( elem ) {
  20667. return siblings( elem.firstChild );
  20668. },
  20669. contents: function( elem ) {
  20670. if ( elem.contentDocument != null &&
  20671. // Support: IE 11+
  20672. // <object> elements with no `data` attribute has an object
  20673. // `contentDocument` with a `null` prototype.
  20674. getProto( elem.contentDocument ) ) {
  20675. return elem.contentDocument;
  20676. }
  20677. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  20678. // Treat the template element as a regular one in browsers that
  20679. // don't support it.
  20680. if ( nodeName( elem, "template" ) ) {
  20681. elem = elem.content || elem;
  20682. }
  20683. return jQuery.merge( [], elem.childNodes );
  20684. }
  20685. }, function( name, fn ) {
  20686. jQuery.fn[ name ] = function( until, selector ) {
  20687. var matched = jQuery.map( this, fn, until );
  20688. if ( name.slice( -5 ) !== "Until" ) {
  20689. selector = until;
  20690. }
  20691. if ( selector && typeof selector === "string" ) {
  20692. matched = jQuery.filter( selector, matched );
  20693. }
  20694. if ( this.length > 1 ) {
  20695. // Remove duplicates
  20696. if ( !guaranteedUnique[ name ] ) {
  20697. jQuery.uniqueSort( matched );
  20698. }
  20699. // Reverse order for parents* and prev-derivatives
  20700. if ( rparentsprev.test( name ) ) {
  20701. matched.reverse();
  20702. }
  20703. }
  20704. return this.pushStack( matched );
  20705. };
  20706. } );
  20707. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  20708. // Convert String-formatted options into Object-formatted ones
  20709. function createOptions( options ) {
  20710. var object = {};
  20711. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  20712. object[ flag ] = true;
  20713. } );
  20714. return object;
  20715. }
  20716. /*
  20717. * Create a callback list using the following parameters:
  20718. *
  20719. * options: an optional list of space-separated options that will change how
  20720. * the callback list behaves or a more traditional option object
  20721. *
  20722. * By default a callback list will act like an event callback list and can be
  20723. * "fired" multiple times.
  20724. *
  20725. * Possible options:
  20726. *
  20727. * once: will ensure the callback list can only be fired once (like a Deferred)
  20728. *
  20729. * memory: will keep track of previous values and will call any callback added
  20730. * after the list has been fired right away with the latest "memorized"
  20731. * values (like a Deferred)
  20732. *
  20733. * unique: will ensure a callback can only be added once (no duplicate in the list)
  20734. *
  20735. * stopOnFalse: interrupt callings when a callback returns false
  20736. *
  20737. */
  20738. jQuery.Callbacks = function( options ) {
  20739. // Convert options from String-formatted to Object-formatted if needed
  20740. // (we check in cache first)
  20741. options = typeof options === "string" ?
  20742. createOptions( options ) :
  20743. jQuery.extend( {}, options );
  20744. var // Flag to know if list is currently firing
  20745. firing,
  20746. // Last fire value for non-forgettable lists
  20747. memory,
  20748. // Flag to know if list was already fired
  20749. fired,
  20750. // Flag to prevent firing
  20751. locked,
  20752. // Actual callback list
  20753. list = [],
  20754. // Queue of execution data for repeatable lists
  20755. queue = [],
  20756. // Index of currently firing callback (modified by add/remove as needed)
  20757. firingIndex = -1,
  20758. // Fire callbacks
  20759. fire = function() {
  20760. // Enforce single-firing
  20761. locked = locked || options.once;
  20762. // Execute callbacks for all pending executions,
  20763. // respecting firingIndex overrides and runtime changes
  20764. fired = firing = true;
  20765. for ( ; queue.length; firingIndex = -1 ) {
  20766. memory = queue.shift();
  20767. while ( ++firingIndex < list.length ) {
  20768. // Run callback and check for early termination
  20769. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  20770. options.stopOnFalse ) {
  20771. // Jump to end and forget the data so .add doesn't re-fire
  20772. firingIndex = list.length;
  20773. memory = false;
  20774. }
  20775. }
  20776. }
  20777. // Forget the data if we're done with it
  20778. if ( !options.memory ) {
  20779. memory = false;
  20780. }
  20781. firing = false;
  20782. // Clean up if we're done firing for good
  20783. if ( locked ) {
  20784. // Keep an empty list if we have data for future add calls
  20785. if ( memory ) {
  20786. list = [];
  20787. // Otherwise, this object is spent
  20788. } else {
  20789. list = "";
  20790. }
  20791. }
  20792. },
  20793. // Actual Callbacks object
  20794. self = {
  20795. // Add a callback or a collection of callbacks to the list
  20796. add: function() {
  20797. if ( list ) {
  20798. // If we have memory from a past run, we should fire after adding
  20799. if ( memory && !firing ) {
  20800. firingIndex = list.length - 1;
  20801. queue.push( memory );
  20802. }
  20803. ( function add( args ) {
  20804. jQuery.each( args, function( _, arg ) {
  20805. if ( isFunction( arg ) ) {
  20806. if ( !options.unique || !self.has( arg ) ) {
  20807. list.push( arg );
  20808. }
  20809. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  20810. // Inspect recursively
  20811. add( arg );
  20812. }
  20813. } );
  20814. } )( arguments );
  20815. if ( memory && !firing ) {
  20816. fire();
  20817. }
  20818. }
  20819. return this;
  20820. },
  20821. // Remove a callback from the list
  20822. remove: function() {
  20823. jQuery.each( arguments, function( _, arg ) {
  20824. var index;
  20825. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  20826. list.splice( index, 1 );
  20827. // Handle firing indexes
  20828. if ( index <= firingIndex ) {
  20829. firingIndex--;
  20830. }
  20831. }
  20832. } );
  20833. return this;
  20834. },
  20835. // Check if a given callback is in the list.
  20836. // If no argument is given, return whether or not list has callbacks attached.
  20837. has: function( fn ) {
  20838. return fn ?
  20839. jQuery.inArray( fn, list ) > -1 :
  20840. list.length > 0;
  20841. },
  20842. // Remove all callbacks from the list
  20843. empty: function() {
  20844. if ( list ) {
  20845. list = [];
  20846. }
  20847. return this;
  20848. },
  20849. // Disable .fire and .add
  20850. // Abort any current/pending executions
  20851. // Clear all callbacks and values
  20852. disable: function() {
  20853. locked = queue = [];
  20854. list = memory = "";
  20855. return this;
  20856. },
  20857. disabled: function() {
  20858. return !list;
  20859. },
  20860. // Disable .fire
  20861. // Also disable .add unless we have memory (since it would have no effect)
  20862. // Abort any pending executions
  20863. lock: function() {
  20864. locked = queue = [];
  20865. if ( !memory && !firing ) {
  20866. list = memory = "";
  20867. }
  20868. return this;
  20869. },
  20870. locked: function() {
  20871. return !!locked;
  20872. },
  20873. // Call all callbacks with the given context and arguments
  20874. fireWith: function( context, args ) {
  20875. if ( !locked ) {
  20876. args = args || [];
  20877. args = [ context, args.slice ? args.slice() : args ];
  20878. queue.push( args );
  20879. if ( !firing ) {
  20880. fire();
  20881. }
  20882. }
  20883. return this;
  20884. },
  20885. // Call all the callbacks with the given arguments
  20886. fire: function() {
  20887. self.fireWith( this, arguments );
  20888. return this;
  20889. },
  20890. // To know if the callbacks have already been called at least once
  20891. fired: function() {
  20892. return !!fired;
  20893. }
  20894. };
  20895. return self;
  20896. };
  20897. function Identity( v ) {
  20898. return v;
  20899. }
  20900. function Thrower( ex ) {
  20901. throw ex;
  20902. }
  20903. function adoptValue( value, resolve, reject, noValue ) {
  20904. var method;
  20905. try {
  20906. // Check for promise aspect first to privilege synchronous behavior
  20907. if ( value && isFunction( ( method = value.promise ) ) ) {
  20908. method.call( value ).done( resolve ).fail( reject );
  20909. // Other thenables
  20910. } else if ( value && isFunction( ( method = value.then ) ) ) {
  20911. method.call( value, resolve, reject );
  20912. // Other non-thenables
  20913. } else {
  20914. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  20915. // * false: [ value ].slice( 0 ) => resolve( value )
  20916. // * true: [ value ].slice( 1 ) => resolve()
  20917. resolve.apply( undefined, [ value ].slice( noValue ) );
  20918. }
  20919. // For Promises/A+, convert exceptions into rejections
  20920. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  20921. // Deferred#then to conditionally suppress rejection.
  20922. } catch ( value ) {
  20923. // Support: Android 4.0 only
  20924. // Strict mode functions invoked without .call/.apply get global-object context
  20925. reject.apply( undefined, [ value ] );
  20926. }
  20927. }
  20928. jQuery.extend( {
  20929. Deferred: function( func ) {
  20930. var tuples = [
  20931. // action, add listener, callbacks,
  20932. // ... .then handlers, argument index, [final state]
  20933. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  20934. jQuery.Callbacks( "memory" ), 2 ],
  20935. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  20936. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  20937. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  20938. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  20939. ],
  20940. state = "pending",
  20941. promise = {
  20942. state: function() {
  20943. return state;
  20944. },
  20945. always: function() {
  20946. deferred.done( arguments ).fail( arguments );
  20947. return this;
  20948. },
  20949. "catch": function( fn ) {
  20950. return promise.then( null, fn );
  20951. },
  20952. // Keep pipe for back-compat
  20953. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  20954. var fns = arguments;
  20955. return jQuery.Deferred( function( newDefer ) {
  20956. jQuery.each( tuples, function( _i, tuple ) {
  20957. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  20958. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  20959. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  20960. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  20961. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  20962. deferred[ tuple[ 1 ] ]( function() {
  20963. var returned = fn && fn.apply( this, arguments );
  20964. if ( returned && isFunction( returned.promise ) ) {
  20965. returned.promise()
  20966. .progress( newDefer.notify )
  20967. .done( newDefer.resolve )
  20968. .fail( newDefer.reject );
  20969. } else {
  20970. newDefer[ tuple[ 0 ] + "With" ](
  20971. this,
  20972. fn ? [ returned ] : arguments
  20973. );
  20974. }
  20975. } );
  20976. } );
  20977. fns = null;
  20978. } ).promise();
  20979. },
  20980. then: function( onFulfilled, onRejected, onProgress ) {
  20981. var maxDepth = 0;
  20982. function resolve( depth, deferred, handler, special ) {
  20983. return function() {
  20984. var that = this,
  20985. args = arguments,
  20986. mightThrow = function() {
  20987. var returned, then;
  20988. // Support: Promises/A+ section 2.3.3.3.3
  20989. // https://promisesaplus.com/#point-59
  20990. // Ignore double-resolution attempts
  20991. if ( depth < maxDepth ) {
  20992. return;
  20993. }
  20994. returned = handler.apply( that, args );
  20995. // Support: Promises/A+ section 2.3.1
  20996. // https://promisesaplus.com/#point-48
  20997. if ( returned === deferred.promise() ) {
  20998. throw new TypeError( "Thenable self-resolution" );
  20999. }
  21000. // Support: Promises/A+ sections 2.3.3.1, 3.5
  21001. // https://promisesaplus.com/#point-54
  21002. // https://promisesaplus.com/#point-75
  21003. // Retrieve `then` only once
  21004. then = returned &&
  21005. // Support: Promises/A+ section 2.3.4
  21006. // https://promisesaplus.com/#point-64
  21007. // Only check objects and functions for thenability
  21008. ( typeof returned === "object" ||
  21009. typeof returned === "function" ) &&
  21010. returned.then;
  21011. // Handle a returned thenable
  21012. if ( isFunction( then ) ) {
  21013. // Special processors (notify) just wait for resolution
  21014. if ( special ) {
  21015. then.call(
  21016. returned,
  21017. resolve( maxDepth, deferred, Identity, special ),
  21018. resolve( maxDepth, deferred, Thrower, special )
  21019. );
  21020. // Normal processors (resolve) also hook into progress
  21021. } else {
  21022. // ...and disregard older resolution values
  21023. maxDepth++;
  21024. then.call(
  21025. returned,
  21026. resolve( maxDepth, deferred, Identity, special ),
  21027. resolve( maxDepth, deferred, Thrower, special ),
  21028. resolve( maxDepth, deferred, Identity,
  21029. deferred.notifyWith )
  21030. );
  21031. }
  21032. // Handle all other returned values
  21033. } else {
  21034. // Only substitute handlers pass on context
  21035. // and multiple values (non-spec behavior)
  21036. if ( handler !== Identity ) {
  21037. that = undefined;
  21038. args = [ returned ];
  21039. }
  21040. // Process the value(s)
  21041. // Default process is resolve
  21042. ( special || deferred.resolveWith )( that, args );
  21043. }
  21044. },
  21045. // Only normal processors (resolve) catch and reject exceptions
  21046. process = special ?
  21047. mightThrow :
  21048. function() {
  21049. try {
  21050. mightThrow();
  21051. } catch ( e ) {
  21052. if ( jQuery.Deferred.exceptionHook ) {
  21053. jQuery.Deferred.exceptionHook( e,
  21054. process.stackTrace );
  21055. }
  21056. // Support: Promises/A+ section 2.3.3.3.4.1
  21057. // https://promisesaplus.com/#point-61
  21058. // Ignore post-resolution exceptions
  21059. if ( depth + 1 >= maxDepth ) {
  21060. // Only substitute handlers pass on context
  21061. // and multiple values (non-spec behavior)
  21062. if ( handler !== Thrower ) {
  21063. that = undefined;
  21064. args = [ e ];
  21065. }
  21066. deferred.rejectWith( that, args );
  21067. }
  21068. }
  21069. };
  21070. // Support: Promises/A+ section 2.3.3.3.1
  21071. // https://promisesaplus.com/#point-57
  21072. // Re-resolve promises immediately to dodge false rejection from
  21073. // subsequent errors
  21074. if ( depth ) {
  21075. process();
  21076. } else {
  21077. // Call an optional hook to record the stack, in case of exception
  21078. // since it's otherwise lost when execution goes async
  21079. if ( jQuery.Deferred.getStackHook ) {
  21080. process.stackTrace = jQuery.Deferred.getStackHook();
  21081. }
  21082. window.setTimeout( process );
  21083. }
  21084. };
  21085. }
  21086. return jQuery.Deferred( function( newDefer ) {
  21087. // progress_handlers.add( ... )
  21088. tuples[ 0 ][ 3 ].add(
  21089. resolve(
  21090. 0,
  21091. newDefer,
  21092. isFunction( onProgress ) ?
  21093. onProgress :
  21094. Identity,
  21095. newDefer.notifyWith
  21096. )
  21097. );
  21098. // fulfilled_handlers.add( ... )
  21099. tuples[ 1 ][ 3 ].add(
  21100. resolve(
  21101. 0,
  21102. newDefer,
  21103. isFunction( onFulfilled ) ?
  21104. onFulfilled :
  21105. Identity
  21106. )
  21107. );
  21108. // rejected_handlers.add( ... )
  21109. tuples[ 2 ][ 3 ].add(
  21110. resolve(
  21111. 0,
  21112. newDefer,
  21113. isFunction( onRejected ) ?
  21114. onRejected :
  21115. Thrower
  21116. )
  21117. );
  21118. } ).promise();
  21119. },
  21120. // Get a promise for this deferred
  21121. // If obj is provided, the promise aspect is added to the object
  21122. promise: function( obj ) {
  21123. return obj != null ? jQuery.extend( obj, promise ) : promise;
  21124. }
  21125. },
  21126. deferred = {};
  21127. // Add list-specific methods
  21128. jQuery.each( tuples, function( i, tuple ) {
  21129. var list = tuple[ 2 ],
  21130. stateString = tuple[ 5 ];
  21131. // promise.progress = list.add
  21132. // promise.done = list.add
  21133. // promise.fail = list.add
  21134. promise[ tuple[ 1 ] ] = list.add;
  21135. // Handle state
  21136. if ( stateString ) {
  21137. list.add(
  21138. function() {
  21139. // state = "resolved" (i.e., fulfilled)
  21140. // state = "rejected"
  21141. state = stateString;
  21142. },
  21143. // rejected_callbacks.disable
  21144. // fulfilled_callbacks.disable
  21145. tuples[ 3 - i ][ 2 ].disable,
  21146. // rejected_handlers.disable
  21147. // fulfilled_handlers.disable
  21148. tuples[ 3 - i ][ 3 ].disable,
  21149. // progress_callbacks.lock
  21150. tuples[ 0 ][ 2 ].lock,
  21151. // progress_handlers.lock
  21152. tuples[ 0 ][ 3 ].lock
  21153. );
  21154. }
  21155. // progress_handlers.fire
  21156. // fulfilled_handlers.fire
  21157. // rejected_handlers.fire
  21158. list.add( tuple[ 3 ].fire );
  21159. // deferred.notify = function() { deferred.notifyWith(...) }
  21160. // deferred.resolve = function() { deferred.resolveWith(...) }
  21161. // deferred.reject = function() { deferred.rejectWith(...) }
  21162. deferred[ tuple[ 0 ] ] = function() {
  21163. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  21164. return this;
  21165. };
  21166. // deferred.notifyWith = list.fireWith
  21167. // deferred.resolveWith = list.fireWith
  21168. // deferred.rejectWith = list.fireWith
  21169. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  21170. } );
  21171. // Make the deferred a promise
  21172. promise.promise( deferred );
  21173. // Call given func if any
  21174. if ( func ) {
  21175. func.call( deferred, deferred );
  21176. }
  21177. // All done!
  21178. return deferred;
  21179. },
  21180. // Deferred helper
  21181. when: function( singleValue ) {
  21182. var
  21183. // count of uncompleted subordinates
  21184. remaining = arguments.length,
  21185. // count of unprocessed arguments
  21186. i = remaining,
  21187. // subordinate fulfillment data
  21188. resolveContexts = Array( i ),
  21189. resolveValues = slice.call( arguments ),
  21190. // the primary Deferred
  21191. primary = jQuery.Deferred(),
  21192. // subordinate callback factory
  21193. updateFunc = function( i ) {
  21194. return function( value ) {
  21195. resolveContexts[ i ] = this;
  21196. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  21197. if ( !( --remaining ) ) {
  21198. primary.resolveWith( resolveContexts, resolveValues );
  21199. }
  21200. };
  21201. };
  21202. // Single- and empty arguments are adopted like Promise.resolve
  21203. if ( remaining <= 1 ) {
  21204. adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
  21205. !remaining );
  21206. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  21207. if ( primary.state() === "pending" ||
  21208. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  21209. return primary.then();
  21210. }
  21211. }
  21212. // Multiple arguments are aggregated like Promise.all array elements
  21213. while ( i-- ) {
  21214. adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
  21215. }
  21216. return primary.promise();
  21217. }
  21218. } );
  21219. // These usually indicate a programmer mistake during development,
  21220. // warn about them ASAP rather than swallowing them by default.
  21221. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  21222. jQuery.Deferred.exceptionHook = function( error, stack ) {
  21223. // Support: IE 8 - 9 only
  21224. // Console exists when dev tools are open, which can happen at any time
  21225. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  21226. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  21227. }
  21228. };
  21229. jQuery.readyException = function( error ) {
  21230. window.setTimeout( function() {
  21231. throw error;
  21232. } );
  21233. };
  21234. // The deferred used on DOM ready
  21235. var readyList = jQuery.Deferred();
  21236. jQuery.fn.ready = function( fn ) {
  21237. readyList
  21238. .then( fn )
  21239. // Wrap jQuery.readyException in a function so that the lookup
  21240. // happens at the time of error handling instead of callback
  21241. // registration.
  21242. .catch( function( error ) {
  21243. jQuery.readyException( error );
  21244. } );
  21245. return this;
  21246. };
  21247. jQuery.extend( {
  21248. // Is the DOM ready to be used? Set to true once it occurs.
  21249. isReady: false,
  21250. // A counter to track how many items to wait for before
  21251. // the ready event fires. See #6781
  21252. readyWait: 1,
  21253. // Handle when the DOM is ready
  21254. ready: function( wait ) {
  21255. // Abort if there are pending holds or we're already ready
  21256. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  21257. return;
  21258. }
  21259. // Remember that the DOM is ready
  21260. jQuery.isReady = true;
  21261. // If a normal DOM Ready event fired, decrement, and wait if need be
  21262. if ( wait !== true && --jQuery.readyWait > 0 ) {
  21263. return;
  21264. }
  21265. // If there are functions bound, to execute
  21266. readyList.resolveWith( document, [ jQuery ] );
  21267. }
  21268. } );
  21269. jQuery.ready.then = readyList.then;
  21270. // The ready event handler and self cleanup method
  21271. function completed() {
  21272. document.removeEventListener( "DOMContentLoaded", completed );
  21273. window.removeEventListener( "load", completed );
  21274. jQuery.ready();
  21275. }
  21276. // Catch cases where $(document).ready() is called
  21277. // after the browser event has already occurred.
  21278. // Support: IE <=9 - 10 only
  21279. // Older IE sometimes signals "interactive" too soon
  21280. if ( document.readyState === "complete" ||
  21281. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  21282. // Handle it asynchronously to allow scripts the opportunity to delay ready
  21283. window.setTimeout( jQuery.ready );
  21284. } else {
  21285. // Use the handy event callback
  21286. document.addEventListener( "DOMContentLoaded", completed );
  21287. // A fallback to window.onload, that will always work
  21288. window.addEventListener( "load", completed );
  21289. }
  21290. // Multifunctional method to get and set values of a collection
  21291. // The value/s can optionally be executed if it's a function
  21292. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  21293. var i = 0,
  21294. len = elems.length,
  21295. bulk = key == null;
  21296. // Sets many values
  21297. if ( toType( key ) === "object" ) {
  21298. chainable = true;
  21299. for ( i in key ) {
  21300. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  21301. }
  21302. // Sets one value
  21303. } else if ( value !== undefined ) {
  21304. chainable = true;
  21305. if ( !isFunction( value ) ) {
  21306. raw = true;
  21307. }
  21308. if ( bulk ) {
  21309. // Bulk operations run against the entire set
  21310. if ( raw ) {
  21311. fn.call( elems, value );
  21312. fn = null;
  21313. // ...except when executing function values
  21314. } else {
  21315. bulk = fn;
  21316. fn = function( elem, _key, value ) {
  21317. return bulk.call( jQuery( elem ), value );
  21318. };
  21319. }
  21320. }
  21321. if ( fn ) {
  21322. for ( ; i < len; i++ ) {
  21323. fn(
  21324. elems[ i ], key, raw ?
  21325. value :
  21326. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  21327. );
  21328. }
  21329. }
  21330. }
  21331. if ( chainable ) {
  21332. return elems;
  21333. }
  21334. // Gets
  21335. if ( bulk ) {
  21336. return fn.call( elems );
  21337. }
  21338. return len ? fn( elems[ 0 ], key ) : emptyGet;
  21339. };
  21340. // Matches dashed string for camelizing
  21341. var rmsPrefix = /^-ms-/,
  21342. rdashAlpha = /-([a-z])/g;
  21343. // Used by camelCase as callback to replace()
  21344. function fcamelCase( _all, letter ) {
  21345. return letter.toUpperCase();
  21346. }
  21347. // Convert dashed to camelCase; used by the css and data modules
  21348. // Support: IE <=9 - 11, Edge 12 - 15
  21349. // Microsoft forgot to hump their vendor prefix (#9572)
  21350. function camelCase( string ) {
  21351. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  21352. }
  21353. var acceptData = function( owner ) {
  21354. // Accepts only:
  21355. // - Node
  21356. // - Node.ELEMENT_NODE
  21357. // - Node.DOCUMENT_NODE
  21358. // - Object
  21359. // - Any
  21360. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  21361. };
  21362. function Data() {
  21363. this.expando = jQuery.expando + Data.uid++;
  21364. }
  21365. Data.uid = 1;
  21366. Data.prototype = {
  21367. cache: function( owner ) {
  21368. // Check if the owner object already has a cache
  21369. var value = owner[ this.expando ];
  21370. // If not, create one
  21371. if ( !value ) {
  21372. value = {};
  21373. // We can accept data for non-element nodes in modern browsers,
  21374. // but we should not, see #8335.
  21375. // Always return an empty object.
  21376. if ( acceptData( owner ) ) {
  21377. // If it is a node unlikely to be stringify-ed or looped over
  21378. // use plain assignment
  21379. if ( owner.nodeType ) {
  21380. owner[ this.expando ] = value;
  21381. // Otherwise secure it in a non-enumerable property
  21382. // configurable must be true to allow the property to be
  21383. // deleted when data is removed
  21384. } else {
  21385. Object.defineProperty( owner, this.expando, {
  21386. value: value,
  21387. configurable: true
  21388. } );
  21389. }
  21390. }
  21391. }
  21392. return value;
  21393. },
  21394. set: function( owner, data, value ) {
  21395. var prop,
  21396. cache = this.cache( owner );
  21397. // Handle: [ owner, key, value ] args
  21398. // Always use camelCase key (gh-2257)
  21399. if ( typeof data === "string" ) {
  21400. cache[ camelCase( data ) ] = value;
  21401. // Handle: [ owner, { properties } ] args
  21402. } else {
  21403. // Copy the properties one-by-one to the cache object
  21404. for ( prop in data ) {
  21405. cache[ camelCase( prop ) ] = data[ prop ];
  21406. }
  21407. }
  21408. return cache;
  21409. },
  21410. get: function( owner, key ) {
  21411. return key === undefined ?
  21412. this.cache( owner ) :
  21413. // Always use camelCase key (gh-2257)
  21414. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  21415. },
  21416. access: function( owner, key, value ) {
  21417. // In cases where either:
  21418. //
  21419. // 1. No key was specified
  21420. // 2. A string key was specified, but no value provided
  21421. //
  21422. // Take the "read" path and allow the get method to determine
  21423. // which value to return, respectively either:
  21424. //
  21425. // 1. The entire cache object
  21426. // 2. The data stored at the key
  21427. //
  21428. if ( key === undefined ||
  21429. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  21430. return this.get( owner, key );
  21431. }
  21432. // When the key is not a string, or both a key and value
  21433. // are specified, set or extend (existing objects) with either:
  21434. //
  21435. // 1. An object of properties
  21436. // 2. A key and value
  21437. //
  21438. this.set( owner, key, value );
  21439. // Since the "set" path can have two possible entry points
  21440. // return the expected data based on which path was taken[*]
  21441. return value !== undefined ? value : key;
  21442. },
  21443. remove: function( owner, key ) {
  21444. var i,
  21445. cache = owner[ this.expando ];
  21446. if ( cache === undefined ) {
  21447. return;
  21448. }
  21449. if ( key !== undefined ) {
  21450. // Support array or space separated string of keys
  21451. if ( Array.isArray( key ) ) {
  21452. // If key is an array of keys...
  21453. // We always set camelCase keys, so remove that.
  21454. key = key.map( camelCase );
  21455. } else {
  21456. key = camelCase( key );
  21457. // If a key with the spaces exists, use it.
  21458. // Otherwise, create an array by matching non-whitespace
  21459. key = key in cache ?
  21460. [ key ] :
  21461. ( key.match( rnothtmlwhite ) || [] );
  21462. }
  21463. i = key.length;
  21464. while ( i-- ) {
  21465. delete cache[ key[ i ] ];
  21466. }
  21467. }
  21468. // Remove the expando if there's no more data
  21469. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  21470. // Support: Chrome <=35 - 45
  21471. // Webkit & Blink performance suffers when deleting properties
  21472. // from DOM nodes, so set to undefined instead
  21473. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  21474. if ( owner.nodeType ) {
  21475. owner[ this.expando ] = undefined;
  21476. } else {
  21477. delete owner[ this.expando ];
  21478. }
  21479. }
  21480. },
  21481. hasData: function( owner ) {
  21482. var cache = owner[ this.expando ];
  21483. return cache !== undefined && !jQuery.isEmptyObject( cache );
  21484. }
  21485. };
  21486. var dataPriv = new Data();
  21487. var dataUser = new Data();
  21488. // Implementation Summary
  21489. //
  21490. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  21491. // 2. Improve the module's maintainability by reducing the storage
  21492. // paths to a single mechanism.
  21493. // 3. Use the same single mechanism to support "private" and "user" data.
  21494. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  21495. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  21496. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  21497. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  21498. rmultiDash = /[A-Z]/g;
  21499. function getData( data ) {
  21500. if ( data === "true" ) {
  21501. return true;
  21502. }
  21503. if ( data === "false" ) {
  21504. return false;
  21505. }
  21506. if ( data === "null" ) {
  21507. return null;
  21508. }
  21509. // Only convert to a number if it doesn't change the string
  21510. if ( data === +data + "" ) {
  21511. return +data;
  21512. }
  21513. if ( rbrace.test( data ) ) {
  21514. return JSON.parse( data );
  21515. }
  21516. return data;
  21517. }
  21518. function dataAttr( elem, key, data ) {
  21519. var name;
  21520. // If nothing was found internally, try to fetch any
  21521. // data from the HTML5 data-* attribute
  21522. if ( data === undefined && elem.nodeType === 1 ) {
  21523. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  21524. data = elem.getAttribute( name );
  21525. if ( typeof data === "string" ) {
  21526. try {
  21527. data = getData( data );
  21528. } catch ( e ) {}
  21529. // Make sure we set the data so it isn't changed later
  21530. dataUser.set( elem, key, data );
  21531. } else {
  21532. data = undefined;
  21533. }
  21534. }
  21535. return data;
  21536. }
  21537. jQuery.extend( {
  21538. hasData: function( elem ) {
  21539. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  21540. },
  21541. data: function( elem, name, data ) {
  21542. return dataUser.access( elem, name, data );
  21543. },
  21544. removeData: function( elem, name ) {
  21545. dataUser.remove( elem, name );
  21546. },
  21547. // TODO: Now that all calls to _data and _removeData have been replaced
  21548. // with direct calls to dataPriv methods, these can be deprecated.
  21549. _data: function( elem, name, data ) {
  21550. return dataPriv.access( elem, name, data );
  21551. },
  21552. _removeData: function( elem, name ) {
  21553. dataPriv.remove( elem, name );
  21554. }
  21555. } );
  21556. jQuery.fn.extend( {
  21557. data: function( key, value ) {
  21558. var i, name, data,
  21559. elem = this[ 0 ],
  21560. attrs = elem && elem.attributes;
  21561. // Gets all values
  21562. if ( key === undefined ) {
  21563. if ( this.length ) {
  21564. data = dataUser.get( elem );
  21565. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  21566. i = attrs.length;
  21567. while ( i-- ) {
  21568. // Support: IE 11 only
  21569. // The attrs elements can be null (#14894)
  21570. if ( attrs[ i ] ) {
  21571. name = attrs[ i ].name;
  21572. if ( name.indexOf( "data-" ) === 0 ) {
  21573. name = camelCase( name.slice( 5 ) );
  21574. dataAttr( elem, name, data[ name ] );
  21575. }
  21576. }
  21577. }
  21578. dataPriv.set( elem, "hasDataAttrs", true );
  21579. }
  21580. }
  21581. return data;
  21582. }
  21583. // Sets multiple values
  21584. if ( typeof key === "object" ) {
  21585. return this.each( function() {
  21586. dataUser.set( this, key );
  21587. } );
  21588. }
  21589. return access( this, function( value ) {
  21590. var data;
  21591. // The calling jQuery object (element matches) is not empty
  21592. // (and therefore has an element appears at this[ 0 ]) and the
  21593. // `value` parameter was not undefined. An empty jQuery object
  21594. // will result in `undefined` for elem = this[ 0 ] which will
  21595. // throw an exception if an attempt to read a data cache is made.
  21596. if ( elem && value === undefined ) {
  21597. // Attempt to get data from the cache
  21598. // The key will always be camelCased in Data
  21599. data = dataUser.get( elem, key );
  21600. if ( data !== undefined ) {
  21601. return data;
  21602. }
  21603. // Attempt to "discover" the data in
  21604. // HTML5 custom data-* attrs
  21605. data = dataAttr( elem, key );
  21606. if ( data !== undefined ) {
  21607. return data;
  21608. }
  21609. // We tried really hard, but the data doesn't exist.
  21610. return;
  21611. }
  21612. // Set the data...
  21613. this.each( function() {
  21614. // We always store the camelCased key
  21615. dataUser.set( this, key, value );
  21616. } );
  21617. }, null, value, arguments.length > 1, null, true );
  21618. },
  21619. removeData: function( key ) {
  21620. return this.each( function() {
  21621. dataUser.remove( this, key );
  21622. } );
  21623. }
  21624. } );
  21625. jQuery.extend( {
  21626. queue: function( elem, type, data ) {
  21627. var queue;
  21628. if ( elem ) {
  21629. type = ( type || "fx" ) + "queue";
  21630. queue = dataPriv.get( elem, type );
  21631. // Speed up dequeue by getting out quickly if this is just a lookup
  21632. if ( data ) {
  21633. if ( !queue || Array.isArray( data ) ) {
  21634. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  21635. } else {
  21636. queue.push( data );
  21637. }
  21638. }
  21639. return queue || [];
  21640. }
  21641. },
  21642. dequeue: function( elem, type ) {
  21643. type = type || "fx";
  21644. var queue = jQuery.queue( elem, type ),
  21645. startLength = queue.length,
  21646. fn = queue.shift(),
  21647. hooks = jQuery._queueHooks( elem, type ),
  21648. next = function() {
  21649. jQuery.dequeue( elem, type );
  21650. };
  21651. // If the fx queue is dequeued, always remove the progress sentinel
  21652. if ( fn === "inprogress" ) {
  21653. fn = queue.shift();
  21654. startLength--;
  21655. }
  21656. if ( fn ) {
  21657. // Add a progress sentinel to prevent the fx queue from being
  21658. // automatically dequeued
  21659. if ( type === "fx" ) {
  21660. queue.unshift( "inprogress" );
  21661. }
  21662. // Clear up the last queue stop function
  21663. delete hooks.stop;
  21664. fn.call( elem, next, hooks );
  21665. }
  21666. if ( !startLength && hooks ) {
  21667. hooks.empty.fire();
  21668. }
  21669. },
  21670. // Not public - generate a queueHooks object, or return the current one
  21671. _queueHooks: function( elem, type ) {
  21672. var key = type + "queueHooks";
  21673. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  21674. empty: jQuery.Callbacks( "once memory" ).add( function() {
  21675. dataPriv.remove( elem, [ type + "queue", key ] );
  21676. } )
  21677. } );
  21678. }
  21679. } );
  21680. jQuery.fn.extend( {
  21681. queue: function( type, data ) {
  21682. var setter = 2;
  21683. if ( typeof type !== "string" ) {
  21684. data = type;
  21685. type = "fx";
  21686. setter--;
  21687. }
  21688. if ( arguments.length < setter ) {
  21689. return jQuery.queue( this[ 0 ], type );
  21690. }
  21691. return data === undefined ?
  21692. this :
  21693. this.each( function() {
  21694. var queue = jQuery.queue( this, type, data );
  21695. // Ensure a hooks for this queue
  21696. jQuery._queueHooks( this, type );
  21697. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  21698. jQuery.dequeue( this, type );
  21699. }
  21700. } );
  21701. },
  21702. dequeue: function( type ) {
  21703. return this.each( function() {
  21704. jQuery.dequeue( this, type );
  21705. } );
  21706. },
  21707. clearQueue: function( type ) {
  21708. return this.queue( type || "fx", [] );
  21709. },
  21710. // Get a promise resolved when queues of a certain type
  21711. // are emptied (fx is the type by default)
  21712. promise: function( type, obj ) {
  21713. var tmp,
  21714. count = 1,
  21715. defer = jQuery.Deferred(),
  21716. elements = this,
  21717. i = this.length,
  21718. resolve = function() {
  21719. if ( !( --count ) ) {
  21720. defer.resolveWith( elements, [ elements ] );
  21721. }
  21722. };
  21723. if ( typeof type !== "string" ) {
  21724. obj = type;
  21725. type = undefined;
  21726. }
  21727. type = type || "fx";
  21728. while ( i-- ) {
  21729. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  21730. if ( tmp && tmp.empty ) {
  21731. count++;
  21732. tmp.empty.add( resolve );
  21733. }
  21734. }
  21735. resolve();
  21736. return defer.promise( obj );
  21737. }
  21738. } );
  21739. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  21740. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  21741. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  21742. var documentElement = document.documentElement;
  21743. var isAttached = function( elem ) {
  21744. return jQuery.contains( elem.ownerDocument, elem );
  21745. },
  21746. composed = { composed: true };
  21747. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  21748. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  21749. // Support: iOS 10.0-10.2 only
  21750. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  21751. // leading to errors. We need to check for `getRootNode`.
  21752. if ( documentElement.getRootNode ) {
  21753. isAttached = function( elem ) {
  21754. return jQuery.contains( elem.ownerDocument, elem ) ||
  21755. elem.getRootNode( composed ) === elem.ownerDocument;
  21756. };
  21757. }
  21758. var isHiddenWithinTree = function( elem, el ) {
  21759. // isHiddenWithinTree might be called from jQuery#filter function;
  21760. // in that case, element will be second argument
  21761. elem = el || elem;
  21762. // Inline style trumps all
  21763. return elem.style.display === "none" ||
  21764. elem.style.display === "" &&
  21765. // Otherwise, check computed style
  21766. // Support: Firefox <=43 - 45
  21767. // Disconnected elements can have computed display: none, so first confirm that elem is
  21768. // in the document.
  21769. isAttached( elem ) &&
  21770. jQuery.css( elem, "display" ) === "none";
  21771. };
  21772. function adjustCSS( elem, prop, valueParts, tween ) {
  21773. var adjusted, scale,
  21774. maxIterations = 20,
  21775. currentValue = tween ?
  21776. function() {
  21777. return tween.cur();
  21778. } :
  21779. function() {
  21780. return jQuery.css( elem, prop, "" );
  21781. },
  21782. initial = currentValue(),
  21783. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  21784. // Starting value computation is required for potential unit mismatches
  21785. initialInUnit = elem.nodeType &&
  21786. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  21787. rcssNum.exec( jQuery.css( elem, prop ) );
  21788. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  21789. // Support: Firefox <=54
  21790. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  21791. initial = initial / 2;
  21792. // Trust units reported by jQuery.css
  21793. unit = unit || initialInUnit[ 3 ];
  21794. // Iteratively approximate from a nonzero starting point
  21795. initialInUnit = +initial || 1;
  21796. while ( maxIterations-- ) {
  21797. // Evaluate and update our best guess (doubling guesses that zero out).
  21798. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  21799. jQuery.style( elem, prop, initialInUnit + unit );
  21800. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  21801. maxIterations = 0;
  21802. }
  21803. initialInUnit = initialInUnit / scale;
  21804. }
  21805. initialInUnit = initialInUnit * 2;
  21806. jQuery.style( elem, prop, initialInUnit + unit );
  21807. // Make sure we update the tween properties later on
  21808. valueParts = valueParts || [];
  21809. }
  21810. if ( valueParts ) {
  21811. initialInUnit = +initialInUnit || +initial || 0;
  21812. // Apply relative offset (+=/-=) if specified
  21813. adjusted = valueParts[ 1 ] ?
  21814. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  21815. +valueParts[ 2 ];
  21816. if ( tween ) {
  21817. tween.unit = unit;
  21818. tween.start = initialInUnit;
  21819. tween.end = adjusted;
  21820. }
  21821. }
  21822. return adjusted;
  21823. }
  21824. var defaultDisplayMap = {};
  21825. function getDefaultDisplay( elem ) {
  21826. var temp,
  21827. doc = elem.ownerDocument,
  21828. nodeName = elem.nodeName,
  21829. display = defaultDisplayMap[ nodeName ];
  21830. if ( display ) {
  21831. return display;
  21832. }
  21833. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  21834. display = jQuery.css( temp, "display" );
  21835. temp.parentNode.removeChild( temp );
  21836. if ( display === "none" ) {
  21837. display = "block";
  21838. }
  21839. defaultDisplayMap[ nodeName ] = display;
  21840. return display;
  21841. }
  21842. function showHide( elements, show ) {
  21843. var display, elem,
  21844. values = [],
  21845. index = 0,
  21846. length = elements.length;
  21847. // Determine new display value for elements that need to change
  21848. for ( ; index < length; index++ ) {
  21849. elem = elements[ index ];
  21850. if ( !elem.style ) {
  21851. continue;
  21852. }
  21853. display = elem.style.display;
  21854. if ( show ) {
  21855. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  21856. // check is required in this first loop unless we have a nonempty display value (either
  21857. // inline or about-to-be-restored)
  21858. if ( display === "none" ) {
  21859. values[ index ] = dataPriv.get( elem, "display" ) || null;
  21860. if ( !values[ index ] ) {
  21861. elem.style.display = "";
  21862. }
  21863. }
  21864. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  21865. values[ index ] = getDefaultDisplay( elem );
  21866. }
  21867. } else {
  21868. if ( display !== "none" ) {
  21869. values[ index ] = "none";
  21870. // Remember what we're overwriting
  21871. dataPriv.set( elem, "display", display );
  21872. }
  21873. }
  21874. }
  21875. // Set the display of the elements in a second loop to avoid constant reflow
  21876. for ( index = 0; index < length; index++ ) {
  21877. if ( values[ index ] != null ) {
  21878. elements[ index ].style.display = values[ index ];
  21879. }
  21880. }
  21881. return elements;
  21882. }
  21883. jQuery.fn.extend( {
  21884. show: function() {
  21885. return showHide( this, true );
  21886. },
  21887. hide: function() {
  21888. return showHide( this );
  21889. },
  21890. toggle: function( state ) {
  21891. if ( typeof state === "boolean" ) {
  21892. return state ? this.show() : this.hide();
  21893. }
  21894. return this.each( function() {
  21895. if ( isHiddenWithinTree( this ) ) {
  21896. jQuery( this ).show();
  21897. } else {
  21898. jQuery( this ).hide();
  21899. }
  21900. } );
  21901. }
  21902. } );
  21903. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  21904. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  21905. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  21906. ( function() {
  21907. var fragment = document.createDocumentFragment(),
  21908. div = fragment.appendChild( document.createElement( "div" ) ),
  21909. input = document.createElement( "input" );
  21910. // Support: Android 4.0 - 4.3 only
  21911. // Check state lost if the name is set (#11217)
  21912. // Support: Windows Web Apps (WWA)
  21913. // `name` and `type` must use .setAttribute for WWA (#14901)
  21914. input.setAttribute( "type", "radio" );
  21915. input.setAttribute( "checked", "checked" );
  21916. input.setAttribute( "name", "t" );
  21917. div.appendChild( input );
  21918. // Support: Android <=4.1 only
  21919. // Older WebKit doesn't clone checked state correctly in fragments
  21920. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  21921. // Support: IE <=11 only
  21922. // Make sure textarea (and checkbox) defaultValue is properly cloned
  21923. div.innerHTML = "<textarea>x</textarea>";
  21924. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  21925. // Support: IE <=9 only
  21926. // IE <=9 replaces <option> tags with their contents when inserted outside of
  21927. // the select element.
  21928. div.innerHTML = "<option></option>";
  21929. support.option = !!div.lastChild;
  21930. } )();
  21931. // We have to close these tags to support XHTML (#13200)
  21932. var wrapMap = {
  21933. // XHTML parsers do not magically insert elements in the
  21934. // same way that tag soup parsers do. So we cannot shorten
  21935. // this by omitting <tbody> or other required elements.
  21936. thead: [ 1, "<table>", "</table>" ],
  21937. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  21938. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  21939. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  21940. _default: [ 0, "", "" ]
  21941. };
  21942. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  21943. wrapMap.th = wrapMap.td;
  21944. // Support: IE <=9 only
  21945. if ( !support.option ) {
  21946. wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
  21947. }
  21948. function getAll( context, tag ) {
  21949. // Support: IE <=9 - 11 only
  21950. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  21951. var ret;
  21952. if ( typeof context.getElementsByTagName !== "undefined" ) {
  21953. ret = context.getElementsByTagName( tag || "*" );
  21954. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  21955. ret = context.querySelectorAll( tag || "*" );
  21956. } else {
  21957. ret = [];
  21958. }
  21959. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  21960. return jQuery.merge( [ context ], ret );
  21961. }
  21962. return ret;
  21963. }
  21964. // Mark scripts as having already been evaluated
  21965. function setGlobalEval( elems, refElements ) {
  21966. var i = 0,
  21967. l = elems.length;
  21968. for ( ; i < l; i++ ) {
  21969. dataPriv.set(
  21970. elems[ i ],
  21971. "globalEval",
  21972. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  21973. );
  21974. }
  21975. }
  21976. var rhtml = /<|&#?\w+;/;
  21977. function buildFragment( elems, context, scripts, selection, ignored ) {
  21978. var elem, tmp, tag, wrap, attached, j,
  21979. fragment = context.createDocumentFragment(),
  21980. nodes = [],
  21981. i = 0,
  21982. l = elems.length;
  21983. for ( ; i < l; i++ ) {
  21984. elem = elems[ i ];
  21985. if ( elem || elem === 0 ) {
  21986. // Add nodes directly
  21987. if ( toType( elem ) === "object" ) {
  21988. // Support: Android <=4.0 only, PhantomJS 1 only
  21989. // push.apply(_, arraylike) throws on ancient WebKit
  21990. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  21991. // Convert non-html into a text node
  21992. } else if ( !rhtml.test( elem ) ) {
  21993. nodes.push( context.createTextNode( elem ) );
  21994. // Convert html into DOM nodes
  21995. } else {
  21996. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  21997. // Deserialize a standard representation
  21998. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  21999. wrap = wrapMap[ tag ] || wrapMap._default;
  22000. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  22001. // Descend through wrappers to the right content
  22002. j = wrap[ 0 ];
  22003. while ( j-- ) {
  22004. tmp = tmp.lastChild;
  22005. }
  22006. // Support: Android <=4.0 only, PhantomJS 1 only
  22007. // push.apply(_, arraylike) throws on ancient WebKit
  22008. jQuery.merge( nodes, tmp.childNodes );
  22009. // Remember the top-level container
  22010. tmp = fragment.firstChild;
  22011. // Ensure the created nodes are orphaned (#12392)
  22012. tmp.textContent = "";
  22013. }
  22014. }
  22015. }
  22016. // Remove wrapper from fragment
  22017. fragment.textContent = "";
  22018. i = 0;
  22019. while ( ( elem = nodes[ i++ ] ) ) {
  22020. // Skip elements already in the context collection (trac-4087)
  22021. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  22022. if ( ignored ) {
  22023. ignored.push( elem );
  22024. }
  22025. continue;
  22026. }
  22027. attached = isAttached( elem );
  22028. // Append to fragment
  22029. tmp = getAll( fragment.appendChild( elem ), "script" );
  22030. // Preserve script evaluation history
  22031. if ( attached ) {
  22032. setGlobalEval( tmp );
  22033. }
  22034. // Capture executables
  22035. if ( scripts ) {
  22036. j = 0;
  22037. while ( ( elem = tmp[ j++ ] ) ) {
  22038. if ( rscriptType.test( elem.type || "" ) ) {
  22039. scripts.push( elem );
  22040. }
  22041. }
  22042. }
  22043. }
  22044. return fragment;
  22045. }
  22046. var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  22047. function returnTrue() {
  22048. return true;
  22049. }
  22050. function returnFalse() {
  22051. return false;
  22052. }
  22053. // Support: IE <=9 - 11+
  22054. // focus() and blur() are asynchronous, except when they are no-op.
  22055. // So expect focus to be synchronous when the element is already active,
  22056. // and blur to be synchronous when the element is not already active.
  22057. // (focus and blur are always synchronous in other supported browsers,
  22058. // this just defines when we can count on it).
  22059. function expectSync( elem, type ) {
  22060. return ( elem === safeActiveElement() ) === ( type === "focus" );
  22061. }
  22062. // Support: IE <=9 only
  22063. // Accessing document.activeElement can throw unexpectedly
  22064. // https://bugs.jquery.com/ticket/13393
  22065. function safeActiveElement() {
  22066. try {
  22067. return document.activeElement;
  22068. } catch ( err ) { }
  22069. }
  22070. function on( elem, types, selector, data, fn, one ) {
  22071. var origFn, type;
  22072. // Types can be a map of types/handlers
  22073. if ( typeof types === "object" ) {
  22074. // ( types-Object, selector, data )
  22075. if ( typeof selector !== "string" ) {
  22076. // ( types-Object, data )
  22077. data = data || selector;
  22078. selector = undefined;
  22079. }
  22080. for ( type in types ) {
  22081. on( elem, type, selector, data, types[ type ], one );
  22082. }
  22083. return elem;
  22084. }
  22085. if ( data == null && fn == null ) {
  22086. // ( types, fn )
  22087. fn = selector;
  22088. data = selector = undefined;
  22089. } else if ( fn == null ) {
  22090. if ( typeof selector === "string" ) {
  22091. // ( types, selector, fn )
  22092. fn = data;
  22093. data = undefined;
  22094. } else {
  22095. // ( types, data, fn )
  22096. fn = data;
  22097. data = selector;
  22098. selector = undefined;
  22099. }
  22100. }
  22101. if ( fn === false ) {
  22102. fn = returnFalse;
  22103. } else if ( !fn ) {
  22104. return elem;
  22105. }
  22106. if ( one === 1 ) {
  22107. origFn = fn;
  22108. fn = function( event ) {
  22109. // Can use an empty set, since event contains the info
  22110. jQuery().off( event );
  22111. return origFn.apply( this, arguments );
  22112. };
  22113. // Use same guid so caller can remove using origFn
  22114. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  22115. }
  22116. return elem.each( function() {
  22117. jQuery.event.add( this, types, fn, data, selector );
  22118. } );
  22119. }
  22120. /*
  22121. * Helper functions for managing events -- not part of the public interface.
  22122. * Props to Dean Edwards' addEvent library for many of the ideas.
  22123. */
  22124. jQuery.event = {
  22125. global: {},
  22126. add: function( elem, types, handler, data, selector ) {
  22127. var handleObjIn, eventHandle, tmp,
  22128. events, t, handleObj,
  22129. special, handlers, type, namespaces, origType,
  22130. elemData = dataPriv.get( elem );
  22131. // Only attach events to objects that accept data
  22132. if ( !acceptData( elem ) ) {
  22133. return;
  22134. }
  22135. // Caller can pass in an object of custom data in lieu of the handler
  22136. if ( handler.handler ) {
  22137. handleObjIn = handler;
  22138. handler = handleObjIn.handler;
  22139. selector = handleObjIn.selector;
  22140. }
  22141. // Ensure that invalid selectors throw exceptions at attach time
  22142. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  22143. if ( selector ) {
  22144. jQuery.find.matchesSelector( documentElement, selector );
  22145. }
  22146. // Make sure that the handler has a unique ID, used to find/remove it later
  22147. if ( !handler.guid ) {
  22148. handler.guid = jQuery.guid++;
  22149. }
  22150. // Init the element's event structure and main handler, if this is the first
  22151. if ( !( events = elemData.events ) ) {
  22152. events = elemData.events = Object.create( null );
  22153. }
  22154. if ( !( eventHandle = elemData.handle ) ) {
  22155. eventHandle = elemData.handle = function( e ) {
  22156. // Discard the second event of a jQuery.event.trigger() and
  22157. // when an event is called after a page has unloaded
  22158. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  22159. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  22160. };
  22161. }
  22162. // Handle multiple events separated by a space
  22163. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  22164. t = types.length;
  22165. while ( t-- ) {
  22166. tmp = rtypenamespace.exec( types[ t ] ) || [];
  22167. type = origType = tmp[ 1 ];
  22168. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  22169. // There *must* be a type, no attaching namespace-only handlers
  22170. if ( !type ) {
  22171. continue;
  22172. }
  22173. // If event changes its type, use the special event handlers for the changed type
  22174. special = jQuery.event.special[ type ] || {};
  22175. // If selector defined, determine special event api type, otherwise given type
  22176. type = ( selector ? special.delegateType : special.bindType ) || type;
  22177. // Update special based on newly reset type
  22178. special = jQuery.event.special[ type ] || {};
  22179. // handleObj is passed to all event handlers
  22180. handleObj = jQuery.extend( {
  22181. type: type,
  22182. origType: origType,
  22183. data: data,
  22184. handler: handler,
  22185. guid: handler.guid,
  22186. selector: selector,
  22187. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  22188. namespace: namespaces.join( "." )
  22189. }, handleObjIn );
  22190. // Init the event handler queue if we're the first
  22191. if ( !( handlers = events[ type ] ) ) {
  22192. handlers = events[ type ] = [];
  22193. handlers.delegateCount = 0;
  22194. // Only use addEventListener if the special events handler returns false
  22195. if ( !special.setup ||
  22196. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  22197. if ( elem.addEventListener ) {
  22198. elem.addEventListener( type, eventHandle );
  22199. }
  22200. }
  22201. }
  22202. if ( special.add ) {
  22203. special.add.call( elem, handleObj );
  22204. if ( !handleObj.handler.guid ) {
  22205. handleObj.handler.guid = handler.guid;
  22206. }
  22207. }
  22208. // Add to the element's handler list, delegates in front
  22209. if ( selector ) {
  22210. handlers.splice( handlers.delegateCount++, 0, handleObj );
  22211. } else {
  22212. handlers.push( handleObj );
  22213. }
  22214. // Keep track of which events have ever been used, for event optimization
  22215. jQuery.event.global[ type ] = true;
  22216. }
  22217. },
  22218. // Detach an event or set of events from an element
  22219. remove: function( elem, types, handler, selector, mappedTypes ) {
  22220. var j, origCount, tmp,
  22221. events, t, handleObj,
  22222. special, handlers, type, namespaces, origType,
  22223. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  22224. if ( !elemData || !( events = elemData.events ) ) {
  22225. return;
  22226. }
  22227. // Once for each type.namespace in types; type may be omitted
  22228. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  22229. t = types.length;
  22230. while ( t-- ) {
  22231. tmp = rtypenamespace.exec( types[ t ] ) || [];
  22232. type = origType = tmp[ 1 ];
  22233. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  22234. // Unbind all events (on this namespace, if provided) for the element
  22235. if ( !type ) {
  22236. for ( type in events ) {
  22237. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  22238. }
  22239. continue;
  22240. }
  22241. special = jQuery.event.special[ type ] || {};
  22242. type = ( selector ? special.delegateType : special.bindType ) || type;
  22243. handlers = events[ type ] || [];
  22244. tmp = tmp[ 2 ] &&
  22245. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  22246. // Remove matching events
  22247. origCount = j = handlers.length;
  22248. while ( j-- ) {
  22249. handleObj = handlers[ j ];
  22250. if ( ( mappedTypes || origType === handleObj.origType ) &&
  22251. ( !handler || handler.guid === handleObj.guid ) &&
  22252. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  22253. ( !selector || selector === handleObj.selector ||
  22254. selector === "**" && handleObj.selector ) ) {
  22255. handlers.splice( j, 1 );
  22256. if ( handleObj.selector ) {
  22257. handlers.delegateCount--;
  22258. }
  22259. if ( special.remove ) {
  22260. special.remove.call( elem, handleObj );
  22261. }
  22262. }
  22263. }
  22264. // Remove generic event handler if we removed something and no more handlers exist
  22265. // (avoids potential for endless recursion during removal of special event handlers)
  22266. if ( origCount && !handlers.length ) {
  22267. if ( !special.teardown ||
  22268. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  22269. jQuery.removeEvent( elem, type, elemData.handle );
  22270. }
  22271. delete events[ type ];
  22272. }
  22273. }
  22274. // Remove data and the expando if it's no longer used
  22275. if ( jQuery.isEmptyObject( events ) ) {
  22276. dataPriv.remove( elem, "handle events" );
  22277. }
  22278. },
  22279. dispatch: function( nativeEvent ) {
  22280. var i, j, ret, matched, handleObj, handlerQueue,
  22281. args = new Array( arguments.length ),
  22282. // Make a writable jQuery.Event from the native event object
  22283. event = jQuery.event.fix( nativeEvent ),
  22284. handlers = (
  22285. dataPriv.get( this, "events" ) || Object.create( null )
  22286. )[ event.type ] || [],
  22287. special = jQuery.event.special[ event.type ] || {};
  22288. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  22289. args[ 0 ] = event;
  22290. for ( i = 1; i < arguments.length; i++ ) {
  22291. args[ i ] = arguments[ i ];
  22292. }
  22293. event.delegateTarget = this;
  22294. // Call the preDispatch hook for the mapped type, and let it bail if desired
  22295. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  22296. return;
  22297. }
  22298. // Determine handlers
  22299. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  22300. // Run delegates first; they may want to stop propagation beneath us
  22301. i = 0;
  22302. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  22303. event.currentTarget = matched.elem;
  22304. j = 0;
  22305. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  22306. !event.isImmediatePropagationStopped() ) {
  22307. // If the event is namespaced, then each handler is only invoked if it is
  22308. // specially universal or its namespaces are a superset of the event's.
  22309. if ( !event.rnamespace || handleObj.namespace === false ||
  22310. event.rnamespace.test( handleObj.namespace ) ) {
  22311. event.handleObj = handleObj;
  22312. event.data = handleObj.data;
  22313. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  22314. handleObj.handler ).apply( matched.elem, args );
  22315. if ( ret !== undefined ) {
  22316. if ( ( event.result = ret ) === false ) {
  22317. event.preventDefault();
  22318. event.stopPropagation();
  22319. }
  22320. }
  22321. }
  22322. }
  22323. }
  22324. // Call the postDispatch hook for the mapped type
  22325. if ( special.postDispatch ) {
  22326. special.postDispatch.call( this, event );
  22327. }
  22328. return event.result;
  22329. },
  22330. handlers: function( event, handlers ) {
  22331. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  22332. handlerQueue = [],
  22333. delegateCount = handlers.delegateCount,
  22334. cur = event.target;
  22335. // Find delegate handlers
  22336. if ( delegateCount &&
  22337. // Support: IE <=9
  22338. // Black-hole SVG <use> instance trees (trac-13180)
  22339. cur.nodeType &&
  22340. // Support: Firefox <=42
  22341. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  22342. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  22343. // Support: IE 11 only
  22344. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  22345. !( event.type === "click" && event.button >= 1 ) ) {
  22346. for ( ; cur !== this; cur = cur.parentNode || this ) {
  22347. // Don't check non-elements (#13208)
  22348. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  22349. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  22350. matchedHandlers = [];
  22351. matchedSelectors = {};
  22352. for ( i = 0; i < delegateCount; i++ ) {
  22353. handleObj = handlers[ i ];
  22354. // Don't conflict with Object.prototype properties (#13203)
  22355. sel = handleObj.selector + " ";
  22356. if ( matchedSelectors[ sel ] === undefined ) {
  22357. matchedSelectors[ sel ] = handleObj.needsContext ?
  22358. jQuery( sel, this ).index( cur ) > -1 :
  22359. jQuery.find( sel, this, null, [ cur ] ).length;
  22360. }
  22361. if ( matchedSelectors[ sel ] ) {
  22362. matchedHandlers.push( handleObj );
  22363. }
  22364. }
  22365. if ( matchedHandlers.length ) {
  22366. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  22367. }
  22368. }
  22369. }
  22370. }
  22371. // Add the remaining (directly-bound) handlers
  22372. cur = this;
  22373. if ( delegateCount < handlers.length ) {
  22374. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  22375. }
  22376. return handlerQueue;
  22377. },
  22378. addProp: function( name, hook ) {
  22379. Object.defineProperty( jQuery.Event.prototype, name, {
  22380. enumerable: true,
  22381. configurable: true,
  22382. get: isFunction( hook ) ?
  22383. function() {
  22384. if ( this.originalEvent ) {
  22385. return hook( this.originalEvent );
  22386. }
  22387. } :
  22388. function() {
  22389. if ( this.originalEvent ) {
  22390. return this.originalEvent[ name ];
  22391. }
  22392. },
  22393. set: function( value ) {
  22394. Object.defineProperty( this, name, {
  22395. enumerable: true,
  22396. configurable: true,
  22397. writable: true,
  22398. value: value
  22399. } );
  22400. }
  22401. } );
  22402. },
  22403. fix: function( originalEvent ) {
  22404. return originalEvent[ jQuery.expando ] ?
  22405. originalEvent :
  22406. new jQuery.Event( originalEvent );
  22407. },
  22408. special: {
  22409. load: {
  22410. // Prevent triggered image.load events from bubbling to window.load
  22411. noBubble: true
  22412. },
  22413. click: {
  22414. // Utilize native event to ensure correct state for checkable inputs
  22415. setup: function( data ) {
  22416. // For mutual compressibility with _default, replace `this` access with a local var.
  22417. // `|| data` is dead code meant only to preserve the variable through minification.
  22418. var el = this || data;
  22419. // Claim the first handler
  22420. if ( rcheckableType.test( el.type ) &&
  22421. el.click && nodeName( el, "input" ) ) {
  22422. // dataPriv.set( el, "click", ... )
  22423. leverageNative( el, "click", returnTrue );
  22424. }
  22425. // Return false to allow normal processing in the caller
  22426. return false;
  22427. },
  22428. trigger: function( data ) {
  22429. // For mutual compressibility with _default, replace `this` access with a local var.
  22430. // `|| data` is dead code meant only to preserve the variable through minification.
  22431. var el = this || data;
  22432. // Force setup before triggering a click
  22433. if ( rcheckableType.test( el.type ) &&
  22434. el.click && nodeName( el, "input" ) ) {
  22435. leverageNative( el, "click" );
  22436. }
  22437. // Return non-false to allow normal event-path propagation
  22438. return true;
  22439. },
  22440. // For cross-browser consistency, suppress native .click() on links
  22441. // Also prevent it if we're currently inside a leveraged native-event stack
  22442. _default: function( event ) {
  22443. var target = event.target;
  22444. return rcheckableType.test( target.type ) &&
  22445. target.click && nodeName( target, "input" ) &&
  22446. dataPriv.get( target, "click" ) ||
  22447. nodeName( target, "a" );
  22448. }
  22449. },
  22450. beforeunload: {
  22451. postDispatch: function( event ) {
  22452. // Support: Firefox 20+
  22453. // Firefox doesn't alert if the returnValue field is not set.
  22454. if ( event.result !== undefined && event.originalEvent ) {
  22455. event.originalEvent.returnValue = event.result;
  22456. }
  22457. }
  22458. }
  22459. }
  22460. };
  22461. // Ensure the presence of an event listener that handles manually-triggered
  22462. // synthetic events by interrupting progress until reinvoked in response to
  22463. // *native* events that it fires directly, ensuring that state changes have
  22464. // already occurred before other listeners are invoked.
  22465. function leverageNative( el, type, expectSync ) {
  22466. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  22467. if ( !expectSync ) {
  22468. if ( dataPriv.get( el, type ) === undefined ) {
  22469. jQuery.event.add( el, type, returnTrue );
  22470. }
  22471. return;
  22472. }
  22473. // Register the controller as a special universal handler for all event namespaces
  22474. dataPriv.set( el, type, false );
  22475. jQuery.event.add( el, type, {
  22476. namespace: false,
  22477. handler: function( event ) {
  22478. var notAsync, result,
  22479. saved = dataPriv.get( this, type );
  22480. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  22481. // Interrupt processing of the outer synthetic .trigger()ed event
  22482. // Saved data should be false in such cases, but might be a leftover capture object
  22483. // from an async native handler (gh-4350)
  22484. if ( !saved.length ) {
  22485. // Store arguments for use when handling the inner native event
  22486. // There will always be at least one argument (an event object), so this array
  22487. // will not be confused with a leftover capture object.
  22488. saved = slice.call( arguments );
  22489. dataPriv.set( this, type, saved );
  22490. // Trigger the native event and capture its result
  22491. // Support: IE <=9 - 11+
  22492. // focus() and blur() are asynchronous
  22493. notAsync = expectSync( this, type );
  22494. this[ type ]();
  22495. result = dataPriv.get( this, type );
  22496. if ( saved !== result || notAsync ) {
  22497. dataPriv.set( this, type, false );
  22498. } else {
  22499. result = {};
  22500. }
  22501. if ( saved !== result ) {
  22502. // Cancel the outer synthetic event
  22503. event.stopImmediatePropagation();
  22504. event.preventDefault();
  22505. // Support: Chrome 86+
  22506. // In Chrome, if an element having a focusout handler is blurred by
  22507. // clicking outside of it, it invokes the handler synchronously. If
  22508. // that handler calls `.remove()` on the element, the data is cleared,
  22509. // leaving `result` undefined. We need to guard against this.
  22510. return result && result.value;
  22511. }
  22512. // If this is an inner synthetic event for an event with a bubbling surrogate
  22513. // (focus or blur), assume that the surrogate already propagated from triggering the
  22514. // native event and prevent that from happening again here.
  22515. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  22516. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  22517. // less bad than duplication.
  22518. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  22519. event.stopPropagation();
  22520. }
  22521. // If this is a native event triggered above, everything is now in order
  22522. // Fire an inner synthetic event with the original arguments
  22523. } else if ( saved.length ) {
  22524. // ...and capture the result
  22525. dataPriv.set( this, type, {
  22526. value: jQuery.event.trigger(
  22527. // Support: IE <=9 - 11+
  22528. // Extend with the prototype to reset the above stopImmediatePropagation()
  22529. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  22530. saved.slice( 1 ),
  22531. this
  22532. )
  22533. } );
  22534. // Abort handling of the native event
  22535. event.stopImmediatePropagation();
  22536. }
  22537. }
  22538. } );
  22539. }
  22540. jQuery.removeEvent = function( elem, type, handle ) {
  22541. // This "if" is needed for plain objects
  22542. if ( elem.removeEventListener ) {
  22543. elem.removeEventListener( type, handle );
  22544. }
  22545. };
  22546. jQuery.Event = function( src, props ) {
  22547. // Allow instantiation without the 'new' keyword
  22548. if ( !( this instanceof jQuery.Event ) ) {
  22549. return new jQuery.Event( src, props );
  22550. }
  22551. // Event object
  22552. if ( src && src.type ) {
  22553. this.originalEvent = src;
  22554. this.type = src.type;
  22555. // Events bubbling up the document may have been marked as prevented
  22556. // by a handler lower down the tree; reflect the correct value.
  22557. this.isDefaultPrevented = src.defaultPrevented ||
  22558. src.defaultPrevented === undefined &&
  22559. // Support: Android <=2.3 only
  22560. src.returnValue === false ?
  22561. returnTrue :
  22562. returnFalse;
  22563. // Create target properties
  22564. // Support: Safari <=6 - 7 only
  22565. // Target should not be a text node (#504, #13143)
  22566. this.target = ( src.target && src.target.nodeType === 3 ) ?
  22567. src.target.parentNode :
  22568. src.target;
  22569. this.currentTarget = src.currentTarget;
  22570. this.relatedTarget = src.relatedTarget;
  22571. // Event type
  22572. } else {
  22573. this.type = src;
  22574. }
  22575. // Put explicitly provided properties onto the event object
  22576. if ( props ) {
  22577. jQuery.extend( this, props );
  22578. }
  22579. // Create a timestamp if incoming event doesn't have one
  22580. this.timeStamp = src && src.timeStamp || Date.now();
  22581. // Mark it as fixed
  22582. this[ jQuery.expando ] = true;
  22583. };
  22584. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  22585. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  22586. jQuery.Event.prototype = {
  22587. constructor: jQuery.Event,
  22588. isDefaultPrevented: returnFalse,
  22589. isPropagationStopped: returnFalse,
  22590. isImmediatePropagationStopped: returnFalse,
  22591. isSimulated: false,
  22592. preventDefault: function() {
  22593. var e = this.originalEvent;
  22594. this.isDefaultPrevented = returnTrue;
  22595. if ( e && !this.isSimulated ) {
  22596. e.preventDefault();
  22597. }
  22598. },
  22599. stopPropagation: function() {
  22600. var e = this.originalEvent;
  22601. this.isPropagationStopped = returnTrue;
  22602. if ( e && !this.isSimulated ) {
  22603. e.stopPropagation();
  22604. }
  22605. },
  22606. stopImmediatePropagation: function() {
  22607. var e = this.originalEvent;
  22608. this.isImmediatePropagationStopped = returnTrue;
  22609. if ( e && !this.isSimulated ) {
  22610. e.stopImmediatePropagation();
  22611. }
  22612. this.stopPropagation();
  22613. }
  22614. };
  22615. // Includes all common event props including KeyEvent and MouseEvent specific props
  22616. jQuery.each( {
  22617. altKey: true,
  22618. bubbles: true,
  22619. cancelable: true,
  22620. changedTouches: true,
  22621. ctrlKey: true,
  22622. detail: true,
  22623. eventPhase: true,
  22624. metaKey: true,
  22625. pageX: true,
  22626. pageY: true,
  22627. shiftKey: true,
  22628. view: true,
  22629. "char": true,
  22630. code: true,
  22631. charCode: true,
  22632. key: true,
  22633. keyCode: true,
  22634. button: true,
  22635. buttons: true,
  22636. clientX: true,
  22637. clientY: true,
  22638. offsetX: true,
  22639. offsetY: true,
  22640. pointerId: true,
  22641. pointerType: true,
  22642. screenX: true,
  22643. screenY: true,
  22644. targetTouches: true,
  22645. toElement: true,
  22646. touches: true,
  22647. which: true
  22648. }, jQuery.event.addProp );
  22649. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  22650. jQuery.event.special[ type ] = {
  22651. // Utilize native event if possible so blur/focus sequence is correct
  22652. setup: function() {
  22653. // Claim the first handler
  22654. // dataPriv.set( this, "focus", ... )
  22655. // dataPriv.set( this, "blur", ... )
  22656. leverageNative( this, type, expectSync );
  22657. // Return false to allow normal processing in the caller
  22658. return false;
  22659. },
  22660. trigger: function() {
  22661. // Force setup before trigger
  22662. leverageNative( this, type );
  22663. // Return non-false to allow normal event-path propagation
  22664. return true;
  22665. },
  22666. // Suppress native focus or blur as it's already being fired
  22667. // in leverageNative.
  22668. _default: function() {
  22669. return true;
  22670. },
  22671. delegateType: delegateType
  22672. };
  22673. } );
  22674. // Create mouseenter/leave events using mouseover/out and event-time checks
  22675. // so that event delegation works in jQuery.
  22676. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  22677. //
  22678. // Support: Safari 7 only
  22679. // Safari sends mouseenter too often; see:
  22680. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  22681. // for the description of the bug (it existed in older Chrome versions as well).
  22682. jQuery.each( {
  22683. mouseenter: "mouseover",
  22684. mouseleave: "mouseout",
  22685. pointerenter: "pointerover",
  22686. pointerleave: "pointerout"
  22687. }, function( orig, fix ) {
  22688. jQuery.event.special[ orig ] = {
  22689. delegateType: fix,
  22690. bindType: fix,
  22691. handle: function( event ) {
  22692. var ret,
  22693. target = this,
  22694. related = event.relatedTarget,
  22695. handleObj = event.handleObj;
  22696. // For mouseenter/leave call the handler if related is outside the target.
  22697. // NB: No relatedTarget if the mouse left/entered the browser window
  22698. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  22699. event.type = handleObj.origType;
  22700. ret = handleObj.handler.apply( this, arguments );
  22701. event.type = fix;
  22702. }
  22703. return ret;
  22704. }
  22705. };
  22706. } );
  22707. jQuery.fn.extend( {
  22708. on: function( types, selector, data, fn ) {
  22709. return on( this, types, selector, data, fn );
  22710. },
  22711. one: function( types, selector, data, fn ) {
  22712. return on( this, types, selector, data, fn, 1 );
  22713. },
  22714. off: function( types, selector, fn ) {
  22715. var handleObj, type;
  22716. if ( types && types.preventDefault && types.handleObj ) {
  22717. // ( event ) dispatched jQuery.Event
  22718. handleObj = types.handleObj;
  22719. jQuery( types.delegateTarget ).off(
  22720. handleObj.namespace ?
  22721. handleObj.origType + "." + handleObj.namespace :
  22722. handleObj.origType,
  22723. handleObj.selector,
  22724. handleObj.handler
  22725. );
  22726. return this;
  22727. }
  22728. if ( typeof types === "object" ) {
  22729. // ( types-object [, selector] )
  22730. for ( type in types ) {
  22731. this.off( type, selector, types[ type ] );
  22732. }
  22733. return this;
  22734. }
  22735. if ( selector === false || typeof selector === "function" ) {
  22736. // ( types [, fn] )
  22737. fn = selector;
  22738. selector = undefined;
  22739. }
  22740. if ( fn === false ) {
  22741. fn = returnFalse;
  22742. }
  22743. return this.each( function() {
  22744. jQuery.event.remove( this, types, fn, selector );
  22745. } );
  22746. }
  22747. } );
  22748. var
  22749. // Support: IE <=10 - 11, Edge 12 - 13 only
  22750. // In IE/Edge using regex groups here causes severe slowdowns.
  22751. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  22752. rnoInnerhtml = /<script|<style|<link/i,
  22753. // checked="checked" or checked
  22754. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  22755. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  22756. // Prefer a tbody over its parent table for containing new rows
  22757. function manipulationTarget( elem, content ) {
  22758. if ( nodeName( elem, "table" ) &&
  22759. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  22760. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  22761. }
  22762. return elem;
  22763. }
  22764. // Replace/restore the type attribute of script elements for safe DOM manipulation
  22765. function disableScript( elem ) {
  22766. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  22767. return elem;
  22768. }
  22769. function restoreScript( elem ) {
  22770. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  22771. elem.type = elem.type.slice( 5 );
  22772. } else {
  22773. elem.removeAttribute( "type" );
  22774. }
  22775. return elem;
  22776. }
  22777. function cloneCopyEvent( src, dest ) {
  22778. var i, l, type, pdataOld, udataOld, udataCur, events;
  22779. if ( dest.nodeType !== 1 ) {
  22780. return;
  22781. }
  22782. // 1. Copy private data: events, handlers, etc.
  22783. if ( dataPriv.hasData( src ) ) {
  22784. pdataOld = dataPriv.get( src );
  22785. events = pdataOld.events;
  22786. if ( events ) {
  22787. dataPriv.remove( dest, "handle events" );
  22788. for ( type in events ) {
  22789. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  22790. jQuery.event.add( dest, type, events[ type ][ i ] );
  22791. }
  22792. }
  22793. }
  22794. }
  22795. // 2. Copy user data
  22796. if ( dataUser.hasData( src ) ) {
  22797. udataOld = dataUser.access( src );
  22798. udataCur = jQuery.extend( {}, udataOld );
  22799. dataUser.set( dest, udataCur );
  22800. }
  22801. }
  22802. // Fix IE bugs, see support tests
  22803. function fixInput( src, dest ) {
  22804. var nodeName = dest.nodeName.toLowerCase();
  22805. // Fails to persist the checked state of a cloned checkbox or radio button.
  22806. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  22807. dest.checked = src.checked;
  22808. // Fails to return the selected option to the default selected state when cloning options
  22809. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  22810. dest.defaultValue = src.defaultValue;
  22811. }
  22812. }
  22813. function domManip( collection, args, callback, ignored ) {
  22814. // Flatten any nested arrays
  22815. args = flat( args );
  22816. var fragment, first, scripts, hasScripts, node, doc,
  22817. i = 0,
  22818. l = collection.length,
  22819. iNoClone = l - 1,
  22820. value = args[ 0 ],
  22821. valueIsFunction = isFunction( value );
  22822. // We can't cloneNode fragments that contain checked, in WebKit
  22823. if ( valueIsFunction ||
  22824. ( l > 1 && typeof value === "string" &&
  22825. !support.checkClone && rchecked.test( value ) ) ) {
  22826. return collection.each( function( index ) {
  22827. var self = collection.eq( index );
  22828. if ( valueIsFunction ) {
  22829. args[ 0 ] = value.call( this, index, self.html() );
  22830. }
  22831. domManip( self, args, callback, ignored );
  22832. } );
  22833. }
  22834. if ( l ) {
  22835. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  22836. first = fragment.firstChild;
  22837. if ( fragment.childNodes.length === 1 ) {
  22838. fragment = first;
  22839. }
  22840. // Require either new content or an interest in ignored elements to invoke the callback
  22841. if ( first || ignored ) {
  22842. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  22843. hasScripts = scripts.length;
  22844. // Use the original fragment for the last item
  22845. // instead of the first because it can end up
  22846. // being emptied incorrectly in certain situations (#8070).
  22847. for ( ; i < l; i++ ) {
  22848. node = fragment;
  22849. if ( i !== iNoClone ) {
  22850. node = jQuery.clone( node, true, true );
  22851. // Keep references to cloned scripts for later restoration
  22852. if ( hasScripts ) {
  22853. // Support: Android <=4.0 only, PhantomJS 1 only
  22854. // push.apply(_, arraylike) throws on ancient WebKit
  22855. jQuery.merge( scripts, getAll( node, "script" ) );
  22856. }
  22857. }
  22858. callback.call( collection[ i ], node, i );
  22859. }
  22860. if ( hasScripts ) {
  22861. doc = scripts[ scripts.length - 1 ].ownerDocument;
  22862. // Reenable scripts
  22863. jQuery.map( scripts, restoreScript );
  22864. // Evaluate executable scripts on first document insertion
  22865. for ( i = 0; i < hasScripts; i++ ) {
  22866. node = scripts[ i ];
  22867. if ( rscriptType.test( node.type || "" ) &&
  22868. !dataPriv.access( node, "globalEval" ) &&
  22869. jQuery.contains( doc, node ) ) {
  22870. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  22871. // Optional AJAX dependency, but won't run scripts if not present
  22872. if ( jQuery._evalUrl && !node.noModule ) {
  22873. jQuery._evalUrl( node.src, {
  22874. nonce: node.nonce || node.getAttribute( "nonce" )
  22875. }, doc );
  22876. }
  22877. } else {
  22878. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  22879. }
  22880. }
  22881. }
  22882. }
  22883. }
  22884. }
  22885. return collection;
  22886. }
  22887. function remove( elem, selector, keepData ) {
  22888. var node,
  22889. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  22890. i = 0;
  22891. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  22892. if ( !keepData && node.nodeType === 1 ) {
  22893. jQuery.cleanData( getAll( node ) );
  22894. }
  22895. if ( node.parentNode ) {
  22896. if ( keepData && isAttached( node ) ) {
  22897. setGlobalEval( getAll( node, "script" ) );
  22898. }
  22899. node.parentNode.removeChild( node );
  22900. }
  22901. }
  22902. return elem;
  22903. }
  22904. jQuery.extend( {
  22905. htmlPrefilter: function( html ) {
  22906. return html;
  22907. },
  22908. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  22909. var i, l, srcElements, destElements,
  22910. clone = elem.cloneNode( true ),
  22911. inPage = isAttached( elem );
  22912. // Fix IE cloning issues
  22913. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  22914. !jQuery.isXMLDoc( elem ) ) {
  22915. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  22916. destElements = getAll( clone );
  22917. srcElements = getAll( elem );
  22918. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  22919. fixInput( srcElements[ i ], destElements[ i ] );
  22920. }
  22921. }
  22922. // Copy the events from the original to the clone
  22923. if ( dataAndEvents ) {
  22924. if ( deepDataAndEvents ) {
  22925. srcElements = srcElements || getAll( elem );
  22926. destElements = destElements || getAll( clone );
  22927. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  22928. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  22929. }
  22930. } else {
  22931. cloneCopyEvent( elem, clone );
  22932. }
  22933. }
  22934. // Preserve script evaluation history
  22935. destElements = getAll( clone, "script" );
  22936. if ( destElements.length > 0 ) {
  22937. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  22938. }
  22939. // Return the cloned set
  22940. return clone;
  22941. },
  22942. cleanData: function( elems ) {
  22943. var data, elem, type,
  22944. special = jQuery.event.special,
  22945. i = 0;
  22946. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  22947. if ( acceptData( elem ) ) {
  22948. if ( ( data = elem[ dataPriv.expando ] ) ) {
  22949. if ( data.events ) {
  22950. for ( type in data.events ) {
  22951. if ( special[ type ] ) {
  22952. jQuery.event.remove( elem, type );
  22953. // This is a shortcut to avoid jQuery.event.remove's overhead
  22954. } else {
  22955. jQuery.removeEvent( elem, type, data.handle );
  22956. }
  22957. }
  22958. }
  22959. // Support: Chrome <=35 - 45+
  22960. // Assign undefined instead of using delete, see Data#remove
  22961. elem[ dataPriv.expando ] = undefined;
  22962. }
  22963. if ( elem[ dataUser.expando ] ) {
  22964. // Support: Chrome <=35 - 45+
  22965. // Assign undefined instead of using delete, see Data#remove
  22966. elem[ dataUser.expando ] = undefined;
  22967. }
  22968. }
  22969. }
  22970. }
  22971. } );
  22972. jQuery.fn.extend( {
  22973. detach: function( selector ) {
  22974. return remove( this, selector, true );
  22975. },
  22976. remove: function( selector ) {
  22977. return remove( this, selector );
  22978. },
  22979. text: function( value ) {
  22980. return access( this, function( value ) {
  22981. return value === undefined ?
  22982. jQuery.text( this ) :
  22983. this.empty().each( function() {
  22984. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  22985. this.textContent = value;
  22986. }
  22987. } );
  22988. }, null, value, arguments.length );
  22989. },
  22990. append: function() {
  22991. return domManip( this, arguments, function( elem ) {
  22992. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  22993. var target = manipulationTarget( this, elem );
  22994. target.appendChild( elem );
  22995. }
  22996. } );
  22997. },
  22998. prepend: function() {
  22999. return domManip( this, arguments, function( elem ) {
  23000. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  23001. var target = manipulationTarget( this, elem );
  23002. target.insertBefore( elem, target.firstChild );
  23003. }
  23004. } );
  23005. },
  23006. before: function() {
  23007. return domManip( this, arguments, function( elem ) {
  23008. if ( this.parentNode ) {
  23009. this.parentNode.insertBefore( elem, this );
  23010. }
  23011. } );
  23012. },
  23013. after: function() {
  23014. return domManip( this, arguments, function( elem ) {
  23015. if ( this.parentNode ) {
  23016. this.parentNode.insertBefore( elem, this.nextSibling );
  23017. }
  23018. } );
  23019. },
  23020. empty: function() {
  23021. var elem,
  23022. i = 0;
  23023. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  23024. if ( elem.nodeType === 1 ) {
  23025. // Prevent memory leaks
  23026. jQuery.cleanData( getAll( elem, false ) );
  23027. // Remove any remaining nodes
  23028. elem.textContent = "";
  23029. }
  23030. }
  23031. return this;
  23032. },
  23033. clone: function( dataAndEvents, deepDataAndEvents ) {
  23034. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  23035. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  23036. return this.map( function() {
  23037. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  23038. } );
  23039. },
  23040. html: function( value ) {
  23041. return access( this, function( value ) {
  23042. var elem = this[ 0 ] || {},
  23043. i = 0,
  23044. l = this.length;
  23045. if ( value === undefined && elem.nodeType === 1 ) {
  23046. return elem.innerHTML;
  23047. }
  23048. // See if we can take a shortcut and just use innerHTML
  23049. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  23050. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  23051. value = jQuery.htmlPrefilter( value );
  23052. try {
  23053. for ( ; i < l; i++ ) {
  23054. elem = this[ i ] || {};
  23055. // Remove element nodes and prevent memory leaks
  23056. if ( elem.nodeType === 1 ) {
  23057. jQuery.cleanData( getAll( elem, false ) );
  23058. elem.innerHTML = value;
  23059. }
  23060. }
  23061. elem = 0;
  23062. // If using innerHTML throws an exception, use the fallback method
  23063. } catch ( e ) {}
  23064. }
  23065. if ( elem ) {
  23066. this.empty().append( value );
  23067. }
  23068. }, null, value, arguments.length );
  23069. },
  23070. replaceWith: function() {
  23071. var ignored = [];
  23072. // Make the changes, replacing each non-ignored context element with the new content
  23073. return domManip( this, arguments, function( elem ) {
  23074. var parent = this.parentNode;
  23075. if ( jQuery.inArray( this, ignored ) < 0 ) {
  23076. jQuery.cleanData( getAll( this ) );
  23077. if ( parent ) {
  23078. parent.replaceChild( elem, this );
  23079. }
  23080. }
  23081. // Force callback invocation
  23082. }, ignored );
  23083. }
  23084. } );
  23085. jQuery.each( {
  23086. appendTo: "append",
  23087. prependTo: "prepend",
  23088. insertBefore: "before",
  23089. insertAfter: "after",
  23090. replaceAll: "replaceWith"
  23091. }, function( name, original ) {
  23092. jQuery.fn[ name ] = function( selector ) {
  23093. var elems,
  23094. ret = [],
  23095. insert = jQuery( selector ),
  23096. last = insert.length - 1,
  23097. i = 0;
  23098. for ( ; i <= last; i++ ) {
  23099. elems = i === last ? this : this.clone( true );
  23100. jQuery( insert[ i ] )[ original ]( elems );
  23101. // Support: Android <=4.0 only, PhantomJS 1 only
  23102. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  23103. push.apply( ret, elems.get() );
  23104. }
  23105. return this.pushStack( ret );
  23106. };
  23107. } );
  23108. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  23109. var getStyles = function( elem ) {
  23110. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  23111. // IE throws on elements created in popups
  23112. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  23113. var view = elem.ownerDocument.defaultView;
  23114. if ( !view || !view.opener ) {
  23115. view = window;
  23116. }
  23117. return view.getComputedStyle( elem );
  23118. };
  23119. var swap = function( elem, options, callback ) {
  23120. var ret, name,
  23121. old = {};
  23122. // Remember the old values, and insert the new ones
  23123. for ( name in options ) {
  23124. old[ name ] = elem.style[ name ];
  23125. elem.style[ name ] = options[ name ];
  23126. }
  23127. ret = callback.call( elem );
  23128. // Revert the old values
  23129. for ( name in options ) {
  23130. elem.style[ name ] = old[ name ];
  23131. }
  23132. return ret;
  23133. };
  23134. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  23135. ( function() {
  23136. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  23137. // so they're executed at the same time to save the second computation.
  23138. function computeStyleTests() {
  23139. // This is a singleton, we need to execute it only once
  23140. if ( !div ) {
  23141. return;
  23142. }
  23143. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  23144. "margin-top:1px;padding:0;border:0";
  23145. div.style.cssText =
  23146. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  23147. "margin:auto;border:1px;padding:1px;" +
  23148. "width:60%;top:1%";
  23149. documentElement.appendChild( container ).appendChild( div );
  23150. var divStyle = window.getComputedStyle( div );
  23151. pixelPositionVal = divStyle.top !== "1%";
  23152. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  23153. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  23154. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  23155. // Some styles come back with percentage values, even though they shouldn't
  23156. div.style.right = "60%";
  23157. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  23158. // Support: IE 9 - 11 only
  23159. // Detect misreporting of content dimensions for box-sizing:border-box elements
  23160. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  23161. // Support: IE 9 only
  23162. // Detect overflow:scroll screwiness (gh-3699)
  23163. // Support: Chrome <=64
  23164. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  23165. div.style.position = "absolute";
  23166. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  23167. documentElement.removeChild( container );
  23168. // Nullify the div so it wouldn't be stored in the memory and
  23169. // it will also be a sign that checks already performed
  23170. div = null;
  23171. }
  23172. function roundPixelMeasures( measure ) {
  23173. return Math.round( parseFloat( measure ) );
  23174. }
  23175. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  23176. reliableTrDimensionsVal, reliableMarginLeftVal,
  23177. container = document.createElement( "div" ),
  23178. div = document.createElement( "div" );
  23179. // Finish early in limited (non-browser) environments
  23180. if ( !div.style ) {
  23181. return;
  23182. }
  23183. // Support: IE <=9 - 11 only
  23184. // Style of cloned element affects source element cloned (#8908)
  23185. div.style.backgroundClip = "content-box";
  23186. div.cloneNode( true ).style.backgroundClip = "";
  23187. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  23188. jQuery.extend( support, {
  23189. boxSizingReliable: function() {
  23190. computeStyleTests();
  23191. return boxSizingReliableVal;
  23192. },
  23193. pixelBoxStyles: function() {
  23194. computeStyleTests();
  23195. return pixelBoxStylesVal;
  23196. },
  23197. pixelPosition: function() {
  23198. computeStyleTests();
  23199. return pixelPositionVal;
  23200. },
  23201. reliableMarginLeft: function() {
  23202. computeStyleTests();
  23203. return reliableMarginLeftVal;
  23204. },
  23205. scrollboxSize: function() {
  23206. computeStyleTests();
  23207. return scrollboxSizeVal;
  23208. },
  23209. // Support: IE 9 - 11+, Edge 15 - 18+
  23210. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  23211. // set in CSS while `offset*` properties report correct values.
  23212. // Behavior in IE 9 is more subtle than in newer versions & it passes
  23213. // some versions of this test; make sure not to make it pass there!
  23214. //
  23215. // Support: Firefox 70+
  23216. // Only Firefox includes border widths
  23217. // in computed dimensions. (gh-4529)
  23218. reliableTrDimensions: function() {
  23219. var table, tr, trChild, trStyle;
  23220. if ( reliableTrDimensionsVal == null ) {
  23221. table = document.createElement( "table" );
  23222. tr = document.createElement( "tr" );
  23223. trChild = document.createElement( "div" );
  23224. table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
  23225. tr.style.cssText = "border:1px solid";
  23226. // Support: Chrome 86+
  23227. // Height set through cssText does not get applied.
  23228. // Computed height then comes back as 0.
  23229. tr.style.height = "1px";
  23230. trChild.style.height = "9px";
  23231. // Support: Android 8 Chrome 86+
  23232. // In our bodyBackground.html iframe,
  23233. // display for all div elements is set to "inline",
  23234. // which causes a problem only in Android 8 Chrome 86.
  23235. // Ensuring the div is display: block
  23236. // gets around this issue.
  23237. trChild.style.display = "block";
  23238. documentElement
  23239. .appendChild( table )
  23240. .appendChild( tr )
  23241. .appendChild( trChild );
  23242. trStyle = window.getComputedStyle( tr );
  23243. reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
  23244. parseInt( trStyle.borderTopWidth, 10 ) +
  23245. parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
  23246. documentElement.removeChild( table );
  23247. }
  23248. return reliableTrDimensionsVal;
  23249. }
  23250. } );
  23251. } )();
  23252. function curCSS( elem, name, computed ) {
  23253. var width, minWidth, maxWidth, ret,
  23254. // Support: Firefox 51+
  23255. // Retrieving style before computed somehow
  23256. // fixes an issue with getting wrong values
  23257. // on detached elements
  23258. style = elem.style;
  23259. computed = computed || getStyles( elem );
  23260. // getPropertyValue is needed for:
  23261. // .css('filter') (IE 9 only, #12537)
  23262. // .css('--customProperty) (#3144)
  23263. if ( computed ) {
  23264. ret = computed.getPropertyValue( name ) || computed[ name ];
  23265. if ( ret === "" && !isAttached( elem ) ) {
  23266. ret = jQuery.style( elem, name );
  23267. }
  23268. // A tribute to the "awesome hack by Dean Edwards"
  23269. // Android Browser returns percentage for some values,
  23270. // but width seems to be reliably pixels.
  23271. // This is against the CSSOM draft spec:
  23272. // https://drafts.csswg.org/cssom/#resolved-values
  23273. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  23274. // Remember the original values
  23275. width = style.width;
  23276. minWidth = style.minWidth;
  23277. maxWidth = style.maxWidth;
  23278. // Put in the new values to get a computed value out
  23279. style.minWidth = style.maxWidth = style.width = ret;
  23280. ret = computed.width;
  23281. // Revert the changed values
  23282. style.width = width;
  23283. style.minWidth = minWidth;
  23284. style.maxWidth = maxWidth;
  23285. }
  23286. }
  23287. return ret !== undefined ?
  23288. // Support: IE <=9 - 11 only
  23289. // IE returns zIndex value as an integer.
  23290. ret + "" :
  23291. ret;
  23292. }
  23293. function addGetHookIf( conditionFn, hookFn ) {
  23294. // Define the hook, we'll check on the first run if it's really needed.
  23295. return {
  23296. get: function() {
  23297. if ( conditionFn() ) {
  23298. // Hook not needed (or it's not possible to use it due
  23299. // to missing dependency), remove it.
  23300. delete this.get;
  23301. return;
  23302. }
  23303. // Hook needed; redefine it so that the support test is not executed again.
  23304. return ( this.get = hookFn ).apply( this, arguments );
  23305. }
  23306. };
  23307. }
  23308. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  23309. emptyStyle = document.createElement( "div" ).style,
  23310. vendorProps = {};
  23311. // Return a vendor-prefixed property or undefined
  23312. function vendorPropName( name ) {
  23313. // Check for vendor prefixed names
  23314. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  23315. i = cssPrefixes.length;
  23316. while ( i-- ) {
  23317. name = cssPrefixes[ i ] + capName;
  23318. if ( name in emptyStyle ) {
  23319. return name;
  23320. }
  23321. }
  23322. }
  23323. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  23324. function finalPropName( name ) {
  23325. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  23326. if ( final ) {
  23327. return final;
  23328. }
  23329. if ( name in emptyStyle ) {
  23330. return name;
  23331. }
  23332. return vendorProps[ name ] = vendorPropName( name ) || name;
  23333. }
  23334. var
  23335. // Swappable if display is none or starts with table
  23336. // except "table", "table-cell", or "table-caption"
  23337. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  23338. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  23339. rcustomProp = /^--/,
  23340. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  23341. cssNormalTransform = {
  23342. letterSpacing: "0",
  23343. fontWeight: "400"
  23344. };
  23345. function setPositiveNumber( _elem, value, subtract ) {
  23346. // Any relative (+/-) values have already been
  23347. // normalized at this point
  23348. var matches = rcssNum.exec( value );
  23349. return matches ?
  23350. // Guard against undefined "subtract", e.g., when used as in cssHooks
  23351. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  23352. value;
  23353. }
  23354. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  23355. var i = dimension === "width" ? 1 : 0,
  23356. extra = 0,
  23357. delta = 0;
  23358. // Adjustment may not be necessary
  23359. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  23360. return 0;
  23361. }
  23362. for ( ; i < 4; i += 2 ) {
  23363. // Both box models exclude margin
  23364. if ( box === "margin" ) {
  23365. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  23366. }
  23367. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  23368. if ( !isBorderBox ) {
  23369. // Add padding
  23370. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  23371. // For "border" or "margin", add border
  23372. if ( box !== "padding" ) {
  23373. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  23374. // But still keep track of it otherwise
  23375. } else {
  23376. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  23377. }
  23378. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  23379. // "padding" or "margin"
  23380. } else {
  23381. // For "content", subtract padding
  23382. if ( box === "content" ) {
  23383. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  23384. }
  23385. // For "content" or "padding", subtract border
  23386. if ( box !== "margin" ) {
  23387. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  23388. }
  23389. }
  23390. }
  23391. // Account for positive content-box scroll gutter when requested by providing computedVal
  23392. if ( !isBorderBox && computedVal >= 0 ) {
  23393. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  23394. // Assuming integer scroll gutter, subtract the rest and round down
  23395. delta += Math.max( 0, Math.ceil(
  23396. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  23397. computedVal -
  23398. delta -
  23399. extra -
  23400. 0.5
  23401. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  23402. // Use an explicit zero to avoid NaN (gh-3964)
  23403. ) ) || 0;
  23404. }
  23405. return delta;
  23406. }
  23407. function getWidthOrHeight( elem, dimension, extra ) {
  23408. // Start with computed style
  23409. var styles = getStyles( elem ),
  23410. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  23411. // Fake content-box until we know it's needed to know the true value.
  23412. boxSizingNeeded = !support.boxSizingReliable() || extra,
  23413. isBorderBox = boxSizingNeeded &&
  23414. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  23415. valueIsBorderBox = isBorderBox,
  23416. val = curCSS( elem, dimension, styles ),
  23417. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  23418. // Support: Firefox <=54
  23419. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  23420. if ( rnumnonpx.test( val ) ) {
  23421. if ( !extra ) {
  23422. return val;
  23423. }
  23424. val = "auto";
  23425. }
  23426. // Support: IE 9 - 11 only
  23427. // Use offsetWidth/offsetHeight for when box sizing is unreliable.
  23428. // In those cases, the computed value can be trusted to be border-box.
  23429. if ( ( !support.boxSizingReliable() && isBorderBox ||
  23430. // Support: IE 10 - 11+, Edge 15 - 18+
  23431. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  23432. // set in CSS while `offset*` properties report correct values.
  23433. // Interestingly, in some cases IE 9 doesn't suffer from this issue.
  23434. !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
  23435. // Fall back to offsetWidth/offsetHeight when value is "auto"
  23436. // This happens for inline elements with no explicit setting (gh-3571)
  23437. val === "auto" ||
  23438. // Support: Android <=4.1 - 4.3 only
  23439. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  23440. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  23441. // Make sure the element is visible & connected
  23442. elem.getClientRects().length ) {
  23443. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  23444. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  23445. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  23446. // retrieved value as a content box dimension.
  23447. valueIsBorderBox = offsetProp in elem;
  23448. if ( valueIsBorderBox ) {
  23449. val = elem[ offsetProp ];
  23450. }
  23451. }
  23452. // Normalize "" and auto
  23453. val = parseFloat( val ) || 0;
  23454. // Adjust for the element's box model
  23455. return ( val +
  23456. boxModelAdjustment(
  23457. elem,
  23458. dimension,
  23459. extra || ( isBorderBox ? "border" : "content" ),
  23460. valueIsBorderBox,
  23461. styles,
  23462. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  23463. val
  23464. )
  23465. ) + "px";
  23466. }
  23467. jQuery.extend( {
  23468. // Add in style property hooks for overriding the default
  23469. // behavior of getting and setting a style property
  23470. cssHooks: {
  23471. opacity: {
  23472. get: function( elem, computed ) {
  23473. if ( computed ) {
  23474. // We should always get a number back from opacity
  23475. var ret = curCSS( elem, "opacity" );
  23476. return ret === "" ? "1" : ret;
  23477. }
  23478. }
  23479. }
  23480. },
  23481. // Don't automatically add "px" to these possibly-unitless properties
  23482. cssNumber: {
  23483. "animationIterationCount": true,
  23484. "columnCount": true,
  23485. "fillOpacity": true,
  23486. "flexGrow": true,
  23487. "flexShrink": true,
  23488. "fontWeight": true,
  23489. "gridArea": true,
  23490. "gridColumn": true,
  23491. "gridColumnEnd": true,
  23492. "gridColumnStart": true,
  23493. "gridRow": true,
  23494. "gridRowEnd": true,
  23495. "gridRowStart": true,
  23496. "lineHeight": true,
  23497. "opacity": true,
  23498. "order": true,
  23499. "orphans": true,
  23500. "widows": true,
  23501. "zIndex": true,
  23502. "zoom": true
  23503. },
  23504. // Add in properties whose names you wish to fix before
  23505. // setting or getting the value
  23506. cssProps: {},
  23507. // Get and set the style property on a DOM Node
  23508. style: function( elem, name, value, extra ) {
  23509. // Don't set styles on text and comment nodes
  23510. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  23511. return;
  23512. }
  23513. // Make sure that we're working with the right name
  23514. var ret, type, hooks,
  23515. origName = camelCase( name ),
  23516. isCustomProp = rcustomProp.test( name ),
  23517. style = elem.style;
  23518. // Make sure that we're working with the right name. We don't
  23519. // want to query the value if it is a CSS custom property
  23520. // since they are user-defined.
  23521. if ( !isCustomProp ) {
  23522. name = finalPropName( origName );
  23523. }
  23524. // Gets hook for the prefixed version, then unprefixed version
  23525. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  23526. // Check if we're setting a value
  23527. if ( value !== undefined ) {
  23528. type = typeof value;
  23529. // Convert "+=" or "-=" to relative numbers (#7345)
  23530. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  23531. value = adjustCSS( elem, name, ret );
  23532. // Fixes bug #9237
  23533. type = "number";
  23534. }
  23535. // Make sure that null and NaN values aren't set (#7116)
  23536. if ( value == null || value !== value ) {
  23537. return;
  23538. }
  23539. // If a number was passed in, add the unit (except for certain CSS properties)
  23540. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  23541. // "px" to a few hardcoded values.
  23542. if ( type === "number" && !isCustomProp ) {
  23543. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  23544. }
  23545. // background-* props affect original clone's values
  23546. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  23547. style[ name ] = "inherit";
  23548. }
  23549. // If a hook was provided, use that value, otherwise just set the specified value
  23550. if ( !hooks || !( "set" in hooks ) ||
  23551. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  23552. if ( isCustomProp ) {
  23553. style.setProperty( name, value );
  23554. } else {
  23555. style[ name ] = value;
  23556. }
  23557. }
  23558. } else {
  23559. // If a hook was provided get the non-computed value from there
  23560. if ( hooks && "get" in hooks &&
  23561. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  23562. return ret;
  23563. }
  23564. // Otherwise just get the value from the style object
  23565. return style[ name ];
  23566. }
  23567. },
  23568. css: function( elem, name, extra, styles ) {
  23569. var val, num, hooks,
  23570. origName = camelCase( name ),
  23571. isCustomProp = rcustomProp.test( name );
  23572. // Make sure that we're working with the right name. We don't
  23573. // want to modify the value if it is a CSS custom property
  23574. // since they are user-defined.
  23575. if ( !isCustomProp ) {
  23576. name = finalPropName( origName );
  23577. }
  23578. // Try prefixed name followed by the unprefixed name
  23579. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  23580. // If a hook was provided get the computed value from there
  23581. if ( hooks && "get" in hooks ) {
  23582. val = hooks.get( elem, true, extra );
  23583. }
  23584. // Otherwise, if a way to get the computed value exists, use that
  23585. if ( val === undefined ) {
  23586. val = curCSS( elem, name, styles );
  23587. }
  23588. // Convert "normal" to computed value
  23589. if ( val === "normal" && name in cssNormalTransform ) {
  23590. val = cssNormalTransform[ name ];
  23591. }
  23592. // Make numeric if forced or a qualifier was provided and val looks numeric
  23593. if ( extra === "" || extra ) {
  23594. num = parseFloat( val );
  23595. return extra === true || isFinite( num ) ? num || 0 : val;
  23596. }
  23597. return val;
  23598. }
  23599. } );
  23600. jQuery.each( [ "height", "width" ], function( _i, dimension ) {
  23601. jQuery.cssHooks[ dimension ] = {
  23602. get: function( elem, computed, extra ) {
  23603. if ( computed ) {
  23604. // Certain elements can have dimension info if we invisibly show them
  23605. // but it must have a current display style that would benefit
  23606. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  23607. // Support: Safari 8+
  23608. // Table columns in Safari have non-zero offsetWidth & zero
  23609. // getBoundingClientRect().width unless display is changed.
  23610. // Support: IE <=11 only
  23611. // Running getBoundingClientRect on a disconnected node
  23612. // in IE throws an error.
  23613. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  23614. swap( elem, cssShow, function() {
  23615. return getWidthOrHeight( elem, dimension, extra );
  23616. } ) :
  23617. getWidthOrHeight( elem, dimension, extra );
  23618. }
  23619. },
  23620. set: function( elem, value, extra ) {
  23621. var matches,
  23622. styles = getStyles( elem ),
  23623. // Only read styles.position if the test has a chance to fail
  23624. // to avoid forcing a reflow.
  23625. scrollboxSizeBuggy = !support.scrollboxSize() &&
  23626. styles.position === "absolute",
  23627. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  23628. boxSizingNeeded = scrollboxSizeBuggy || extra,
  23629. isBorderBox = boxSizingNeeded &&
  23630. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  23631. subtract = extra ?
  23632. boxModelAdjustment(
  23633. elem,
  23634. dimension,
  23635. extra,
  23636. isBorderBox,
  23637. styles
  23638. ) :
  23639. 0;
  23640. // Account for unreliable border-box dimensions by comparing offset* to computed and
  23641. // faking a content-box to get border and padding (gh-3699)
  23642. if ( isBorderBox && scrollboxSizeBuggy ) {
  23643. subtract -= Math.ceil(
  23644. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  23645. parseFloat( styles[ dimension ] ) -
  23646. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  23647. 0.5
  23648. );
  23649. }
  23650. // Convert to pixels if value adjustment is needed
  23651. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  23652. ( matches[ 3 ] || "px" ) !== "px" ) {
  23653. elem.style[ dimension ] = value;
  23654. value = jQuery.css( elem, dimension );
  23655. }
  23656. return setPositiveNumber( elem, value, subtract );
  23657. }
  23658. };
  23659. } );
  23660. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  23661. function( elem, computed ) {
  23662. if ( computed ) {
  23663. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  23664. elem.getBoundingClientRect().left -
  23665. swap( elem, { marginLeft: 0 }, function() {
  23666. return elem.getBoundingClientRect().left;
  23667. } )
  23668. ) + "px";
  23669. }
  23670. }
  23671. );
  23672. // These hooks are used by animate to expand properties
  23673. jQuery.each( {
  23674. margin: "",
  23675. padding: "",
  23676. border: "Width"
  23677. }, function( prefix, suffix ) {
  23678. jQuery.cssHooks[ prefix + suffix ] = {
  23679. expand: function( value ) {
  23680. var i = 0,
  23681. expanded = {},
  23682. // Assumes a single number if not a string
  23683. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  23684. for ( ; i < 4; i++ ) {
  23685. expanded[ prefix + cssExpand[ i ] + suffix ] =
  23686. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  23687. }
  23688. return expanded;
  23689. }
  23690. };
  23691. if ( prefix !== "margin" ) {
  23692. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  23693. }
  23694. } );
  23695. jQuery.fn.extend( {
  23696. css: function( name, value ) {
  23697. return access( this, function( elem, name, value ) {
  23698. var styles, len,
  23699. map = {},
  23700. i = 0;
  23701. if ( Array.isArray( name ) ) {
  23702. styles = getStyles( elem );
  23703. len = name.length;
  23704. for ( ; i < len; i++ ) {
  23705. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  23706. }
  23707. return map;
  23708. }
  23709. return value !== undefined ?
  23710. jQuery.style( elem, name, value ) :
  23711. jQuery.css( elem, name );
  23712. }, name, value, arguments.length > 1 );
  23713. }
  23714. } );
  23715. function Tween( elem, options, prop, end, easing ) {
  23716. return new Tween.prototype.init( elem, options, prop, end, easing );
  23717. }
  23718. jQuery.Tween = Tween;
  23719. Tween.prototype = {
  23720. constructor: Tween,
  23721. init: function( elem, options, prop, end, easing, unit ) {
  23722. this.elem = elem;
  23723. this.prop = prop;
  23724. this.easing = easing || jQuery.easing._default;
  23725. this.options = options;
  23726. this.start = this.now = this.cur();
  23727. this.end = end;
  23728. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  23729. },
  23730. cur: function() {
  23731. var hooks = Tween.propHooks[ this.prop ];
  23732. return hooks && hooks.get ?
  23733. hooks.get( this ) :
  23734. Tween.propHooks._default.get( this );
  23735. },
  23736. run: function( percent ) {
  23737. var eased,
  23738. hooks = Tween.propHooks[ this.prop ];
  23739. if ( this.options.duration ) {
  23740. this.pos = eased = jQuery.easing[ this.easing ](
  23741. percent, this.options.duration * percent, 0, 1, this.options.duration
  23742. );
  23743. } else {
  23744. this.pos = eased = percent;
  23745. }
  23746. this.now = ( this.end - this.start ) * eased + this.start;
  23747. if ( this.options.step ) {
  23748. this.options.step.call( this.elem, this.now, this );
  23749. }
  23750. if ( hooks && hooks.set ) {
  23751. hooks.set( this );
  23752. } else {
  23753. Tween.propHooks._default.set( this );
  23754. }
  23755. return this;
  23756. }
  23757. };
  23758. Tween.prototype.init.prototype = Tween.prototype;
  23759. Tween.propHooks = {
  23760. _default: {
  23761. get: function( tween ) {
  23762. var result;
  23763. // Use a property on the element directly when it is not a DOM element,
  23764. // or when there is no matching style property that exists.
  23765. if ( tween.elem.nodeType !== 1 ||
  23766. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  23767. return tween.elem[ tween.prop ];
  23768. }
  23769. // Passing an empty string as a 3rd parameter to .css will automatically
  23770. // attempt a parseFloat and fallback to a string if the parse fails.
  23771. // Simple values such as "10px" are parsed to Float;
  23772. // complex values such as "rotate(1rad)" are returned as-is.
  23773. result = jQuery.css( tween.elem, tween.prop, "" );
  23774. // Empty strings, null, undefined and "auto" are converted to 0.
  23775. return !result || result === "auto" ? 0 : result;
  23776. },
  23777. set: function( tween ) {
  23778. // Use step hook for back compat.
  23779. // Use cssHook if its there.
  23780. // Use .style if available and use plain properties where available.
  23781. if ( jQuery.fx.step[ tween.prop ] ) {
  23782. jQuery.fx.step[ tween.prop ]( tween );
  23783. } else if ( tween.elem.nodeType === 1 && (
  23784. jQuery.cssHooks[ tween.prop ] ||
  23785. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  23786. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  23787. } else {
  23788. tween.elem[ tween.prop ] = tween.now;
  23789. }
  23790. }
  23791. }
  23792. };
  23793. // Support: IE <=9 only
  23794. // Panic based approach to setting things on disconnected nodes
  23795. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  23796. set: function( tween ) {
  23797. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  23798. tween.elem[ tween.prop ] = tween.now;
  23799. }
  23800. }
  23801. };
  23802. jQuery.easing = {
  23803. linear: function( p ) {
  23804. return p;
  23805. },
  23806. swing: function( p ) {
  23807. return 0.5 - Math.cos( p * Math.PI ) / 2;
  23808. },
  23809. _default: "swing"
  23810. };
  23811. jQuery.fx = Tween.prototype.init;
  23812. // Back compat <1.8 extension point
  23813. jQuery.fx.step = {};
  23814. var
  23815. fxNow, inProgress,
  23816. rfxtypes = /^(?:toggle|show|hide)$/,
  23817. rrun = /queueHooks$/;
  23818. function schedule() {
  23819. if ( inProgress ) {
  23820. if ( document.hidden === false && window.requestAnimationFrame ) {
  23821. window.requestAnimationFrame( schedule );
  23822. } else {
  23823. window.setTimeout( schedule, jQuery.fx.interval );
  23824. }
  23825. jQuery.fx.tick();
  23826. }
  23827. }
  23828. // Animations created synchronously will run synchronously
  23829. function createFxNow() {
  23830. window.setTimeout( function() {
  23831. fxNow = undefined;
  23832. } );
  23833. return ( fxNow = Date.now() );
  23834. }
  23835. // Generate parameters to create a standard animation
  23836. function genFx( type, includeWidth ) {
  23837. var which,
  23838. i = 0,
  23839. attrs = { height: type };
  23840. // If we include width, step value is 1 to do all cssExpand values,
  23841. // otherwise step value is 2 to skip over Left and Right
  23842. includeWidth = includeWidth ? 1 : 0;
  23843. for ( ; i < 4; i += 2 - includeWidth ) {
  23844. which = cssExpand[ i ];
  23845. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  23846. }
  23847. if ( includeWidth ) {
  23848. attrs.opacity = attrs.width = type;
  23849. }
  23850. return attrs;
  23851. }
  23852. function createTween( value, prop, animation ) {
  23853. var tween,
  23854. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  23855. index = 0,
  23856. length = collection.length;
  23857. for ( ; index < length; index++ ) {
  23858. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  23859. // We're done with this property
  23860. return tween;
  23861. }
  23862. }
  23863. }
  23864. function defaultPrefilter( elem, props, opts ) {
  23865. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  23866. isBox = "width" in props || "height" in props,
  23867. anim = this,
  23868. orig = {},
  23869. style = elem.style,
  23870. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  23871. dataShow = dataPriv.get( elem, "fxshow" );
  23872. // Queue-skipping animations hijack the fx hooks
  23873. if ( !opts.queue ) {
  23874. hooks = jQuery._queueHooks( elem, "fx" );
  23875. if ( hooks.unqueued == null ) {
  23876. hooks.unqueued = 0;
  23877. oldfire = hooks.empty.fire;
  23878. hooks.empty.fire = function() {
  23879. if ( !hooks.unqueued ) {
  23880. oldfire();
  23881. }
  23882. };
  23883. }
  23884. hooks.unqueued++;
  23885. anim.always( function() {
  23886. // Ensure the complete handler is called before this completes
  23887. anim.always( function() {
  23888. hooks.unqueued--;
  23889. if ( !jQuery.queue( elem, "fx" ).length ) {
  23890. hooks.empty.fire();
  23891. }
  23892. } );
  23893. } );
  23894. }
  23895. // Detect show/hide animations
  23896. for ( prop in props ) {
  23897. value = props[ prop ];
  23898. if ( rfxtypes.test( value ) ) {
  23899. delete props[ prop ];
  23900. toggle = toggle || value === "toggle";
  23901. if ( value === ( hidden ? "hide" : "show" ) ) {
  23902. // Pretend to be hidden if this is a "show" and
  23903. // there is still data from a stopped show/hide
  23904. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  23905. hidden = true;
  23906. // Ignore all other no-op show/hide data
  23907. } else {
  23908. continue;
  23909. }
  23910. }
  23911. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  23912. }
  23913. }
  23914. // Bail out if this is a no-op like .hide().hide()
  23915. propTween = !jQuery.isEmptyObject( props );
  23916. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  23917. return;
  23918. }
  23919. // Restrict "overflow" and "display" styles during box animations
  23920. if ( isBox && elem.nodeType === 1 ) {
  23921. // Support: IE <=9 - 11, Edge 12 - 15
  23922. // Record all 3 overflow attributes because IE does not infer the shorthand
  23923. // from identically-valued overflowX and overflowY and Edge just mirrors
  23924. // the overflowX value there.
  23925. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  23926. // Identify a display type, preferring old show/hide data over the CSS cascade
  23927. restoreDisplay = dataShow && dataShow.display;
  23928. if ( restoreDisplay == null ) {
  23929. restoreDisplay = dataPriv.get( elem, "display" );
  23930. }
  23931. display = jQuery.css( elem, "display" );
  23932. if ( display === "none" ) {
  23933. if ( restoreDisplay ) {
  23934. display = restoreDisplay;
  23935. } else {
  23936. // Get nonempty value(s) by temporarily forcing visibility
  23937. showHide( [ elem ], true );
  23938. restoreDisplay = elem.style.display || restoreDisplay;
  23939. display = jQuery.css( elem, "display" );
  23940. showHide( [ elem ] );
  23941. }
  23942. }
  23943. // Animate inline elements as inline-block
  23944. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  23945. if ( jQuery.css( elem, "float" ) === "none" ) {
  23946. // Restore the original display value at the end of pure show/hide animations
  23947. if ( !propTween ) {
  23948. anim.done( function() {
  23949. style.display = restoreDisplay;
  23950. } );
  23951. if ( restoreDisplay == null ) {
  23952. display = style.display;
  23953. restoreDisplay = display === "none" ? "" : display;
  23954. }
  23955. }
  23956. style.display = "inline-block";
  23957. }
  23958. }
  23959. }
  23960. if ( opts.overflow ) {
  23961. style.overflow = "hidden";
  23962. anim.always( function() {
  23963. style.overflow = opts.overflow[ 0 ];
  23964. style.overflowX = opts.overflow[ 1 ];
  23965. style.overflowY = opts.overflow[ 2 ];
  23966. } );
  23967. }
  23968. // Implement show/hide animations
  23969. propTween = false;
  23970. for ( prop in orig ) {
  23971. // General show/hide setup for this element animation
  23972. if ( !propTween ) {
  23973. if ( dataShow ) {
  23974. if ( "hidden" in dataShow ) {
  23975. hidden = dataShow.hidden;
  23976. }
  23977. } else {
  23978. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  23979. }
  23980. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  23981. if ( toggle ) {
  23982. dataShow.hidden = !hidden;
  23983. }
  23984. // Show elements before animating them
  23985. if ( hidden ) {
  23986. showHide( [ elem ], true );
  23987. }
  23988. /* eslint-disable no-loop-func */
  23989. anim.done( function() {
  23990. /* eslint-enable no-loop-func */
  23991. // The final step of a "hide" animation is actually hiding the element
  23992. if ( !hidden ) {
  23993. showHide( [ elem ] );
  23994. }
  23995. dataPriv.remove( elem, "fxshow" );
  23996. for ( prop in orig ) {
  23997. jQuery.style( elem, prop, orig[ prop ] );
  23998. }
  23999. } );
  24000. }
  24001. // Per-property setup
  24002. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  24003. if ( !( prop in dataShow ) ) {
  24004. dataShow[ prop ] = propTween.start;
  24005. if ( hidden ) {
  24006. propTween.end = propTween.start;
  24007. propTween.start = 0;
  24008. }
  24009. }
  24010. }
  24011. }
  24012. function propFilter( props, specialEasing ) {
  24013. var index, name, easing, value, hooks;
  24014. // camelCase, specialEasing and expand cssHook pass
  24015. for ( index in props ) {
  24016. name = camelCase( index );
  24017. easing = specialEasing[ name ];
  24018. value = props[ index ];
  24019. if ( Array.isArray( value ) ) {
  24020. easing = value[ 1 ];
  24021. value = props[ index ] = value[ 0 ];
  24022. }
  24023. if ( index !== name ) {
  24024. props[ name ] = value;
  24025. delete props[ index ];
  24026. }
  24027. hooks = jQuery.cssHooks[ name ];
  24028. if ( hooks && "expand" in hooks ) {
  24029. value = hooks.expand( value );
  24030. delete props[ name ];
  24031. // Not quite $.extend, this won't overwrite existing keys.
  24032. // Reusing 'index' because we have the correct "name"
  24033. for ( index in value ) {
  24034. if ( !( index in props ) ) {
  24035. props[ index ] = value[ index ];
  24036. specialEasing[ index ] = easing;
  24037. }
  24038. }
  24039. } else {
  24040. specialEasing[ name ] = easing;
  24041. }
  24042. }
  24043. }
  24044. function Animation( elem, properties, options ) {
  24045. var result,
  24046. stopped,
  24047. index = 0,
  24048. length = Animation.prefilters.length,
  24049. deferred = jQuery.Deferred().always( function() {
  24050. // Don't match elem in the :animated selector
  24051. delete tick.elem;
  24052. } ),
  24053. tick = function() {
  24054. if ( stopped ) {
  24055. return false;
  24056. }
  24057. var currentTime = fxNow || createFxNow(),
  24058. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  24059. // Support: Android 2.3 only
  24060. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  24061. temp = remaining / animation.duration || 0,
  24062. percent = 1 - temp,
  24063. index = 0,
  24064. length = animation.tweens.length;
  24065. for ( ; index < length; index++ ) {
  24066. animation.tweens[ index ].run( percent );
  24067. }
  24068. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  24069. // If there's more to do, yield
  24070. if ( percent < 1 && length ) {
  24071. return remaining;
  24072. }
  24073. // If this was an empty animation, synthesize a final progress notification
  24074. if ( !length ) {
  24075. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  24076. }
  24077. // Resolve the animation and report its conclusion
  24078. deferred.resolveWith( elem, [ animation ] );
  24079. return false;
  24080. },
  24081. animation = deferred.promise( {
  24082. elem: elem,
  24083. props: jQuery.extend( {}, properties ),
  24084. opts: jQuery.extend( true, {
  24085. specialEasing: {},
  24086. easing: jQuery.easing._default
  24087. }, options ),
  24088. originalProperties: properties,
  24089. originalOptions: options,
  24090. startTime: fxNow || createFxNow(),
  24091. duration: options.duration,
  24092. tweens: [],
  24093. createTween: function( prop, end ) {
  24094. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  24095. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  24096. animation.tweens.push( tween );
  24097. return tween;
  24098. },
  24099. stop: function( gotoEnd ) {
  24100. var index = 0,
  24101. // If we are going to the end, we want to run all the tweens
  24102. // otherwise we skip this part
  24103. length = gotoEnd ? animation.tweens.length : 0;
  24104. if ( stopped ) {
  24105. return this;
  24106. }
  24107. stopped = true;
  24108. for ( ; index < length; index++ ) {
  24109. animation.tweens[ index ].run( 1 );
  24110. }
  24111. // Resolve when we played the last frame; otherwise, reject
  24112. if ( gotoEnd ) {
  24113. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  24114. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  24115. } else {
  24116. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  24117. }
  24118. return this;
  24119. }
  24120. } ),
  24121. props = animation.props;
  24122. propFilter( props, animation.opts.specialEasing );
  24123. for ( ; index < length; index++ ) {
  24124. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  24125. if ( result ) {
  24126. if ( isFunction( result.stop ) ) {
  24127. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  24128. result.stop.bind( result );
  24129. }
  24130. return result;
  24131. }
  24132. }
  24133. jQuery.map( props, createTween, animation );
  24134. if ( isFunction( animation.opts.start ) ) {
  24135. animation.opts.start.call( elem, animation );
  24136. }
  24137. // Attach callbacks from options
  24138. animation
  24139. .progress( animation.opts.progress )
  24140. .done( animation.opts.done, animation.opts.complete )
  24141. .fail( animation.opts.fail )
  24142. .always( animation.opts.always );
  24143. jQuery.fx.timer(
  24144. jQuery.extend( tick, {
  24145. elem: elem,
  24146. anim: animation,
  24147. queue: animation.opts.queue
  24148. } )
  24149. );
  24150. return animation;
  24151. }
  24152. jQuery.Animation = jQuery.extend( Animation, {
  24153. tweeners: {
  24154. "*": [ function( prop, value ) {
  24155. var tween = this.createTween( prop, value );
  24156. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  24157. return tween;
  24158. } ]
  24159. },
  24160. tweener: function( props, callback ) {
  24161. if ( isFunction( props ) ) {
  24162. callback = props;
  24163. props = [ "*" ];
  24164. } else {
  24165. props = props.match( rnothtmlwhite );
  24166. }
  24167. var prop,
  24168. index = 0,
  24169. length = props.length;
  24170. for ( ; index < length; index++ ) {
  24171. prop = props[ index ];
  24172. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  24173. Animation.tweeners[ prop ].unshift( callback );
  24174. }
  24175. },
  24176. prefilters: [ defaultPrefilter ],
  24177. prefilter: function( callback, prepend ) {
  24178. if ( prepend ) {
  24179. Animation.prefilters.unshift( callback );
  24180. } else {
  24181. Animation.prefilters.push( callback );
  24182. }
  24183. }
  24184. } );
  24185. jQuery.speed = function( speed, easing, fn ) {
  24186. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  24187. complete: fn || !fn && easing ||
  24188. isFunction( speed ) && speed,
  24189. duration: speed,
  24190. easing: fn && easing || easing && !isFunction( easing ) && easing
  24191. };
  24192. // Go to the end state if fx are off
  24193. if ( jQuery.fx.off ) {
  24194. opt.duration = 0;
  24195. } else {
  24196. if ( typeof opt.duration !== "number" ) {
  24197. if ( opt.duration in jQuery.fx.speeds ) {
  24198. opt.duration = jQuery.fx.speeds[ opt.duration ];
  24199. } else {
  24200. opt.duration = jQuery.fx.speeds._default;
  24201. }
  24202. }
  24203. }
  24204. // Normalize opt.queue - true/undefined/null -> "fx"
  24205. if ( opt.queue == null || opt.queue === true ) {
  24206. opt.queue = "fx";
  24207. }
  24208. // Queueing
  24209. opt.old = opt.complete;
  24210. opt.complete = function() {
  24211. if ( isFunction( opt.old ) ) {
  24212. opt.old.call( this );
  24213. }
  24214. if ( opt.queue ) {
  24215. jQuery.dequeue( this, opt.queue );
  24216. }
  24217. };
  24218. return opt;
  24219. };
  24220. jQuery.fn.extend( {
  24221. fadeTo: function( speed, to, easing, callback ) {
  24222. // Show any hidden elements after setting opacity to 0
  24223. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  24224. // Animate to the value specified
  24225. .end().animate( { opacity: to }, speed, easing, callback );
  24226. },
  24227. animate: function( prop, speed, easing, callback ) {
  24228. var empty = jQuery.isEmptyObject( prop ),
  24229. optall = jQuery.speed( speed, easing, callback ),
  24230. doAnimation = function() {
  24231. // Operate on a copy of prop so per-property easing won't be lost
  24232. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  24233. // Empty animations, or finishing resolves immediately
  24234. if ( empty || dataPriv.get( this, "finish" ) ) {
  24235. anim.stop( true );
  24236. }
  24237. };
  24238. doAnimation.finish = doAnimation;
  24239. return empty || optall.queue === false ?
  24240. this.each( doAnimation ) :
  24241. this.queue( optall.queue, doAnimation );
  24242. },
  24243. stop: function( type, clearQueue, gotoEnd ) {
  24244. var stopQueue = function( hooks ) {
  24245. var stop = hooks.stop;
  24246. delete hooks.stop;
  24247. stop( gotoEnd );
  24248. };
  24249. if ( typeof type !== "string" ) {
  24250. gotoEnd = clearQueue;
  24251. clearQueue = type;
  24252. type = undefined;
  24253. }
  24254. if ( clearQueue ) {
  24255. this.queue( type || "fx", [] );
  24256. }
  24257. return this.each( function() {
  24258. var dequeue = true,
  24259. index = type != null && type + "queueHooks",
  24260. timers = jQuery.timers,
  24261. data = dataPriv.get( this );
  24262. if ( index ) {
  24263. if ( data[ index ] && data[ index ].stop ) {
  24264. stopQueue( data[ index ] );
  24265. }
  24266. } else {
  24267. for ( index in data ) {
  24268. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  24269. stopQueue( data[ index ] );
  24270. }
  24271. }
  24272. }
  24273. for ( index = timers.length; index--; ) {
  24274. if ( timers[ index ].elem === this &&
  24275. ( type == null || timers[ index ].queue === type ) ) {
  24276. timers[ index ].anim.stop( gotoEnd );
  24277. dequeue = false;
  24278. timers.splice( index, 1 );
  24279. }
  24280. }
  24281. // Start the next in the queue if the last step wasn't forced.
  24282. // Timers currently will call their complete callbacks, which
  24283. // will dequeue but only if they were gotoEnd.
  24284. if ( dequeue || !gotoEnd ) {
  24285. jQuery.dequeue( this, type );
  24286. }
  24287. } );
  24288. },
  24289. finish: function( type ) {
  24290. if ( type !== false ) {
  24291. type = type || "fx";
  24292. }
  24293. return this.each( function() {
  24294. var index,
  24295. data = dataPriv.get( this ),
  24296. queue = data[ type + "queue" ],
  24297. hooks = data[ type + "queueHooks" ],
  24298. timers = jQuery.timers,
  24299. length = queue ? queue.length : 0;
  24300. // Enable finishing flag on private data
  24301. data.finish = true;
  24302. // Empty the queue first
  24303. jQuery.queue( this, type, [] );
  24304. if ( hooks && hooks.stop ) {
  24305. hooks.stop.call( this, true );
  24306. }
  24307. // Look for any active animations, and finish them
  24308. for ( index = timers.length; index--; ) {
  24309. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  24310. timers[ index ].anim.stop( true );
  24311. timers.splice( index, 1 );
  24312. }
  24313. }
  24314. // Look for any animations in the old queue and finish them
  24315. for ( index = 0; index < length; index++ ) {
  24316. if ( queue[ index ] && queue[ index ].finish ) {
  24317. queue[ index ].finish.call( this );
  24318. }
  24319. }
  24320. // Turn off finishing flag
  24321. delete data.finish;
  24322. } );
  24323. }
  24324. } );
  24325. jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
  24326. var cssFn = jQuery.fn[ name ];
  24327. jQuery.fn[ name ] = function( speed, easing, callback ) {
  24328. return speed == null || typeof speed === "boolean" ?
  24329. cssFn.apply( this, arguments ) :
  24330. this.animate( genFx( name, true ), speed, easing, callback );
  24331. };
  24332. } );
  24333. // Generate shortcuts for custom animations
  24334. jQuery.each( {
  24335. slideDown: genFx( "show" ),
  24336. slideUp: genFx( "hide" ),
  24337. slideToggle: genFx( "toggle" ),
  24338. fadeIn: { opacity: "show" },
  24339. fadeOut: { opacity: "hide" },
  24340. fadeToggle: { opacity: "toggle" }
  24341. }, function( name, props ) {
  24342. jQuery.fn[ name ] = function( speed, easing, callback ) {
  24343. return this.animate( props, speed, easing, callback );
  24344. };
  24345. } );
  24346. jQuery.timers = [];
  24347. jQuery.fx.tick = function() {
  24348. var timer,
  24349. i = 0,
  24350. timers = jQuery.timers;
  24351. fxNow = Date.now();
  24352. for ( ; i < timers.length; i++ ) {
  24353. timer = timers[ i ];
  24354. // Run the timer and safely remove it when done (allowing for external removal)
  24355. if ( !timer() && timers[ i ] === timer ) {
  24356. timers.splice( i--, 1 );
  24357. }
  24358. }
  24359. if ( !timers.length ) {
  24360. jQuery.fx.stop();
  24361. }
  24362. fxNow = undefined;
  24363. };
  24364. jQuery.fx.timer = function( timer ) {
  24365. jQuery.timers.push( timer );
  24366. jQuery.fx.start();
  24367. };
  24368. jQuery.fx.interval = 13;
  24369. jQuery.fx.start = function() {
  24370. if ( inProgress ) {
  24371. return;
  24372. }
  24373. inProgress = true;
  24374. schedule();
  24375. };
  24376. jQuery.fx.stop = function() {
  24377. inProgress = null;
  24378. };
  24379. jQuery.fx.speeds = {
  24380. slow: 600,
  24381. fast: 200,
  24382. // Default speed
  24383. _default: 400
  24384. };
  24385. // Based off of the plugin by Clint Helfers, with permission.
  24386. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  24387. jQuery.fn.delay = function( time, type ) {
  24388. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  24389. type = type || "fx";
  24390. return this.queue( type, function( next, hooks ) {
  24391. var timeout = window.setTimeout( next, time );
  24392. hooks.stop = function() {
  24393. window.clearTimeout( timeout );
  24394. };
  24395. } );
  24396. };
  24397. ( function() {
  24398. var input = document.createElement( "input" ),
  24399. select = document.createElement( "select" ),
  24400. opt = select.appendChild( document.createElement( "option" ) );
  24401. input.type = "checkbox";
  24402. // Support: Android <=4.3 only
  24403. // Default value for a checkbox should be "on"
  24404. support.checkOn = input.value !== "";
  24405. // Support: IE <=11 only
  24406. // Must access selectedIndex to make default options select
  24407. support.optSelected = opt.selected;
  24408. // Support: IE <=11 only
  24409. // An input loses its value after becoming a radio
  24410. input = document.createElement( "input" );
  24411. input.value = "t";
  24412. input.type = "radio";
  24413. support.radioValue = input.value === "t";
  24414. } )();
  24415. var boolHook,
  24416. attrHandle = jQuery.expr.attrHandle;
  24417. jQuery.fn.extend( {
  24418. attr: function( name, value ) {
  24419. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  24420. },
  24421. removeAttr: function( name ) {
  24422. return this.each( function() {
  24423. jQuery.removeAttr( this, name );
  24424. } );
  24425. }
  24426. } );
  24427. jQuery.extend( {
  24428. attr: function( elem, name, value ) {
  24429. var ret, hooks,
  24430. nType = elem.nodeType;
  24431. // Don't get/set attributes on text, comment and attribute nodes
  24432. if ( nType === 3 || nType === 8 || nType === 2 ) {
  24433. return;
  24434. }
  24435. // Fallback to prop when attributes are not supported
  24436. if ( typeof elem.getAttribute === "undefined" ) {
  24437. return jQuery.prop( elem, name, value );
  24438. }
  24439. // Attribute hooks are determined by the lowercase version
  24440. // Grab necessary hook if one is defined
  24441. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  24442. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  24443. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  24444. }
  24445. if ( value !== undefined ) {
  24446. if ( value === null ) {
  24447. jQuery.removeAttr( elem, name );
  24448. return;
  24449. }
  24450. if ( hooks && "set" in hooks &&
  24451. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  24452. return ret;
  24453. }
  24454. elem.setAttribute( name, value + "" );
  24455. return value;
  24456. }
  24457. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  24458. return ret;
  24459. }
  24460. ret = jQuery.find.attr( elem, name );
  24461. // Non-existent attributes return null, we normalize to undefined
  24462. return ret == null ? undefined : ret;
  24463. },
  24464. attrHooks: {
  24465. type: {
  24466. set: function( elem, value ) {
  24467. if ( !support.radioValue && value === "radio" &&
  24468. nodeName( elem, "input" ) ) {
  24469. var val = elem.value;
  24470. elem.setAttribute( "type", value );
  24471. if ( val ) {
  24472. elem.value = val;
  24473. }
  24474. return value;
  24475. }
  24476. }
  24477. }
  24478. },
  24479. removeAttr: function( elem, value ) {
  24480. var name,
  24481. i = 0,
  24482. // Attribute names can contain non-HTML whitespace characters
  24483. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  24484. attrNames = value && value.match( rnothtmlwhite );
  24485. if ( attrNames && elem.nodeType === 1 ) {
  24486. while ( ( name = attrNames[ i++ ] ) ) {
  24487. elem.removeAttribute( name );
  24488. }
  24489. }
  24490. }
  24491. } );
  24492. // Hooks for boolean attributes
  24493. boolHook = {
  24494. set: function( elem, value, name ) {
  24495. if ( value === false ) {
  24496. // Remove boolean attributes when set to false
  24497. jQuery.removeAttr( elem, name );
  24498. } else {
  24499. elem.setAttribute( name, name );
  24500. }
  24501. return name;
  24502. }
  24503. };
  24504. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
  24505. var getter = attrHandle[ name ] || jQuery.find.attr;
  24506. attrHandle[ name ] = function( elem, name, isXML ) {
  24507. var ret, handle,
  24508. lowercaseName = name.toLowerCase();
  24509. if ( !isXML ) {
  24510. // Avoid an infinite loop by temporarily removing this function from the getter
  24511. handle = attrHandle[ lowercaseName ];
  24512. attrHandle[ lowercaseName ] = ret;
  24513. ret = getter( elem, name, isXML ) != null ?
  24514. lowercaseName :
  24515. null;
  24516. attrHandle[ lowercaseName ] = handle;
  24517. }
  24518. return ret;
  24519. };
  24520. } );
  24521. var rfocusable = /^(?:input|select|textarea|button)$/i,
  24522. rclickable = /^(?:a|area)$/i;
  24523. jQuery.fn.extend( {
  24524. prop: function( name, value ) {
  24525. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  24526. },
  24527. removeProp: function( name ) {
  24528. return this.each( function() {
  24529. delete this[ jQuery.propFix[ name ] || name ];
  24530. } );
  24531. }
  24532. } );
  24533. jQuery.extend( {
  24534. prop: function( elem, name, value ) {
  24535. var ret, hooks,
  24536. nType = elem.nodeType;
  24537. // Don't get/set properties on text, comment and attribute nodes
  24538. if ( nType === 3 || nType === 8 || nType === 2 ) {
  24539. return;
  24540. }
  24541. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  24542. // Fix name and attach hooks
  24543. name = jQuery.propFix[ name ] || name;
  24544. hooks = jQuery.propHooks[ name ];
  24545. }
  24546. if ( value !== undefined ) {
  24547. if ( hooks && "set" in hooks &&
  24548. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  24549. return ret;
  24550. }
  24551. return ( elem[ name ] = value );
  24552. }
  24553. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  24554. return ret;
  24555. }
  24556. return elem[ name ];
  24557. },
  24558. propHooks: {
  24559. tabIndex: {
  24560. get: function( elem ) {
  24561. // Support: IE <=9 - 11 only
  24562. // elem.tabIndex doesn't always return the
  24563. // correct value when it hasn't been explicitly set
  24564. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  24565. // Use proper attribute retrieval(#12072)
  24566. var tabindex = jQuery.find.attr( elem, "tabindex" );
  24567. if ( tabindex ) {
  24568. return parseInt( tabindex, 10 );
  24569. }
  24570. if (
  24571. rfocusable.test( elem.nodeName ) ||
  24572. rclickable.test( elem.nodeName ) &&
  24573. elem.href
  24574. ) {
  24575. return 0;
  24576. }
  24577. return -1;
  24578. }
  24579. }
  24580. },
  24581. propFix: {
  24582. "for": "htmlFor",
  24583. "class": "className"
  24584. }
  24585. } );
  24586. // Support: IE <=11 only
  24587. // Accessing the selectedIndex property
  24588. // forces the browser to respect setting selected
  24589. // on the option
  24590. // The getter ensures a default option is selected
  24591. // when in an optgroup
  24592. // eslint rule "no-unused-expressions" is disabled for this code
  24593. // since it considers such accessions noop
  24594. if ( !support.optSelected ) {
  24595. jQuery.propHooks.selected = {
  24596. get: function( elem ) {
  24597. /* eslint no-unused-expressions: "off" */
  24598. var parent = elem.parentNode;
  24599. if ( parent && parent.parentNode ) {
  24600. parent.parentNode.selectedIndex;
  24601. }
  24602. return null;
  24603. },
  24604. set: function( elem ) {
  24605. /* eslint no-unused-expressions: "off" */
  24606. var parent = elem.parentNode;
  24607. if ( parent ) {
  24608. parent.selectedIndex;
  24609. if ( parent.parentNode ) {
  24610. parent.parentNode.selectedIndex;
  24611. }
  24612. }
  24613. }
  24614. };
  24615. }
  24616. jQuery.each( [
  24617. "tabIndex",
  24618. "readOnly",
  24619. "maxLength",
  24620. "cellSpacing",
  24621. "cellPadding",
  24622. "rowSpan",
  24623. "colSpan",
  24624. "useMap",
  24625. "frameBorder",
  24626. "contentEditable"
  24627. ], function() {
  24628. jQuery.propFix[ this.toLowerCase() ] = this;
  24629. } );
  24630. // Strip and collapse whitespace according to HTML spec
  24631. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  24632. function stripAndCollapse( value ) {
  24633. var tokens = value.match( rnothtmlwhite ) || [];
  24634. return tokens.join( " " );
  24635. }
  24636. function getClass( elem ) {
  24637. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  24638. }
  24639. function classesToArray( value ) {
  24640. if ( Array.isArray( value ) ) {
  24641. return value;
  24642. }
  24643. if ( typeof value === "string" ) {
  24644. return value.match( rnothtmlwhite ) || [];
  24645. }
  24646. return [];
  24647. }
  24648. jQuery.fn.extend( {
  24649. addClass: function( value ) {
  24650. var classes, elem, cur, curValue, clazz, j, finalValue,
  24651. i = 0;
  24652. if ( isFunction( value ) ) {
  24653. return this.each( function( j ) {
  24654. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  24655. } );
  24656. }
  24657. classes = classesToArray( value );
  24658. if ( classes.length ) {
  24659. while ( ( elem = this[ i++ ] ) ) {
  24660. curValue = getClass( elem );
  24661. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  24662. if ( cur ) {
  24663. j = 0;
  24664. while ( ( clazz = classes[ j++ ] ) ) {
  24665. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  24666. cur += clazz + " ";
  24667. }
  24668. }
  24669. // Only assign if different to avoid unneeded rendering.
  24670. finalValue = stripAndCollapse( cur );
  24671. if ( curValue !== finalValue ) {
  24672. elem.setAttribute( "class", finalValue );
  24673. }
  24674. }
  24675. }
  24676. }
  24677. return this;
  24678. },
  24679. removeClass: function( value ) {
  24680. var classes, elem, cur, curValue, clazz, j, finalValue,
  24681. i = 0;
  24682. if ( isFunction( value ) ) {
  24683. return this.each( function( j ) {
  24684. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  24685. } );
  24686. }
  24687. if ( !arguments.length ) {
  24688. return this.attr( "class", "" );
  24689. }
  24690. classes = classesToArray( value );
  24691. if ( classes.length ) {
  24692. while ( ( elem = this[ i++ ] ) ) {
  24693. curValue = getClass( elem );
  24694. // This expression is here for better compressibility (see addClass)
  24695. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  24696. if ( cur ) {
  24697. j = 0;
  24698. while ( ( clazz = classes[ j++ ] ) ) {
  24699. // Remove *all* instances
  24700. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  24701. cur = cur.replace( " " + clazz + " ", " " );
  24702. }
  24703. }
  24704. // Only assign if different to avoid unneeded rendering.
  24705. finalValue = stripAndCollapse( cur );
  24706. if ( curValue !== finalValue ) {
  24707. elem.setAttribute( "class", finalValue );
  24708. }
  24709. }
  24710. }
  24711. }
  24712. return this;
  24713. },
  24714. toggleClass: function( value, stateVal ) {
  24715. var type = typeof value,
  24716. isValidValue = type === "string" || Array.isArray( value );
  24717. if ( typeof stateVal === "boolean" && isValidValue ) {
  24718. return stateVal ? this.addClass( value ) : this.removeClass( value );
  24719. }
  24720. if ( isFunction( value ) ) {
  24721. return this.each( function( i ) {
  24722. jQuery( this ).toggleClass(
  24723. value.call( this, i, getClass( this ), stateVal ),
  24724. stateVal
  24725. );
  24726. } );
  24727. }
  24728. return this.each( function() {
  24729. var className, i, self, classNames;
  24730. if ( isValidValue ) {
  24731. // Toggle individual class names
  24732. i = 0;
  24733. self = jQuery( this );
  24734. classNames = classesToArray( value );
  24735. while ( ( className = classNames[ i++ ] ) ) {
  24736. // Check each className given, space separated list
  24737. if ( self.hasClass( className ) ) {
  24738. self.removeClass( className );
  24739. } else {
  24740. self.addClass( className );
  24741. }
  24742. }
  24743. // Toggle whole class name
  24744. } else if ( value === undefined || type === "boolean" ) {
  24745. className = getClass( this );
  24746. if ( className ) {
  24747. // Store className if set
  24748. dataPriv.set( this, "__className__", className );
  24749. }
  24750. // If the element has a class name or if we're passed `false`,
  24751. // then remove the whole classname (if there was one, the above saved it).
  24752. // Otherwise bring back whatever was previously saved (if anything),
  24753. // falling back to the empty string if nothing was stored.
  24754. if ( this.setAttribute ) {
  24755. this.setAttribute( "class",
  24756. className || value === false ?
  24757. "" :
  24758. dataPriv.get( this, "__className__" ) || ""
  24759. );
  24760. }
  24761. }
  24762. } );
  24763. },
  24764. hasClass: function( selector ) {
  24765. var className, elem,
  24766. i = 0;
  24767. className = " " + selector + " ";
  24768. while ( ( elem = this[ i++ ] ) ) {
  24769. if ( elem.nodeType === 1 &&
  24770. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  24771. return true;
  24772. }
  24773. }
  24774. return false;
  24775. }
  24776. } );
  24777. var rreturn = /\r/g;
  24778. jQuery.fn.extend( {
  24779. val: function( value ) {
  24780. var hooks, ret, valueIsFunction,
  24781. elem = this[ 0 ];
  24782. if ( !arguments.length ) {
  24783. if ( elem ) {
  24784. hooks = jQuery.valHooks[ elem.type ] ||
  24785. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  24786. if ( hooks &&
  24787. "get" in hooks &&
  24788. ( ret = hooks.get( elem, "value" ) ) !== undefined
  24789. ) {
  24790. return ret;
  24791. }
  24792. ret = elem.value;
  24793. // Handle most common string cases
  24794. if ( typeof ret === "string" ) {
  24795. return ret.replace( rreturn, "" );
  24796. }
  24797. // Handle cases where value is null/undef or number
  24798. return ret == null ? "" : ret;
  24799. }
  24800. return;
  24801. }
  24802. valueIsFunction = isFunction( value );
  24803. return this.each( function( i ) {
  24804. var val;
  24805. if ( this.nodeType !== 1 ) {
  24806. return;
  24807. }
  24808. if ( valueIsFunction ) {
  24809. val = value.call( this, i, jQuery( this ).val() );
  24810. } else {
  24811. val = value;
  24812. }
  24813. // Treat null/undefined as ""; convert numbers to string
  24814. if ( val == null ) {
  24815. val = "";
  24816. } else if ( typeof val === "number" ) {
  24817. val += "";
  24818. } else if ( Array.isArray( val ) ) {
  24819. val = jQuery.map( val, function( value ) {
  24820. return value == null ? "" : value + "";
  24821. } );
  24822. }
  24823. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  24824. // If set returns undefined, fall back to normal setting
  24825. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  24826. this.value = val;
  24827. }
  24828. } );
  24829. }
  24830. } );
  24831. jQuery.extend( {
  24832. valHooks: {
  24833. option: {
  24834. get: function( elem ) {
  24835. var val = jQuery.find.attr( elem, "value" );
  24836. return val != null ?
  24837. val :
  24838. // Support: IE <=10 - 11 only
  24839. // option.text throws exceptions (#14686, #14858)
  24840. // Strip and collapse whitespace
  24841. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  24842. stripAndCollapse( jQuery.text( elem ) );
  24843. }
  24844. },
  24845. select: {
  24846. get: function( elem ) {
  24847. var value, option, i,
  24848. options = elem.options,
  24849. index = elem.selectedIndex,
  24850. one = elem.type === "select-one",
  24851. values = one ? null : [],
  24852. max = one ? index + 1 : options.length;
  24853. if ( index < 0 ) {
  24854. i = max;
  24855. } else {
  24856. i = one ? index : 0;
  24857. }
  24858. // Loop through all the selected options
  24859. for ( ; i < max; i++ ) {
  24860. option = options[ i ];
  24861. // Support: IE <=9 only
  24862. // IE8-9 doesn't update selected after form reset (#2551)
  24863. if ( ( option.selected || i === index ) &&
  24864. // Don't return options that are disabled or in a disabled optgroup
  24865. !option.disabled &&
  24866. ( !option.parentNode.disabled ||
  24867. !nodeName( option.parentNode, "optgroup" ) ) ) {
  24868. // Get the specific value for the option
  24869. value = jQuery( option ).val();
  24870. // We don't need an array for one selects
  24871. if ( one ) {
  24872. return value;
  24873. }
  24874. // Multi-Selects return an array
  24875. values.push( value );
  24876. }
  24877. }
  24878. return values;
  24879. },
  24880. set: function( elem, value ) {
  24881. var optionSet, option,
  24882. options = elem.options,
  24883. values = jQuery.makeArray( value ),
  24884. i = options.length;
  24885. while ( i-- ) {
  24886. option = options[ i ];
  24887. /* eslint-disable no-cond-assign */
  24888. if ( option.selected =
  24889. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  24890. ) {
  24891. optionSet = true;
  24892. }
  24893. /* eslint-enable no-cond-assign */
  24894. }
  24895. // Force browsers to behave consistently when non-matching value is set
  24896. if ( !optionSet ) {
  24897. elem.selectedIndex = -1;
  24898. }
  24899. return values;
  24900. }
  24901. }
  24902. }
  24903. } );
  24904. // Radios and checkboxes getter/setter
  24905. jQuery.each( [ "radio", "checkbox" ], function() {
  24906. jQuery.valHooks[ this ] = {
  24907. set: function( elem, value ) {
  24908. if ( Array.isArray( value ) ) {
  24909. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  24910. }
  24911. }
  24912. };
  24913. if ( !support.checkOn ) {
  24914. jQuery.valHooks[ this ].get = function( elem ) {
  24915. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  24916. };
  24917. }
  24918. } );
  24919. // Return jQuery for attributes-only inclusion
  24920. support.focusin = "onfocusin" in window;
  24921. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  24922. stopPropagationCallback = function( e ) {
  24923. e.stopPropagation();
  24924. };
  24925. jQuery.extend( jQuery.event, {
  24926. trigger: function( event, data, elem, onlyHandlers ) {
  24927. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  24928. eventPath = [ elem || document ],
  24929. type = hasOwn.call( event, "type" ) ? event.type : event,
  24930. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  24931. cur = lastElement = tmp = elem = elem || document;
  24932. // Don't do events on text and comment nodes
  24933. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  24934. return;
  24935. }
  24936. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  24937. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  24938. return;
  24939. }
  24940. if ( type.indexOf( "." ) > -1 ) {
  24941. // Namespaced trigger; create a regexp to match event type in handle()
  24942. namespaces = type.split( "." );
  24943. type = namespaces.shift();
  24944. namespaces.sort();
  24945. }
  24946. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  24947. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  24948. event = event[ jQuery.expando ] ?
  24949. event :
  24950. new jQuery.Event( type, typeof event === "object" && event );
  24951. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  24952. event.isTrigger = onlyHandlers ? 2 : 3;
  24953. event.namespace = namespaces.join( "." );
  24954. event.rnamespace = event.namespace ?
  24955. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  24956. null;
  24957. // Clean up the event in case it is being reused
  24958. event.result = undefined;
  24959. if ( !event.target ) {
  24960. event.target = elem;
  24961. }
  24962. // Clone any incoming data and prepend the event, creating the handler arg list
  24963. data = data == null ?
  24964. [ event ] :
  24965. jQuery.makeArray( data, [ event ] );
  24966. // Allow special events to draw outside the lines
  24967. special = jQuery.event.special[ type ] || {};
  24968. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  24969. return;
  24970. }
  24971. // Determine event propagation path in advance, per W3C events spec (#9951)
  24972. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  24973. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  24974. bubbleType = special.delegateType || type;
  24975. if ( !rfocusMorph.test( bubbleType + type ) ) {
  24976. cur = cur.parentNode;
  24977. }
  24978. for ( ; cur; cur = cur.parentNode ) {
  24979. eventPath.push( cur );
  24980. tmp = cur;
  24981. }
  24982. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  24983. if ( tmp === ( elem.ownerDocument || document ) ) {
  24984. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  24985. }
  24986. }
  24987. // Fire handlers on the event path
  24988. i = 0;
  24989. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  24990. lastElement = cur;
  24991. event.type = i > 1 ?
  24992. bubbleType :
  24993. special.bindType || type;
  24994. // jQuery handler
  24995. handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
  24996. dataPriv.get( cur, "handle" );
  24997. if ( handle ) {
  24998. handle.apply( cur, data );
  24999. }
  25000. // Native handler
  25001. handle = ontype && cur[ ontype ];
  25002. if ( handle && handle.apply && acceptData( cur ) ) {
  25003. event.result = handle.apply( cur, data );
  25004. if ( event.result === false ) {
  25005. event.preventDefault();
  25006. }
  25007. }
  25008. }
  25009. event.type = type;
  25010. // If nobody prevented the default action, do it now
  25011. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  25012. if ( ( !special._default ||
  25013. special._default.apply( eventPath.pop(), data ) === false ) &&
  25014. acceptData( elem ) ) {
  25015. // Call a native DOM method on the target with the same name as the event.
  25016. // Don't do default actions on window, that's where global variables be (#6170)
  25017. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  25018. // Don't re-trigger an onFOO event when we call its FOO() method
  25019. tmp = elem[ ontype ];
  25020. if ( tmp ) {
  25021. elem[ ontype ] = null;
  25022. }
  25023. // Prevent re-triggering of the same event, since we already bubbled it above
  25024. jQuery.event.triggered = type;
  25025. if ( event.isPropagationStopped() ) {
  25026. lastElement.addEventListener( type, stopPropagationCallback );
  25027. }
  25028. elem[ type ]();
  25029. if ( event.isPropagationStopped() ) {
  25030. lastElement.removeEventListener( type, stopPropagationCallback );
  25031. }
  25032. jQuery.event.triggered = undefined;
  25033. if ( tmp ) {
  25034. elem[ ontype ] = tmp;
  25035. }
  25036. }
  25037. }
  25038. }
  25039. return event.result;
  25040. },
  25041. // Piggyback on a donor event to simulate a different one
  25042. // Used only for `focus(in | out)` events
  25043. simulate: function( type, elem, event ) {
  25044. var e = jQuery.extend(
  25045. new jQuery.Event(),
  25046. event,
  25047. {
  25048. type: type,
  25049. isSimulated: true
  25050. }
  25051. );
  25052. jQuery.event.trigger( e, null, elem );
  25053. }
  25054. } );
  25055. jQuery.fn.extend( {
  25056. trigger: function( type, data ) {
  25057. return this.each( function() {
  25058. jQuery.event.trigger( type, data, this );
  25059. } );
  25060. },
  25061. triggerHandler: function( type, data ) {
  25062. var elem = this[ 0 ];
  25063. if ( elem ) {
  25064. return jQuery.event.trigger( type, data, elem, true );
  25065. }
  25066. }
  25067. } );
  25068. // Support: Firefox <=44
  25069. // Firefox doesn't have focus(in | out) events
  25070. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  25071. //
  25072. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  25073. // focus(in | out) events fire after focus & blur events,
  25074. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  25075. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  25076. if ( !support.focusin ) {
  25077. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  25078. // Attach a single capturing handler on the document while someone wants focusin/focusout
  25079. var handler = function( event ) {
  25080. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  25081. };
  25082. jQuery.event.special[ fix ] = {
  25083. setup: function() {
  25084. // Handle: regular nodes (via `this.ownerDocument`), window
  25085. // (via `this.document`) & document (via `this`).
  25086. var doc = this.ownerDocument || this.document || this,
  25087. attaches = dataPriv.access( doc, fix );
  25088. if ( !attaches ) {
  25089. doc.addEventListener( orig, handler, true );
  25090. }
  25091. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  25092. },
  25093. teardown: function() {
  25094. var doc = this.ownerDocument || this.document || this,
  25095. attaches = dataPriv.access( doc, fix ) - 1;
  25096. if ( !attaches ) {
  25097. doc.removeEventListener( orig, handler, true );
  25098. dataPriv.remove( doc, fix );
  25099. } else {
  25100. dataPriv.access( doc, fix, attaches );
  25101. }
  25102. }
  25103. };
  25104. } );
  25105. }
  25106. var location = window.location;
  25107. var nonce = { guid: Date.now() };
  25108. var rquery = ( /\?/ );
  25109. // Cross-browser xml parsing
  25110. jQuery.parseXML = function( data ) {
  25111. var xml, parserErrorElem;
  25112. if ( !data || typeof data !== "string" ) {
  25113. return null;
  25114. }
  25115. // Support: IE 9 - 11 only
  25116. // IE throws on parseFromString with invalid input.
  25117. try {
  25118. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  25119. } catch ( e ) {}
  25120. parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
  25121. if ( !xml || parserErrorElem ) {
  25122. jQuery.error( "Invalid XML: " + (
  25123. parserErrorElem ?
  25124. jQuery.map( parserErrorElem.childNodes, function( el ) {
  25125. return el.textContent;
  25126. } ).join( "\n" ) :
  25127. data
  25128. ) );
  25129. }
  25130. return xml;
  25131. };
  25132. var
  25133. rbracket = /\[\]$/,
  25134. rCRLF = /\r?\n/g,
  25135. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  25136. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  25137. function buildParams( prefix, obj, traditional, add ) {
  25138. var name;
  25139. if ( Array.isArray( obj ) ) {
  25140. // Serialize array item.
  25141. jQuery.each( obj, function( i, v ) {
  25142. if ( traditional || rbracket.test( prefix ) ) {
  25143. // Treat each array item as a scalar.
  25144. add( prefix, v );
  25145. } else {
  25146. // Item is non-scalar (array or object), encode its numeric index.
  25147. buildParams(
  25148. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  25149. v,
  25150. traditional,
  25151. add
  25152. );
  25153. }
  25154. } );
  25155. } else if ( !traditional && toType( obj ) === "object" ) {
  25156. // Serialize object item.
  25157. for ( name in obj ) {
  25158. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  25159. }
  25160. } else {
  25161. // Serialize scalar item.
  25162. add( prefix, obj );
  25163. }
  25164. }
  25165. // Serialize an array of form elements or a set of
  25166. // key/values into a query string
  25167. jQuery.param = function( a, traditional ) {
  25168. var prefix,
  25169. s = [],
  25170. add = function( key, valueOrFunction ) {
  25171. // If value is a function, invoke it and use its return value
  25172. var value = isFunction( valueOrFunction ) ?
  25173. valueOrFunction() :
  25174. valueOrFunction;
  25175. s[ s.length ] = encodeURIComponent( key ) + "=" +
  25176. encodeURIComponent( value == null ? "" : value );
  25177. };
  25178. if ( a == null ) {
  25179. return "";
  25180. }
  25181. // If an array was passed in, assume that it is an array of form elements.
  25182. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  25183. // Serialize the form elements
  25184. jQuery.each( a, function() {
  25185. add( this.name, this.value );
  25186. } );
  25187. } else {
  25188. // If traditional, encode the "old" way (the way 1.3.2 or older
  25189. // did it), otherwise encode params recursively.
  25190. for ( prefix in a ) {
  25191. buildParams( prefix, a[ prefix ], traditional, add );
  25192. }
  25193. }
  25194. // Return the resulting serialization
  25195. return s.join( "&" );
  25196. };
  25197. jQuery.fn.extend( {
  25198. serialize: function() {
  25199. return jQuery.param( this.serializeArray() );
  25200. },
  25201. serializeArray: function() {
  25202. return this.map( function() {
  25203. // Can add propHook for "elements" to filter or add form elements
  25204. var elements = jQuery.prop( this, "elements" );
  25205. return elements ? jQuery.makeArray( elements ) : this;
  25206. } ).filter( function() {
  25207. var type = this.type;
  25208. // Use .is( ":disabled" ) so that fieldset[disabled] works
  25209. return this.name && !jQuery( this ).is( ":disabled" ) &&
  25210. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  25211. ( this.checked || !rcheckableType.test( type ) );
  25212. } ).map( function( _i, elem ) {
  25213. var val = jQuery( this ).val();
  25214. if ( val == null ) {
  25215. return null;
  25216. }
  25217. if ( Array.isArray( val ) ) {
  25218. return jQuery.map( val, function( val ) {
  25219. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  25220. } );
  25221. }
  25222. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  25223. } ).get();
  25224. }
  25225. } );
  25226. var
  25227. r20 = /%20/g,
  25228. rhash = /#.*$/,
  25229. rantiCache = /([?&])_=[^&]*/,
  25230. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  25231. // #7653, #8125, #8152: local protocol detection
  25232. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  25233. rnoContent = /^(?:GET|HEAD)$/,
  25234. rprotocol = /^\/\//,
  25235. /* Prefilters
  25236. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  25237. * 2) These are called:
  25238. * - BEFORE asking for a transport
  25239. * - AFTER param serialization (s.data is a string if s.processData is true)
  25240. * 3) key is the dataType
  25241. * 4) the catchall symbol "*" can be used
  25242. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  25243. */
  25244. prefilters = {},
  25245. /* Transports bindings
  25246. * 1) key is the dataType
  25247. * 2) the catchall symbol "*" can be used
  25248. * 3) selection will start with transport dataType and THEN go to "*" if needed
  25249. */
  25250. transports = {},
  25251. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  25252. allTypes = "*/".concat( "*" ),
  25253. // Anchor tag for parsing the document origin
  25254. originAnchor = document.createElement( "a" );
  25255. originAnchor.href = location.href;
  25256. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  25257. function addToPrefiltersOrTransports( structure ) {
  25258. // dataTypeExpression is optional and defaults to "*"
  25259. return function( dataTypeExpression, func ) {
  25260. if ( typeof dataTypeExpression !== "string" ) {
  25261. func = dataTypeExpression;
  25262. dataTypeExpression = "*";
  25263. }
  25264. var dataType,
  25265. i = 0,
  25266. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  25267. if ( isFunction( func ) ) {
  25268. // For each dataType in the dataTypeExpression
  25269. while ( ( dataType = dataTypes[ i++ ] ) ) {
  25270. // Prepend if requested
  25271. if ( dataType[ 0 ] === "+" ) {
  25272. dataType = dataType.slice( 1 ) || "*";
  25273. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  25274. // Otherwise append
  25275. } else {
  25276. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  25277. }
  25278. }
  25279. }
  25280. };
  25281. }
  25282. // Base inspection function for prefilters and transports
  25283. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  25284. var inspected = {},
  25285. seekingTransport = ( structure === transports );
  25286. function inspect( dataType ) {
  25287. var selected;
  25288. inspected[ dataType ] = true;
  25289. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  25290. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  25291. if ( typeof dataTypeOrTransport === "string" &&
  25292. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  25293. options.dataTypes.unshift( dataTypeOrTransport );
  25294. inspect( dataTypeOrTransport );
  25295. return false;
  25296. } else if ( seekingTransport ) {
  25297. return !( selected = dataTypeOrTransport );
  25298. }
  25299. } );
  25300. return selected;
  25301. }
  25302. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  25303. }
  25304. // A special extend for ajax options
  25305. // that takes "flat" options (not to be deep extended)
  25306. // Fixes #9887
  25307. function ajaxExtend( target, src ) {
  25308. var key, deep,
  25309. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  25310. for ( key in src ) {
  25311. if ( src[ key ] !== undefined ) {
  25312. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  25313. }
  25314. }
  25315. if ( deep ) {
  25316. jQuery.extend( true, target, deep );
  25317. }
  25318. return target;
  25319. }
  25320. /* Handles responses to an ajax request:
  25321. * - finds the right dataType (mediates between content-type and expected dataType)
  25322. * - returns the corresponding response
  25323. */
  25324. function ajaxHandleResponses( s, jqXHR, responses ) {
  25325. var ct, type, finalDataType, firstDataType,
  25326. contents = s.contents,
  25327. dataTypes = s.dataTypes;
  25328. // Remove auto dataType and get content-type in the process
  25329. while ( dataTypes[ 0 ] === "*" ) {
  25330. dataTypes.shift();
  25331. if ( ct === undefined ) {
  25332. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  25333. }
  25334. }
  25335. // Check if we're dealing with a known content-type
  25336. if ( ct ) {
  25337. for ( type in contents ) {
  25338. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  25339. dataTypes.unshift( type );
  25340. break;
  25341. }
  25342. }
  25343. }
  25344. // Check to see if we have a response for the expected dataType
  25345. if ( dataTypes[ 0 ] in responses ) {
  25346. finalDataType = dataTypes[ 0 ];
  25347. } else {
  25348. // Try convertible dataTypes
  25349. for ( type in responses ) {
  25350. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  25351. finalDataType = type;
  25352. break;
  25353. }
  25354. if ( !firstDataType ) {
  25355. firstDataType = type;
  25356. }
  25357. }
  25358. // Or just use first one
  25359. finalDataType = finalDataType || firstDataType;
  25360. }
  25361. // If we found a dataType
  25362. // We add the dataType to the list if needed
  25363. // and return the corresponding response
  25364. if ( finalDataType ) {
  25365. if ( finalDataType !== dataTypes[ 0 ] ) {
  25366. dataTypes.unshift( finalDataType );
  25367. }
  25368. return responses[ finalDataType ];
  25369. }
  25370. }
  25371. /* Chain conversions given the request and the original response
  25372. * Also sets the responseXXX fields on the jqXHR instance
  25373. */
  25374. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  25375. var conv2, current, conv, tmp, prev,
  25376. converters = {},
  25377. // Work with a copy of dataTypes in case we need to modify it for conversion
  25378. dataTypes = s.dataTypes.slice();
  25379. // Create converters map with lowercased keys
  25380. if ( dataTypes[ 1 ] ) {
  25381. for ( conv in s.converters ) {
  25382. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  25383. }
  25384. }
  25385. current = dataTypes.shift();
  25386. // Convert to each sequential dataType
  25387. while ( current ) {
  25388. if ( s.responseFields[ current ] ) {
  25389. jqXHR[ s.responseFields[ current ] ] = response;
  25390. }
  25391. // Apply the dataFilter if provided
  25392. if ( !prev && isSuccess && s.dataFilter ) {
  25393. response = s.dataFilter( response, s.dataType );
  25394. }
  25395. prev = current;
  25396. current = dataTypes.shift();
  25397. if ( current ) {
  25398. // There's only work to do if current dataType is non-auto
  25399. if ( current === "*" ) {
  25400. current = prev;
  25401. // Convert response if prev dataType is non-auto and differs from current
  25402. } else if ( prev !== "*" && prev !== current ) {
  25403. // Seek a direct converter
  25404. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  25405. // If none found, seek a pair
  25406. if ( !conv ) {
  25407. for ( conv2 in converters ) {
  25408. // If conv2 outputs current
  25409. tmp = conv2.split( " " );
  25410. if ( tmp[ 1 ] === current ) {
  25411. // If prev can be converted to accepted input
  25412. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  25413. converters[ "* " + tmp[ 0 ] ];
  25414. if ( conv ) {
  25415. // Condense equivalence converters
  25416. if ( conv === true ) {
  25417. conv = converters[ conv2 ];
  25418. // Otherwise, insert the intermediate dataType
  25419. } else if ( converters[ conv2 ] !== true ) {
  25420. current = tmp[ 0 ];
  25421. dataTypes.unshift( tmp[ 1 ] );
  25422. }
  25423. break;
  25424. }
  25425. }
  25426. }
  25427. }
  25428. // Apply converter (if not an equivalence)
  25429. if ( conv !== true ) {
  25430. // Unless errors are allowed to bubble, catch and return them
  25431. if ( conv && s.throws ) {
  25432. response = conv( response );
  25433. } else {
  25434. try {
  25435. response = conv( response );
  25436. } catch ( e ) {
  25437. return {
  25438. state: "parsererror",
  25439. error: conv ? e : "No conversion from " + prev + " to " + current
  25440. };
  25441. }
  25442. }
  25443. }
  25444. }
  25445. }
  25446. }
  25447. return { state: "success", data: response };
  25448. }
  25449. jQuery.extend( {
  25450. // Counter for holding the number of active queries
  25451. active: 0,
  25452. // Last-Modified header cache for next request
  25453. lastModified: {},
  25454. etag: {},
  25455. ajaxSettings: {
  25456. url: location.href,
  25457. type: "GET",
  25458. isLocal: rlocalProtocol.test( location.protocol ),
  25459. global: true,
  25460. processData: true,
  25461. async: true,
  25462. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  25463. /*
  25464. timeout: 0,
  25465. data: null,
  25466. dataType: null,
  25467. username: null,
  25468. password: null,
  25469. cache: null,
  25470. throws: false,
  25471. traditional: false,
  25472. headers: {},
  25473. */
  25474. accepts: {
  25475. "*": allTypes,
  25476. text: "text/plain",
  25477. html: "text/html",
  25478. xml: "application/xml, text/xml",
  25479. json: "application/json, text/javascript"
  25480. },
  25481. contents: {
  25482. xml: /\bxml\b/,
  25483. html: /\bhtml/,
  25484. json: /\bjson\b/
  25485. },
  25486. responseFields: {
  25487. xml: "responseXML",
  25488. text: "responseText",
  25489. json: "responseJSON"
  25490. },
  25491. // Data converters
  25492. // Keys separate source (or catchall "*") and destination types with a single space
  25493. converters: {
  25494. // Convert anything to text
  25495. "* text": String,
  25496. // Text to html (true = no transformation)
  25497. "text html": true,
  25498. // Evaluate text as a json expression
  25499. "text json": JSON.parse,
  25500. // Parse text as xml
  25501. "text xml": jQuery.parseXML
  25502. },
  25503. // For options that shouldn't be deep extended:
  25504. // you can add your own custom options here if
  25505. // and when you create one that shouldn't be
  25506. // deep extended (see ajaxExtend)
  25507. flatOptions: {
  25508. url: true,
  25509. context: true
  25510. }
  25511. },
  25512. // Creates a full fledged settings object into target
  25513. // with both ajaxSettings and settings fields.
  25514. // If target is omitted, writes into ajaxSettings.
  25515. ajaxSetup: function( target, settings ) {
  25516. return settings ?
  25517. // Building a settings object
  25518. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  25519. // Extending ajaxSettings
  25520. ajaxExtend( jQuery.ajaxSettings, target );
  25521. },
  25522. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  25523. ajaxTransport: addToPrefiltersOrTransports( transports ),
  25524. // Main method
  25525. ajax: function( url, options ) {
  25526. // If url is an object, simulate pre-1.5 signature
  25527. if ( typeof url === "object" ) {
  25528. options = url;
  25529. url = undefined;
  25530. }
  25531. // Force options to be an object
  25532. options = options || {};
  25533. var transport,
  25534. // URL without anti-cache param
  25535. cacheURL,
  25536. // Response headers
  25537. responseHeadersString,
  25538. responseHeaders,
  25539. // timeout handle
  25540. timeoutTimer,
  25541. // Url cleanup var
  25542. urlAnchor,
  25543. // Request state (becomes false upon send and true upon completion)
  25544. completed,
  25545. // To know if global events are to be dispatched
  25546. fireGlobals,
  25547. // Loop variable
  25548. i,
  25549. // uncached part of the url
  25550. uncached,
  25551. // Create the final options object
  25552. s = jQuery.ajaxSetup( {}, options ),
  25553. // Callbacks context
  25554. callbackContext = s.context || s,
  25555. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  25556. globalEventContext = s.context &&
  25557. ( callbackContext.nodeType || callbackContext.jquery ) ?
  25558. jQuery( callbackContext ) :
  25559. jQuery.event,
  25560. // Deferreds
  25561. deferred = jQuery.Deferred(),
  25562. completeDeferred = jQuery.Callbacks( "once memory" ),
  25563. // Status-dependent callbacks
  25564. statusCode = s.statusCode || {},
  25565. // Headers (they are sent all at once)
  25566. requestHeaders = {},
  25567. requestHeadersNames = {},
  25568. // Default abort message
  25569. strAbort = "canceled",
  25570. // Fake xhr
  25571. jqXHR = {
  25572. readyState: 0,
  25573. // Builds headers hashtable if needed
  25574. getResponseHeader: function( key ) {
  25575. var match;
  25576. if ( completed ) {
  25577. if ( !responseHeaders ) {
  25578. responseHeaders = {};
  25579. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  25580. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  25581. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  25582. .concat( match[ 2 ] );
  25583. }
  25584. }
  25585. match = responseHeaders[ key.toLowerCase() + " " ];
  25586. }
  25587. return match == null ? null : match.join( ", " );
  25588. },
  25589. // Raw string
  25590. getAllResponseHeaders: function() {
  25591. return completed ? responseHeadersString : null;
  25592. },
  25593. // Caches the header
  25594. setRequestHeader: function( name, value ) {
  25595. if ( completed == null ) {
  25596. name = requestHeadersNames[ name.toLowerCase() ] =
  25597. requestHeadersNames[ name.toLowerCase() ] || name;
  25598. requestHeaders[ name ] = value;
  25599. }
  25600. return this;
  25601. },
  25602. // Overrides response content-type header
  25603. overrideMimeType: function( type ) {
  25604. if ( completed == null ) {
  25605. s.mimeType = type;
  25606. }
  25607. return this;
  25608. },
  25609. // Status-dependent callbacks
  25610. statusCode: function( map ) {
  25611. var code;
  25612. if ( map ) {
  25613. if ( completed ) {
  25614. // Execute the appropriate callbacks
  25615. jqXHR.always( map[ jqXHR.status ] );
  25616. } else {
  25617. // Lazy-add the new callbacks in a way that preserves old ones
  25618. for ( code in map ) {
  25619. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  25620. }
  25621. }
  25622. }
  25623. return this;
  25624. },
  25625. // Cancel the request
  25626. abort: function( statusText ) {
  25627. var finalText = statusText || strAbort;
  25628. if ( transport ) {
  25629. transport.abort( finalText );
  25630. }
  25631. done( 0, finalText );
  25632. return this;
  25633. }
  25634. };
  25635. // Attach deferreds
  25636. deferred.promise( jqXHR );
  25637. // Add protocol if not provided (prefilters might expect it)
  25638. // Handle falsy url in the settings object (#10093: consistency with old signature)
  25639. // We also use the url parameter if available
  25640. s.url = ( ( url || s.url || location.href ) + "" )
  25641. .replace( rprotocol, location.protocol + "//" );
  25642. // Alias method option to type as per ticket #12004
  25643. s.type = options.method || options.type || s.method || s.type;
  25644. // Extract dataTypes list
  25645. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  25646. // A cross-domain request is in order when the origin doesn't match the current origin.
  25647. if ( s.crossDomain == null ) {
  25648. urlAnchor = document.createElement( "a" );
  25649. // Support: IE <=8 - 11, Edge 12 - 15
  25650. // IE throws exception on accessing the href property if url is malformed,
  25651. // e.g. http://example.com:80x/
  25652. try {
  25653. urlAnchor.href = s.url;
  25654. // Support: IE <=8 - 11 only
  25655. // Anchor's host property isn't correctly set when s.url is relative
  25656. urlAnchor.href = urlAnchor.href;
  25657. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  25658. urlAnchor.protocol + "//" + urlAnchor.host;
  25659. } catch ( e ) {
  25660. // If there is an error parsing the URL, assume it is crossDomain,
  25661. // it can be rejected by the transport if it is invalid
  25662. s.crossDomain = true;
  25663. }
  25664. }
  25665. // Convert data if not already a string
  25666. if ( s.data && s.processData && typeof s.data !== "string" ) {
  25667. s.data = jQuery.param( s.data, s.traditional );
  25668. }
  25669. // Apply prefilters
  25670. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  25671. // If request was aborted inside a prefilter, stop there
  25672. if ( completed ) {
  25673. return jqXHR;
  25674. }
  25675. // We can fire global events as of now if asked to
  25676. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  25677. fireGlobals = jQuery.event && s.global;
  25678. // Watch for a new set of requests
  25679. if ( fireGlobals && jQuery.active++ === 0 ) {
  25680. jQuery.event.trigger( "ajaxStart" );
  25681. }
  25682. // Uppercase the type
  25683. s.type = s.type.toUpperCase();
  25684. // Determine if request has content
  25685. s.hasContent = !rnoContent.test( s.type );
  25686. // Save the URL in case we're toying with the If-Modified-Since
  25687. // and/or If-None-Match header later on
  25688. // Remove hash to simplify url manipulation
  25689. cacheURL = s.url.replace( rhash, "" );
  25690. // More options handling for requests with no content
  25691. if ( !s.hasContent ) {
  25692. // Remember the hash so we can put it back
  25693. uncached = s.url.slice( cacheURL.length );
  25694. // If data is available and should be processed, append data to url
  25695. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  25696. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  25697. // #9682: remove data so that it's not used in an eventual retry
  25698. delete s.data;
  25699. }
  25700. // Add or update anti-cache param if needed
  25701. if ( s.cache === false ) {
  25702. cacheURL = cacheURL.replace( rantiCache, "$1" );
  25703. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
  25704. uncached;
  25705. }
  25706. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  25707. s.url = cacheURL + uncached;
  25708. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  25709. } else if ( s.data && s.processData &&
  25710. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  25711. s.data = s.data.replace( r20, "+" );
  25712. }
  25713. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  25714. if ( s.ifModified ) {
  25715. if ( jQuery.lastModified[ cacheURL ] ) {
  25716. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  25717. }
  25718. if ( jQuery.etag[ cacheURL ] ) {
  25719. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  25720. }
  25721. }
  25722. // Set the correct header, if data is being sent
  25723. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  25724. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  25725. }
  25726. // Set the Accepts header for the server, depending on the dataType
  25727. jqXHR.setRequestHeader(
  25728. "Accept",
  25729. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  25730. s.accepts[ s.dataTypes[ 0 ] ] +
  25731. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  25732. s.accepts[ "*" ]
  25733. );
  25734. // Check for headers option
  25735. for ( i in s.headers ) {
  25736. jqXHR.setRequestHeader( i, s.headers[ i ] );
  25737. }
  25738. // Allow custom headers/mimetypes and early abort
  25739. if ( s.beforeSend &&
  25740. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  25741. // Abort if not done already and return
  25742. return jqXHR.abort();
  25743. }
  25744. // Aborting is no longer a cancellation
  25745. strAbort = "abort";
  25746. // Install callbacks on deferreds
  25747. completeDeferred.add( s.complete );
  25748. jqXHR.done( s.success );
  25749. jqXHR.fail( s.error );
  25750. // Get transport
  25751. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  25752. // If no transport, we auto-abort
  25753. if ( !transport ) {
  25754. done( -1, "No Transport" );
  25755. } else {
  25756. jqXHR.readyState = 1;
  25757. // Send global event
  25758. if ( fireGlobals ) {
  25759. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  25760. }
  25761. // If request was aborted inside ajaxSend, stop there
  25762. if ( completed ) {
  25763. return jqXHR;
  25764. }
  25765. // Timeout
  25766. if ( s.async && s.timeout > 0 ) {
  25767. timeoutTimer = window.setTimeout( function() {
  25768. jqXHR.abort( "timeout" );
  25769. }, s.timeout );
  25770. }
  25771. try {
  25772. completed = false;
  25773. transport.send( requestHeaders, done );
  25774. } catch ( e ) {
  25775. // Rethrow post-completion exceptions
  25776. if ( completed ) {
  25777. throw e;
  25778. }
  25779. // Propagate others as results
  25780. done( -1, e );
  25781. }
  25782. }
  25783. // Callback for when everything is done
  25784. function done( status, nativeStatusText, responses, headers ) {
  25785. var isSuccess, success, error, response, modified,
  25786. statusText = nativeStatusText;
  25787. // Ignore repeat invocations
  25788. if ( completed ) {
  25789. return;
  25790. }
  25791. completed = true;
  25792. // Clear timeout if it exists
  25793. if ( timeoutTimer ) {
  25794. window.clearTimeout( timeoutTimer );
  25795. }
  25796. // Dereference transport for early garbage collection
  25797. // (no matter how long the jqXHR object will be used)
  25798. transport = undefined;
  25799. // Cache response headers
  25800. responseHeadersString = headers || "";
  25801. // Set readyState
  25802. jqXHR.readyState = status > 0 ? 4 : 0;
  25803. // Determine if successful
  25804. isSuccess = status >= 200 && status < 300 || status === 304;
  25805. // Get response data
  25806. if ( responses ) {
  25807. response = ajaxHandleResponses( s, jqXHR, responses );
  25808. }
  25809. // Use a noop converter for missing script but not if jsonp
  25810. if ( !isSuccess &&
  25811. jQuery.inArray( "script", s.dataTypes ) > -1 &&
  25812. jQuery.inArray( "json", s.dataTypes ) < 0 ) {
  25813. s.converters[ "text script" ] = function() {};
  25814. }
  25815. // Convert no matter what (that way responseXXX fields are always set)
  25816. response = ajaxConvert( s, response, jqXHR, isSuccess );
  25817. // If successful, handle type chaining
  25818. if ( isSuccess ) {
  25819. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  25820. if ( s.ifModified ) {
  25821. modified = jqXHR.getResponseHeader( "Last-Modified" );
  25822. if ( modified ) {
  25823. jQuery.lastModified[ cacheURL ] = modified;
  25824. }
  25825. modified = jqXHR.getResponseHeader( "etag" );
  25826. if ( modified ) {
  25827. jQuery.etag[ cacheURL ] = modified;
  25828. }
  25829. }
  25830. // if no content
  25831. if ( status === 204 || s.type === "HEAD" ) {
  25832. statusText = "nocontent";
  25833. // if not modified
  25834. } else if ( status === 304 ) {
  25835. statusText = "notmodified";
  25836. // If we have data, let's convert it
  25837. } else {
  25838. statusText = response.state;
  25839. success = response.data;
  25840. error = response.error;
  25841. isSuccess = !error;
  25842. }
  25843. } else {
  25844. // Extract error from statusText and normalize for non-aborts
  25845. error = statusText;
  25846. if ( status || !statusText ) {
  25847. statusText = "error";
  25848. if ( status < 0 ) {
  25849. status = 0;
  25850. }
  25851. }
  25852. }
  25853. // Set data for the fake xhr object
  25854. jqXHR.status = status;
  25855. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  25856. // Success/Error
  25857. if ( isSuccess ) {
  25858. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  25859. } else {
  25860. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  25861. }
  25862. // Status-dependent callbacks
  25863. jqXHR.statusCode( statusCode );
  25864. statusCode = undefined;
  25865. if ( fireGlobals ) {
  25866. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  25867. [ jqXHR, s, isSuccess ? success : error ] );
  25868. }
  25869. // Complete
  25870. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  25871. if ( fireGlobals ) {
  25872. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  25873. // Handle the global AJAX counter
  25874. if ( !( --jQuery.active ) ) {
  25875. jQuery.event.trigger( "ajaxStop" );
  25876. }
  25877. }
  25878. }
  25879. return jqXHR;
  25880. },
  25881. getJSON: function( url, data, callback ) {
  25882. return jQuery.get( url, data, callback, "json" );
  25883. },
  25884. getScript: function( url, callback ) {
  25885. return jQuery.get( url, undefined, callback, "script" );
  25886. }
  25887. } );
  25888. jQuery.each( [ "get", "post" ], function( _i, method ) {
  25889. jQuery[ method ] = function( url, data, callback, type ) {
  25890. // Shift arguments if data argument was omitted
  25891. if ( isFunction( data ) ) {
  25892. type = type || callback;
  25893. callback = data;
  25894. data = undefined;
  25895. }
  25896. // The url can be an options object (which then must have .url)
  25897. return jQuery.ajax( jQuery.extend( {
  25898. url: url,
  25899. type: method,
  25900. dataType: type,
  25901. data: data,
  25902. success: callback
  25903. }, jQuery.isPlainObject( url ) && url ) );
  25904. };
  25905. } );
  25906. jQuery.ajaxPrefilter( function( s ) {
  25907. var i;
  25908. for ( i in s.headers ) {
  25909. if ( i.toLowerCase() === "content-type" ) {
  25910. s.contentType = s.headers[ i ] || "";
  25911. }
  25912. }
  25913. } );
  25914. jQuery._evalUrl = function( url, options, doc ) {
  25915. return jQuery.ajax( {
  25916. url: url,
  25917. // Make this explicit, since user can override this through ajaxSetup (#11264)
  25918. type: "GET",
  25919. dataType: "script",
  25920. cache: true,
  25921. async: false,
  25922. global: false,
  25923. // Only evaluate the response if it is successful (gh-4126)
  25924. // dataFilter is not invoked for failure responses, so using it instead
  25925. // of the default converter is kludgy but it works.
  25926. converters: {
  25927. "text script": function() {}
  25928. },
  25929. dataFilter: function( response ) {
  25930. jQuery.globalEval( response, options, doc );
  25931. }
  25932. } );
  25933. };
  25934. jQuery.fn.extend( {
  25935. wrapAll: function( html ) {
  25936. var wrap;
  25937. if ( this[ 0 ] ) {
  25938. if ( isFunction( html ) ) {
  25939. html = html.call( this[ 0 ] );
  25940. }
  25941. // The elements to wrap the target around
  25942. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  25943. if ( this[ 0 ].parentNode ) {
  25944. wrap.insertBefore( this[ 0 ] );
  25945. }
  25946. wrap.map( function() {
  25947. var elem = this;
  25948. while ( elem.firstElementChild ) {
  25949. elem = elem.firstElementChild;
  25950. }
  25951. return elem;
  25952. } ).append( this );
  25953. }
  25954. return this;
  25955. },
  25956. wrapInner: function( html ) {
  25957. if ( isFunction( html ) ) {
  25958. return this.each( function( i ) {
  25959. jQuery( this ).wrapInner( html.call( this, i ) );
  25960. } );
  25961. }
  25962. return this.each( function() {
  25963. var self = jQuery( this ),
  25964. contents = self.contents();
  25965. if ( contents.length ) {
  25966. contents.wrapAll( html );
  25967. } else {
  25968. self.append( html );
  25969. }
  25970. } );
  25971. },
  25972. wrap: function( html ) {
  25973. var htmlIsFunction = isFunction( html );
  25974. return this.each( function( i ) {
  25975. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  25976. } );
  25977. },
  25978. unwrap: function( selector ) {
  25979. this.parent( selector ).not( "body" ).each( function() {
  25980. jQuery( this ).replaceWith( this.childNodes );
  25981. } );
  25982. return this;
  25983. }
  25984. } );
  25985. jQuery.expr.pseudos.hidden = function( elem ) {
  25986. return !jQuery.expr.pseudos.visible( elem );
  25987. };
  25988. jQuery.expr.pseudos.visible = function( elem ) {
  25989. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  25990. };
  25991. jQuery.ajaxSettings.xhr = function() {
  25992. try {
  25993. return new window.XMLHttpRequest();
  25994. } catch ( e ) {}
  25995. };
  25996. var xhrSuccessStatus = {
  25997. // File protocol always yields status code 0, assume 200
  25998. 0: 200,
  25999. // Support: IE <=9 only
  26000. // #1450: sometimes IE returns 1223 when it should be 204
  26001. 1223: 204
  26002. },
  26003. xhrSupported = jQuery.ajaxSettings.xhr();
  26004. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  26005. support.ajax = xhrSupported = !!xhrSupported;
  26006. jQuery.ajaxTransport( function( options ) {
  26007. var callback, errorCallback;
  26008. // Cross domain only allowed if supported through XMLHttpRequest
  26009. if ( support.cors || xhrSupported && !options.crossDomain ) {
  26010. return {
  26011. send: function( headers, complete ) {
  26012. var i,
  26013. xhr = options.xhr();
  26014. xhr.open(
  26015. options.type,
  26016. options.url,
  26017. options.async,
  26018. options.username,
  26019. options.password
  26020. );
  26021. // Apply custom fields if provided
  26022. if ( options.xhrFields ) {
  26023. for ( i in options.xhrFields ) {
  26024. xhr[ i ] = options.xhrFields[ i ];
  26025. }
  26026. }
  26027. // Override mime type if needed
  26028. if ( options.mimeType && xhr.overrideMimeType ) {
  26029. xhr.overrideMimeType( options.mimeType );
  26030. }
  26031. // X-Requested-With header
  26032. // For cross-domain requests, seeing as conditions for a preflight are
  26033. // akin to a jigsaw puzzle, we simply never set it to be sure.
  26034. // (it can always be set on a per-request basis or even using ajaxSetup)
  26035. // For same-domain requests, won't change header if already provided.
  26036. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  26037. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  26038. }
  26039. // Set headers
  26040. for ( i in headers ) {
  26041. xhr.setRequestHeader( i, headers[ i ] );
  26042. }
  26043. // Callback
  26044. callback = function( type ) {
  26045. return function() {
  26046. if ( callback ) {
  26047. callback = errorCallback = xhr.onload =
  26048. xhr.onerror = xhr.onabort = xhr.ontimeout =
  26049. xhr.onreadystatechange = null;
  26050. if ( type === "abort" ) {
  26051. xhr.abort();
  26052. } else if ( type === "error" ) {
  26053. // Support: IE <=9 only
  26054. // On a manual native abort, IE9 throws
  26055. // errors on any property access that is not readyState
  26056. if ( typeof xhr.status !== "number" ) {
  26057. complete( 0, "error" );
  26058. } else {
  26059. complete(
  26060. // File: protocol always yields status 0; see #8605, #14207
  26061. xhr.status,
  26062. xhr.statusText
  26063. );
  26064. }
  26065. } else {
  26066. complete(
  26067. xhrSuccessStatus[ xhr.status ] || xhr.status,
  26068. xhr.statusText,
  26069. // Support: IE <=9 only
  26070. // IE9 has no XHR2 but throws on binary (trac-11426)
  26071. // For XHR2 non-text, let the caller handle it (gh-2498)
  26072. ( xhr.responseType || "text" ) !== "text" ||
  26073. typeof xhr.responseText !== "string" ?
  26074. { binary: xhr.response } :
  26075. { text: xhr.responseText },
  26076. xhr.getAllResponseHeaders()
  26077. );
  26078. }
  26079. }
  26080. };
  26081. };
  26082. // Listen to events
  26083. xhr.onload = callback();
  26084. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  26085. // Support: IE 9 only
  26086. // Use onreadystatechange to replace onabort
  26087. // to handle uncaught aborts
  26088. if ( xhr.onabort !== undefined ) {
  26089. xhr.onabort = errorCallback;
  26090. } else {
  26091. xhr.onreadystatechange = function() {
  26092. // Check readyState before timeout as it changes
  26093. if ( xhr.readyState === 4 ) {
  26094. // Allow onerror to be called first,
  26095. // but that will not handle a native abort
  26096. // Also, save errorCallback to a variable
  26097. // as xhr.onerror cannot be accessed
  26098. window.setTimeout( function() {
  26099. if ( callback ) {
  26100. errorCallback();
  26101. }
  26102. } );
  26103. }
  26104. };
  26105. }
  26106. // Create the abort callback
  26107. callback = callback( "abort" );
  26108. try {
  26109. // Do send the request (this may raise an exception)
  26110. xhr.send( options.hasContent && options.data || null );
  26111. } catch ( e ) {
  26112. // #14683: Only rethrow if this hasn't been notified as an error yet
  26113. if ( callback ) {
  26114. throw e;
  26115. }
  26116. }
  26117. },
  26118. abort: function() {
  26119. if ( callback ) {
  26120. callback();
  26121. }
  26122. }
  26123. };
  26124. }
  26125. } );
  26126. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  26127. jQuery.ajaxPrefilter( function( s ) {
  26128. if ( s.crossDomain ) {
  26129. s.contents.script = false;
  26130. }
  26131. } );
  26132. // Install script dataType
  26133. jQuery.ajaxSetup( {
  26134. accepts: {
  26135. script: "text/javascript, application/javascript, " +
  26136. "application/ecmascript, application/x-ecmascript"
  26137. },
  26138. contents: {
  26139. script: /\b(?:java|ecma)script\b/
  26140. },
  26141. converters: {
  26142. "text script": function( text ) {
  26143. jQuery.globalEval( text );
  26144. return text;
  26145. }
  26146. }
  26147. } );
  26148. // Handle cache's special case and crossDomain
  26149. jQuery.ajaxPrefilter( "script", function( s ) {
  26150. if ( s.cache === undefined ) {
  26151. s.cache = false;
  26152. }
  26153. if ( s.crossDomain ) {
  26154. s.type = "GET";
  26155. }
  26156. } );
  26157. // Bind script tag hack transport
  26158. jQuery.ajaxTransport( "script", function( s ) {
  26159. // This transport only deals with cross domain or forced-by-attrs requests
  26160. if ( s.crossDomain || s.scriptAttrs ) {
  26161. var script, callback;
  26162. return {
  26163. send: function( _, complete ) {
  26164. script = jQuery( "<script>" )
  26165. .attr( s.scriptAttrs || {} )
  26166. .prop( { charset: s.scriptCharset, src: s.url } )
  26167. .on( "load error", callback = function( evt ) {
  26168. script.remove();
  26169. callback = null;
  26170. if ( evt ) {
  26171. complete( evt.type === "error" ? 404 : 200, evt.type );
  26172. }
  26173. } );
  26174. // Use native DOM manipulation to avoid our domManip AJAX trickery
  26175. document.head.appendChild( script[ 0 ] );
  26176. },
  26177. abort: function() {
  26178. if ( callback ) {
  26179. callback();
  26180. }
  26181. }
  26182. };
  26183. }
  26184. } );
  26185. var oldCallbacks = [],
  26186. rjsonp = /(=)\?(?=&|$)|\?\?/;
  26187. // Default jsonp settings
  26188. jQuery.ajaxSetup( {
  26189. jsonp: "callback",
  26190. jsonpCallback: function() {
  26191. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
  26192. this[ callback ] = true;
  26193. return callback;
  26194. }
  26195. } );
  26196. // Detect, normalize options and install callbacks for jsonp requests
  26197. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  26198. var callbackName, overwritten, responseContainer,
  26199. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  26200. "url" :
  26201. typeof s.data === "string" &&
  26202. ( s.contentType || "" )
  26203. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  26204. rjsonp.test( s.data ) && "data"
  26205. );
  26206. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  26207. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  26208. // Get callback name, remembering preexisting value associated with it
  26209. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  26210. s.jsonpCallback() :
  26211. s.jsonpCallback;
  26212. // Insert callback into url or form data
  26213. if ( jsonProp ) {
  26214. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  26215. } else if ( s.jsonp !== false ) {
  26216. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  26217. }
  26218. // Use data converter to retrieve json after script execution
  26219. s.converters[ "script json" ] = function() {
  26220. if ( !responseContainer ) {
  26221. jQuery.error( callbackName + " was not called" );
  26222. }
  26223. return responseContainer[ 0 ];
  26224. };
  26225. // Force json dataType
  26226. s.dataTypes[ 0 ] = "json";
  26227. // Install callback
  26228. overwritten = window[ callbackName ];
  26229. window[ callbackName ] = function() {
  26230. responseContainer = arguments;
  26231. };
  26232. // Clean-up function (fires after converters)
  26233. jqXHR.always( function() {
  26234. // If previous value didn't exist - remove it
  26235. if ( overwritten === undefined ) {
  26236. jQuery( window ).removeProp( callbackName );
  26237. // Otherwise restore preexisting value
  26238. } else {
  26239. window[ callbackName ] = overwritten;
  26240. }
  26241. // Save back as free
  26242. if ( s[ callbackName ] ) {
  26243. // Make sure that re-using the options doesn't screw things around
  26244. s.jsonpCallback = originalSettings.jsonpCallback;
  26245. // Save the callback name for future use
  26246. oldCallbacks.push( callbackName );
  26247. }
  26248. // Call if it was a function and we have a response
  26249. if ( responseContainer && isFunction( overwritten ) ) {
  26250. overwritten( responseContainer[ 0 ] );
  26251. }
  26252. responseContainer = overwritten = undefined;
  26253. } );
  26254. // Delegate to script
  26255. return "script";
  26256. }
  26257. } );
  26258. // Support: Safari 8 only
  26259. // In Safari 8 documents created via document.implementation.createHTMLDocument
  26260. // collapse sibling forms: the second one becomes a child of the first one.
  26261. // Because of that, this security measure has to be disabled in Safari 8.
  26262. // https://bugs.webkit.org/show_bug.cgi?id=137337
  26263. support.createHTMLDocument = ( function() {
  26264. var body = document.implementation.createHTMLDocument( "" ).body;
  26265. body.innerHTML = "<form></form><form></form>";
  26266. return body.childNodes.length === 2;
  26267. } )();
  26268. // Argument "data" should be string of html
  26269. // context (optional): If specified, the fragment will be created in this context,
  26270. // defaults to document
  26271. // keepScripts (optional): If true, will include scripts passed in the html string
  26272. jQuery.parseHTML = function( data, context, keepScripts ) {
  26273. if ( typeof data !== "string" ) {
  26274. return [];
  26275. }
  26276. if ( typeof context === "boolean" ) {
  26277. keepScripts = context;
  26278. context = false;
  26279. }
  26280. var base, parsed, scripts;
  26281. if ( !context ) {
  26282. // Stop scripts or inline event handlers from being executed immediately
  26283. // by using document.implementation
  26284. if ( support.createHTMLDocument ) {
  26285. context = document.implementation.createHTMLDocument( "" );
  26286. // Set the base href for the created document
  26287. // so any parsed elements with URLs
  26288. // are based on the document's URL (gh-2965)
  26289. base = context.createElement( "base" );
  26290. base.href = document.location.href;
  26291. context.head.appendChild( base );
  26292. } else {
  26293. context = document;
  26294. }
  26295. }
  26296. parsed = rsingleTag.exec( data );
  26297. scripts = !keepScripts && [];
  26298. // Single tag
  26299. if ( parsed ) {
  26300. return [ context.createElement( parsed[ 1 ] ) ];
  26301. }
  26302. parsed = buildFragment( [ data ], context, scripts );
  26303. if ( scripts && scripts.length ) {
  26304. jQuery( scripts ).remove();
  26305. }
  26306. return jQuery.merge( [], parsed.childNodes );
  26307. };
  26308. /**
  26309. * Load a url into a page
  26310. */
  26311. jQuery.fn.load = function( url, params, callback ) {
  26312. var selector, type, response,
  26313. self = this,
  26314. off = url.indexOf( " " );
  26315. if ( off > -1 ) {
  26316. selector = stripAndCollapse( url.slice( off ) );
  26317. url = url.slice( 0, off );
  26318. }
  26319. // If it's a function
  26320. if ( isFunction( params ) ) {
  26321. // We assume that it's the callback
  26322. callback = params;
  26323. params = undefined;
  26324. // Otherwise, build a param string
  26325. } else if ( params && typeof params === "object" ) {
  26326. type = "POST";
  26327. }
  26328. // If we have elements to modify, make the request
  26329. if ( self.length > 0 ) {
  26330. jQuery.ajax( {
  26331. url: url,
  26332. // If "type" variable is undefined, then "GET" method will be used.
  26333. // Make value of this field explicit since
  26334. // user can override it through ajaxSetup method
  26335. type: type || "GET",
  26336. dataType: "html",
  26337. data: params
  26338. } ).done( function( responseText ) {
  26339. // Save response for use in complete callback
  26340. response = arguments;
  26341. self.html( selector ?
  26342. // If a selector was specified, locate the right elements in a dummy div
  26343. // Exclude scripts to avoid IE 'Permission Denied' errors
  26344. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  26345. // Otherwise use the full result
  26346. responseText );
  26347. // If the request succeeds, this function gets "data", "status", "jqXHR"
  26348. // but they are ignored because response was set above.
  26349. // If it fails, this function gets "jqXHR", "status", "error"
  26350. } ).always( callback && function( jqXHR, status ) {
  26351. self.each( function() {
  26352. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  26353. } );
  26354. } );
  26355. }
  26356. return this;
  26357. };
  26358. jQuery.expr.pseudos.animated = function( elem ) {
  26359. return jQuery.grep( jQuery.timers, function( fn ) {
  26360. return elem === fn.elem;
  26361. } ).length;
  26362. };
  26363. jQuery.offset = {
  26364. setOffset: function( elem, options, i ) {
  26365. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  26366. position = jQuery.css( elem, "position" ),
  26367. curElem = jQuery( elem ),
  26368. props = {};
  26369. // Set position first, in-case top/left are set even on static elem
  26370. if ( position === "static" ) {
  26371. elem.style.position = "relative";
  26372. }
  26373. curOffset = curElem.offset();
  26374. curCSSTop = jQuery.css( elem, "top" );
  26375. curCSSLeft = jQuery.css( elem, "left" );
  26376. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  26377. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  26378. // Need to be able to calculate position if either
  26379. // top or left is auto and position is either absolute or fixed
  26380. if ( calculatePosition ) {
  26381. curPosition = curElem.position();
  26382. curTop = curPosition.top;
  26383. curLeft = curPosition.left;
  26384. } else {
  26385. curTop = parseFloat( curCSSTop ) || 0;
  26386. curLeft = parseFloat( curCSSLeft ) || 0;
  26387. }
  26388. if ( isFunction( options ) ) {
  26389. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  26390. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  26391. }
  26392. if ( options.top != null ) {
  26393. props.top = ( options.top - curOffset.top ) + curTop;
  26394. }
  26395. if ( options.left != null ) {
  26396. props.left = ( options.left - curOffset.left ) + curLeft;
  26397. }
  26398. if ( "using" in options ) {
  26399. options.using.call( elem, props );
  26400. } else {
  26401. curElem.css( props );
  26402. }
  26403. }
  26404. };
  26405. jQuery.fn.extend( {
  26406. // offset() relates an element's border box to the document origin
  26407. offset: function( options ) {
  26408. // Preserve chaining for setter
  26409. if ( arguments.length ) {
  26410. return options === undefined ?
  26411. this :
  26412. this.each( function( i ) {
  26413. jQuery.offset.setOffset( this, options, i );
  26414. } );
  26415. }
  26416. var rect, win,
  26417. elem = this[ 0 ];
  26418. if ( !elem ) {
  26419. return;
  26420. }
  26421. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  26422. // Support: IE <=11 only
  26423. // Running getBoundingClientRect on a
  26424. // disconnected node in IE throws an error
  26425. if ( !elem.getClientRects().length ) {
  26426. return { top: 0, left: 0 };
  26427. }
  26428. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  26429. rect = elem.getBoundingClientRect();
  26430. win = elem.ownerDocument.defaultView;
  26431. return {
  26432. top: rect.top + win.pageYOffset,
  26433. left: rect.left + win.pageXOffset
  26434. };
  26435. },
  26436. // position() relates an element's margin box to its offset parent's padding box
  26437. // This corresponds to the behavior of CSS absolute positioning
  26438. position: function() {
  26439. if ( !this[ 0 ] ) {
  26440. return;
  26441. }
  26442. var offsetParent, offset, doc,
  26443. elem = this[ 0 ],
  26444. parentOffset = { top: 0, left: 0 };
  26445. // position:fixed elements are offset from the viewport, which itself always has zero offset
  26446. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  26447. // Assume position:fixed implies availability of getBoundingClientRect
  26448. offset = elem.getBoundingClientRect();
  26449. } else {
  26450. offset = this.offset();
  26451. // Account for the *real* offset parent, which can be the document or its root element
  26452. // when a statically positioned element is identified
  26453. doc = elem.ownerDocument;
  26454. offsetParent = elem.offsetParent || doc.documentElement;
  26455. while ( offsetParent &&
  26456. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  26457. jQuery.css( offsetParent, "position" ) === "static" ) {
  26458. offsetParent = offsetParent.parentNode;
  26459. }
  26460. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  26461. // Incorporate borders into its offset, since they are outside its content origin
  26462. parentOffset = jQuery( offsetParent ).offset();
  26463. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  26464. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  26465. }
  26466. }
  26467. // Subtract parent offsets and element margins
  26468. return {
  26469. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  26470. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  26471. };
  26472. },
  26473. // This method will return documentElement in the following cases:
  26474. // 1) For the element inside the iframe without offsetParent, this method will return
  26475. // documentElement of the parent window
  26476. // 2) For the hidden or detached element
  26477. // 3) For body or html element, i.e. in case of the html node - it will return itself
  26478. //
  26479. // but those exceptions were never presented as a real life use-cases
  26480. // and might be considered as more preferable results.
  26481. //
  26482. // This logic, however, is not guaranteed and can change at any point in the future
  26483. offsetParent: function() {
  26484. return this.map( function() {
  26485. var offsetParent = this.offsetParent;
  26486. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  26487. offsetParent = offsetParent.offsetParent;
  26488. }
  26489. return offsetParent || documentElement;
  26490. } );
  26491. }
  26492. } );
  26493. // Create scrollLeft and scrollTop methods
  26494. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  26495. var top = "pageYOffset" === prop;
  26496. jQuery.fn[ method ] = function( val ) {
  26497. return access( this, function( elem, method, val ) {
  26498. // Coalesce documents and windows
  26499. var win;
  26500. if ( isWindow( elem ) ) {
  26501. win = elem;
  26502. } else if ( elem.nodeType === 9 ) {
  26503. win = elem.defaultView;
  26504. }
  26505. if ( val === undefined ) {
  26506. return win ? win[ prop ] : elem[ method ];
  26507. }
  26508. if ( win ) {
  26509. win.scrollTo(
  26510. !top ? val : win.pageXOffset,
  26511. top ? val : win.pageYOffset
  26512. );
  26513. } else {
  26514. elem[ method ] = val;
  26515. }
  26516. }, method, val, arguments.length );
  26517. };
  26518. } );
  26519. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  26520. // Add the top/left cssHooks using jQuery.fn.position
  26521. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  26522. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  26523. // getComputedStyle returns percent when specified for top/left/bottom/right;
  26524. // rather than make the css module depend on the offset module, just check for it here
  26525. jQuery.each( [ "top", "left" ], function( _i, prop ) {
  26526. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  26527. function( elem, computed ) {
  26528. if ( computed ) {
  26529. computed = curCSS( elem, prop );
  26530. // If curCSS returns percentage, fallback to offset
  26531. return rnumnonpx.test( computed ) ?
  26532. jQuery( elem ).position()[ prop ] + "px" :
  26533. computed;
  26534. }
  26535. }
  26536. );
  26537. } );
  26538. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  26539. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  26540. jQuery.each( {
  26541. padding: "inner" + name,
  26542. content: type,
  26543. "": "outer" + name
  26544. }, function( defaultExtra, funcName ) {
  26545. // Margin is only for outerHeight, outerWidth
  26546. jQuery.fn[ funcName ] = function( margin, value ) {
  26547. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  26548. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  26549. return access( this, function( elem, type, value ) {
  26550. var doc;
  26551. if ( isWindow( elem ) ) {
  26552. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  26553. return funcName.indexOf( "outer" ) === 0 ?
  26554. elem[ "inner" + name ] :
  26555. elem.document.documentElement[ "client" + name ];
  26556. }
  26557. // Get document width or height
  26558. if ( elem.nodeType === 9 ) {
  26559. doc = elem.documentElement;
  26560. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  26561. // whichever is greatest
  26562. return Math.max(
  26563. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  26564. elem.body[ "offset" + name ], doc[ "offset" + name ],
  26565. doc[ "client" + name ]
  26566. );
  26567. }
  26568. return value === undefined ?
  26569. // Get width or height on the element, requesting but not forcing parseFloat
  26570. jQuery.css( elem, type, extra ) :
  26571. // Set width or height on the element
  26572. jQuery.style( elem, type, value, extra );
  26573. }, type, chainable ? margin : undefined, chainable );
  26574. };
  26575. } );
  26576. } );
  26577. jQuery.each( [
  26578. "ajaxStart",
  26579. "ajaxStop",
  26580. "ajaxComplete",
  26581. "ajaxError",
  26582. "ajaxSuccess",
  26583. "ajaxSend"
  26584. ], function( _i, type ) {
  26585. jQuery.fn[ type ] = function( fn ) {
  26586. return this.on( type, fn );
  26587. };
  26588. } );
  26589. jQuery.fn.extend( {
  26590. bind: function( types, data, fn ) {
  26591. return this.on( types, null, data, fn );
  26592. },
  26593. unbind: function( types, fn ) {
  26594. return this.off( types, null, fn );
  26595. },
  26596. delegate: function( selector, types, data, fn ) {
  26597. return this.on( types, selector, data, fn );
  26598. },
  26599. undelegate: function( selector, types, fn ) {
  26600. // ( namespace ) or ( selector, types [, fn] )
  26601. return arguments.length === 1 ?
  26602. this.off( selector, "**" ) :
  26603. this.off( types, selector || "**", fn );
  26604. },
  26605. hover: function( fnOver, fnOut ) {
  26606. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  26607. }
  26608. } );
  26609. jQuery.each(
  26610. ( "blur focus focusin focusout resize scroll click dblclick " +
  26611. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  26612. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  26613. function( _i, name ) {
  26614. // Handle event binding
  26615. jQuery.fn[ name ] = function( data, fn ) {
  26616. return arguments.length > 0 ?
  26617. this.on( name, null, data, fn ) :
  26618. this.trigger( name );
  26619. };
  26620. }
  26621. );
  26622. // Support: Android <=4.0 only
  26623. // Make sure we trim BOM and NBSP
  26624. var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  26625. // Bind a function to a context, optionally partially applying any
  26626. // arguments.
  26627. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  26628. // However, it is not slated for removal any time soon
  26629. jQuery.proxy = function( fn, context ) {
  26630. var tmp, args, proxy;
  26631. if ( typeof context === "string" ) {
  26632. tmp = fn[ context ];
  26633. context = fn;
  26634. fn = tmp;
  26635. }
  26636. // Quick check to determine if target is callable, in the spec
  26637. // this throws a TypeError, but we will just return undefined.
  26638. if ( !isFunction( fn ) ) {
  26639. return undefined;
  26640. }
  26641. // Simulated bind
  26642. args = slice.call( arguments, 2 );
  26643. proxy = function() {
  26644. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  26645. };
  26646. // Set the guid of unique handler to the same of original handler, so it can be removed
  26647. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  26648. return proxy;
  26649. };
  26650. jQuery.holdReady = function( hold ) {
  26651. if ( hold ) {
  26652. jQuery.readyWait++;
  26653. } else {
  26654. jQuery.ready( true );
  26655. }
  26656. };
  26657. jQuery.isArray = Array.isArray;
  26658. jQuery.parseJSON = JSON.parse;
  26659. jQuery.nodeName = nodeName;
  26660. jQuery.isFunction = isFunction;
  26661. jQuery.isWindow = isWindow;
  26662. jQuery.camelCase = camelCase;
  26663. jQuery.type = toType;
  26664. jQuery.now = Date.now;
  26665. jQuery.isNumeric = function( obj ) {
  26666. // As of jQuery 3.0, isNumeric is limited to
  26667. // strings and numbers (primitives or objects)
  26668. // that can be coerced to finite numbers (gh-2662)
  26669. var type = jQuery.type( obj );
  26670. return ( type === "number" || type === "string" ) &&
  26671. // parseFloat NaNs numeric-cast false positives ("")
  26672. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  26673. // subtraction forces infinities to NaN
  26674. !isNaN( obj - parseFloat( obj ) );
  26675. };
  26676. jQuery.trim = function( text ) {
  26677. return text == null ?
  26678. "" :
  26679. ( text + "" ).replace( rtrim, "" );
  26680. };
  26681. var
  26682. // Map over jQuery in case of overwrite
  26683. _jQuery = window.jQuery,
  26684. // Map over the $ in case of overwrite
  26685. _$ = window.$;
  26686. jQuery.noConflict = function( deep ) {
  26687. if ( window.$ === jQuery ) {
  26688. window.$ = _$;
  26689. }
  26690. if ( deep && window.jQuery === jQuery ) {
  26691. window.jQuery = _jQuery;
  26692. }
  26693. return jQuery;
  26694. };
  26695. // Expose jQuery and $ identifiers, even in AMD
  26696. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  26697. // and CommonJS for browser emulators (#13566)
  26698. if ( typeof noGlobal === "undefined" ) {
  26699. window.jQuery = window.$ = jQuery;
  26700. }
  26701. return jQuery;
  26702. } );
  26703. });
  26704. var dist = createCommonjsModule(function (module, exports) {
  26705. (function (global, factory) {
  26706. module.exports = factory() ;
  26707. }(commonjsGlobal, (function () {
  26708. function createCommonjsModule(fn, module) {
  26709. return module = { exports: {} }, fn(module, module.exports), module.exports;
  26710. }
  26711. var _global = createCommonjsModule(function (module) {
  26712. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  26713. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  26714. ? window : typeof self != 'undefined' && self.Math == Math ? self
  26715. // eslint-disable-next-line no-new-func
  26716. : Function('return this')();
  26717. if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
  26718. });
  26719. var _core = createCommonjsModule(function (module) {
  26720. var core = module.exports = { version: '2.6.5' };
  26721. if (typeof __e == 'number') { __e = core; } // eslint-disable-line no-undef
  26722. });
  26723. var _core_1 = _core.version;
  26724. var _isObject = function (it) {
  26725. return typeof it === 'object' ? it !== null : typeof it === 'function';
  26726. };
  26727. var _anObject = function (it) {
  26728. if (!_isObject(it)) { throw TypeError(it + ' is not an object!'); }
  26729. return it;
  26730. };
  26731. var _fails = function (exec) {
  26732. try {
  26733. return !!exec();
  26734. } catch (e) {
  26735. return true;
  26736. }
  26737. };
  26738. // Thank's IE8 for his funny defineProperty
  26739. var _descriptors = !_fails(function () {
  26740. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  26741. });
  26742. var document = _global.document;
  26743. // typeof document.createElement is 'object' in old IE
  26744. var is = _isObject(document) && _isObject(document.createElement);
  26745. var _domCreate = function (it) {
  26746. return is ? document.createElement(it) : {};
  26747. };
  26748. var _ie8DomDefine = !_descriptors && !_fails(function () {
  26749. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  26750. });
  26751. // 7.1.1 ToPrimitive(input [, PreferredType])
  26752. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  26753. // and the second argument - flag - preferred type is a string
  26754. var _toPrimitive = function (it, S) {
  26755. if (!_isObject(it)) { return it; }
  26756. var fn, val;
  26757. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  26758. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  26759. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
  26760. throw TypeError("Can't convert object to primitive value");
  26761. };
  26762. var dP = Object.defineProperty;
  26763. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  26764. _anObject(O);
  26765. P = _toPrimitive(P, true);
  26766. _anObject(Attributes);
  26767. if (_ie8DomDefine) { try {
  26768. return dP(O, P, Attributes);
  26769. } catch (e) { /* empty */ } }
  26770. if ('get' in Attributes || 'set' in Attributes) { throw TypeError('Accessors not supported!'); }
  26771. if ('value' in Attributes) { O[P] = Attributes.value; }
  26772. return O;
  26773. };
  26774. var _objectDp = {
  26775. f: f
  26776. };
  26777. var _propertyDesc = function (bitmap, value) {
  26778. return {
  26779. enumerable: !(bitmap & 1),
  26780. configurable: !(bitmap & 2),
  26781. writable: !(bitmap & 4),
  26782. value: value
  26783. };
  26784. };
  26785. var _hide = _descriptors ? function (object, key, value) {
  26786. return _objectDp.f(object, key, _propertyDesc(1, value));
  26787. } : function (object, key, value) {
  26788. object[key] = value;
  26789. return object;
  26790. };
  26791. var hasOwnProperty = {}.hasOwnProperty;
  26792. var _has = function (it, key) {
  26793. return hasOwnProperty.call(it, key);
  26794. };
  26795. var id = 0;
  26796. var px = Math.random();
  26797. var _uid = function (key) {
  26798. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  26799. };
  26800. var _shared = createCommonjsModule(function (module) {
  26801. var SHARED = '__core-js_shared__';
  26802. var store = _global[SHARED] || (_global[SHARED] = {});
  26803. (module.exports = function (key, value) {
  26804. return store[key] || (store[key] = value !== undefined ? value : {});
  26805. })('versions', []).push({
  26806. version: _core.version,
  26807. mode: 'global',
  26808. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  26809. });
  26810. });
  26811. var _functionToString = _shared('native-function-to-string', Function.toString);
  26812. var _redefine = createCommonjsModule(function (module) {
  26813. var SRC = _uid('src');
  26814. var TO_STRING = 'toString';
  26815. var TPL = ('' + _functionToString).split(TO_STRING);
  26816. _core.inspectSource = function (it) {
  26817. return _functionToString.call(it);
  26818. };
  26819. (module.exports = function (O, key, val, safe) {
  26820. var isFunction = typeof val == 'function';
  26821. if (isFunction) { _has(val, 'name') || _hide(val, 'name', key); }
  26822. if (O[key] === val) { return; }
  26823. if (isFunction) { _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); }
  26824. if (O === _global) {
  26825. O[key] = val;
  26826. } else if (!safe) {
  26827. delete O[key];
  26828. _hide(O, key, val);
  26829. } else if (O[key]) {
  26830. O[key] = val;
  26831. } else {
  26832. _hide(O, key, val);
  26833. }
  26834. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  26835. })(Function.prototype, TO_STRING, function toString() {
  26836. return typeof this == 'function' && this[SRC] || _functionToString.call(this);
  26837. });
  26838. });
  26839. var _aFunction = function (it) {
  26840. if (typeof it != 'function') { throw TypeError(it + ' is not a function!'); }
  26841. return it;
  26842. };
  26843. // optional / simple context binding
  26844. var _ctx = function (fn, that, length) {
  26845. _aFunction(fn);
  26846. if (that === undefined) { return fn; }
  26847. switch (length) {
  26848. case 1: return function (a) {
  26849. return fn.call(that, a);
  26850. };
  26851. case 2: return function (a, b) {
  26852. return fn.call(that, a, b);
  26853. };
  26854. case 3: return function (a, b, c) {
  26855. return fn.call(that, a, b, c);
  26856. };
  26857. }
  26858. return function (/* ...args */) {
  26859. return fn.apply(that, arguments);
  26860. };
  26861. };
  26862. var PROTOTYPE = 'prototype';
  26863. var $export = function (type, name, source) {
  26864. var IS_FORCED = type & $export.F;
  26865. var IS_GLOBAL = type & $export.G;
  26866. var IS_STATIC = type & $export.S;
  26867. var IS_PROTO = type & $export.P;
  26868. var IS_BIND = type & $export.B;
  26869. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
  26870. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  26871. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  26872. var key, own, out, exp;
  26873. if (IS_GLOBAL) { source = name; }
  26874. for (key in source) {
  26875. // contains in native
  26876. own = !IS_FORCED && target && target[key] !== undefined;
  26877. // export native or passed
  26878. out = (own ? target : source)[key];
  26879. // bind timers to global for call from export context
  26880. exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  26881. // extend global
  26882. if (target) { _redefine(target, key, out, type & $export.U); }
  26883. // export
  26884. if (exports[key] != out) { _hide(exports, key, exp); }
  26885. if (IS_PROTO && expProto[key] != out) { expProto[key] = out; }
  26886. }
  26887. };
  26888. _global.core = _core;
  26889. // type bitmap
  26890. $export.F = 1; // forced
  26891. $export.G = 2; // global
  26892. $export.S = 4; // static
  26893. $export.P = 8; // proto
  26894. $export.B = 16; // bind
  26895. $export.W = 32; // wrap
  26896. $export.U = 64; // safe
  26897. $export.R = 128; // real proto method for `library`
  26898. var _export = $export;
  26899. // 7.1.4 ToInteger
  26900. var ceil = Math.ceil;
  26901. var floor = Math.floor;
  26902. var _toInteger = function (it) {
  26903. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  26904. };
  26905. // 7.2.1 RequireObjectCoercible(argument)
  26906. var _defined = function (it) {
  26907. if (it == undefined) { throw TypeError("Can't call method on " + it); }
  26908. return it;
  26909. };
  26910. // true -> String#at
  26911. // false -> String#codePointAt
  26912. var _stringAt = function (TO_STRING) {
  26913. return function (that, pos) {
  26914. var s = String(_defined(that));
  26915. var i = _toInteger(pos);
  26916. var l = s.length;
  26917. var a, b;
  26918. if (i < 0 || i >= l) { return TO_STRING ? '' : undefined; }
  26919. a = s.charCodeAt(i);
  26920. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  26921. ? TO_STRING ? s.charAt(i) : a
  26922. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  26923. };
  26924. };
  26925. var $at = _stringAt(false);
  26926. _export(_export.P, 'String', {
  26927. // 21.1.3.3 String.prototype.codePointAt(pos)
  26928. codePointAt: function codePointAt(pos) {
  26929. return $at(this, pos);
  26930. }
  26931. });
  26932. var codePointAt = _core.String.codePointAt;
  26933. var max = Math.max;
  26934. var min = Math.min;
  26935. var _toAbsoluteIndex = function (index, length) {
  26936. index = _toInteger(index);
  26937. return index < 0 ? max(index + length, 0) : min(index, length);
  26938. };
  26939. var fromCharCode = String.fromCharCode;
  26940. var $fromCodePoint = String.fromCodePoint;
  26941. // length should be 1, old FF problem
  26942. _export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  26943. // 21.1.2.2 String.fromCodePoint(...codePoints)
  26944. fromCodePoint: function fromCodePoint(x) {
  26945. var arguments$1 = arguments;
  26946. // eslint-disable-line no-unused-vars
  26947. var res = [];
  26948. var aLen = arguments.length;
  26949. var i = 0;
  26950. var code;
  26951. while (aLen > i) {
  26952. code = +arguments$1[i++];
  26953. if (_toAbsoluteIndex(code, 0x10ffff) !== code) { throw RangeError(code + ' is not a valid code point'); }
  26954. res.push(code < 0x10000
  26955. ? fromCharCode(code)
  26956. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  26957. );
  26958. } return res.join('');
  26959. }
  26960. });
  26961. var fromCodePoint = _core.String.fromCodePoint;
  26962. // This is a generated file. Do not edit.
  26963. var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  26964. var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
  26965. var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
  26966. var unicode = {
  26967. Space_Separator: Space_Separator,
  26968. ID_Start: ID_Start,
  26969. ID_Continue: ID_Continue
  26970. };
  26971. var util = {
  26972. isSpaceSeparator: function isSpaceSeparator (c) {
  26973. return typeof c === 'string' && unicode.Space_Separator.test(c)
  26974. },
  26975. isIdStartChar: function isIdStartChar (c) {
  26976. return typeof c === 'string' && (
  26977. (c >= 'a' && c <= 'z') ||
  26978. (c >= 'A' && c <= 'Z') ||
  26979. (c === '$') || (c === '_') ||
  26980. unicode.ID_Start.test(c)
  26981. )
  26982. },
  26983. isIdContinueChar: function isIdContinueChar (c) {
  26984. return typeof c === 'string' && (
  26985. (c >= 'a' && c <= 'z') ||
  26986. (c >= 'A' && c <= 'Z') ||
  26987. (c >= '0' && c <= '9') ||
  26988. (c === '$') || (c === '_') ||
  26989. (c === '\u200C') || (c === '\u200D') ||
  26990. unicode.ID_Continue.test(c)
  26991. )
  26992. },
  26993. isDigit: function isDigit (c) {
  26994. return typeof c === 'string' && /[0-9]/.test(c)
  26995. },
  26996. isHexDigit: function isHexDigit (c) {
  26997. return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
  26998. },
  26999. };
  27000. var source;
  27001. var parseState;
  27002. var stack;
  27003. var pos;
  27004. var line;
  27005. var column;
  27006. var token;
  27007. var key;
  27008. var root;
  27009. var parse = function parse (text, reviver) {
  27010. source = String(text);
  27011. parseState = 'start';
  27012. stack = [];
  27013. pos = 0;
  27014. line = 1;
  27015. column = 0;
  27016. token = undefined;
  27017. key = undefined;
  27018. root = undefined;
  27019. do {
  27020. token = lex();
  27021. // This code is unreachable.
  27022. // if (!parseStates[parseState]) {
  27023. // throw invalidParseState()
  27024. // }
  27025. parseStates[parseState]();
  27026. } while (token.type !== 'eof')
  27027. if (typeof reviver === 'function') {
  27028. return internalize({'': root}, '', reviver)
  27029. }
  27030. return root
  27031. };
  27032. function internalize (holder, name, reviver) {
  27033. var value = holder[name];
  27034. if (value != null && typeof value === 'object') {
  27035. for (var key in value) {
  27036. var replacement = internalize(value, key, reviver);
  27037. if (replacement === undefined) {
  27038. delete value[key];
  27039. } else {
  27040. value[key] = replacement;
  27041. }
  27042. }
  27043. }
  27044. return reviver.call(holder, name, value)
  27045. }
  27046. var lexState;
  27047. var buffer;
  27048. var doubleQuote;
  27049. var sign;
  27050. var c;
  27051. function lex () {
  27052. lexState = 'default';
  27053. buffer = '';
  27054. doubleQuote = false;
  27055. sign = 1;
  27056. for (;;) {
  27057. c = peek();
  27058. // This code is unreachable.
  27059. // if (!lexStates[lexState]) {
  27060. // throw invalidLexState(lexState)
  27061. // }
  27062. var token = lexStates[lexState]();
  27063. if (token) {
  27064. return token
  27065. }
  27066. }
  27067. }
  27068. function peek () {
  27069. if (source[pos]) {
  27070. return String.fromCodePoint(source.codePointAt(pos))
  27071. }
  27072. }
  27073. function read () {
  27074. var c = peek();
  27075. if (c === '\n') {
  27076. line++;
  27077. column = 0;
  27078. } else if (c) {
  27079. column += c.length;
  27080. } else {
  27081. column++;
  27082. }
  27083. if (c) {
  27084. pos += c.length;
  27085. }
  27086. return c
  27087. }
  27088. var lexStates = {
  27089. default: function default$1 () {
  27090. switch (c) {
  27091. case '\t':
  27092. case '\v':
  27093. case '\f':
  27094. case ' ':
  27095. case '\u00A0':
  27096. case '\uFEFF':
  27097. case '\n':
  27098. case '\r':
  27099. case '\u2028':
  27100. case '\u2029':
  27101. read();
  27102. return
  27103. case '/':
  27104. read();
  27105. lexState = 'comment';
  27106. return
  27107. case undefined:
  27108. read();
  27109. return newToken('eof')
  27110. }
  27111. if (util.isSpaceSeparator(c)) {
  27112. read();
  27113. return
  27114. }
  27115. // This code is unreachable.
  27116. // if (!lexStates[parseState]) {
  27117. // throw invalidLexState(parseState)
  27118. // }
  27119. return lexStates[parseState]()
  27120. },
  27121. comment: function comment () {
  27122. switch (c) {
  27123. case '*':
  27124. read();
  27125. lexState = 'multiLineComment';
  27126. return
  27127. case '/':
  27128. read();
  27129. lexState = 'singleLineComment';
  27130. return
  27131. }
  27132. throw invalidChar(read())
  27133. },
  27134. multiLineComment: function multiLineComment () {
  27135. switch (c) {
  27136. case '*':
  27137. read();
  27138. lexState = 'multiLineCommentAsterisk';
  27139. return
  27140. case undefined:
  27141. throw invalidChar(read())
  27142. }
  27143. read();
  27144. },
  27145. multiLineCommentAsterisk: function multiLineCommentAsterisk () {
  27146. switch (c) {
  27147. case '*':
  27148. read();
  27149. return
  27150. case '/':
  27151. read();
  27152. lexState = 'default';
  27153. return
  27154. case undefined:
  27155. throw invalidChar(read())
  27156. }
  27157. read();
  27158. lexState = 'multiLineComment';
  27159. },
  27160. singleLineComment: function singleLineComment () {
  27161. switch (c) {
  27162. case '\n':
  27163. case '\r':
  27164. case '\u2028':
  27165. case '\u2029':
  27166. read();
  27167. lexState = 'default';
  27168. return
  27169. case undefined:
  27170. read();
  27171. return newToken('eof')
  27172. }
  27173. read();
  27174. },
  27175. value: function value () {
  27176. switch (c) {
  27177. case '{':
  27178. case '[':
  27179. return newToken('punctuator', read())
  27180. case 'n':
  27181. read();
  27182. literal('ull');
  27183. return newToken('null', null)
  27184. case 't':
  27185. read();
  27186. literal('rue');
  27187. return newToken('boolean', true)
  27188. case 'f':
  27189. read();
  27190. literal('alse');
  27191. return newToken('boolean', false)
  27192. case '-':
  27193. case '+':
  27194. if (read() === '-') {
  27195. sign = -1;
  27196. }
  27197. lexState = 'sign';
  27198. return
  27199. case '.':
  27200. buffer = read();
  27201. lexState = 'decimalPointLeading';
  27202. return
  27203. case '0':
  27204. buffer = read();
  27205. lexState = 'zero';
  27206. return
  27207. case '1':
  27208. case '2':
  27209. case '3':
  27210. case '4':
  27211. case '5':
  27212. case '6':
  27213. case '7':
  27214. case '8':
  27215. case '9':
  27216. buffer = read();
  27217. lexState = 'decimalInteger';
  27218. return
  27219. case 'I':
  27220. read();
  27221. literal('nfinity');
  27222. return newToken('numeric', Infinity)
  27223. case 'N':
  27224. read();
  27225. literal('aN');
  27226. return newToken('numeric', NaN)
  27227. case '"':
  27228. case "'":
  27229. doubleQuote = (read() === '"');
  27230. buffer = '';
  27231. lexState = 'string';
  27232. return
  27233. }
  27234. throw invalidChar(read())
  27235. },
  27236. identifierNameStartEscape: function identifierNameStartEscape () {
  27237. if (c !== 'u') {
  27238. throw invalidChar(read())
  27239. }
  27240. read();
  27241. var u = unicodeEscape();
  27242. switch (u) {
  27243. case '$':
  27244. case '_':
  27245. break
  27246. default:
  27247. if (!util.isIdStartChar(u)) {
  27248. throw invalidIdentifier()
  27249. }
  27250. break
  27251. }
  27252. buffer += u;
  27253. lexState = 'identifierName';
  27254. },
  27255. identifierName: function identifierName () {
  27256. switch (c) {
  27257. case '$':
  27258. case '_':
  27259. case '\u200C':
  27260. case '\u200D':
  27261. buffer += read();
  27262. return
  27263. case '\\':
  27264. read();
  27265. lexState = 'identifierNameEscape';
  27266. return
  27267. }
  27268. if (util.isIdContinueChar(c)) {
  27269. buffer += read();
  27270. return
  27271. }
  27272. return newToken('identifier', buffer)
  27273. },
  27274. identifierNameEscape: function identifierNameEscape () {
  27275. if (c !== 'u') {
  27276. throw invalidChar(read())
  27277. }
  27278. read();
  27279. var u = unicodeEscape();
  27280. switch (u) {
  27281. case '$':
  27282. case '_':
  27283. case '\u200C':
  27284. case '\u200D':
  27285. break
  27286. default:
  27287. if (!util.isIdContinueChar(u)) {
  27288. throw invalidIdentifier()
  27289. }
  27290. break
  27291. }
  27292. buffer += u;
  27293. lexState = 'identifierName';
  27294. },
  27295. sign: function sign$1 () {
  27296. switch (c) {
  27297. case '.':
  27298. buffer = read();
  27299. lexState = 'decimalPointLeading';
  27300. return
  27301. case '0':
  27302. buffer = read();
  27303. lexState = 'zero';
  27304. return
  27305. case '1':
  27306. case '2':
  27307. case '3':
  27308. case '4':
  27309. case '5':
  27310. case '6':
  27311. case '7':
  27312. case '8':
  27313. case '9':
  27314. buffer = read();
  27315. lexState = 'decimalInteger';
  27316. return
  27317. case 'I':
  27318. read();
  27319. literal('nfinity');
  27320. return newToken('numeric', sign * Infinity)
  27321. case 'N':
  27322. read();
  27323. literal('aN');
  27324. return newToken('numeric', NaN)
  27325. }
  27326. throw invalidChar(read())
  27327. },
  27328. zero: function zero () {
  27329. switch (c) {
  27330. case '.':
  27331. buffer += read();
  27332. lexState = 'decimalPoint';
  27333. return
  27334. case 'e':
  27335. case 'E':
  27336. buffer += read();
  27337. lexState = 'decimalExponent';
  27338. return
  27339. case 'x':
  27340. case 'X':
  27341. buffer += read();
  27342. lexState = 'hexadecimal';
  27343. return
  27344. }
  27345. return newToken('numeric', sign * 0)
  27346. },
  27347. decimalInteger: function decimalInteger () {
  27348. switch (c) {
  27349. case '.':
  27350. buffer += read();
  27351. lexState = 'decimalPoint';
  27352. return
  27353. case 'e':
  27354. case 'E':
  27355. buffer += read();
  27356. lexState = 'decimalExponent';
  27357. return
  27358. }
  27359. if (util.isDigit(c)) {
  27360. buffer += read();
  27361. return
  27362. }
  27363. return newToken('numeric', sign * Number(buffer))
  27364. },
  27365. decimalPointLeading: function decimalPointLeading () {
  27366. if (util.isDigit(c)) {
  27367. buffer += read();
  27368. lexState = 'decimalFraction';
  27369. return
  27370. }
  27371. throw invalidChar(read())
  27372. },
  27373. decimalPoint: function decimalPoint () {
  27374. switch (c) {
  27375. case 'e':
  27376. case 'E':
  27377. buffer += read();
  27378. lexState = 'decimalExponent';
  27379. return
  27380. }
  27381. if (util.isDigit(c)) {
  27382. buffer += read();
  27383. lexState = 'decimalFraction';
  27384. return
  27385. }
  27386. return newToken('numeric', sign * Number(buffer))
  27387. },
  27388. decimalFraction: function decimalFraction () {
  27389. switch (c) {
  27390. case 'e':
  27391. case 'E':
  27392. buffer += read();
  27393. lexState = 'decimalExponent';
  27394. return
  27395. }
  27396. if (util.isDigit(c)) {
  27397. buffer += read();
  27398. return
  27399. }
  27400. return newToken('numeric', sign * Number(buffer))
  27401. },
  27402. decimalExponent: function decimalExponent () {
  27403. switch (c) {
  27404. case '+':
  27405. case '-':
  27406. buffer += read();
  27407. lexState = 'decimalExponentSign';
  27408. return
  27409. }
  27410. if (util.isDigit(c)) {
  27411. buffer += read();
  27412. lexState = 'decimalExponentInteger';
  27413. return
  27414. }
  27415. throw invalidChar(read())
  27416. },
  27417. decimalExponentSign: function decimalExponentSign () {
  27418. if (util.isDigit(c)) {
  27419. buffer += read();
  27420. lexState = 'decimalExponentInteger';
  27421. return
  27422. }
  27423. throw invalidChar(read())
  27424. },
  27425. decimalExponentInteger: function decimalExponentInteger () {
  27426. if (util.isDigit(c)) {
  27427. buffer += read();
  27428. return
  27429. }
  27430. return newToken('numeric', sign * Number(buffer))
  27431. },
  27432. hexadecimal: function hexadecimal () {
  27433. if (util.isHexDigit(c)) {
  27434. buffer += read();
  27435. lexState = 'hexadecimalInteger';
  27436. return
  27437. }
  27438. throw invalidChar(read())
  27439. },
  27440. hexadecimalInteger: function hexadecimalInteger () {
  27441. if (util.isHexDigit(c)) {
  27442. buffer += read();
  27443. return
  27444. }
  27445. return newToken('numeric', sign * Number(buffer))
  27446. },
  27447. string: function string () {
  27448. switch (c) {
  27449. case '\\':
  27450. read();
  27451. buffer += escape();
  27452. return
  27453. case '"':
  27454. if (doubleQuote) {
  27455. read();
  27456. return newToken('string', buffer)
  27457. }
  27458. buffer += read();
  27459. return
  27460. case "'":
  27461. if (!doubleQuote) {
  27462. read();
  27463. return newToken('string', buffer)
  27464. }
  27465. buffer += read();
  27466. return
  27467. case '\n':
  27468. case '\r':
  27469. throw invalidChar(read())
  27470. case '\u2028':
  27471. case '\u2029':
  27472. separatorChar(c);
  27473. break
  27474. case undefined:
  27475. throw invalidChar(read())
  27476. }
  27477. buffer += read();
  27478. },
  27479. start: function start () {
  27480. switch (c) {
  27481. case '{':
  27482. case '[':
  27483. return newToken('punctuator', read())
  27484. // This code is unreachable since the default lexState handles eof.
  27485. // case undefined:
  27486. // return newToken('eof')
  27487. }
  27488. lexState = 'value';
  27489. },
  27490. beforePropertyName: function beforePropertyName () {
  27491. switch (c) {
  27492. case '$':
  27493. case '_':
  27494. buffer = read();
  27495. lexState = 'identifierName';
  27496. return
  27497. case '\\':
  27498. read();
  27499. lexState = 'identifierNameStartEscape';
  27500. return
  27501. case '}':
  27502. return newToken('punctuator', read())
  27503. case '"':
  27504. case "'":
  27505. doubleQuote = (read() === '"');
  27506. lexState = 'string';
  27507. return
  27508. }
  27509. if (util.isIdStartChar(c)) {
  27510. buffer += read();
  27511. lexState = 'identifierName';
  27512. return
  27513. }
  27514. throw invalidChar(read())
  27515. },
  27516. afterPropertyName: function afterPropertyName () {
  27517. if (c === ':') {
  27518. return newToken('punctuator', read())
  27519. }
  27520. throw invalidChar(read())
  27521. },
  27522. beforePropertyValue: function beforePropertyValue () {
  27523. lexState = 'value';
  27524. },
  27525. afterPropertyValue: function afterPropertyValue () {
  27526. switch (c) {
  27527. case ',':
  27528. case '}':
  27529. return newToken('punctuator', read())
  27530. }
  27531. throw invalidChar(read())
  27532. },
  27533. beforeArrayValue: function beforeArrayValue () {
  27534. if (c === ']') {
  27535. return newToken('punctuator', read())
  27536. }
  27537. lexState = 'value';
  27538. },
  27539. afterArrayValue: function afterArrayValue () {
  27540. switch (c) {
  27541. case ',':
  27542. case ']':
  27543. return newToken('punctuator', read())
  27544. }
  27545. throw invalidChar(read())
  27546. },
  27547. end: function end () {
  27548. // This code is unreachable since it's handled by the default lexState.
  27549. // if (c === undefined) {
  27550. // read()
  27551. // return newToken('eof')
  27552. // }
  27553. throw invalidChar(read())
  27554. },
  27555. };
  27556. function newToken (type, value) {
  27557. return {
  27558. type: type,
  27559. value: value,
  27560. line: line,
  27561. column: column,
  27562. }
  27563. }
  27564. function literal (s) {
  27565. for (var i = 0, list = s; i < list.length; i += 1) {
  27566. var c = list[i];
  27567. var p = peek();
  27568. if (p !== c) {
  27569. throw invalidChar(read())
  27570. }
  27571. read();
  27572. }
  27573. }
  27574. function escape () {
  27575. var c = peek();
  27576. switch (c) {
  27577. case 'b':
  27578. read();
  27579. return '\b'
  27580. case 'f':
  27581. read();
  27582. return '\f'
  27583. case 'n':
  27584. read();
  27585. return '\n'
  27586. case 'r':
  27587. read();
  27588. return '\r'
  27589. case 't':
  27590. read();
  27591. return '\t'
  27592. case 'v':
  27593. read();
  27594. return '\v'
  27595. case '0':
  27596. read();
  27597. if (util.isDigit(peek())) {
  27598. throw invalidChar(read())
  27599. }
  27600. return '\0'
  27601. case 'x':
  27602. read();
  27603. return hexEscape()
  27604. case 'u':
  27605. read();
  27606. return unicodeEscape()
  27607. case '\n':
  27608. case '\u2028':
  27609. case '\u2029':
  27610. read();
  27611. return ''
  27612. case '\r':
  27613. read();
  27614. if (peek() === '\n') {
  27615. read();
  27616. }
  27617. return ''
  27618. case '1':
  27619. case '2':
  27620. case '3':
  27621. case '4':
  27622. case '5':
  27623. case '6':
  27624. case '7':
  27625. case '8':
  27626. case '9':
  27627. throw invalidChar(read())
  27628. case undefined:
  27629. throw invalidChar(read())
  27630. }
  27631. return read()
  27632. }
  27633. function hexEscape () {
  27634. var buffer = '';
  27635. var c = peek();
  27636. if (!util.isHexDigit(c)) {
  27637. throw invalidChar(read())
  27638. }
  27639. buffer += read();
  27640. c = peek();
  27641. if (!util.isHexDigit(c)) {
  27642. throw invalidChar(read())
  27643. }
  27644. buffer += read();
  27645. return String.fromCodePoint(parseInt(buffer, 16))
  27646. }
  27647. function unicodeEscape () {
  27648. var buffer = '';
  27649. var count = 4;
  27650. while (count-- > 0) {
  27651. var c = peek();
  27652. if (!util.isHexDigit(c)) {
  27653. throw invalidChar(read())
  27654. }
  27655. buffer += read();
  27656. }
  27657. return String.fromCodePoint(parseInt(buffer, 16))
  27658. }
  27659. var parseStates = {
  27660. start: function start () {
  27661. if (token.type === 'eof') {
  27662. throw invalidEOF()
  27663. }
  27664. push();
  27665. },
  27666. beforePropertyName: function beforePropertyName () {
  27667. switch (token.type) {
  27668. case 'identifier':
  27669. case 'string':
  27670. key = token.value;
  27671. parseState = 'afterPropertyName';
  27672. return
  27673. case 'punctuator':
  27674. // This code is unreachable since it's handled by the lexState.
  27675. // if (token.value !== '}') {
  27676. // throw invalidToken()
  27677. // }
  27678. pop();
  27679. return
  27680. case 'eof':
  27681. throw invalidEOF()
  27682. }
  27683. // This code is unreachable since it's handled by the lexState.
  27684. // throw invalidToken()
  27685. },
  27686. afterPropertyName: function afterPropertyName () {
  27687. // This code is unreachable since it's handled by the lexState.
  27688. // if (token.type !== 'punctuator' || token.value !== ':') {
  27689. // throw invalidToken()
  27690. // }
  27691. if (token.type === 'eof') {
  27692. throw invalidEOF()
  27693. }
  27694. parseState = 'beforePropertyValue';
  27695. },
  27696. beforePropertyValue: function beforePropertyValue () {
  27697. if (token.type === 'eof') {
  27698. throw invalidEOF()
  27699. }
  27700. push();
  27701. },
  27702. beforeArrayValue: function beforeArrayValue () {
  27703. if (token.type === 'eof') {
  27704. throw invalidEOF()
  27705. }
  27706. if (token.type === 'punctuator' && token.value === ']') {
  27707. pop();
  27708. return
  27709. }
  27710. push();
  27711. },
  27712. afterPropertyValue: function afterPropertyValue () {
  27713. // This code is unreachable since it's handled by the lexState.
  27714. // if (token.type !== 'punctuator') {
  27715. // throw invalidToken()
  27716. // }
  27717. if (token.type === 'eof') {
  27718. throw invalidEOF()
  27719. }
  27720. switch (token.value) {
  27721. case ',':
  27722. parseState = 'beforePropertyName';
  27723. return
  27724. case '}':
  27725. pop();
  27726. }
  27727. // This code is unreachable since it's handled by the lexState.
  27728. // throw invalidToken()
  27729. },
  27730. afterArrayValue: function afterArrayValue () {
  27731. // This code is unreachable since it's handled by the lexState.
  27732. // if (token.type !== 'punctuator') {
  27733. // throw invalidToken()
  27734. // }
  27735. if (token.type === 'eof') {
  27736. throw invalidEOF()
  27737. }
  27738. switch (token.value) {
  27739. case ',':
  27740. parseState = 'beforeArrayValue';
  27741. return
  27742. case ']':
  27743. pop();
  27744. }
  27745. // This code is unreachable since it's handled by the lexState.
  27746. // throw invalidToken()
  27747. },
  27748. end: function end () {
  27749. // This code is unreachable since it's handled by the lexState.
  27750. // if (token.type !== 'eof') {
  27751. // throw invalidToken()
  27752. // }
  27753. },
  27754. };
  27755. function push () {
  27756. var value;
  27757. switch (token.type) {
  27758. case 'punctuator':
  27759. switch (token.value) {
  27760. case '{':
  27761. value = {};
  27762. break
  27763. case '[':
  27764. value = [];
  27765. break
  27766. }
  27767. break
  27768. case 'null':
  27769. case 'boolean':
  27770. case 'numeric':
  27771. case 'string':
  27772. value = token.value;
  27773. break
  27774. // This code is unreachable.
  27775. // default:
  27776. // throw invalidToken()
  27777. }
  27778. if (root === undefined) {
  27779. root = value;
  27780. } else {
  27781. var parent = stack[stack.length - 1];
  27782. if (Array.isArray(parent)) {
  27783. parent.push(value);
  27784. } else {
  27785. parent[key] = value;
  27786. }
  27787. }
  27788. if (value !== null && typeof value === 'object') {
  27789. stack.push(value);
  27790. if (Array.isArray(value)) {
  27791. parseState = 'beforeArrayValue';
  27792. } else {
  27793. parseState = 'beforePropertyName';
  27794. }
  27795. } else {
  27796. var current = stack[stack.length - 1];
  27797. if (current == null) {
  27798. parseState = 'end';
  27799. } else if (Array.isArray(current)) {
  27800. parseState = 'afterArrayValue';
  27801. } else {
  27802. parseState = 'afterPropertyValue';
  27803. }
  27804. }
  27805. }
  27806. function pop () {
  27807. stack.pop();
  27808. var current = stack[stack.length - 1];
  27809. if (current == null) {
  27810. parseState = 'end';
  27811. } else if (Array.isArray(current)) {
  27812. parseState = 'afterArrayValue';
  27813. } else {
  27814. parseState = 'afterPropertyValue';
  27815. }
  27816. }
  27817. // This code is unreachable.
  27818. // function invalidParseState () {
  27819. // return new Error(`JSON5: invalid parse state '${parseState}'`)
  27820. // }
  27821. // This code is unreachable.
  27822. // function invalidLexState (state) {
  27823. // return new Error(`JSON5: invalid lex state '${state}'`)
  27824. // }
  27825. function invalidChar (c) {
  27826. if (c === undefined) {
  27827. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  27828. }
  27829. return syntaxError(("JSON5: invalid character '" + (formatChar(c)) + "' at " + line + ":" + column))
  27830. }
  27831. function invalidEOF () {
  27832. return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
  27833. }
  27834. // This code is unreachable.
  27835. // function invalidToken () {
  27836. // if (token.type === 'eof') {
  27837. // return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
  27838. // }
  27839. // const c = String.fromCodePoint(token.value.codePointAt(0))
  27840. // return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
  27841. // }
  27842. function invalidIdentifier () {
  27843. column -= 5;
  27844. return syntaxError(("JSON5: invalid identifier character at " + line + ":" + column))
  27845. }
  27846. function separatorChar (c) {
  27847. console.warn(("JSON5: '" + (formatChar(c)) + "' in strings is not valid ECMAScript; consider escaping"));
  27848. }
  27849. function formatChar (c) {
  27850. var replacements = {
  27851. "'": "\\'",
  27852. '"': '\\"',
  27853. '\\': '\\\\',
  27854. '\b': '\\b',
  27855. '\f': '\\f',
  27856. '\n': '\\n',
  27857. '\r': '\\r',
  27858. '\t': '\\t',
  27859. '\v': '\\v',
  27860. '\0': '\\0',
  27861. '\u2028': '\\u2028',
  27862. '\u2029': '\\u2029',
  27863. };
  27864. if (replacements[c]) {
  27865. return replacements[c]
  27866. }
  27867. if (c < ' ') {
  27868. var hexString = c.charCodeAt(0).toString(16);
  27869. return '\\x' + ('00' + hexString).substring(hexString.length)
  27870. }
  27871. return c
  27872. }
  27873. function syntaxError (message) {
  27874. var err = new SyntaxError(message);
  27875. err.lineNumber = line;
  27876. err.columnNumber = column;
  27877. return err
  27878. }
  27879. var stringify = function stringify (value, replacer, space) {
  27880. var stack = [];
  27881. var indent = '';
  27882. var propertyList;
  27883. var replacerFunc;
  27884. var gap = '';
  27885. var quote;
  27886. if (
  27887. replacer != null &&
  27888. typeof replacer === 'object' &&
  27889. !Array.isArray(replacer)
  27890. ) {
  27891. space = replacer.space;
  27892. quote = replacer.quote;
  27893. replacer = replacer.replacer;
  27894. }
  27895. if (typeof replacer === 'function') {
  27896. replacerFunc = replacer;
  27897. } else if (Array.isArray(replacer)) {
  27898. propertyList = [];
  27899. for (var i = 0, list = replacer; i < list.length; i += 1) {
  27900. var v = list[i];
  27901. var item = (void 0);
  27902. if (typeof v === 'string') {
  27903. item = v;
  27904. } else if (
  27905. typeof v === 'number' ||
  27906. v instanceof String ||
  27907. v instanceof Number
  27908. ) {
  27909. item = String(v);
  27910. }
  27911. if (item !== undefined && propertyList.indexOf(item) < 0) {
  27912. propertyList.push(item);
  27913. }
  27914. }
  27915. }
  27916. if (space instanceof Number) {
  27917. space = Number(space);
  27918. } else if (space instanceof String) {
  27919. space = String(space);
  27920. }
  27921. if (typeof space === 'number') {
  27922. if (space > 0) {
  27923. space = Math.min(10, Math.floor(space));
  27924. gap = ' '.substr(0, space);
  27925. }
  27926. } else if (typeof space === 'string') {
  27927. gap = space.substr(0, 10);
  27928. }
  27929. return serializeProperty('', {'': value})
  27930. function serializeProperty (key, holder) {
  27931. var value = holder[key];
  27932. if (value != null) {
  27933. if (typeof value.toJSON5 === 'function') {
  27934. value = value.toJSON5(key);
  27935. } else if (typeof value.toJSON === 'function') {
  27936. value = value.toJSON(key);
  27937. }
  27938. }
  27939. if (replacerFunc) {
  27940. value = replacerFunc.call(holder, key, value);
  27941. }
  27942. if (value instanceof Number) {
  27943. value = Number(value);
  27944. } else if (value instanceof String) {
  27945. value = String(value);
  27946. } else if (value instanceof Boolean) {
  27947. value = value.valueOf();
  27948. }
  27949. switch (value) {
  27950. case null: return 'null'
  27951. case true: return 'true'
  27952. case false: return 'false'
  27953. }
  27954. if (typeof value === 'string') {
  27955. return quoteString(value)
  27956. }
  27957. if (typeof value === 'number') {
  27958. return String(value)
  27959. }
  27960. if (typeof value === 'object') {
  27961. return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
  27962. }
  27963. return undefined
  27964. }
  27965. function quoteString (value) {
  27966. var quotes = {
  27967. "'": 0.1,
  27968. '"': 0.2,
  27969. };
  27970. var replacements = {
  27971. "'": "\\'",
  27972. '"': '\\"',
  27973. '\\': '\\\\',
  27974. '\b': '\\b',
  27975. '\f': '\\f',
  27976. '\n': '\\n',
  27977. '\r': '\\r',
  27978. '\t': '\\t',
  27979. '\v': '\\v',
  27980. '\0': '\\0',
  27981. '\u2028': '\\u2028',
  27982. '\u2029': '\\u2029',
  27983. };
  27984. var product = '';
  27985. for (var i = 0; i < value.length; i++) {
  27986. var c = value[i];
  27987. switch (c) {
  27988. case "'":
  27989. case '"':
  27990. quotes[c]++;
  27991. product += c;
  27992. continue
  27993. case '\0':
  27994. if (util.isDigit(value[i + 1])) {
  27995. product += '\\x00';
  27996. continue
  27997. }
  27998. }
  27999. if (replacements[c]) {
  28000. product += replacements[c];
  28001. continue
  28002. }
  28003. if (c < ' ') {
  28004. var hexString = c.charCodeAt(0).toString(16);
  28005. product += '\\x' + ('00' + hexString).substring(hexString.length);
  28006. continue
  28007. }
  28008. product += c;
  28009. }
  28010. var quoteChar = quote || Object.keys(quotes).reduce(function (a, b) { return (quotes[a] < quotes[b]) ? a : b; });
  28011. product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
  28012. return quoteChar + product + quoteChar
  28013. }
  28014. function serializeObject (value) {
  28015. if (stack.indexOf(value) >= 0) {
  28016. throw TypeError('Converting circular structure to JSON5')
  28017. }
  28018. stack.push(value);
  28019. var stepback = indent;
  28020. indent = indent + gap;
  28021. var keys = propertyList || Object.keys(value);
  28022. var partial = [];
  28023. for (var i = 0, list = keys; i < list.length; i += 1) {
  28024. var key = list[i];
  28025. var propertyString = serializeProperty(key, value);
  28026. if (propertyString !== undefined) {
  28027. var member = serializeKey(key) + ':';
  28028. if (gap !== '') {
  28029. member += ' ';
  28030. }
  28031. member += propertyString;
  28032. partial.push(member);
  28033. }
  28034. }
  28035. var final;
  28036. if (partial.length === 0) {
  28037. final = '{}';
  28038. } else {
  28039. var properties;
  28040. if (gap === '') {
  28041. properties = partial.join(',');
  28042. final = '{' + properties + '}';
  28043. } else {
  28044. var separator = ',\n' + indent;
  28045. properties = partial.join(separator);
  28046. final = '{\n' + indent + properties + ',\n' + stepback + '}';
  28047. }
  28048. }
  28049. stack.pop();
  28050. indent = stepback;
  28051. return final
  28052. }
  28053. function serializeKey (key) {
  28054. if (key.length === 0) {
  28055. return quoteString(key)
  28056. }
  28057. var firstChar = String.fromCodePoint(key.codePointAt(0));
  28058. if (!util.isIdStartChar(firstChar)) {
  28059. return quoteString(key)
  28060. }
  28061. for (var i = firstChar.length; i < key.length; i++) {
  28062. if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
  28063. return quoteString(key)
  28064. }
  28065. }
  28066. return key
  28067. }
  28068. function serializeArray (value) {
  28069. if (stack.indexOf(value) >= 0) {
  28070. throw TypeError('Converting circular structure to JSON5')
  28071. }
  28072. stack.push(value);
  28073. var stepback = indent;
  28074. indent = indent + gap;
  28075. var partial = [];
  28076. for (var i = 0; i < value.length; i++) {
  28077. var propertyString = serializeProperty(String(i), value);
  28078. partial.push((propertyString !== undefined) ? propertyString : 'null');
  28079. }
  28080. var final;
  28081. if (partial.length === 0) {
  28082. final = '[]';
  28083. } else {
  28084. if (gap === '') {
  28085. var properties = partial.join(',');
  28086. final = '[' + properties + ']';
  28087. } else {
  28088. var separator = ',\n' + indent;
  28089. var properties$1 = partial.join(separator);
  28090. final = '[\n' + indent + properties$1 + ',\n' + stepback + ']';
  28091. }
  28092. }
  28093. stack.pop();
  28094. indent = stepback;
  28095. return final
  28096. }
  28097. };
  28098. var JSON5 = {
  28099. parse: parse,
  28100. stringify: stringify,
  28101. };
  28102. var lib = JSON5;
  28103. var es5 = lib;
  28104. return es5;
  28105. })));
  28106. });
  28107. var moment = createCommonjsModule(function (module, exports) {
  28108. (function (global, factory) {
  28109. module.exports = factory() ;
  28110. }(commonjsGlobal, (function () {
  28111. var hookCallback;
  28112. function hooks() {
  28113. return hookCallback.apply(null, arguments);
  28114. }
  28115. // This is done to register the method called with moment()
  28116. // without creating circular dependencies.
  28117. function setHookCallback(callback) {
  28118. hookCallback = callback;
  28119. }
  28120. function isArray(input) {
  28121. return (
  28122. input instanceof Array ||
  28123. Object.prototype.toString.call(input) === '[object Array]'
  28124. );
  28125. }
  28126. function isObject(input) {
  28127. // IE8 will treat undefined and null as object if it wasn't for
  28128. // input != null
  28129. return (
  28130. input != null &&
  28131. Object.prototype.toString.call(input) === '[object Object]'
  28132. );
  28133. }
  28134. function hasOwnProp(a, b) {
  28135. return Object.prototype.hasOwnProperty.call(a, b);
  28136. }
  28137. function isObjectEmpty(obj) {
  28138. if (Object.getOwnPropertyNames) {
  28139. return Object.getOwnPropertyNames(obj).length === 0;
  28140. } else {
  28141. var k;
  28142. for (k in obj) {
  28143. if (hasOwnProp(obj, k)) {
  28144. return false;
  28145. }
  28146. }
  28147. return true;
  28148. }
  28149. }
  28150. function isUndefined(input) {
  28151. return input === void 0;
  28152. }
  28153. function isNumber(input) {
  28154. return (
  28155. typeof input === 'number' ||
  28156. Object.prototype.toString.call(input) === '[object Number]'
  28157. );
  28158. }
  28159. function isDate(input) {
  28160. return (
  28161. input instanceof Date ||
  28162. Object.prototype.toString.call(input) === '[object Date]'
  28163. );
  28164. }
  28165. function map(arr, fn) {
  28166. var res = [],
  28167. i;
  28168. for (i = 0; i < arr.length; ++i) {
  28169. res.push(fn(arr[i], i));
  28170. }
  28171. return res;
  28172. }
  28173. function extend(a, b) {
  28174. for (var i in b) {
  28175. if (hasOwnProp(b, i)) {
  28176. a[i] = b[i];
  28177. }
  28178. }
  28179. if (hasOwnProp(b, 'toString')) {
  28180. a.toString = b.toString;
  28181. }
  28182. if (hasOwnProp(b, 'valueOf')) {
  28183. a.valueOf = b.valueOf;
  28184. }
  28185. return a;
  28186. }
  28187. function createUTC(input, format, locale, strict) {
  28188. return createLocalOrUTC(input, format, locale, strict, true).utc();
  28189. }
  28190. function defaultParsingFlags() {
  28191. // We need to deep clone this object.
  28192. return {
  28193. empty: false,
  28194. unusedTokens: [],
  28195. unusedInput: [],
  28196. overflow: -2,
  28197. charsLeftOver: 0,
  28198. nullInput: false,
  28199. invalidEra: null,
  28200. invalidMonth: null,
  28201. invalidFormat: false,
  28202. userInvalidated: false,
  28203. iso: false,
  28204. parsedDateParts: [],
  28205. era: null,
  28206. meridiem: null,
  28207. rfc2822: false,
  28208. weekdayMismatch: false,
  28209. };
  28210. }
  28211. function getParsingFlags(m) {
  28212. if (m._pf == null) {
  28213. m._pf = defaultParsingFlags();
  28214. }
  28215. return m._pf;
  28216. }
  28217. var some;
  28218. if (Array.prototype.some) {
  28219. some = Array.prototype.some;
  28220. } else {
  28221. some = function (fun) {
  28222. var t = Object(this),
  28223. len = t.length >>> 0,
  28224. i;
  28225. for (i = 0; i < len; i++) {
  28226. if (i in t && fun.call(this, t[i], i, t)) {
  28227. return true;
  28228. }
  28229. }
  28230. return false;
  28231. };
  28232. }
  28233. function isValid(m) {
  28234. if (m._isValid == null) {
  28235. var flags = getParsingFlags(m),
  28236. parsedParts = some.call(flags.parsedDateParts, function (i) {
  28237. return i != null;
  28238. }),
  28239. isNowValid =
  28240. !isNaN(m._d.getTime()) &&
  28241. flags.overflow < 0 &&
  28242. !flags.empty &&
  28243. !flags.invalidEra &&
  28244. !flags.invalidMonth &&
  28245. !flags.invalidWeekday &&
  28246. !flags.weekdayMismatch &&
  28247. !flags.nullInput &&
  28248. !flags.invalidFormat &&
  28249. !flags.userInvalidated &&
  28250. (!flags.meridiem || (flags.meridiem && parsedParts));
  28251. if (m._strict) {
  28252. isNowValid =
  28253. isNowValid &&
  28254. flags.charsLeftOver === 0 &&
  28255. flags.unusedTokens.length === 0 &&
  28256. flags.bigHour === undefined;
  28257. }
  28258. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  28259. m._isValid = isNowValid;
  28260. } else {
  28261. return isNowValid;
  28262. }
  28263. }
  28264. return m._isValid;
  28265. }
  28266. function createInvalid(flags) {
  28267. var m = createUTC(NaN);
  28268. if (flags != null) {
  28269. extend(getParsingFlags(m), flags);
  28270. } else {
  28271. getParsingFlags(m).userInvalidated = true;
  28272. }
  28273. return m;
  28274. }
  28275. // Plugins that add properties should also add the key here (null value),
  28276. // so we can properly clone ourselves.
  28277. var momentProperties = (hooks.momentProperties = []),
  28278. updateInProgress = false;
  28279. function copyConfig(to, from) {
  28280. var i, prop, val;
  28281. if (!isUndefined(from._isAMomentObject)) {
  28282. to._isAMomentObject = from._isAMomentObject;
  28283. }
  28284. if (!isUndefined(from._i)) {
  28285. to._i = from._i;
  28286. }
  28287. if (!isUndefined(from._f)) {
  28288. to._f = from._f;
  28289. }
  28290. if (!isUndefined(from._l)) {
  28291. to._l = from._l;
  28292. }
  28293. if (!isUndefined(from._strict)) {
  28294. to._strict = from._strict;
  28295. }
  28296. if (!isUndefined(from._tzm)) {
  28297. to._tzm = from._tzm;
  28298. }
  28299. if (!isUndefined(from._isUTC)) {
  28300. to._isUTC = from._isUTC;
  28301. }
  28302. if (!isUndefined(from._offset)) {
  28303. to._offset = from._offset;
  28304. }
  28305. if (!isUndefined(from._pf)) {
  28306. to._pf = getParsingFlags(from);
  28307. }
  28308. if (!isUndefined(from._locale)) {
  28309. to._locale = from._locale;
  28310. }
  28311. if (momentProperties.length > 0) {
  28312. for (i = 0; i < momentProperties.length; i++) {
  28313. prop = momentProperties[i];
  28314. val = from[prop];
  28315. if (!isUndefined(val)) {
  28316. to[prop] = val;
  28317. }
  28318. }
  28319. }
  28320. return to;
  28321. }
  28322. // Moment prototype object
  28323. function Moment(config) {
  28324. copyConfig(this, config);
  28325. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  28326. if (!this.isValid()) {
  28327. this._d = new Date(NaN);
  28328. }
  28329. // Prevent infinite loop in case updateOffset creates new moment
  28330. // objects.
  28331. if (updateInProgress === false) {
  28332. updateInProgress = true;
  28333. hooks.updateOffset(this);
  28334. updateInProgress = false;
  28335. }
  28336. }
  28337. function isMoment(obj) {
  28338. return (
  28339. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  28340. );
  28341. }
  28342. function warn(msg) {
  28343. if (
  28344. hooks.suppressDeprecationWarnings === false &&
  28345. typeof console !== 'undefined' &&
  28346. console.warn
  28347. ) {
  28348. console.warn('Deprecation warning: ' + msg);
  28349. }
  28350. }
  28351. function deprecate(msg, fn) {
  28352. var firstTime = true;
  28353. return extend(function () {
  28354. if (hooks.deprecationHandler != null) {
  28355. hooks.deprecationHandler(null, msg);
  28356. }
  28357. if (firstTime) {
  28358. var args = [],
  28359. arg,
  28360. i,
  28361. key;
  28362. for (i = 0; i < arguments.length; i++) {
  28363. arg = '';
  28364. if (typeof arguments[i] === 'object') {
  28365. arg += '\n[' + i + '] ';
  28366. for (key in arguments[0]) {
  28367. if (hasOwnProp(arguments[0], key)) {
  28368. arg += key + ': ' + arguments[0][key] + ', ';
  28369. }
  28370. }
  28371. arg = arg.slice(0, -2); // Remove trailing comma and space
  28372. } else {
  28373. arg = arguments[i];
  28374. }
  28375. args.push(arg);
  28376. }
  28377. warn(
  28378. msg +
  28379. '\nArguments: ' +
  28380. Array.prototype.slice.call(args).join('') +
  28381. '\n' +
  28382. new Error().stack
  28383. );
  28384. firstTime = false;
  28385. }
  28386. return fn.apply(this, arguments);
  28387. }, fn);
  28388. }
  28389. var deprecations = {};
  28390. function deprecateSimple(name, msg) {
  28391. if (hooks.deprecationHandler != null) {
  28392. hooks.deprecationHandler(name, msg);
  28393. }
  28394. if (!deprecations[name]) {
  28395. warn(msg);
  28396. deprecations[name] = true;
  28397. }
  28398. }
  28399. hooks.suppressDeprecationWarnings = false;
  28400. hooks.deprecationHandler = null;
  28401. function isFunction(input) {
  28402. return (
  28403. (typeof Function !== 'undefined' && input instanceof Function) ||
  28404. Object.prototype.toString.call(input) === '[object Function]'
  28405. );
  28406. }
  28407. function set(config) {
  28408. var prop, i;
  28409. for (i in config) {
  28410. if (hasOwnProp(config, i)) {
  28411. prop = config[i];
  28412. if (isFunction(prop)) {
  28413. this[i] = prop;
  28414. } else {
  28415. this['_' + i] = prop;
  28416. }
  28417. }
  28418. }
  28419. this._config = config;
  28420. // Lenient ordinal parsing accepts just a number in addition to
  28421. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  28422. // TODO: Remove "ordinalParse" fallback in next major release.
  28423. this._dayOfMonthOrdinalParseLenient = new RegExp(
  28424. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  28425. '|' +
  28426. /\d{1,2}/.source
  28427. );
  28428. }
  28429. function mergeConfigs(parentConfig, childConfig) {
  28430. var res = extend({}, parentConfig),
  28431. prop;
  28432. for (prop in childConfig) {
  28433. if (hasOwnProp(childConfig, prop)) {
  28434. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  28435. res[prop] = {};
  28436. extend(res[prop], parentConfig[prop]);
  28437. extend(res[prop], childConfig[prop]);
  28438. } else if (childConfig[prop] != null) {
  28439. res[prop] = childConfig[prop];
  28440. } else {
  28441. delete res[prop];
  28442. }
  28443. }
  28444. }
  28445. for (prop in parentConfig) {
  28446. if (
  28447. hasOwnProp(parentConfig, prop) &&
  28448. !hasOwnProp(childConfig, prop) &&
  28449. isObject(parentConfig[prop])
  28450. ) {
  28451. // make sure changes to properties don't modify parent config
  28452. res[prop] = extend({}, res[prop]);
  28453. }
  28454. }
  28455. return res;
  28456. }
  28457. function Locale(config) {
  28458. if (config != null) {
  28459. this.set(config);
  28460. }
  28461. }
  28462. var keys;
  28463. if (Object.keys) {
  28464. keys = Object.keys;
  28465. } else {
  28466. keys = function (obj) {
  28467. var i,
  28468. res = [];
  28469. for (i in obj) {
  28470. if (hasOwnProp(obj, i)) {
  28471. res.push(i);
  28472. }
  28473. }
  28474. return res;
  28475. };
  28476. }
  28477. var defaultCalendar = {
  28478. sameDay: '[Today at] LT',
  28479. nextDay: '[Tomorrow at] LT',
  28480. nextWeek: 'dddd [at] LT',
  28481. lastDay: '[Yesterday at] LT',
  28482. lastWeek: '[Last] dddd [at] LT',
  28483. sameElse: 'L',
  28484. };
  28485. function calendar(key, mom, now) {
  28486. var output = this._calendar[key] || this._calendar['sameElse'];
  28487. return isFunction(output) ? output.call(mom, now) : output;
  28488. }
  28489. function zeroFill(number, targetLength, forceSign) {
  28490. var absNumber = '' + Math.abs(number),
  28491. zerosToFill = targetLength - absNumber.length,
  28492. sign = number >= 0;
  28493. return (
  28494. (sign ? (forceSign ? '+' : '') : '-') +
  28495. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  28496. absNumber
  28497. );
  28498. }
  28499. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
  28500. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  28501. formatFunctions = {},
  28502. formatTokenFunctions = {};
  28503. // token: 'M'
  28504. // padded: ['MM', 2]
  28505. // ordinal: 'Mo'
  28506. // callback: function () { this.month() + 1 }
  28507. function addFormatToken(token, padded, ordinal, callback) {
  28508. var func = callback;
  28509. if (typeof callback === 'string') {
  28510. func = function () {
  28511. return this[callback]();
  28512. };
  28513. }
  28514. if (token) {
  28515. formatTokenFunctions[token] = func;
  28516. }
  28517. if (padded) {
  28518. formatTokenFunctions[padded[0]] = function () {
  28519. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  28520. };
  28521. }
  28522. if (ordinal) {
  28523. formatTokenFunctions[ordinal] = function () {
  28524. return this.localeData().ordinal(
  28525. func.apply(this, arguments),
  28526. token
  28527. );
  28528. };
  28529. }
  28530. }
  28531. function removeFormattingTokens(input) {
  28532. if (input.match(/\[[\s\S]/)) {
  28533. return input.replace(/^\[|\]$/g, '');
  28534. }
  28535. return input.replace(/\\/g, '');
  28536. }
  28537. function makeFormatFunction(format) {
  28538. var array = format.match(formattingTokens),
  28539. i,
  28540. length;
  28541. for (i = 0, length = array.length; i < length; i++) {
  28542. if (formatTokenFunctions[array[i]]) {
  28543. array[i] = formatTokenFunctions[array[i]];
  28544. } else {
  28545. array[i] = removeFormattingTokens(array[i]);
  28546. }
  28547. }
  28548. return function (mom) {
  28549. var output = '',
  28550. i;
  28551. for (i = 0; i < length; i++) {
  28552. output += isFunction(array[i])
  28553. ? array[i].call(mom, format)
  28554. : array[i];
  28555. }
  28556. return output;
  28557. };
  28558. }
  28559. // format date using native date object
  28560. function formatMoment(m, format) {
  28561. if (!m.isValid()) {
  28562. return m.localeData().invalidDate();
  28563. }
  28564. format = expandFormat(format, m.localeData());
  28565. formatFunctions[format] =
  28566. formatFunctions[format] || makeFormatFunction(format);
  28567. return formatFunctions[format](m);
  28568. }
  28569. function expandFormat(format, locale) {
  28570. var i = 5;
  28571. function replaceLongDateFormatTokens(input) {
  28572. return locale.longDateFormat(input) || input;
  28573. }
  28574. localFormattingTokens.lastIndex = 0;
  28575. while (i >= 0 && localFormattingTokens.test(format)) {
  28576. format = format.replace(
  28577. localFormattingTokens,
  28578. replaceLongDateFormatTokens
  28579. );
  28580. localFormattingTokens.lastIndex = 0;
  28581. i -= 1;
  28582. }
  28583. return format;
  28584. }
  28585. var defaultLongDateFormat = {
  28586. LTS: 'h:mm:ss A',
  28587. LT: 'h:mm A',
  28588. L: 'MM/DD/YYYY',
  28589. LL: 'MMMM D, YYYY',
  28590. LLL: 'MMMM D, YYYY h:mm A',
  28591. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  28592. };
  28593. function longDateFormat(key) {
  28594. var format = this._longDateFormat[key],
  28595. formatUpper = this._longDateFormat[key.toUpperCase()];
  28596. if (format || !formatUpper) {
  28597. return format;
  28598. }
  28599. this._longDateFormat[key] = formatUpper
  28600. .match(formattingTokens)
  28601. .map(function (tok) {
  28602. if (
  28603. tok === 'MMMM' ||
  28604. tok === 'MM' ||
  28605. tok === 'DD' ||
  28606. tok === 'dddd'
  28607. ) {
  28608. return tok.slice(1);
  28609. }
  28610. return tok;
  28611. })
  28612. .join('');
  28613. return this._longDateFormat[key];
  28614. }
  28615. var defaultInvalidDate = 'Invalid date';
  28616. function invalidDate() {
  28617. return this._invalidDate;
  28618. }
  28619. var defaultOrdinal = '%d',
  28620. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  28621. function ordinal(number) {
  28622. return this._ordinal.replace('%d', number);
  28623. }
  28624. var defaultRelativeTime = {
  28625. future: 'in %s',
  28626. past: '%s ago',
  28627. s: 'a few seconds',
  28628. ss: '%d seconds',
  28629. m: 'a minute',
  28630. mm: '%d minutes',
  28631. h: 'an hour',
  28632. hh: '%d hours',
  28633. d: 'a day',
  28634. dd: '%d days',
  28635. w: 'a week',
  28636. ww: '%d weeks',
  28637. M: 'a month',
  28638. MM: '%d months',
  28639. y: 'a year',
  28640. yy: '%d years',
  28641. };
  28642. function relativeTime(number, withoutSuffix, string, isFuture) {
  28643. var output = this._relativeTime[string];
  28644. return isFunction(output)
  28645. ? output(number, withoutSuffix, string, isFuture)
  28646. : output.replace(/%d/i, number);
  28647. }
  28648. function pastFuture(diff, output) {
  28649. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  28650. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  28651. }
  28652. var aliases = {};
  28653. function addUnitAlias(unit, shorthand) {
  28654. var lowerCase = unit.toLowerCase();
  28655. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  28656. }
  28657. function normalizeUnits(units) {
  28658. return typeof units === 'string'
  28659. ? aliases[units] || aliases[units.toLowerCase()]
  28660. : undefined;
  28661. }
  28662. function normalizeObjectUnits(inputObject) {
  28663. var normalizedInput = {},
  28664. normalizedProp,
  28665. prop;
  28666. for (prop in inputObject) {
  28667. if (hasOwnProp(inputObject, prop)) {
  28668. normalizedProp = normalizeUnits(prop);
  28669. if (normalizedProp) {
  28670. normalizedInput[normalizedProp] = inputObject[prop];
  28671. }
  28672. }
  28673. }
  28674. return normalizedInput;
  28675. }
  28676. var priorities = {};
  28677. function addUnitPriority(unit, priority) {
  28678. priorities[unit] = priority;
  28679. }
  28680. function getPrioritizedUnits(unitsObj) {
  28681. var units = [],
  28682. u;
  28683. for (u in unitsObj) {
  28684. if (hasOwnProp(unitsObj, u)) {
  28685. units.push({ unit: u, priority: priorities[u] });
  28686. }
  28687. }
  28688. units.sort(function (a, b) {
  28689. return a.priority - b.priority;
  28690. });
  28691. return units;
  28692. }
  28693. function isLeapYear(year) {
  28694. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  28695. }
  28696. function absFloor(number) {
  28697. if (number < 0) {
  28698. // -0 -> 0
  28699. return Math.ceil(number) || 0;
  28700. } else {
  28701. return Math.floor(number);
  28702. }
  28703. }
  28704. function toInt(argumentForCoercion) {
  28705. var coercedNumber = +argumentForCoercion,
  28706. value = 0;
  28707. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  28708. value = absFloor(coercedNumber);
  28709. }
  28710. return value;
  28711. }
  28712. function makeGetSet(unit, keepTime) {
  28713. return function (value) {
  28714. if (value != null) {
  28715. set$1(this, unit, value);
  28716. hooks.updateOffset(this, keepTime);
  28717. return this;
  28718. } else {
  28719. return get(this, unit);
  28720. }
  28721. };
  28722. }
  28723. function get(mom, unit) {
  28724. return mom.isValid()
  28725. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  28726. : NaN;
  28727. }
  28728. function set$1(mom, unit, value) {
  28729. if (mom.isValid() && !isNaN(value)) {
  28730. if (
  28731. unit === 'FullYear' &&
  28732. isLeapYear(mom.year()) &&
  28733. mom.month() === 1 &&
  28734. mom.date() === 29
  28735. ) {
  28736. value = toInt(value);
  28737. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  28738. value,
  28739. mom.month(),
  28740. daysInMonth(value, mom.month())
  28741. );
  28742. } else {
  28743. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  28744. }
  28745. }
  28746. }
  28747. // MOMENTS
  28748. function stringGet(units) {
  28749. units = normalizeUnits(units);
  28750. if (isFunction(this[units])) {
  28751. return this[units]();
  28752. }
  28753. return this;
  28754. }
  28755. function stringSet(units, value) {
  28756. if (typeof units === 'object') {
  28757. units = normalizeObjectUnits(units);
  28758. var prioritized = getPrioritizedUnits(units),
  28759. i;
  28760. for (i = 0; i < prioritized.length; i++) {
  28761. this[prioritized[i].unit](units[prioritized[i].unit]);
  28762. }
  28763. } else {
  28764. units = normalizeUnits(units);
  28765. if (isFunction(this[units])) {
  28766. return this[units](value);
  28767. }
  28768. }
  28769. return this;
  28770. }
  28771. var match1 = /\d/, // 0 - 9
  28772. match2 = /\d\d/, // 00 - 99
  28773. match3 = /\d{3}/, // 000 - 999
  28774. match4 = /\d{4}/, // 0000 - 9999
  28775. match6 = /[+-]?\d{6}/, // -999999 - 999999
  28776. match1to2 = /\d\d?/, // 0 - 99
  28777. match3to4 = /\d\d\d\d?/, // 999 - 9999
  28778. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  28779. match1to3 = /\d{1,3}/, // 0 - 999
  28780. match1to4 = /\d{1,4}/, // 0 - 9999
  28781. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  28782. matchUnsigned = /\d+/, // 0 - inf
  28783. matchSigned = /[+-]?\d+/, // -inf - inf
  28784. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  28785. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  28786. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  28787. // any word (or two) characters or numbers including two/three word month in arabic.
  28788. // includes scottish gaelic two word and hyphenated months
  28789. matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
  28790. regexes;
  28791. regexes = {};
  28792. function addRegexToken(token, regex, strictRegex) {
  28793. regexes[token] = isFunction(regex)
  28794. ? regex
  28795. : function (isStrict, localeData) {
  28796. return isStrict && strictRegex ? strictRegex : regex;
  28797. };
  28798. }
  28799. function getParseRegexForToken(token, config) {
  28800. if (!hasOwnProp(regexes, token)) {
  28801. return new RegExp(unescapeFormat(token));
  28802. }
  28803. return regexes[token](config._strict, config._locale);
  28804. }
  28805. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  28806. function unescapeFormat(s) {
  28807. return regexEscape(
  28808. s
  28809. .replace('\\', '')
  28810. .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
  28811. matched,
  28812. p1,
  28813. p2,
  28814. p3,
  28815. p4
  28816. ) {
  28817. return p1 || p2 || p3 || p4;
  28818. })
  28819. );
  28820. }
  28821. function regexEscape(s) {
  28822. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  28823. }
  28824. var tokens = {};
  28825. function addParseToken(token, callback) {
  28826. var i,
  28827. func = callback;
  28828. if (typeof token === 'string') {
  28829. token = [token];
  28830. }
  28831. if (isNumber(callback)) {
  28832. func = function (input, array) {
  28833. array[callback] = toInt(input);
  28834. };
  28835. }
  28836. for (i = 0; i < token.length; i++) {
  28837. tokens[token[i]] = func;
  28838. }
  28839. }
  28840. function addWeekParseToken(token, callback) {
  28841. addParseToken(token, function (input, array, config, token) {
  28842. config._w = config._w || {};
  28843. callback(input, config._w, config, token);
  28844. });
  28845. }
  28846. function addTimeToArrayFromToken(token, input, config) {
  28847. if (input != null && hasOwnProp(tokens, token)) {
  28848. tokens[token](input, config._a, config, token);
  28849. }
  28850. }
  28851. var YEAR = 0,
  28852. MONTH = 1,
  28853. DATE = 2,
  28854. HOUR = 3,
  28855. MINUTE = 4,
  28856. SECOND = 5,
  28857. MILLISECOND = 6,
  28858. WEEK = 7,
  28859. WEEKDAY = 8;
  28860. function mod(n, x) {
  28861. return ((n % x) + x) % x;
  28862. }
  28863. var indexOf;
  28864. if (Array.prototype.indexOf) {
  28865. indexOf = Array.prototype.indexOf;
  28866. } else {
  28867. indexOf = function (o) {
  28868. // I know
  28869. var i;
  28870. for (i = 0; i < this.length; ++i) {
  28871. if (this[i] === o) {
  28872. return i;
  28873. }
  28874. }
  28875. return -1;
  28876. };
  28877. }
  28878. function daysInMonth(year, month) {
  28879. if (isNaN(year) || isNaN(month)) {
  28880. return NaN;
  28881. }
  28882. var modMonth = mod(month, 12);
  28883. year += (month - modMonth) / 12;
  28884. return modMonth === 1
  28885. ? isLeapYear(year)
  28886. ? 29
  28887. : 28
  28888. : 31 - ((modMonth % 7) % 2);
  28889. }
  28890. // FORMATTING
  28891. addFormatToken('M', ['MM', 2], 'Mo', function () {
  28892. return this.month() + 1;
  28893. });
  28894. addFormatToken('MMM', 0, 0, function (format) {
  28895. return this.localeData().monthsShort(this, format);
  28896. });
  28897. addFormatToken('MMMM', 0, 0, function (format) {
  28898. return this.localeData().months(this, format);
  28899. });
  28900. // ALIASES
  28901. addUnitAlias('month', 'M');
  28902. // PRIORITY
  28903. addUnitPriority('month', 8);
  28904. // PARSING
  28905. addRegexToken('M', match1to2);
  28906. addRegexToken('MM', match1to2, match2);
  28907. addRegexToken('MMM', function (isStrict, locale) {
  28908. return locale.monthsShortRegex(isStrict);
  28909. });
  28910. addRegexToken('MMMM', function (isStrict, locale) {
  28911. return locale.monthsRegex(isStrict);
  28912. });
  28913. addParseToken(['M', 'MM'], function (input, array) {
  28914. array[MONTH] = toInt(input) - 1;
  28915. });
  28916. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  28917. var month = config._locale.monthsParse(input, token, config._strict);
  28918. // if we didn't find a month name, mark the date as invalid.
  28919. if (month != null) {
  28920. array[MONTH] = month;
  28921. } else {
  28922. getParsingFlags(config).invalidMonth = input;
  28923. }
  28924. });
  28925. // LOCALES
  28926. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  28927. '_'
  28928. ),
  28929. defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
  28930. '_'
  28931. ),
  28932. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  28933. defaultMonthsShortRegex = matchWord,
  28934. defaultMonthsRegex = matchWord;
  28935. function localeMonths(m, format) {
  28936. if (!m) {
  28937. return isArray(this._months)
  28938. ? this._months
  28939. : this._months['standalone'];
  28940. }
  28941. return isArray(this._months)
  28942. ? this._months[m.month()]
  28943. : this._months[
  28944. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  28945. ? 'format'
  28946. : 'standalone'
  28947. ][m.month()];
  28948. }
  28949. function localeMonthsShort(m, format) {
  28950. if (!m) {
  28951. return isArray(this._monthsShort)
  28952. ? this._monthsShort
  28953. : this._monthsShort['standalone'];
  28954. }
  28955. return isArray(this._monthsShort)
  28956. ? this._monthsShort[m.month()]
  28957. : this._monthsShort[
  28958. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  28959. ][m.month()];
  28960. }
  28961. function handleStrictParse(monthName, format, strict) {
  28962. var i,
  28963. ii,
  28964. mom,
  28965. llc = monthName.toLocaleLowerCase();
  28966. if (!this._monthsParse) {
  28967. // this is not used
  28968. this._monthsParse = [];
  28969. this._longMonthsParse = [];
  28970. this._shortMonthsParse = [];
  28971. for (i = 0; i < 12; ++i) {
  28972. mom = createUTC([2000, i]);
  28973. this._shortMonthsParse[i] = this.monthsShort(
  28974. mom,
  28975. ''
  28976. ).toLocaleLowerCase();
  28977. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  28978. }
  28979. }
  28980. if (strict) {
  28981. if (format === 'MMM') {
  28982. ii = indexOf.call(this._shortMonthsParse, llc);
  28983. return ii !== -1 ? ii : null;
  28984. } else {
  28985. ii = indexOf.call(this._longMonthsParse, llc);
  28986. return ii !== -1 ? ii : null;
  28987. }
  28988. } else {
  28989. if (format === 'MMM') {
  28990. ii = indexOf.call(this._shortMonthsParse, llc);
  28991. if (ii !== -1) {
  28992. return ii;
  28993. }
  28994. ii = indexOf.call(this._longMonthsParse, llc);
  28995. return ii !== -1 ? ii : null;
  28996. } else {
  28997. ii = indexOf.call(this._longMonthsParse, llc);
  28998. if (ii !== -1) {
  28999. return ii;
  29000. }
  29001. ii = indexOf.call(this._shortMonthsParse, llc);
  29002. return ii !== -1 ? ii : null;
  29003. }
  29004. }
  29005. }
  29006. function localeMonthsParse(monthName, format, strict) {
  29007. var i, mom, regex;
  29008. if (this._monthsParseExact) {
  29009. return handleStrictParse.call(this, monthName, format, strict);
  29010. }
  29011. if (!this._monthsParse) {
  29012. this._monthsParse = [];
  29013. this._longMonthsParse = [];
  29014. this._shortMonthsParse = [];
  29015. }
  29016. // TODO: add sorting
  29017. // Sorting makes sure if one month (or abbr) is a prefix of another
  29018. // see sorting in computeMonthsParse
  29019. for (i = 0; i < 12; i++) {
  29020. // make the regex if we don't have it already
  29021. mom = createUTC([2000, i]);
  29022. if (strict && !this._longMonthsParse[i]) {
  29023. this._longMonthsParse[i] = new RegExp(
  29024. '^' + this.months(mom, '').replace('.', '') + '$',
  29025. 'i'
  29026. );
  29027. this._shortMonthsParse[i] = new RegExp(
  29028. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  29029. 'i'
  29030. );
  29031. }
  29032. if (!strict && !this._monthsParse[i]) {
  29033. regex =
  29034. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  29035. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  29036. }
  29037. // test the regex
  29038. if (
  29039. strict &&
  29040. format === 'MMMM' &&
  29041. this._longMonthsParse[i].test(monthName)
  29042. ) {
  29043. return i;
  29044. } else if (
  29045. strict &&
  29046. format === 'MMM' &&
  29047. this._shortMonthsParse[i].test(monthName)
  29048. ) {
  29049. return i;
  29050. } else if (!strict && this._monthsParse[i].test(monthName)) {
  29051. return i;
  29052. }
  29053. }
  29054. }
  29055. // MOMENTS
  29056. function setMonth(mom, value) {
  29057. var dayOfMonth;
  29058. if (!mom.isValid()) {
  29059. // No op
  29060. return mom;
  29061. }
  29062. if (typeof value === 'string') {
  29063. if (/^\d+$/.test(value)) {
  29064. value = toInt(value);
  29065. } else {
  29066. value = mom.localeData().monthsParse(value);
  29067. // TODO: Another silent failure?
  29068. if (!isNumber(value)) {
  29069. return mom;
  29070. }
  29071. }
  29072. }
  29073. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  29074. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  29075. return mom;
  29076. }
  29077. function getSetMonth(value) {
  29078. if (value != null) {
  29079. setMonth(this, value);
  29080. hooks.updateOffset(this, true);
  29081. return this;
  29082. } else {
  29083. return get(this, 'Month');
  29084. }
  29085. }
  29086. function getDaysInMonth() {
  29087. return daysInMonth(this.year(), this.month());
  29088. }
  29089. function monthsShortRegex(isStrict) {
  29090. if (this._monthsParseExact) {
  29091. if (!hasOwnProp(this, '_monthsRegex')) {
  29092. computeMonthsParse.call(this);
  29093. }
  29094. if (isStrict) {
  29095. return this._monthsShortStrictRegex;
  29096. } else {
  29097. return this._monthsShortRegex;
  29098. }
  29099. } else {
  29100. if (!hasOwnProp(this, '_monthsShortRegex')) {
  29101. this._monthsShortRegex = defaultMonthsShortRegex;
  29102. }
  29103. return this._monthsShortStrictRegex && isStrict
  29104. ? this._monthsShortStrictRegex
  29105. : this._monthsShortRegex;
  29106. }
  29107. }
  29108. function monthsRegex(isStrict) {
  29109. if (this._monthsParseExact) {
  29110. if (!hasOwnProp(this, '_monthsRegex')) {
  29111. computeMonthsParse.call(this);
  29112. }
  29113. if (isStrict) {
  29114. return this._monthsStrictRegex;
  29115. } else {
  29116. return this._monthsRegex;
  29117. }
  29118. } else {
  29119. if (!hasOwnProp(this, '_monthsRegex')) {
  29120. this._monthsRegex = defaultMonthsRegex;
  29121. }
  29122. return this._monthsStrictRegex && isStrict
  29123. ? this._monthsStrictRegex
  29124. : this._monthsRegex;
  29125. }
  29126. }
  29127. function computeMonthsParse() {
  29128. function cmpLenRev(a, b) {
  29129. return b.length - a.length;
  29130. }
  29131. var shortPieces = [],
  29132. longPieces = [],
  29133. mixedPieces = [],
  29134. i,
  29135. mom;
  29136. for (i = 0; i < 12; i++) {
  29137. // make the regex if we don't have it already
  29138. mom = createUTC([2000, i]);
  29139. shortPieces.push(this.monthsShort(mom, ''));
  29140. longPieces.push(this.months(mom, ''));
  29141. mixedPieces.push(this.months(mom, ''));
  29142. mixedPieces.push(this.monthsShort(mom, ''));
  29143. }
  29144. // Sorting makes sure if one month (or abbr) is a prefix of another it
  29145. // will match the longer piece.
  29146. shortPieces.sort(cmpLenRev);
  29147. longPieces.sort(cmpLenRev);
  29148. mixedPieces.sort(cmpLenRev);
  29149. for (i = 0; i < 12; i++) {
  29150. shortPieces[i] = regexEscape(shortPieces[i]);
  29151. longPieces[i] = regexEscape(longPieces[i]);
  29152. }
  29153. for (i = 0; i < 24; i++) {
  29154. mixedPieces[i] = regexEscape(mixedPieces[i]);
  29155. }
  29156. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  29157. this._monthsShortRegex = this._monthsRegex;
  29158. this._monthsStrictRegex = new RegExp(
  29159. '^(' + longPieces.join('|') + ')',
  29160. 'i'
  29161. );
  29162. this._monthsShortStrictRegex = new RegExp(
  29163. '^(' + shortPieces.join('|') + ')',
  29164. 'i'
  29165. );
  29166. }
  29167. // FORMATTING
  29168. addFormatToken('Y', 0, 0, function () {
  29169. var y = this.year();
  29170. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  29171. });
  29172. addFormatToken(0, ['YY', 2], 0, function () {
  29173. return this.year() % 100;
  29174. });
  29175. addFormatToken(0, ['YYYY', 4], 0, 'year');
  29176. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  29177. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  29178. // ALIASES
  29179. addUnitAlias('year', 'y');
  29180. // PRIORITIES
  29181. addUnitPriority('year', 1);
  29182. // PARSING
  29183. addRegexToken('Y', matchSigned);
  29184. addRegexToken('YY', match1to2, match2);
  29185. addRegexToken('YYYY', match1to4, match4);
  29186. addRegexToken('YYYYY', match1to6, match6);
  29187. addRegexToken('YYYYYY', match1to6, match6);
  29188. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  29189. addParseToken('YYYY', function (input, array) {
  29190. array[YEAR] =
  29191. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  29192. });
  29193. addParseToken('YY', function (input, array) {
  29194. array[YEAR] = hooks.parseTwoDigitYear(input);
  29195. });
  29196. addParseToken('Y', function (input, array) {
  29197. array[YEAR] = parseInt(input, 10);
  29198. });
  29199. // HELPERS
  29200. function daysInYear(year) {
  29201. return isLeapYear(year) ? 366 : 365;
  29202. }
  29203. // HOOKS
  29204. hooks.parseTwoDigitYear = function (input) {
  29205. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  29206. };
  29207. // MOMENTS
  29208. var getSetYear = makeGetSet('FullYear', true);
  29209. function getIsLeapYear() {
  29210. return isLeapYear(this.year());
  29211. }
  29212. function createDate(y, m, d, h, M, s, ms) {
  29213. // can't just apply() to create a date:
  29214. // https://stackoverflow.com/q/181348
  29215. var date;
  29216. // the date constructor remaps years 0-99 to 1900-1999
  29217. if (y < 100 && y >= 0) {
  29218. // preserve leap years using a full 400 year cycle, then reset
  29219. date = new Date(y + 400, m, d, h, M, s, ms);
  29220. if (isFinite(date.getFullYear())) {
  29221. date.setFullYear(y);
  29222. }
  29223. } else {
  29224. date = new Date(y, m, d, h, M, s, ms);
  29225. }
  29226. return date;
  29227. }
  29228. function createUTCDate(y) {
  29229. var date, args;
  29230. // the Date.UTC function remaps years 0-99 to 1900-1999
  29231. if (y < 100 && y >= 0) {
  29232. args = Array.prototype.slice.call(arguments);
  29233. // preserve leap years using a full 400 year cycle, then reset
  29234. args[0] = y + 400;
  29235. date = new Date(Date.UTC.apply(null, args));
  29236. if (isFinite(date.getUTCFullYear())) {
  29237. date.setUTCFullYear(y);
  29238. }
  29239. } else {
  29240. date = new Date(Date.UTC.apply(null, arguments));
  29241. }
  29242. return date;
  29243. }
  29244. // start-of-first-week - start-of-year
  29245. function firstWeekOffset(year, dow, doy) {
  29246. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  29247. fwd = 7 + dow - doy,
  29248. // first-week day local weekday -- which local weekday is fwd
  29249. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  29250. return -fwdlw + fwd - 1;
  29251. }
  29252. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  29253. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  29254. var localWeekday = (7 + weekday - dow) % 7,
  29255. weekOffset = firstWeekOffset(year, dow, doy),
  29256. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  29257. resYear,
  29258. resDayOfYear;
  29259. if (dayOfYear <= 0) {
  29260. resYear = year - 1;
  29261. resDayOfYear = daysInYear(resYear) + dayOfYear;
  29262. } else if (dayOfYear > daysInYear(year)) {
  29263. resYear = year + 1;
  29264. resDayOfYear = dayOfYear - daysInYear(year);
  29265. } else {
  29266. resYear = year;
  29267. resDayOfYear = dayOfYear;
  29268. }
  29269. return {
  29270. year: resYear,
  29271. dayOfYear: resDayOfYear,
  29272. };
  29273. }
  29274. function weekOfYear(mom, dow, doy) {
  29275. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  29276. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  29277. resWeek,
  29278. resYear;
  29279. if (week < 1) {
  29280. resYear = mom.year() - 1;
  29281. resWeek = week + weeksInYear(resYear, dow, doy);
  29282. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  29283. resWeek = week - weeksInYear(mom.year(), dow, doy);
  29284. resYear = mom.year() + 1;
  29285. } else {
  29286. resYear = mom.year();
  29287. resWeek = week;
  29288. }
  29289. return {
  29290. week: resWeek,
  29291. year: resYear,
  29292. };
  29293. }
  29294. function weeksInYear(year, dow, doy) {
  29295. var weekOffset = firstWeekOffset(year, dow, doy),
  29296. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  29297. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  29298. }
  29299. // FORMATTING
  29300. addFormatToken('w', ['ww', 2], 'wo', 'week');
  29301. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  29302. // ALIASES
  29303. addUnitAlias('week', 'w');
  29304. addUnitAlias('isoWeek', 'W');
  29305. // PRIORITIES
  29306. addUnitPriority('week', 5);
  29307. addUnitPriority('isoWeek', 5);
  29308. // PARSING
  29309. addRegexToken('w', match1to2);
  29310. addRegexToken('ww', match1to2, match2);
  29311. addRegexToken('W', match1to2);
  29312. addRegexToken('WW', match1to2, match2);
  29313. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (
  29314. input,
  29315. week,
  29316. config,
  29317. token
  29318. ) {
  29319. week[token.substr(0, 1)] = toInt(input);
  29320. });
  29321. // HELPERS
  29322. // LOCALES
  29323. function localeWeek(mom) {
  29324. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  29325. }
  29326. var defaultLocaleWeek = {
  29327. dow: 0, // Sunday is the first day of the week.
  29328. doy: 6, // The week that contains Jan 6th is the first week of the year.
  29329. };
  29330. function localeFirstDayOfWeek() {
  29331. return this._week.dow;
  29332. }
  29333. function localeFirstDayOfYear() {
  29334. return this._week.doy;
  29335. }
  29336. // MOMENTS
  29337. function getSetWeek(input) {
  29338. var week = this.localeData().week(this);
  29339. return input == null ? week : this.add((input - week) * 7, 'd');
  29340. }
  29341. function getSetISOWeek(input) {
  29342. var week = weekOfYear(this, 1, 4).week;
  29343. return input == null ? week : this.add((input - week) * 7, 'd');
  29344. }
  29345. // FORMATTING
  29346. addFormatToken('d', 0, 'do', 'day');
  29347. addFormatToken('dd', 0, 0, function (format) {
  29348. return this.localeData().weekdaysMin(this, format);
  29349. });
  29350. addFormatToken('ddd', 0, 0, function (format) {
  29351. return this.localeData().weekdaysShort(this, format);
  29352. });
  29353. addFormatToken('dddd', 0, 0, function (format) {
  29354. return this.localeData().weekdays(this, format);
  29355. });
  29356. addFormatToken('e', 0, 0, 'weekday');
  29357. addFormatToken('E', 0, 0, 'isoWeekday');
  29358. // ALIASES
  29359. addUnitAlias('day', 'd');
  29360. addUnitAlias('weekday', 'e');
  29361. addUnitAlias('isoWeekday', 'E');
  29362. // PRIORITY
  29363. addUnitPriority('day', 11);
  29364. addUnitPriority('weekday', 11);
  29365. addUnitPriority('isoWeekday', 11);
  29366. // PARSING
  29367. addRegexToken('d', match1to2);
  29368. addRegexToken('e', match1to2);
  29369. addRegexToken('E', match1to2);
  29370. addRegexToken('dd', function (isStrict, locale) {
  29371. return locale.weekdaysMinRegex(isStrict);
  29372. });
  29373. addRegexToken('ddd', function (isStrict, locale) {
  29374. return locale.weekdaysShortRegex(isStrict);
  29375. });
  29376. addRegexToken('dddd', function (isStrict, locale) {
  29377. return locale.weekdaysRegex(isStrict);
  29378. });
  29379. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  29380. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  29381. // if we didn't get a weekday name, mark the date as invalid
  29382. if (weekday != null) {
  29383. week.d = weekday;
  29384. } else {
  29385. getParsingFlags(config).invalidWeekday = input;
  29386. }
  29387. });
  29388. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  29389. week[token] = toInt(input);
  29390. });
  29391. // HELPERS
  29392. function parseWeekday(input, locale) {
  29393. if (typeof input !== 'string') {
  29394. return input;
  29395. }
  29396. if (!isNaN(input)) {
  29397. return parseInt(input, 10);
  29398. }
  29399. input = locale.weekdaysParse(input);
  29400. if (typeof input === 'number') {
  29401. return input;
  29402. }
  29403. return null;
  29404. }
  29405. function parseIsoWeekday(input, locale) {
  29406. if (typeof input === 'string') {
  29407. return locale.weekdaysParse(input) % 7 || 7;
  29408. }
  29409. return isNaN(input) ? null : input;
  29410. }
  29411. // LOCALES
  29412. function shiftWeekdays(ws, n) {
  29413. return ws.slice(n, 7).concat(ws.slice(0, n));
  29414. }
  29415. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
  29416. '_'
  29417. ),
  29418. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  29419. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  29420. defaultWeekdaysRegex = matchWord,
  29421. defaultWeekdaysShortRegex = matchWord,
  29422. defaultWeekdaysMinRegex = matchWord;
  29423. function localeWeekdays(m, format) {
  29424. var weekdays = isArray(this._weekdays)
  29425. ? this._weekdays
  29426. : this._weekdays[
  29427. m && m !== true && this._weekdays.isFormat.test(format)
  29428. ? 'format'
  29429. : 'standalone'
  29430. ];
  29431. return m === true
  29432. ? shiftWeekdays(weekdays, this._week.dow)
  29433. : m
  29434. ? weekdays[m.day()]
  29435. : weekdays;
  29436. }
  29437. function localeWeekdaysShort(m) {
  29438. return m === true
  29439. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  29440. : m
  29441. ? this._weekdaysShort[m.day()]
  29442. : this._weekdaysShort;
  29443. }
  29444. function localeWeekdaysMin(m) {
  29445. return m === true
  29446. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  29447. : m
  29448. ? this._weekdaysMin[m.day()]
  29449. : this._weekdaysMin;
  29450. }
  29451. function handleStrictParse$1(weekdayName, format, strict) {
  29452. var i,
  29453. ii,
  29454. mom,
  29455. llc = weekdayName.toLocaleLowerCase();
  29456. if (!this._weekdaysParse) {
  29457. this._weekdaysParse = [];
  29458. this._shortWeekdaysParse = [];
  29459. this._minWeekdaysParse = [];
  29460. for (i = 0; i < 7; ++i) {
  29461. mom = createUTC([2000, 1]).day(i);
  29462. this._minWeekdaysParse[i] = this.weekdaysMin(
  29463. mom,
  29464. ''
  29465. ).toLocaleLowerCase();
  29466. this._shortWeekdaysParse[i] = this.weekdaysShort(
  29467. mom,
  29468. ''
  29469. ).toLocaleLowerCase();
  29470. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  29471. }
  29472. }
  29473. if (strict) {
  29474. if (format === 'dddd') {
  29475. ii = indexOf.call(this._weekdaysParse, llc);
  29476. return ii !== -1 ? ii : null;
  29477. } else if (format === 'ddd') {
  29478. ii = indexOf.call(this._shortWeekdaysParse, llc);
  29479. return ii !== -1 ? ii : null;
  29480. } else {
  29481. ii = indexOf.call(this._minWeekdaysParse, llc);
  29482. return ii !== -1 ? ii : null;
  29483. }
  29484. } else {
  29485. if (format === 'dddd') {
  29486. ii = indexOf.call(this._weekdaysParse, llc);
  29487. if (ii !== -1) {
  29488. return ii;
  29489. }
  29490. ii = indexOf.call(this._shortWeekdaysParse, llc);
  29491. if (ii !== -1) {
  29492. return ii;
  29493. }
  29494. ii = indexOf.call(this._minWeekdaysParse, llc);
  29495. return ii !== -1 ? ii : null;
  29496. } else if (format === 'ddd') {
  29497. ii = indexOf.call(this._shortWeekdaysParse, llc);
  29498. if (ii !== -1) {
  29499. return ii;
  29500. }
  29501. ii = indexOf.call(this._weekdaysParse, llc);
  29502. if (ii !== -1) {
  29503. return ii;
  29504. }
  29505. ii = indexOf.call(this._minWeekdaysParse, llc);
  29506. return ii !== -1 ? ii : null;
  29507. } else {
  29508. ii = indexOf.call(this._minWeekdaysParse, llc);
  29509. if (ii !== -1) {
  29510. return ii;
  29511. }
  29512. ii = indexOf.call(this._weekdaysParse, llc);
  29513. if (ii !== -1) {
  29514. return ii;
  29515. }
  29516. ii = indexOf.call(this._shortWeekdaysParse, llc);
  29517. return ii !== -1 ? ii : null;
  29518. }
  29519. }
  29520. }
  29521. function localeWeekdaysParse(weekdayName, format, strict) {
  29522. var i, mom, regex;
  29523. if (this._weekdaysParseExact) {
  29524. return handleStrictParse$1.call(this, weekdayName, format, strict);
  29525. }
  29526. if (!this._weekdaysParse) {
  29527. this._weekdaysParse = [];
  29528. this._minWeekdaysParse = [];
  29529. this._shortWeekdaysParse = [];
  29530. this._fullWeekdaysParse = [];
  29531. }
  29532. for (i = 0; i < 7; i++) {
  29533. // make the regex if we don't have it already
  29534. mom = createUTC([2000, 1]).day(i);
  29535. if (strict && !this._fullWeekdaysParse[i]) {
  29536. this._fullWeekdaysParse[i] = new RegExp(
  29537. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  29538. 'i'
  29539. );
  29540. this._shortWeekdaysParse[i] = new RegExp(
  29541. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  29542. 'i'
  29543. );
  29544. this._minWeekdaysParse[i] = new RegExp(
  29545. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  29546. 'i'
  29547. );
  29548. }
  29549. if (!this._weekdaysParse[i]) {
  29550. regex =
  29551. '^' +
  29552. this.weekdays(mom, '') +
  29553. '|^' +
  29554. this.weekdaysShort(mom, '') +
  29555. '|^' +
  29556. this.weekdaysMin(mom, '');
  29557. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  29558. }
  29559. // test the regex
  29560. if (
  29561. strict &&
  29562. format === 'dddd' &&
  29563. this._fullWeekdaysParse[i].test(weekdayName)
  29564. ) {
  29565. return i;
  29566. } else if (
  29567. strict &&
  29568. format === 'ddd' &&
  29569. this._shortWeekdaysParse[i].test(weekdayName)
  29570. ) {
  29571. return i;
  29572. } else if (
  29573. strict &&
  29574. format === 'dd' &&
  29575. this._minWeekdaysParse[i].test(weekdayName)
  29576. ) {
  29577. return i;
  29578. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  29579. return i;
  29580. }
  29581. }
  29582. }
  29583. // MOMENTS
  29584. function getSetDayOfWeek(input) {
  29585. if (!this.isValid()) {
  29586. return input != null ? this : NaN;
  29587. }
  29588. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  29589. if (input != null) {
  29590. input = parseWeekday(input, this.localeData());
  29591. return this.add(input - day, 'd');
  29592. } else {
  29593. return day;
  29594. }
  29595. }
  29596. function getSetLocaleDayOfWeek(input) {
  29597. if (!this.isValid()) {
  29598. return input != null ? this : NaN;
  29599. }
  29600. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  29601. return input == null ? weekday : this.add(input - weekday, 'd');
  29602. }
  29603. function getSetISODayOfWeek(input) {
  29604. if (!this.isValid()) {
  29605. return input != null ? this : NaN;
  29606. }
  29607. // behaves the same as moment#day except
  29608. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  29609. // as a setter, sunday should belong to the previous week.
  29610. if (input != null) {
  29611. var weekday = parseIsoWeekday(input, this.localeData());
  29612. return this.day(this.day() % 7 ? weekday : weekday - 7);
  29613. } else {
  29614. return this.day() || 7;
  29615. }
  29616. }
  29617. function weekdaysRegex(isStrict) {
  29618. if (this._weekdaysParseExact) {
  29619. if (!hasOwnProp(this, '_weekdaysRegex')) {
  29620. computeWeekdaysParse.call(this);
  29621. }
  29622. if (isStrict) {
  29623. return this._weekdaysStrictRegex;
  29624. } else {
  29625. return this._weekdaysRegex;
  29626. }
  29627. } else {
  29628. if (!hasOwnProp(this, '_weekdaysRegex')) {
  29629. this._weekdaysRegex = defaultWeekdaysRegex;
  29630. }
  29631. return this._weekdaysStrictRegex && isStrict
  29632. ? this._weekdaysStrictRegex
  29633. : this._weekdaysRegex;
  29634. }
  29635. }
  29636. function weekdaysShortRegex(isStrict) {
  29637. if (this._weekdaysParseExact) {
  29638. if (!hasOwnProp(this, '_weekdaysRegex')) {
  29639. computeWeekdaysParse.call(this);
  29640. }
  29641. if (isStrict) {
  29642. return this._weekdaysShortStrictRegex;
  29643. } else {
  29644. return this._weekdaysShortRegex;
  29645. }
  29646. } else {
  29647. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  29648. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  29649. }
  29650. return this._weekdaysShortStrictRegex && isStrict
  29651. ? this._weekdaysShortStrictRegex
  29652. : this._weekdaysShortRegex;
  29653. }
  29654. }
  29655. function weekdaysMinRegex(isStrict) {
  29656. if (this._weekdaysParseExact) {
  29657. if (!hasOwnProp(this, '_weekdaysRegex')) {
  29658. computeWeekdaysParse.call(this);
  29659. }
  29660. if (isStrict) {
  29661. return this._weekdaysMinStrictRegex;
  29662. } else {
  29663. return this._weekdaysMinRegex;
  29664. }
  29665. } else {
  29666. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  29667. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  29668. }
  29669. return this._weekdaysMinStrictRegex && isStrict
  29670. ? this._weekdaysMinStrictRegex
  29671. : this._weekdaysMinRegex;
  29672. }
  29673. }
  29674. function computeWeekdaysParse() {
  29675. function cmpLenRev(a, b) {
  29676. return b.length - a.length;
  29677. }
  29678. var minPieces = [],
  29679. shortPieces = [],
  29680. longPieces = [],
  29681. mixedPieces = [],
  29682. i,
  29683. mom,
  29684. minp,
  29685. shortp,
  29686. longp;
  29687. for (i = 0; i < 7; i++) {
  29688. // make the regex if we don't have it already
  29689. mom = createUTC([2000, 1]).day(i);
  29690. minp = regexEscape(this.weekdaysMin(mom, ''));
  29691. shortp = regexEscape(this.weekdaysShort(mom, ''));
  29692. longp = regexEscape(this.weekdays(mom, ''));
  29693. minPieces.push(minp);
  29694. shortPieces.push(shortp);
  29695. longPieces.push(longp);
  29696. mixedPieces.push(minp);
  29697. mixedPieces.push(shortp);
  29698. mixedPieces.push(longp);
  29699. }
  29700. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  29701. // will match the longer piece.
  29702. minPieces.sort(cmpLenRev);
  29703. shortPieces.sort(cmpLenRev);
  29704. longPieces.sort(cmpLenRev);
  29705. mixedPieces.sort(cmpLenRev);
  29706. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  29707. this._weekdaysShortRegex = this._weekdaysRegex;
  29708. this._weekdaysMinRegex = this._weekdaysRegex;
  29709. this._weekdaysStrictRegex = new RegExp(
  29710. '^(' + longPieces.join('|') + ')',
  29711. 'i'
  29712. );
  29713. this._weekdaysShortStrictRegex = new RegExp(
  29714. '^(' + shortPieces.join('|') + ')',
  29715. 'i'
  29716. );
  29717. this._weekdaysMinStrictRegex = new RegExp(
  29718. '^(' + minPieces.join('|') + ')',
  29719. 'i'
  29720. );
  29721. }
  29722. // FORMATTING
  29723. function hFormat() {
  29724. return this.hours() % 12 || 12;
  29725. }
  29726. function kFormat() {
  29727. return this.hours() || 24;
  29728. }
  29729. addFormatToken('H', ['HH', 2], 0, 'hour');
  29730. addFormatToken('h', ['hh', 2], 0, hFormat);
  29731. addFormatToken('k', ['kk', 2], 0, kFormat);
  29732. addFormatToken('hmm', 0, 0, function () {
  29733. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  29734. });
  29735. addFormatToken('hmmss', 0, 0, function () {
  29736. return (
  29737. '' +
  29738. hFormat.apply(this) +
  29739. zeroFill(this.minutes(), 2) +
  29740. zeroFill(this.seconds(), 2)
  29741. );
  29742. });
  29743. addFormatToken('Hmm', 0, 0, function () {
  29744. return '' + this.hours() + zeroFill(this.minutes(), 2);
  29745. });
  29746. addFormatToken('Hmmss', 0, 0, function () {
  29747. return (
  29748. '' +
  29749. this.hours() +
  29750. zeroFill(this.minutes(), 2) +
  29751. zeroFill(this.seconds(), 2)
  29752. );
  29753. });
  29754. function meridiem(token, lowercase) {
  29755. addFormatToken(token, 0, 0, function () {
  29756. return this.localeData().meridiem(
  29757. this.hours(),
  29758. this.minutes(),
  29759. lowercase
  29760. );
  29761. });
  29762. }
  29763. meridiem('a', true);
  29764. meridiem('A', false);
  29765. // ALIASES
  29766. addUnitAlias('hour', 'h');
  29767. // PRIORITY
  29768. addUnitPriority('hour', 13);
  29769. // PARSING
  29770. function matchMeridiem(isStrict, locale) {
  29771. return locale._meridiemParse;
  29772. }
  29773. addRegexToken('a', matchMeridiem);
  29774. addRegexToken('A', matchMeridiem);
  29775. addRegexToken('H', match1to2);
  29776. addRegexToken('h', match1to2);
  29777. addRegexToken('k', match1to2);
  29778. addRegexToken('HH', match1to2, match2);
  29779. addRegexToken('hh', match1to2, match2);
  29780. addRegexToken('kk', match1to2, match2);
  29781. addRegexToken('hmm', match3to4);
  29782. addRegexToken('hmmss', match5to6);
  29783. addRegexToken('Hmm', match3to4);
  29784. addRegexToken('Hmmss', match5to6);
  29785. addParseToken(['H', 'HH'], HOUR);
  29786. addParseToken(['k', 'kk'], function (input, array, config) {
  29787. var kInput = toInt(input);
  29788. array[HOUR] = kInput === 24 ? 0 : kInput;
  29789. });
  29790. addParseToken(['a', 'A'], function (input, array, config) {
  29791. config._isPm = config._locale.isPM(input);
  29792. config._meridiem = input;
  29793. });
  29794. addParseToken(['h', 'hh'], function (input, array, config) {
  29795. array[HOUR] = toInt(input);
  29796. getParsingFlags(config).bigHour = true;
  29797. });
  29798. addParseToken('hmm', function (input, array, config) {
  29799. var pos = input.length - 2;
  29800. array[HOUR] = toInt(input.substr(0, pos));
  29801. array[MINUTE] = toInt(input.substr(pos));
  29802. getParsingFlags(config).bigHour = true;
  29803. });
  29804. addParseToken('hmmss', function (input, array, config) {
  29805. var pos1 = input.length - 4,
  29806. pos2 = input.length - 2;
  29807. array[HOUR] = toInt(input.substr(0, pos1));
  29808. array[MINUTE] = toInt(input.substr(pos1, 2));
  29809. array[SECOND] = toInt(input.substr(pos2));
  29810. getParsingFlags(config).bigHour = true;
  29811. });
  29812. addParseToken('Hmm', function (input, array, config) {
  29813. var pos = input.length - 2;
  29814. array[HOUR] = toInt(input.substr(0, pos));
  29815. array[MINUTE] = toInt(input.substr(pos));
  29816. });
  29817. addParseToken('Hmmss', function (input, array, config) {
  29818. var pos1 = input.length - 4,
  29819. pos2 = input.length - 2;
  29820. array[HOUR] = toInt(input.substr(0, pos1));
  29821. array[MINUTE] = toInt(input.substr(pos1, 2));
  29822. array[SECOND] = toInt(input.substr(pos2));
  29823. });
  29824. // LOCALES
  29825. function localeIsPM(input) {
  29826. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  29827. // Using charAt should be more compatible.
  29828. return (input + '').toLowerCase().charAt(0) === 'p';
  29829. }
  29830. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  29831. // Setting the hour should keep the time, because the user explicitly
  29832. // specified which hour they want. So trying to maintain the same hour (in
  29833. // a new timezone) makes sense. Adding/subtracting hours does not follow
  29834. // this rule.
  29835. getSetHour = makeGetSet('Hours', true);
  29836. function localeMeridiem(hours, minutes, isLower) {
  29837. if (hours > 11) {
  29838. return isLower ? 'pm' : 'PM';
  29839. } else {
  29840. return isLower ? 'am' : 'AM';
  29841. }
  29842. }
  29843. var baseConfig = {
  29844. calendar: defaultCalendar,
  29845. longDateFormat: defaultLongDateFormat,
  29846. invalidDate: defaultInvalidDate,
  29847. ordinal: defaultOrdinal,
  29848. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  29849. relativeTime: defaultRelativeTime,
  29850. months: defaultLocaleMonths,
  29851. monthsShort: defaultLocaleMonthsShort,
  29852. week: defaultLocaleWeek,
  29853. weekdays: defaultLocaleWeekdays,
  29854. weekdaysMin: defaultLocaleWeekdaysMin,
  29855. weekdaysShort: defaultLocaleWeekdaysShort,
  29856. meridiemParse: defaultLocaleMeridiemParse,
  29857. };
  29858. // internal storage for locale config files
  29859. var locales = {},
  29860. localeFamilies = {},
  29861. globalLocale;
  29862. function commonPrefix(arr1, arr2) {
  29863. var i,
  29864. minl = Math.min(arr1.length, arr2.length);
  29865. for (i = 0; i < minl; i += 1) {
  29866. if (arr1[i] !== arr2[i]) {
  29867. return i;
  29868. }
  29869. }
  29870. return minl;
  29871. }
  29872. function normalizeLocale(key) {
  29873. return key ? key.toLowerCase().replace('_', '-') : key;
  29874. }
  29875. // pick the locale from the array
  29876. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  29877. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  29878. function chooseLocale(names) {
  29879. var i = 0,
  29880. j,
  29881. next,
  29882. locale,
  29883. split;
  29884. while (i < names.length) {
  29885. split = normalizeLocale(names[i]).split('-');
  29886. j = split.length;
  29887. next = normalizeLocale(names[i + 1]);
  29888. next = next ? next.split('-') : null;
  29889. while (j > 0) {
  29890. locale = loadLocale(split.slice(0, j).join('-'));
  29891. if (locale) {
  29892. return locale;
  29893. }
  29894. if (
  29895. next &&
  29896. next.length >= j &&
  29897. commonPrefix(split, next) >= j - 1
  29898. ) {
  29899. //the next array item is better than a shallower substring of this one
  29900. break;
  29901. }
  29902. j--;
  29903. }
  29904. i++;
  29905. }
  29906. return globalLocale;
  29907. }
  29908. function loadLocale(name) {
  29909. var oldLocale = null,
  29910. aliasedRequire;
  29911. // TODO: Find a better way to register and load all the locales in Node
  29912. if (
  29913. locales[name] === undefined &&
  29914. 'object' !== 'undefined' &&
  29915. module &&
  29916. module.exports
  29917. ) {
  29918. try {
  29919. oldLocale = globalLocale._abbr;
  29920. aliasedRequire = commonjsRequire;
  29921. aliasedRequire('./locale/' + name);
  29922. getSetGlobalLocale(oldLocale);
  29923. } catch (e) {
  29924. // mark as not found to avoid repeating expensive file require call causing high CPU
  29925. // when trying to find en-US, en_US, en-us for every format call
  29926. locales[name] = null; // null means not found
  29927. }
  29928. }
  29929. return locales[name];
  29930. }
  29931. // This function will load locale and then set the global locale. If
  29932. // no arguments are passed in, it will simply return the current global
  29933. // locale key.
  29934. function getSetGlobalLocale(key, values) {
  29935. var data;
  29936. if (key) {
  29937. if (isUndefined(values)) {
  29938. data = getLocale(key);
  29939. } else {
  29940. data = defineLocale(key, values);
  29941. }
  29942. if (data) {
  29943. // moment.duration._locale = moment._locale = data;
  29944. globalLocale = data;
  29945. } else {
  29946. if (typeof console !== 'undefined' && console.warn) {
  29947. //warn user if arguments are passed but the locale could not be set
  29948. console.warn(
  29949. 'Locale ' + key + ' not found. Did you forget to load it?'
  29950. );
  29951. }
  29952. }
  29953. }
  29954. return globalLocale._abbr;
  29955. }
  29956. function defineLocale(name, config) {
  29957. if (config !== null) {
  29958. var locale,
  29959. parentConfig = baseConfig;
  29960. config.abbr = name;
  29961. if (locales[name] != null) {
  29962. deprecateSimple(
  29963. 'defineLocaleOverride',
  29964. 'use moment.updateLocale(localeName, config) to change ' +
  29965. 'an existing locale. moment.defineLocale(localeName, ' +
  29966. 'config) should only be used for creating a new locale ' +
  29967. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  29968. );
  29969. parentConfig = locales[name]._config;
  29970. } else if (config.parentLocale != null) {
  29971. if (locales[config.parentLocale] != null) {
  29972. parentConfig = locales[config.parentLocale]._config;
  29973. } else {
  29974. locale = loadLocale(config.parentLocale);
  29975. if (locale != null) {
  29976. parentConfig = locale._config;
  29977. } else {
  29978. if (!localeFamilies[config.parentLocale]) {
  29979. localeFamilies[config.parentLocale] = [];
  29980. }
  29981. localeFamilies[config.parentLocale].push({
  29982. name: name,
  29983. config: config,
  29984. });
  29985. return null;
  29986. }
  29987. }
  29988. }
  29989. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  29990. if (localeFamilies[name]) {
  29991. localeFamilies[name].forEach(function (x) {
  29992. defineLocale(x.name, x.config);
  29993. });
  29994. }
  29995. // backwards compat for now: also set the locale
  29996. // make sure we set the locale AFTER all child locales have been
  29997. // created, so we won't end up with the child locale set.
  29998. getSetGlobalLocale(name);
  29999. return locales[name];
  30000. } else {
  30001. // useful for testing
  30002. delete locales[name];
  30003. return null;
  30004. }
  30005. }
  30006. function updateLocale(name, config) {
  30007. if (config != null) {
  30008. var locale,
  30009. tmpLocale,
  30010. parentConfig = baseConfig;
  30011. if (locales[name] != null && locales[name].parentLocale != null) {
  30012. // Update existing child locale in-place to avoid memory-leaks
  30013. locales[name].set(mergeConfigs(locales[name]._config, config));
  30014. } else {
  30015. // MERGE
  30016. tmpLocale = loadLocale(name);
  30017. if (tmpLocale != null) {
  30018. parentConfig = tmpLocale._config;
  30019. }
  30020. config = mergeConfigs(parentConfig, config);
  30021. if (tmpLocale == null) {
  30022. // updateLocale is called for creating a new locale
  30023. // Set abbr so it will have a name (getters return
  30024. // undefined otherwise).
  30025. config.abbr = name;
  30026. }
  30027. locale = new Locale(config);
  30028. locale.parentLocale = locales[name];
  30029. locales[name] = locale;
  30030. }
  30031. // backwards compat for now: also set the locale
  30032. getSetGlobalLocale(name);
  30033. } else {
  30034. // pass null for config to unupdate, useful for tests
  30035. if (locales[name] != null) {
  30036. if (locales[name].parentLocale != null) {
  30037. locales[name] = locales[name].parentLocale;
  30038. if (name === getSetGlobalLocale()) {
  30039. getSetGlobalLocale(name);
  30040. }
  30041. } else if (locales[name] != null) {
  30042. delete locales[name];
  30043. }
  30044. }
  30045. }
  30046. return locales[name];
  30047. }
  30048. // returns locale data
  30049. function getLocale(key) {
  30050. var locale;
  30051. if (key && key._locale && key._locale._abbr) {
  30052. key = key._locale._abbr;
  30053. }
  30054. if (!key) {
  30055. return globalLocale;
  30056. }
  30057. if (!isArray(key)) {
  30058. //short-circuit everything else
  30059. locale = loadLocale(key);
  30060. if (locale) {
  30061. return locale;
  30062. }
  30063. key = [key];
  30064. }
  30065. return chooseLocale(key);
  30066. }
  30067. function listLocales() {
  30068. return keys(locales);
  30069. }
  30070. function checkOverflow(m) {
  30071. var overflow,
  30072. a = m._a;
  30073. if (a && getParsingFlags(m).overflow === -2) {
  30074. overflow =
  30075. a[MONTH] < 0 || a[MONTH] > 11
  30076. ? MONTH
  30077. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  30078. ? DATE
  30079. : a[HOUR] < 0 ||
  30080. a[HOUR] > 24 ||
  30081. (a[HOUR] === 24 &&
  30082. (a[MINUTE] !== 0 ||
  30083. a[SECOND] !== 0 ||
  30084. a[MILLISECOND] !== 0))
  30085. ? HOUR
  30086. : a[MINUTE] < 0 || a[MINUTE] > 59
  30087. ? MINUTE
  30088. : a[SECOND] < 0 || a[SECOND] > 59
  30089. ? SECOND
  30090. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  30091. ? MILLISECOND
  30092. : -1;
  30093. if (
  30094. getParsingFlags(m)._overflowDayOfYear &&
  30095. (overflow < YEAR || overflow > DATE)
  30096. ) {
  30097. overflow = DATE;
  30098. }
  30099. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  30100. overflow = WEEK;
  30101. }
  30102. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  30103. overflow = WEEKDAY;
  30104. }
  30105. getParsingFlags(m).overflow = overflow;
  30106. }
  30107. return m;
  30108. }
  30109. // iso 8601 regex
  30110. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  30111. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  30112. basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  30113. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  30114. isoDates = [
  30115. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  30116. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  30117. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  30118. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  30119. ['YYYY-DDD', /\d{4}-\d{3}/],
  30120. ['YYYY-MM', /\d{4}-\d\d/, false],
  30121. ['YYYYYYMMDD', /[+-]\d{10}/],
  30122. ['YYYYMMDD', /\d{8}/],
  30123. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  30124. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  30125. ['YYYYDDD', /\d{7}/],
  30126. ['YYYYMM', /\d{6}/, false],
  30127. ['YYYY', /\d{4}/, false],
  30128. ],
  30129. // iso time formats and regexes
  30130. isoTimes = [
  30131. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  30132. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  30133. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  30134. ['HH:mm', /\d\d:\d\d/],
  30135. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  30136. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  30137. ['HHmmss', /\d\d\d\d\d\d/],
  30138. ['HHmm', /\d\d\d\d/],
  30139. ['HH', /\d\d/],
  30140. ],
  30141. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  30142. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  30143. rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,
  30144. obsOffsets = {
  30145. UT: 0,
  30146. GMT: 0,
  30147. EDT: -4 * 60,
  30148. EST: -5 * 60,
  30149. CDT: -5 * 60,
  30150. CST: -6 * 60,
  30151. MDT: -6 * 60,
  30152. MST: -7 * 60,
  30153. PDT: -7 * 60,
  30154. PST: -8 * 60,
  30155. };
  30156. // date from iso format
  30157. function configFromISO(config) {
  30158. var i,
  30159. l,
  30160. string = config._i,
  30161. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  30162. allowTime,
  30163. dateFormat,
  30164. timeFormat,
  30165. tzFormat;
  30166. if (match) {
  30167. getParsingFlags(config).iso = true;
  30168. for (i = 0, l = isoDates.length; i < l; i++) {
  30169. if (isoDates[i][1].exec(match[1])) {
  30170. dateFormat = isoDates[i][0];
  30171. allowTime = isoDates[i][2] !== false;
  30172. break;
  30173. }
  30174. }
  30175. if (dateFormat == null) {
  30176. config._isValid = false;
  30177. return;
  30178. }
  30179. if (match[3]) {
  30180. for (i = 0, l = isoTimes.length; i < l; i++) {
  30181. if (isoTimes[i][1].exec(match[3])) {
  30182. // match[2] should be 'T' or space
  30183. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  30184. break;
  30185. }
  30186. }
  30187. if (timeFormat == null) {
  30188. config._isValid = false;
  30189. return;
  30190. }
  30191. }
  30192. if (!allowTime && timeFormat != null) {
  30193. config._isValid = false;
  30194. return;
  30195. }
  30196. if (match[4]) {
  30197. if (tzRegex.exec(match[4])) {
  30198. tzFormat = 'Z';
  30199. } else {
  30200. config._isValid = false;
  30201. return;
  30202. }
  30203. }
  30204. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  30205. configFromStringAndFormat(config);
  30206. } else {
  30207. config._isValid = false;
  30208. }
  30209. }
  30210. function extractFromRFC2822Strings(
  30211. yearStr,
  30212. monthStr,
  30213. dayStr,
  30214. hourStr,
  30215. minuteStr,
  30216. secondStr
  30217. ) {
  30218. var result = [
  30219. untruncateYear(yearStr),
  30220. defaultLocaleMonthsShort.indexOf(monthStr),
  30221. parseInt(dayStr, 10),
  30222. parseInt(hourStr, 10),
  30223. parseInt(minuteStr, 10),
  30224. ];
  30225. if (secondStr) {
  30226. result.push(parseInt(secondStr, 10));
  30227. }
  30228. return result;
  30229. }
  30230. function untruncateYear(yearStr) {
  30231. var year = parseInt(yearStr, 10);
  30232. if (year <= 49) {
  30233. return 2000 + year;
  30234. } else if (year <= 999) {
  30235. return 1900 + year;
  30236. }
  30237. return year;
  30238. }
  30239. function preprocessRFC2822(s) {
  30240. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  30241. return s
  30242. .replace(/\([^)]*\)|[\n\t]/g, ' ')
  30243. .replace(/(\s\s+)/g, ' ')
  30244. .replace(/^\s\s*/, '')
  30245. .replace(/\s\s*$/, '');
  30246. }
  30247. function checkWeekday(weekdayStr, parsedInput, config) {
  30248. if (weekdayStr) {
  30249. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  30250. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  30251. weekdayActual = new Date(
  30252. parsedInput[0],
  30253. parsedInput[1],
  30254. parsedInput[2]
  30255. ).getDay();
  30256. if (weekdayProvided !== weekdayActual) {
  30257. getParsingFlags(config).weekdayMismatch = true;
  30258. config._isValid = false;
  30259. return false;
  30260. }
  30261. }
  30262. return true;
  30263. }
  30264. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  30265. if (obsOffset) {
  30266. return obsOffsets[obsOffset];
  30267. } else if (militaryOffset) {
  30268. // the only allowed military tz is Z
  30269. return 0;
  30270. } else {
  30271. var hm = parseInt(numOffset, 10),
  30272. m = hm % 100,
  30273. h = (hm - m) / 100;
  30274. return h * 60 + m;
  30275. }
  30276. }
  30277. // date and time from ref 2822 format
  30278. function configFromRFC2822(config) {
  30279. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  30280. parsedArray;
  30281. if (match) {
  30282. parsedArray = extractFromRFC2822Strings(
  30283. match[4],
  30284. match[3],
  30285. match[2],
  30286. match[5],
  30287. match[6],
  30288. match[7]
  30289. );
  30290. if (!checkWeekday(match[1], parsedArray, config)) {
  30291. return;
  30292. }
  30293. config._a = parsedArray;
  30294. config._tzm = calculateOffset(match[8], match[9], match[10]);
  30295. config._d = createUTCDate.apply(null, config._a);
  30296. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  30297. getParsingFlags(config).rfc2822 = true;
  30298. } else {
  30299. config._isValid = false;
  30300. }
  30301. }
  30302. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  30303. function configFromString(config) {
  30304. var matched = aspNetJsonRegex.exec(config._i);
  30305. if (matched !== null) {
  30306. config._d = new Date(+matched[1]);
  30307. return;
  30308. }
  30309. configFromISO(config);
  30310. if (config._isValid === false) {
  30311. delete config._isValid;
  30312. } else {
  30313. return;
  30314. }
  30315. configFromRFC2822(config);
  30316. if (config._isValid === false) {
  30317. delete config._isValid;
  30318. } else {
  30319. return;
  30320. }
  30321. if (config._strict) {
  30322. config._isValid = false;
  30323. } else {
  30324. // Final attempt, use Input Fallback
  30325. hooks.createFromInputFallback(config);
  30326. }
  30327. }
  30328. hooks.createFromInputFallback = deprecate(
  30329. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  30330. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  30331. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  30332. function (config) {
  30333. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  30334. }
  30335. );
  30336. // Pick the first defined of two or three arguments.
  30337. function defaults(a, b, c) {
  30338. if (a != null) {
  30339. return a;
  30340. }
  30341. if (b != null) {
  30342. return b;
  30343. }
  30344. return c;
  30345. }
  30346. function currentDateArray(config) {
  30347. // hooks is actually the exported moment object
  30348. var nowValue = new Date(hooks.now());
  30349. if (config._useUTC) {
  30350. return [
  30351. nowValue.getUTCFullYear(),
  30352. nowValue.getUTCMonth(),
  30353. nowValue.getUTCDate(),
  30354. ];
  30355. }
  30356. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  30357. }
  30358. // convert an array to a date.
  30359. // the array should mirror the parameters below
  30360. // note: all values past the year are optional and will default to the lowest possible value.
  30361. // [year, month, day , hour, minute, second, millisecond]
  30362. function configFromArray(config) {
  30363. var i,
  30364. date,
  30365. input = [],
  30366. currentDate,
  30367. expectedWeekday,
  30368. yearToUse;
  30369. if (config._d) {
  30370. return;
  30371. }
  30372. currentDate = currentDateArray(config);
  30373. //compute day of the year from weeks and weekdays
  30374. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  30375. dayOfYearFromWeekInfo(config);
  30376. }
  30377. //if the day of the year is set, figure out what it is
  30378. if (config._dayOfYear != null) {
  30379. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  30380. if (
  30381. config._dayOfYear > daysInYear(yearToUse) ||
  30382. config._dayOfYear === 0
  30383. ) {
  30384. getParsingFlags(config)._overflowDayOfYear = true;
  30385. }
  30386. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  30387. config._a[MONTH] = date.getUTCMonth();
  30388. config._a[DATE] = date.getUTCDate();
  30389. }
  30390. // Default to current date.
  30391. // * if no year, month, day of month are given, default to today
  30392. // * if day of month is given, default month and year
  30393. // * if month is given, default only year
  30394. // * if year is given, don't default anything
  30395. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  30396. config._a[i] = input[i] = currentDate[i];
  30397. }
  30398. // Zero out whatever was not defaulted, including time
  30399. for (; i < 7; i++) {
  30400. config._a[i] = input[i] =
  30401. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  30402. }
  30403. // Check for 24:00:00.000
  30404. if (
  30405. config._a[HOUR] === 24 &&
  30406. config._a[MINUTE] === 0 &&
  30407. config._a[SECOND] === 0 &&
  30408. config._a[MILLISECOND] === 0
  30409. ) {
  30410. config._nextDay = true;
  30411. config._a[HOUR] = 0;
  30412. }
  30413. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  30414. null,
  30415. input
  30416. );
  30417. expectedWeekday = config._useUTC
  30418. ? config._d.getUTCDay()
  30419. : config._d.getDay();
  30420. // Apply timezone offset from input. The actual utcOffset can be changed
  30421. // with parseZone.
  30422. if (config._tzm != null) {
  30423. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  30424. }
  30425. if (config._nextDay) {
  30426. config._a[HOUR] = 24;
  30427. }
  30428. // check for mismatching day of week
  30429. if (
  30430. config._w &&
  30431. typeof config._w.d !== 'undefined' &&
  30432. config._w.d !== expectedWeekday
  30433. ) {
  30434. getParsingFlags(config).weekdayMismatch = true;
  30435. }
  30436. }
  30437. function dayOfYearFromWeekInfo(config) {
  30438. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  30439. w = config._w;
  30440. if (w.GG != null || w.W != null || w.E != null) {
  30441. dow = 1;
  30442. doy = 4;
  30443. // TODO: We need to take the current isoWeekYear, but that depends on
  30444. // how we interpret now (local, utc, fixed offset). So create
  30445. // a now version of current config (take local/utc/offset flags, and
  30446. // create now).
  30447. weekYear = defaults(
  30448. w.GG,
  30449. config._a[YEAR],
  30450. weekOfYear(createLocal(), 1, 4).year
  30451. );
  30452. week = defaults(w.W, 1);
  30453. weekday = defaults(w.E, 1);
  30454. if (weekday < 1 || weekday > 7) {
  30455. weekdayOverflow = true;
  30456. }
  30457. } else {
  30458. dow = config._locale._week.dow;
  30459. doy = config._locale._week.doy;
  30460. curWeek = weekOfYear(createLocal(), dow, doy);
  30461. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  30462. // Default to current week.
  30463. week = defaults(w.w, curWeek.week);
  30464. if (w.d != null) {
  30465. // weekday -- low day numbers are considered next week
  30466. weekday = w.d;
  30467. if (weekday < 0 || weekday > 6) {
  30468. weekdayOverflow = true;
  30469. }
  30470. } else if (w.e != null) {
  30471. // local weekday -- counting starts from beginning of week
  30472. weekday = w.e + dow;
  30473. if (w.e < 0 || w.e > 6) {
  30474. weekdayOverflow = true;
  30475. }
  30476. } else {
  30477. // default to beginning of week
  30478. weekday = dow;
  30479. }
  30480. }
  30481. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  30482. getParsingFlags(config)._overflowWeeks = true;
  30483. } else if (weekdayOverflow != null) {
  30484. getParsingFlags(config)._overflowWeekday = true;
  30485. } else {
  30486. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  30487. config._a[YEAR] = temp.year;
  30488. config._dayOfYear = temp.dayOfYear;
  30489. }
  30490. }
  30491. // constant that refers to the ISO standard
  30492. hooks.ISO_8601 = function () {};
  30493. // constant that refers to the RFC 2822 form
  30494. hooks.RFC_2822 = function () {};
  30495. // date from string and format string
  30496. function configFromStringAndFormat(config) {
  30497. // TODO: Move this to another part of the creation flow to prevent circular deps
  30498. if (config._f === hooks.ISO_8601) {
  30499. configFromISO(config);
  30500. return;
  30501. }
  30502. if (config._f === hooks.RFC_2822) {
  30503. configFromRFC2822(config);
  30504. return;
  30505. }
  30506. config._a = [];
  30507. getParsingFlags(config).empty = true;
  30508. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  30509. var string = '' + config._i,
  30510. i,
  30511. parsedInput,
  30512. tokens,
  30513. token,
  30514. skipped,
  30515. stringLength = string.length,
  30516. totalParsedInputLength = 0,
  30517. era;
  30518. tokens =
  30519. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  30520. for (i = 0; i < tokens.length; i++) {
  30521. token = tokens[i];
  30522. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  30523. [])[0];
  30524. if (parsedInput) {
  30525. skipped = string.substr(0, string.indexOf(parsedInput));
  30526. if (skipped.length > 0) {
  30527. getParsingFlags(config).unusedInput.push(skipped);
  30528. }
  30529. string = string.slice(
  30530. string.indexOf(parsedInput) + parsedInput.length
  30531. );
  30532. totalParsedInputLength += parsedInput.length;
  30533. }
  30534. // don't parse if it's not a known token
  30535. if (formatTokenFunctions[token]) {
  30536. if (parsedInput) {
  30537. getParsingFlags(config).empty = false;
  30538. } else {
  30539. getParsingFlags(config).unusedTokens.push(token);
  30540. }
  30541. addTimeToArrayFromToken(token, parsedInput, config);
  30542. } else if (config._strict && !parsedInput) {
  30543. getParsingFlags(config).unusedTokens.push(token);
  30544. }
  30545. }
  30546. // add remaining unparsed input length to the string
  30547. getParsingFlags(config).charsLeftOver =
  30548. stringLength - totalParsedInputLength;
  30549. if (string.length > 0) {
  30550. getParsingFlags(config).unusedInput.push(string);
  30551. }
  30552. // clear _12h flag if hour is <= 12
  30553. if (
  30554. config._a[HOUR] <= 12 &&
  30555. getParsingFlags(config).bigHour === true &&
  30556. config._a[HOUR] > 0
  30557. ) {
  30558. getParsingFlags(config).bigHour = undefined;
  30559. }
  30560. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  30561. getParsingFlags(config).meridiem = config._meridiem;
  30562. // handle meridiem
  30563. config._a[HOUR] = meridiemFixWrap(
  30564. config._locale,
  30565. config._a[HOUR],
  30566. config._meridiem
  30567. );
  30568. // handle era
  30569. era = getParsingFlags(config).era;
  30570. if (era !== null) {
  30571. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  30572. }
  30573. configFromArray(config);
  30574. checkOverflow(config);
  30575. }
  30576. function meridiemFixWrap(locale, hour, meridiem) {
  30577. var isPm;
  30578. if (meridiem == null) {
  30579. // nothing to do
  30580. return hour;
  30581. }
  30582. if (locale.meridiemHour != null) {
  30583. return locale.meridiemHour(hour, meridiem);
  30584. } else if (locale.isPM != null) {
  30585. // Fallback
  30586. isPm = locale.isPM(meridiem);
  30587. if (isPm && hour < 12) {
  30588. hour += 12;
  30589. }
  30590. if (!isPm && hour === 12) {
  30591. hour = 0;
  30592. }
  30593. return hour;
  30594. } else {
  30595. // this is not supposed to happen
  30596. return hour;
  30597. }
  30598. }
  30599. // date from string and array of format strings
  30600. function configFromStringAndArray(config) {
  30601. var tempConfig,
  30602. bestMoment,
  30603. scoreToBeat,
  30604. i,
  30605. currentScore,
  30606. validFormatFound,
  30607. bestFormatIsValid = false;
  30608. if (config._f.length === 0) {
  30609. getParsingFlags(config).invalidFormat = true;
  30610. config._d = new Date(NaN);
  30611. return;
  30612. }
  30613. for (i = 0; i < config._f.length; i++) {
  30614. currentScore = 0;
  30615. validFormatFound = false;
  30616. tempConfig = copyConfig({}, config);
  30617. if (config._useUTC != null) {
  30618. tempConfig._useUTC = config._useUTC;
  30619. }
  30620. tempConfig._f = config._f[i];
  30621. configFromStringAndFormat(tempConfig);
  30622. if (isValid(tempConfig)) {
  30623. validFormatFound = true;
  30624. }
  30625. // if there is any input that was not parsed add a penalty for that format
  30626. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  30627. //or tokens
  30628. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  30629. getParsingFlags(tempConfig).score = currentScore;
  30630. if (!bestFormatIsValid) {
  30631. if (
  30632. scoreToBeat == null ||
  30633. currentScore < scoreToBeat ||
  30634. validFormatFound
  30635. ) {
  30636. scoreToBeat = currentScore;
  30637. bestMoment = tempConfig;
  30638. if (validFormatFound) {
  30639. bestFormatIsValid = true;
  30640. }
  30641. }
  30642. } else {
  30643. if (currentScore < scoreToBeat) {
  30644. scoreToBeat = currentScore;
  30645. bestMoment = tempConfig;
  30646. }
  30647. }
  30648. }
  30649. extend(config, bestMoment || tempConfig);
  30650. }
  30651. function configFromObject(config) {
  30652. if (config._d) {
  30653. return;
  30654. }
  30655. var i = normalizeObjectUnits(config._i),
  30656. dayOrDate = i.day === undefined ? i.date : i.day;
  30657. config._a = map(
  30658. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  30659. function (obj) {
  30660. return obj && parseInt(obj, 10);
  30661. }
  30662. );
  30663. configFromArray(config);
  30664. }
  30665. function createFromConfig(config) {
  30666. var res = new Moment(checkOverflow(prepareConfig(config)));
  30667. if (res._nextDay) {
  30668. // Adding is smart enough around DST
  30669. res.add(1, 'd');
  30670. res._nextDay = undefined;
  30671. }
  30672. return res;
  30673. }
  30674. function prepareConfig(config) {
  30675. var input = config._i,
  30676. format = config._f;
  30677. config._locale = config._locale || getLocale(config._l);
  30678. if (input === null || (format === undefined && input === '')) {
  30679. return createInvalid({ nullInput: true });
  30680. }
  30681. if (typeof input === 'string') {
  30682. config._i = input = config._locale.preparse(input);
  30683. }
  30684. if (isMoment(input)) {
  30685. return new Moment(checkOverflow(input));
  30686. } else if (isDate(input)) {
  30687. config._d = input;
  30688. } else if (isArray(format)) {
  30689. configFromStringAndArray(config);
  30690. } else if (format) {
  30691. configFromStringAndFormat(config);
  30692. } else {
  30693. configFromInput(config);
  30694. }
  30695. if (!isValid(config)) {
  30696. config._d = null;
  30697. }
  30698. return config;
  30699. }
  30700. function configFromInput(config) {
  30701. var input = config._i;
  30702. if (isUndefined(input)) {
  30703. config._d = new Date(hooks.now());
  30704. } else if (isDate(input)) {
  30705. config._d = new Date(input.valueOf());
  30706. } else if (typeof input === 'string') {
  30707. configFromString(config);
  30708. } else if (isArray(input)) {
  30709. config._a = map(input.slice(0), function (obj) {
  30710. return parseInt(obj, 10);
  30711. });
  30712. configFromArray(config);
  30713. } else if (isObject(input)) {
  30714. configFromObject(config);
  30715. } else if (isNumber(input)) {
  30716. // from milliseconds
  30717. config._d = new Date(input);
  30718. } else {
  30719. hooks.createFromInputFallback(config);
  30720. }
  30721. }
  30722. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  30723. var c = {};
  30724. if (format === true || format === false) {
  30725. strict = format;
  30726. format = undefined;
  30727. }
  30728. if (locale === true || locale === false) {
  30729. strict = locale;
  30730. locale = undefined;
  30731. }
  30732. if (
  30733. (isObject(input) && isObjectEmpty(input)) ||
  30734. (isArray(input) && input.length === 0)
  30735. ) {
  30736. input = undefined;
  30737. }
  30738. // object construction must be done this way.
  30739. // https://github.com/moment/moment/issues/1423
  30740. c._isAMomentObject = true;
  30741. c._useUTC = c._isUTC = isUTC;
  30742. c._l = locale;
  30743. c._i = input;
  30744. c._f = format;
  30745. c._strict = strict;
  30746. return createFromConfig(c);
  30747. }
  30748. function createLocal(input, format, locale, strict) {
  30749. return createLocalOrUTC(input, format, locale, strict, false);
  30750. }
  30751. var prototypeMin = deprecate(
  30752. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  30753. function () {
  30754. var other = createLocal.apply(null, arguments);
  30755. if (this.isValid() && other.isValid()) {
  30756. return other < this ? this : other;
  30757. } else {
  30758. return createInvalid();
  30759. }
  30760. }
  30761. ),
  30762. prototypeMax = deprecate(
  30763. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  30764. function () {
  30765. var other = createLocal.apply(null, arguments);
  30766. if (this.isValid() && other.isValid()) {
  30767. return other > this ? this : other;
  30768. } else {
  30769. return createInvalid();
  30770. }
  30771. }
  30772. );
  30773. // Pick a moment m from moments so that m[fn](other) is true for all
  30774. // other. This relies on the function fn to be transitive.
  30775. //
  30776. // moments should either be an array of moment objects or an array, whose
  30777. // first element is an array of moment objects.
  30778. function pickBy(fn, moments) {
  30779. var res, i;
  30780. if (moments.length === 1 && isArray(moments[0])) {
  30781. moments = moments[0];
  30782. }
  30783. if (!moments.length) {
  30784. return createLocal();
  30785. }
  30786. res = moments[0];
  30787. for (i = 1; i < moments.length; ++i) {
  30788. if (!moments[i].isValid() || moments[i][fn](res)) {
  30789. res = moments[i];
  30790. }
  30791. }
  30792. return res;
  30793. }
  30794. // TODO: Use [].sort instead?
  30795. function min() {
  30796. var args = [].slice.call(arguments, 0);
  30797. return pickBy('isBefore', args);
  30798. }
  30799. function max() {
  30800. var args = [].slice.call(arguments, 0);
  30801. return pickBy('isAfter', args);
  30802. }
  30803. var now = function () {
  30804. return Date.now ? Date.now() : +new Date();
  30805. };
  30806. var ordering = [
  30807. 'year',
  30808. 'quarter',
  30809. 'month',
  30810. 'week',
  30811. 'day',
  30812. 'hour',
  30813. 'minute',
  30814. 'second',
  30815. 'millisecond',
  30816. ];
  30817. function isDurationValid(m) {
  30818. var key,
  30819. unitHasDecimal = false,
  30820. i;
  30821. for (key in m) {
  30822. if (
  30823. hasOwnProp(m, key) &&
  30824. !(
  30825. indexOf.call(ordering, key) !== -1 &&
  30826. (m[key] == null || !isNaN(m[key]))
  30827. )
  30828. ) {
  30829. return false;
  30830. }
  30831. }
  30832. for (i = 0; i < ordering.length; ++i) {
  30833. if (m[ordering[i]]) {
  30834. if (unitHasDecimal) {
  30835. return false; // only allow non-integers for smallest unit
  30836. }
  30837. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  30838. unitHasDecimal = true;
  30839. }
  30840. }
  30841. }
  30842. return true;
  30843. }
  30844. function isValid$1() {
  30845. return this._isValid;
  30846. }
  30847. function createInvalid$1() {
  30848. return createDuration(NaN);
  30849. }
  30850. function Duration(duration) {
  30851. var normalizedInput = normalizeObjectUnits(duration),
  30852. years = normalizedInput.year || 0,
  30853. quarters = normalizedInput.quarter || 0,
  30854. months = normalizedInput.month || 0,
  30855. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  30856. days = normalizedInput.day || 0,
  30857. hours = normalizedInput.hour || 0,
  30858. minutes = normalizedInput.minute || 0,
  30859. seconds = normalizedInput.second || 0,
  30860. milliseconds = normalizedInput.millisecond || 0;
  30861. this._isValid = isDurationValid(normalizedInput);
  30862. // representation for dateAddRemove
  30863. this._milliseconds =
  30864. +milliseconds +
  30865. seconds * 1e3 + // 1000
  30866. minutes * 6e4 + // 1000 * 60
  30867. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  30868. // Because of dateAddRemove treats 24 hours as different from a
  30869. // day when working around DST, we need to store them separately
  30870. this._days = +days + weeks * 7;
  30871. // It is impossible to translate months into days without knowing
  30872. // which months you are are talking about, so we have to store
  30873. // it separately.
  30874. this._months = +months + quarters * 3 + years * 12;
  30875. this._data = {};
  30876. this._locale = getLocale();
  30877. this._bubble();
  30878. }
  30879. function isDuration(obj) {
  30880. return obj instanceof Duration;
  30881. }
  30882. function absRound(number) {
  30883. if (number < 0) {
  30884. return Math.round(-1 * number) * -1;
  30885. } else {
  30886. return Math.round(number);
  30887. }
  30888. }
  30889. // compare two arrays, return the number of differences
  30890. function compareArrays(array1, array2, dontConvert) {
  30891. var len = Math.min(array1.length, array2.length),
  30892. lengthDiff = Math.abs(array1.length - array2.length),
  30893. diffs = 0,
  30894. i;
  30895. for (i = 0; i < len; i++) {
  30896. if (
  30897. (dontConvert && array1[i] !== array2[i]) ||
  30898. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  30899. ) {
  30900. diffs++;
  30901. }
  30902. }
  30903. return diffs + lengthDiff;
  30904. }
  30905. // FORMATTING
  30906. function offset(token, separator) {
  30907. addFormatToken(token, 0, 0, function () {
  30908. var offset = this.utcOffset(),
  30909. sign = '+';
  30910. if (offset < 0) {
  30911. offset = -offset;
  30912. sign = '-';
  30913. }
  30914. return (
  30915. sign +
  30916. zeroFill(~~(offset / 60), 2) +
  30917. separator +
  30918. zeroFill(~~offset % 60, 2)
  30919. );
  30920. });
  30921. }
  30922. offset('Z', ':');
  30923. offset('ZZ', '');
  30924. // PARSING
  30925. addRegexToken('Z', matchShortOffset);
  30926. addRegexToken('ZZ', matchShortOffset);
  30927. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  30928. config._useUTC = true;
  30929. config._tzm = offsetFromString(matchShortOffset, input);
  30930. });
  30931. // HELPERS
  30932. // timezone chunker
  30933. // '+10:00' > ['10', '00']
  30934. // '-1530' > ['-15', '30']
  30935. var chunkOffset = /([\+\-]|\d\d)/gi;
  30936. function offsetFromString(matcher, string) {
  30937. var matches = (string || '').match(matcher),
  30938. chunk,
  30939. parts,
  30940. minutes;
  30941. if (matches === null) {
  30942. return null;
  30943. }
  30944. chunk = matches[matches.length - 1] || [];
  30945. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  30946. minutes = +(parts[1] * 60) + toInt(parts[2]);
  30947. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  30948. }
  30949. // Return a moment from input, that is local/utc/zone equivalent to model.
  30950. function cloneWithOffset(input, model) {
  30951. var res, diff;
  30952. if (model._isUTC) {
  30953. res = model.clone();
  30954. diff =
  30955. (isMoment(input) || isDate(input)
  30956. ? input.valueOf()
  30957. : createLocal(input).valueOf()) - res.valueOf();
  30958. // Use low-level api, because this fn is low-level api.
  30959. res._d.setTime(res._d.valueOf() + diff);
  30960. hooks.updateOffset(res, false);
  30961. return res;
  30962. } else {
  30963. return createLocal(input).local();
  30964. }
  30965. }
  30966. function getDateOffset(m) {
  30967. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  30968. // https://github.com/moment/moment/pull/1871
  30969. return -Math.round(m._d.getTimezoneOffset());
  30970. }
  30971. // HOOKS
  30972. // This function will be called whenever a moment is mutated.
  30973. // It is intended to keep the offset in sync with the timezone.
  30974. hooks.updateOffset = function () {};
  30975. // MOMENTS
  30976. // keepLocalTime = true means only change the timezone, without
  30977. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  30978. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  30979. // +0200, so we adjust the time as needed, to be valid.
  30980. //
  30981. // Keeping the time actually adds/subtracts (one hour)
  30982. // from the actual represented time. That is why we call updateOffset
  30983. // a second time. In case it wants us to change the offset again
  30984. // _changeInProgress == true case, then we have to adjust, because
  30985. // there is no such time in the given timezone.
  30986. function getSetOffset(input, keepLocalTime, keepMinutes) {
  30987. var offset = this._offset || 0,
  30988. localAdjust;
  30989. if (!this.isValid()) {
  30990. return input != null ? this : NaN;
  30991. }
  30992. if (input != null) {
  30993. if (typeof input === 'string') {
  30994. input = offsetFromString(matchShortOffset, input);
  30995. if (input === null) {
  30996. return this;
  30997. }
  30998. } else if (Math.abs(input) < 16 && !keepMinutes) {
  30999. input = input * 60;
  31000. }
  31001. if (!this._isUTC && keepLocalTime) {
  31002. localAdjust = getDateOffset(this);
  31003. }
  31004. this._offset = input;
  31005. this._isUTC = true;
  31006. if (localAdjust != null) {
  31007. this.add(localAdjust, 'm');
  31008. }
  31009. if (offset !== input) {
  31010. if (!keepLocalTime || this._changeInProgress) {
  31011. addSubtract(
  31012. this,
  31013. createDuration(input - offset, 'm'),
  31014. 1,
  31015. false
  31016. );
  31017. } else if (!this._changeInProgress) {
  31018. this._changeInProgress = true;
  31019. hooks.updateOffset(this, true);
  31020. this._changeInProgress = null;
  31021. }
  31022. }
  31023. return this;
  31024. } else {
  31025. return this._isUTC ? offset : getDateOffset(this);
  31026. }
  31027. }
  31028. function getSetZone(input, keepLocalTime) {
  31029. if (input != null) {
  31030. if (typeof input !== 'string') {
  31031. input = -input;
  31032. }
  31033. this.utcOffset(input, keepLocalTime);
  31034. return this;
  31035. } else {
  31036. return -this.utcOffset();
  31037. }
  31038. }
  31039. function setOffsetToUTC(keepLocalTime) {
  31040. return this.utcOffset(0, keepLocalTime);
  31041. }
  31042. function setOffsetToLocal(keepLocalTime) {
  31043. if (this._isUTC) {
  31044. this.utcOffset(0, keepLocalTime);
  31045. this._isUTC = false;
  31046. if (keepLocalTime) {
  31047. this.subtract(getDateOffset(this), 'm');
  31048. }
  31049. }
  31050. return this;
  31051. }
  31052. function setOffsetToParsedOffset() {
  31053. if (this._tzm != null) {
  31054. this.utcOffset(this._tzm, false, true);
  31055. } else if (typeof this._i === 'string') {
  31056. var tZone = offsetFromString(matchOffset, this._i);
  31057. if (tZone != null) {
  31058. this.utcOffset(tZone);
  31059. } else {
  31060. this.utcOffset(0, true);
  31061. }
  31062. }
  31063. return this;
  31064. }
  31065. function hasAlignedHourOffset(input) {
  31066. if (!this.isValid()) {
  31067. return false;
  31068. }
  31069. input = input ? createLocal(input).utcOffset() : 0;
  31070. return (this.utcOffset() - input) % 60 === 0;
  31071. }
  31072. function isDaylightSavingTime() {
  31073. return (
  31074. this.utcOffset() > this.clone().month(0).utcOffset() ||
  31075. this.utcOffset() > this.clone().month(5).utcOffset()
  31076. );
  31077. }
  31078. function isDaylightSavingTimeShifted() {
  31079. if (!isUndefined(this._isDSTShifted)) {
  31080. return this._isDSTShifted;
  31081. }
  31082. var c = {},
  31083. other;
  31084. copyConfig(c, this);
  31085. c = prepareConfig(c);
  31086. if (c._a) {
  31087. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  31088. this._isDSTShifted =
  31089. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  31090. } else {
  31091. this._isDSTShifted = false;
  31092. }
  31093. return this._isDSTShifted;
  31094. }
  31095. function isLocal() {
  31096. return this.isValid() ? !this._isUTC : false;
  31097. }
  31098. function isUtcOffset() {
  31099. return this.isValid() ? this._isUTC : false;
  31100. }
  31101. function isUtc() {
  31102. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  31103. }
  31104. // ASP.NET json date format regex
  31105. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  31106. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  31107. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  31108. // and further modified to allow for strings containing both week and day
  31109. isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  31110. function createDuration(input, key) {
  31111. var duration = input,
  31112. // matching against regexp is expensive, do it on demand
  31113. match = null,
  31114. sign,
  31115. ret,
  31116. diffRes;
  31117. if (isDuration(input)) {
  31118. duration = {
  31119. ms: input._milliseconds,
  31120. d: input._days,
  31121. M: input._months,
  31122. };
  31123. } else if (isNumber(input) || !isNaN(+input)) {
  31124. duration = {};
  31125. if (key) {
  31126. duration[key] = +input;
  31127. } else {
  31128. duration.milliseconds = +input;
  31129. }
  31130. } else if ((match = aspNetRegex.exec(input))) {
  31131. sign = match[1] === '-' ? -1 : 1;
  31132. duration = {
  31133. y: 0,
  31134. d: toInt(match[DATE]) * sign,
  31135. h: toInt(match[HOUR]) * sign,
  31136. m: toInt(match[MINUTE]) * sign,
  31137. s: toInt(match[SECOND]) * sign,
  31138. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  31139. };
  31140. } else if ((match = isoRegex.exec(input))) {
  31141. sign = match[1] === '-' ? -1 : 1;
  31142. duration = {
  31143. y: parseIso(match[2], sign),
  31144. M: parseIso(match[3], sign),
  31145. w: parseIso(match[4], sign),
  31146. d: parseIso(match[5], sign),
  31147. h: parseIso(match[6], sign),
  31148. m: parseIso(match[7], sign),
  31149. s: parseIso(match[8], sign),
  31150. };
  31151. } else if (duration == null) {
  31152. // checks for null or undefined
  31153. duration = {};
  31154. } else if (
  31155. typeof duration === 'object' &&
  31156. ('from' in duration || 'to' in duration)
  31157. ) {
  31158. diffRes = momentsDifference(
  31159. createLocal(duration.from),
  31160. createLocal(duration.to)
  31161. );
  31162. duration = {};
  31163. duration.ms = diffRes.milliseconds;
  31164. duration.M = diffRes.months;
  31165. }
  31166. ret = new Duration(duration);
  31167. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  31168. ret._locale = input._locale;
  31169. }
  31170. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  31171. ret._isValid = input._isValid;
  31172. }
  31173. return ret;
  31174. }
  31175. createDuration.fn = Duration.prototype;
  31176. createDuration.invalid = createInvalid$1;
  31177. function parseIso(inp, sign) {
  31178. // We'd normally use ~~inp for this, but unfortunately it also
  31179. // converts floats to ints.
  31180. // inp may be undefined, so careful calling replace on it.
  31181. var res = inp && parseFloat(inp.replace(',', '.'));
  31182. // apply sign while we're at it
  31183. return (isNaN(res) ? 0 : res) * sign;
  31184. }
  31185. function positiveMomentsDifference(base, other) {
  31186. var res = {};
  31187. res.months =
  31188. other.month() - base.month() + (other.year() - base.year()) * 12;
  31189. if (base.clone().add(res.months, 'M').isAfter(other)) {
  31190. --res.months;
  31191. }
  31192. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  31193. return res;
  31194. }
  31195. function momentsDifference(base, other) {
  31196. var res;
  31197. if (!(base.isValid() && other.isValid())) {
  31198. return { milliseconds: 0, months: 0 };
  31199. }
  31200. other = cloneWithOffset(other, base);
  31201. if (base.isBefore(other)) {
  31202. res = positiveMomentsDifference(base, other);
  31203. } else {
  31204. res = positiveMomentsDifference(other, base);
  31205. res.milliseconds = -res.milliseconds;
  31206. res.months = -res.months;
  31207. }
  31208. return res;
  31209. }
  31210. // TODO: remove 'name' arg after deprecation is removed
  31211. function createAdder(direction, name) {
  31212. return function (val, period) {
  31213. var dur, tmp;
  31214. //invert the arguments, but complain about it
  31215. if (period !== null && !isNaN(+period)) {
  31216. deprecateSimple(
  31217. name,
  31218. 'moment().' +
  31219. name +
  31220. '(period, number) is deprecated. Please use moment().' +
  31221. name +
  31222. '(number, period). ' +
  31223. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  31224. );
  31225. tmp = val;
  31226. val = period;
  31227. period = tmp;
  31228. }
  31229. dur = createDuration(val, period);
  31230. addSubtract(this, dur, direction);
  31231. return this;
  31232. };
  31233. }
  31234. function addSubtract(mom, duration, isAdding, updateOffset) {
  31235. var milliseconds = duration._milliseconds,
  31236. days = absRound(duration._days),
  31237. months = absRound(duration._months);
  31238. if (!mom.isValid()) {
  31239. // No op
  31240. return;
  31241. }
  31242. updateOffset = updateOffset == null ? true : updateOffset;
  31243. if (months) {
  31244. setMonth(mom, get(mom, 'Month') + months * isAdding);
  31245. }
  31246. if (days) {
  31247. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  31248. }
  31249. if (milliseconds) {
  31250. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  31251. }
  31252. if (updateOffset) {
  31253. hooks.updateOffset(mom, days || months);
  31254. }
  31255. }
  31256. var add = createAdder(1, 'add'),
  31257. subtract = createAdder(-1, 'subtract');
  31258. function isString(input) {
  31259. return typeof input === 'string' || input instanceof String;
  31260. }
  31261. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  31262. function isMomentInput(input) {
  31263. return (
  31264. isMoment(input) ||
  31265. isDate(input) ||
  31266. isString(input) ||
  31267. isNumber(input) ||
  31268. isNumberOrStringArray(input) ||
  31269. isMomentInputObject(input) ||
  31270. input === null ||
  31271. input === undefined
  31272. );
  31273. }
  31274. function isMomentInputObject(input) {
  31275. var objectTest = isObject(input) && !isObjectEmpty(input),
  31276. propertyTest = false,
  31277. properties = [
  31278. 'years',
  31279. 'year',
  31280. 'y',
  31281. 'months',
  31282. 'month',
  31283. 'M',
  31284. 'days',
  31285. 'day',
  31286. 'd',
  31287. 'dates',
  31288. 'date',
  31289. 'D',
  31290. 'hours',
  31291. 'hour',
  31292. 'h',
  31293. 'minutes',
  31294. 'minute',
  31295. 'm',
  31296. 'seconds',
  31297. 'second',
  31298. 's',
  31299. 'milliseconds',
  31300. 'millisecond',
  31301. 'ms',
  31302. ],
  31303. i,
  31304. property;
  31305. for (i = 0; i < properties.length; i += 1) {
  31306. property = properties[i];
  31307. propertyTest = propertyTest || hasOwnProp(input, property);
  31308. }
  31309. return objectTest && propertyTest;
  31310. }
  31311. function isNumberOrStringArray(input) {
  31312. var arrayTest = isArray(input),
  31313. dataTypeTest = false;
  31314. if (arrayTest) {
  31315. dataTypeTest =
  31316. input.filter(function (item) {
  31317. return !isNumber(item) && isString(input);
  31318. }).length === 0;
  31319. }
  31320. return arrayTest && dataTypeTest;
  31321. }
  31322. function isCalendarSpec(input) {
  31323. var objectTest = isObject(input) && !isObjectEmpty(input),
  31324. propertyTest = false,
  31325. properties = [
  31326. 'sameDay',
  31327. 'nextDay',
  31328. 'lastDay',
  31329. 'nextWeek',
  31330. 'lastWeek',
  31331. 'sameElse',
  31332. ],
  31333. i,
  31334. property;
  31335. for (i = 0; i < properties.length; i += 1) {
  31336. property = properties[i];
  31337. propertyTest = propertyTest || hasOwnProp(input, property);
  31338. }
  31339. return objectTest && propertyTest;
  31340. }
  31341. function getCalendarFormat(myMoment, now) {
  31342. var diff = myMoment.diff(now, 'days', true);
  31343. return diff < -6
  31344. ? 'sameElse'
  31345. : diff < -1
  31346. ? 'lastWeek'
  31347. : diff < 0
  31348. ? 'lastDay'
  31349. : diff < 1
  31350. ? 'sameDay'
  31351. : diff < 2
  31352. ? 'nextDay'
  31353. : diff < 7
  31354. ? 'nextWeek'
  31355. : 'sameElse';
  31356. }
  31357. function calendar$1(time, formats) {
  31358. // Support for single parameter, formats only overload to the calendar function
  31359. if (arguments.length === 1) {
  31360. if (!arguments[0]) {
  31361. time = undefined;
  31362. formats = undefined;
  31363. } else if (isMomentInput(arguments[0])) {
  31364. time = arguments[0];
  31365. formats = undefined;
  31366. } else if (isCalendarSpec(arguments[0])) {
  31367. formats = arguments[0];
  31368. time = undefined;
  31369. }
  31370. }
  31371. // We want to compare the start of today, vs this.
  31372. // Getting start-of-today depends on whether we're local/utc/offset or not.
  31373. var now = time || createLocal(),
  31374. sod = cloneWithOffset(now, this).startOf('day'),
  31375. format = hooks.calendarFormat(this, sod) || 'sameElse',
  31376. output =
  31377. formats &&
  31378. (isFunction(formats[format])
  31379. ? formats[format].call(this, now)
  31380. : formats[format]);
  31381. return this.format(
  31382. output || this.localeData().calendar(format, this, createLocal(now))
  31383. );
  31384. }
  31385. function clone() {
  31386. return new Moment(this);
  31387. }
  31388. function isAfter(input, units) {
  31389. var localInput = isMoment(input) ? input : createLocal(input);
  31390. if (!(this.isValid() && localInput.isValid())) {
  31391. return false;
  31392. }
  31393. units = normalizeUnits(units) || 'millisecond';
  31394. if (units === 'millisecond') {
  31395. return this.valueOf() > localInput.valueOf();
  31396. } else {
  31397. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  31398. }
  31399. }
  31400. function isBefore(input, units) {
  31401. var localInput = isMoment(input) ? input : createLocal(input);
  31402. if (!(this.isValid() && localInput.isValid())) {
  31403. return false;
  31404. }
  31405. units = normalizeUnits(units) || 'millisecond';
  31406. if (units === 'millisecond') {
  31407. return this.valueOf() < localInput.valueOf();
  31408. } else {
  31409. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  31410. }
  31411. }
  31412. function isBetween(from, to, units, inclusivity) {
  31413. var localFrom = isMoment(from) ? from : createLocal(from),
  31414. localTo = isMoment(to) ? to : createLocal(to);
  31415. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  31416. return false;
  31417. }
  31418. inclusivity = inclusivity || '()';
  31419. return (
  31420. (inclusivity[0] === '('
  31421. ? this.isAfter(localFrom, units)
  31422. : !this.isBefore(localFrom, units)) &&
  31423. (inclusivity[1] === ')'
  31424. ? this.isBefore(localTo, units)
  31425. : !this.isAfter(localTo, units))
  31426. );
  31427. }
  31428. function isSame(input, units) {
  31429. var localInput = isMoment(input) ? input : createLocal(input),
  31430. inputMs;
  31431. if (!(this.isValid() && localInput.isValid())) {
  31432. return false;
  31433. }
  31434. units = normalizeUnits(units) || 'millisecond';
  31435. if (units === 'millisecond') {
  31436. return this.valueOf() === localInput.valueOf();
  31437. } else {
  31438. inputMs = localInput.valueOf();
  31439. return (
  31440. this.clone().startOf(units).valueOf() <= inputMs &&
  31441. inputMs <= this.clone().endOf(units).valueOf()
  31442. );
  31443. }
  31444. }
  31445. function isSameOrAfter(input, units) {
  31446. return this.isSame(input, units) || this.isAfter(input, units);
  31447. }
  31448. function isSameOrBefore(input, units) {
  31449. return this.isSame(input, units) || this.isBefore(input, units);
  31450. }
  31451. function diff(input, units, asFloat) {
  31452. var that, zoneDelta, output;
  31453. if (!this.isValid()) {
  31454. return NaN;
  31455. }
  31456. that = cloneWithOffset(input, this);
  31457. if (!that.isValid()) {
  31458. return NaN;
  31459. }
  31460. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  31461. units = normalizeUnits(units);
  31462. switch (units) {
  31463. case 'year':
  31464. output = monthDiff(this, that) / 12;
  31465. break;
  31466. case 'month':
  31467. output = monthDiff(this, that);
  31468. break;
  31469. case 'quarter':
  31470. output = monthDiff(this, that) / 3;
  31471. break;
  31472. case 'second':
  31473. output = (this - that) / 1e3;
  31474. break; // 1000
  31475. case 'minute':
  31476. output = (this - that) / 6e4;
  31477. break; // 1000 * 60
  31478. case 'hour':
  31479. output = (this - that) / 36e5;
  31480. break; // 1000 * 60 * 60
  31481. case 'day':
  31482. output = (this - that - zoneDelta) / 864e5;
  31483. break; // 1000 * 60 * 60 * 24, negate dst
  31484. case 'week':
  31485. output = (this - that - zoneDelta) / 6048e5;
  31486. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  31487. default:
  31488. output = this - that;
  31489. }
  31490. return asFloat ? output : absFloor(output);
  31491. }
  31492. function monthDiff(a, b) {
  31493. if (a.date() < b.date()) {
  31494. // end-of-month calculations work correct when the start month has more
  31495. // days than the end month.
  31496. return -monthDiff(b, a);
  31497. }
  31498. // difference in months
  31499. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  31500. // b is in (anchor - 1 month, anchor + 1 month)
  31501. anchor = a.clone().add(wholeMonthDiff, 'months'),
  31502. anchor2,
  31503. adjust;
  31504. if (b - anchor < 0) {
  31505. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  31506. // linear across the month
  31507. adjust = (b - anchor) / (anchor - anchor2);
  31508. } else {
  31509. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  31510. // linear across the month
  31511. adjust = (b - anchor) / (anchor2 - anchor);
  31512. }
  31513. //check for negative zero, return zero if negative zero
  31514. return -(wholeMonthDiff + adjust) || 0;
  31515. }
  31516. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  31517. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  31518. function toString() {
  31519. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  31520. }
  31521. function toISOString(keepOffset) {
  31522. if (!this.isValid()) {
  31523. return null;
  31524. }
  31525. var utc = keepOffset !== true,
  31526. m = utc ? this.clone().utc() : this;
  31527. if (m.year() < 0 || m.year() > 9999) {
  31528. return formatMoment(
  31529. m,
  31530. utc
  31531. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  31532. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  31533. );
  31534. }
  31535. if (isFunction(Date.prototype.toISOString)) {
  31536. // native implementation is ~50x faster, use it when we can
  31537. if (utc) {
  31538. return this.toDate().toISOString();
  31539. } else {
  31540. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  31541. .toISOString()
  31542. .replace('Z', formatMoment(m, 'Z'));
  31543. }
  31544. }
  31545. return formatMoment(
  31546. m,
  31547. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  31548. );
  31549. }
  31550. /**
  31551. * Return a human readable representation of a moment that can
  31552. * also be evaluated to get a new moment which is the same
  31553. *
  31554. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  31555. */
  31556. function inspect() {
  31557. if (!this.isValid()) {
  31558. return 'moment.invalid(/* ' + this._i + ' */)';
  31559. }
  31560. var func = 'moment',
  31561. zone = '',
  31562. prefix,
  31563. year,
  31564. datetime,
  31565. suffix;
  31566. if (!this.isLocal()) {
  31567. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  31568. zone = 'Z';
  31569. }
  31570. prefix = '[' + func + '("]';
  31571. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  31572. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  31573. suffix = zone + '[")]';
  31574. return this.format(prefix + year + datetime + suffix);
  31575. }
  31576. function format(inputString) {
  31577. if (!inputString) {
  31578. inputString = this.isUtc()
  31579. ? hooks.defaultFormatUtc
  31580. : hooks.defaultFormat;
  31581. }
  31582. var output = formatMoment(this, inputString);
  31583. return this.localeData().postformat(output);
  31584. }
  31585. function from(time, withoutSuffix) {
  31586. if (
  31587. this.isValid() &&
  31588. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  31589. ) {
  31590. return createDuration({ to: this, from: time })
  31591. .locale(this.locale())
  31592. .humanize(!withoutSuffix);
  31593. } else {
  31594. return this.localeData().invalidDate();
  31595. }
  31596. }
  31597. function fromNow(withoutSuffix) {
  31598. return this.from(createLocal(), withoutSuffix);
  31599. }
  31600. function to(time, withoutSuffix) {
  31601. if (
  31602. this.isValid() &&
  31603. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  31604. ) {
  31605. return createDuration({ from: this, to: time })
  31606. .locale(this.locale())
  31607. .humanize(!withoutSuffix);
  31608. } else {
  31609. return this.localeData().invalidDate();
  31610. }
  31611. }
  31612. function toNow(withoutSuffix) {
  31613. return this.to(createLocal(), withoutSuffix);
  31614. }
  31615. // If passed a locale key, it will set the locale for this
  31616. // instance. Otherwise, it will return the locale configuration
  31617. // variables for this instance.
  31618. function locale(key) {
  31619. var newLocaleData;
  31620. if (key === undefined) {
  31621. return this._locale._abbr;
  31622. } else {
  31623. newLocaleData = getLocale(key);
  31624. if (newLocaleData != null) {
  31625. this._locale = newLocaleData;
  31626. }
  31627. return this;
  31628. }
  31629. }
  31630. var lang = deprecate(
  31631. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  31632. function (key) {
  31633. if (key === undefined) {
  31634. return this.localeData();
  31635. } else {
  31636. return this.locale(key);
  31637. }
  31638. }
  31639. );
  31640. function localeData() {
  31641. return this._locale;
  31642. }
  31643. var MS_PER_SECOND = 1000,
  31644. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  31645. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  31646. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  31647. // actual modulo - handles negative numbers (for dates before 1970):
  31648. function mod$1(dividend, divisor) {
  31649. return ((dividend % divisor) + divisor) % divisor;
  31650. }
  31651. function localStartOfDate(y, m, d) {
  31652. // the date constructor remaps years 0-99 to 1900-1999
  31653. if (y < 100 && y >= 0) {
  31654. // preserve leap years using a full 400 year cycle, then reset
  31655. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  31656. } else {
  31657. return new Date(y, m, d).valueOf();
  31658. }
  31659. }
  31660. function utcStartOfDate(y, m, d) {
  31661. // Date.UTC remaps years 0-99 to 1900-1999
  31662. if (y < 100 && y >= 0) {
  31663. // preserve leap years using a full 400 year cycle, then reset
  31664. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  31665. } else {
  31666. return Date.UTC(y, m, d);
  31667. }
  31668. }
  31669. function startOf(units) {
  31670. var time, startOfDate;
  31671. units = normalizeUnits(units);
  31672. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  31673. return this;
  31674. }
  31675. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  31676. switch (units) {
  31677. case 'year':
  31678. time = startOfDate(this.year(), 0, 1);
  31679. break;
  31680. case 'quarter':
  31681. time = startOfDate(
  31682. this.year(),
  31683. this.month() - (this.month() % 3),
  31684. 1
  31685. );
  31686. break;
  31687. case 'month':
  31688. time = startOfDate(this.year(), this.month(), 1);
  31689. break;
  31690. case 'week':
  31691. time = startOfDate(
  31692. this.year(),
  31693. this.month(),
  31694. this.date() - this.weekday()
  31695. );
  31696. break;
  31697. case 'isoWeek':
  31698. time = startOfDate(
  31699. this.year(),
  31700. this.month(),
  31701. this.date() - (this.isoWeekday() - 1)
  31702. );
  31703. break;
  31704. case 'day':
  31705. case 'date':
  31706. time = startOfDate(this.year(), this.month(), this.date());
  31707. break;
  31708. case 'hour':
  31709. time = this._d.valueOf();
  31710. time -= mod$1(
  31711. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  31712. MS_PER_HOUR
  31713. );
  31714. break;
  31715. case 'minute':
  31716. time = this._d.valueOf();
  31717. time -= mod$1(time, MS_PER_MINUTE);
  31718. break;
  31719. case 'second':
  31720. time = this._d.valueOf();
  31721. time -= mod$1(time, MS_PER_SECOND);
  31722. break;
  31723. }
  31724. this._d.setTime(time);
  31725. hooks.updateOffset(this, true);
  31726. return this;
  31727. }
  31728. function endOf(units) {
  31729. var time, startOfDate;
  31730. units = normalizeUnits(units);
  31731. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  31732. return this;
  31733. }
  31734. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  31735. switch (units) {
  31736. case 'year':
  31737. time = startOfDate(this.year() + 1, 0, 1) - 1;
  31738. break;
  31739. case 'quarter':
  31740. time =
  31741. startOfDate(
  31742. this.year(),
  31743. this.month() - (this.month() % 3) + 3,
  31744. 1
  31745. ) - 1;
  31746. break;
  31747. case 'month':
  31748. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  31749. break;
  31750. case 'week':
  31751. time =
  31752. startOfDate(
  31753. this.year(),
  31754. this.month(),
  31755. this.date() - this.weekday() + 7
  31756. ) - 1;
  31757. break;
  31758. case 'isoWeek':
  31759. time =
  31760. startOfDate(
  31761. this.year(),
  31762. this.month(),
  31763. this.date() - (this.isoWeekday() - 1) + 7
  31764. ) - 1;
  31765. break;
  31766. case 'day':
  31767. case 'date':
  31768. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  31769. break;
  31770. case 'hour':
  31771. time = this._d.valueOf();
  31772. time +=
  31773. MS_PER_HOUR -
  31774. mod$1(
  31775. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  31776. MS_PER_HOUR
  31777. ) -
  31778. 1;
  31779. break;
  31780. case 'minute':
  31781. time = this._d.valueOf();
  31782. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  31783. break;
  31784. case 'second':
  31785. time = this._d.valueOf();
  31786. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  31787. break;
  31788. }
  31789. this._d.setTime(time);
  31790. hooks.updateOffset(this, true);
  31791. return this;
  31792. }
  31793. function valueOf() {
  31794. return this._d.valueOf() - (this._offset || 0) * 60000;
  31795. }
  31796. function unix() {
  31797. return Math.floor(this.valueOf() / 1000);
  31798. }
  31799. function toDate() {
  31800. return new Date(this.valueOf());
  31801. }
  31802. function toArray() {
  31803. var m = this;
  31804. return [
  31805. m.year(),
  31806. m.month(),
  31807. m.date(),
  31808. m.hour(),
  31809. m.minute(),
  31810. m.second(),
  31811. m.millisecond(),
  31812. ];
  31813. }
  31814. function toObject() {
  31815. var m = this;
  31816. return {
  31817. years: m.year(),
  31818. months: m.month(),
  31819. date: m.date(),
  31820. hours: m.hours(),
  31821. minutes: m.minutes(),
  31822. seconds: m.seconds(),
  31823. milliseconds: m.milliseconds(),
  31824. };
  31825. }
  31826. function toJSON() {
  31827. // new Date(NaN).toJSON() === null
  31828. return this.isValid() ? this.toISOString() : null;
  31829. }
  31830. function isValid$2() {
  31831. return isValid(this);
  31832. }
  31833. function parsingFlags() {
  31834. return extend({}, getParsingFlags(this));
  31835. }
  31836. function invalidAt() {
  31837. return getParsingFlags(this).overflow;
  31838. }
  31839. function creationData() {
  31840. return {
  31841. input: this._i,
  31842. format: this._f,
  31843. locale: this._locale,
  31844. isUTC: this._isUTC,
  31845. strict: this._strict,
  31846. };
  31847. }
  31848. addFormatToken('N', 0, 0, 'eraAbbr');
  31849. addFormatToken('NN', 0, 0, 'eraAbbr');
  31850. addFormatToken('NNN', 0, 0, 'eraAbbr');
  31851. addFormatToken('NNNN', 0, 0, 'eraName');
  31852. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  31853. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  31854. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  31855. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  31856. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  31857. addRegexToken('N', matchEraAbbr);
  31858. addRegexToken('NN', matchEraAbbr);
  31859. addRegexToken('NNN', matchEraAbbr);
  31860. addRegexToken('NNNN', matchEraName);
  31861. addRegexToken('NNNNN', matchEraNarrow);
  31862. addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
  31863. input,
  31864. array,
  31865. config,
  31866. token
  31867. ) {
  31868. var era = config._locale.erasParse(input, token, config._strict);
  31869. if (era) {
  31870. getParsingFlags(config).era = era;
  31871. } else {
  31872. getParsingFlags(config).invalidEra = input;
  31873. }
  31874. });
  31875. addRegexToken('y', matchUnsigned);
  31876. addRegexToken('yy', matchUnsigned);
  31877. addRegexToken('yyy', matchUnsigned);
  31878. addRegexToken('yyyy', matchUnsigned);
  31879. addRegexToken('yo', matchEraYearOrdinal);
  31880. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  31881. addParseToken(['yo'], function (input, array, config, token) {
  31882. var match;
  31883. if (config._locale._eraYearOrdinalRegex) {
  31884. match = input.match(config._locale._eraYearOrdinalRegex);
  31885. }
  31886. if (config._locale.eraYearOrdinalParse) {
  31887. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  31888. } else {
  31889. array[YEAR] = parseInt(input, 10);
  31890. }
  31891. });
  31892. function localeEras(m, format) {
  31893. var i,
  31894. l,
  31895. date,
  31896. eras = this._eras || getLocale('en')._eras;
  31897. for (i = 0, l = eras.length; i < l; ++i) {
  31898. switch (typeof eras[i].since) {
  31899. case 'string':
  31900. // truncate time
  31901. date = hooks(eras[i].since).startOf('day');
  31902. eras[i].since = date.valueOf();
  31903. break;
  31904. }
  31905. switch (typeof eras[i].until) {
  31906. case 'undefined':
  31907. eras[i].until = +Infinity;
  31908. break;
  31909. case 'string':
  31910. // truncate time
  31911. date = hooks(eras[i].until).startOf('day').valueOf();
  31912. eras[i].until = date.valueOf();
  31913. break;
  31914. }
  31915. }
  31916. return eras;
  31917. }
  31918. function localeErasParse(eraName, format, strict) {
  31919. var i,
  31920. l,
  31921. eras = this.eras(),
  31922. name,
  31923. abbr,
  31924. narrow;
  31925. eraName = eraName.toUpperCase();
  31926. for (i = 0, l = eras.length; i < l; ++i) {
  31927. name = eras[i].name.toUpperCase();
  31928. abbr = eras[i].abbr.toUpperCase();
  31929. narrow = eras[i].narrow.toUpperCase();
  31930. if (strict) {
  31931. switch (format) {
  31932. case 'N':
  31933. case 'NN':
  31934. case 'NNN':
  31935. if (abbr === eraName) {
  31936. return eras[i];
  31937. }
  31938. break;
  31939. case 'NNNN':
  31940. if (name === eraName) {
  31941. return eras[i];
  31942. }
  31943. break;
  31944. case 'NNNNN':
  31945. if (narrow === eraName) {
  31946. return eras[i];
  31947. }
  31948. break;
  31949. }
  31950. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  31951. return eras[i];
  31952. }
  31953. }
  31954. }
  31955. function localeErasConvertYear(era, year) {
  31956. var dir = era.since <= era.until ? +1 : -1;
  31957. if (year === undefined) {
  31958. return hooks(era.since).year();
  31959. } else {
  31960. return hooks(era.since).year() + (year - era.offset) * dir;
  31961. }
  31962. }
  31963. function getEraName() {
  31964. var i,
  31965. l,
  31966. val,
  31967. eras = this.localeData().eras();
  31968. for (i = 0, l = eras.length; i < l; ++i) {
  31969. // truncate time
  31970. val = this.clone().startOf('day').valueOf();
  31971. if (eras[i].since <= val && val <= eras[i].until) {
  31972. return eras[i].name;
  31973. }
  31974. if (eras[i].until <= val && val <= eras[i].since) {
  31975. return eras[i].name;
  31976. }
  31977. }
  31978. return '';
  31979. }
  31980. function getEraNarrow() {
  31981. var i,
  31982. l,
  31983. val,
  31984. eras = this.localeData().eras();
  31985. for (i = 0, l = eras.length; i < l; ++i) {
  31986. // truncate time
  31987. val = this.clone().startOf('day').valueOf();
  31988. if (eras[i].since <= val && val <= eras[i].until) {
  31989. return eras[i].narrow;
  31990. }
  31991. if (eras[i].until <= val && val <= eras[i].since) {
  31992. return eras[i].narrow;
  31993. }
  31994. }
  31995. return '';
  31996. }
  31997. function getEraAbbr() {
  31998. var i,
  31999. l,
  32000. val,
  32001. eras = this.localeData().eras();
  32002. for (i = 0, l = eras.length; i < l; ++i) {
  32003. // truncate time
  32004. val = this.clone().startOf('day').valueOf();
  32005. if (eras[i].since <= val && val <= eras[i].until) {
  32006. return eras[i].abbr;
  32007. }
  32008. if (eras[i].until <= val && val <= eras[i].since) {
  32009. return eras[i].abbr;
  32010. }
  32011. }
  32012. return '';
  32013. }
  32014. function getEraYear() {
  32015. var i,
  32016. l,
  32017. dir,
  32018. val,
  32019. eras = this.localeData().eras();
  32020. for (i = 0, l = eras.length; i < l; ++i) {
  32021. dir = eras[i].since <= eras[i].until ? +1 : -1;
  32022. // truncate time
  32023. val = this.clone().startOf('day').valueOf();
  32024. if (
  32025. (eras[i].since <= val && val <= eras[i].until) ||
  32026. (eras[i].until <= val && val <= eras[i].since)
  32027. ) {
  32028. return (
  32029. (this.year() - hooks(eras[i].since).year()) * dir +
  32030. eras[i].offset
  32031. );
  32032. }
  32033. }
  32034. return this.year();
  32035. }
  32036. function erasNameRegex(isStrict) {
  32037. if (!hasOwnProp(this, '_erasNameRegex')) {
  32038. computeErasParse.call(this);
  32039. }
  32040. return isStrict ? this._erasNameRegex : this._erasRegex;
  32041. }
  32042. function erasAbbrRegex(isStrict) {
  32043. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  32044. computeErasParse.call(this);
  32045. }
  32046. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  32047. }
  32048. function erasNarrowRegex(isStrict) {
  32049. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  32050. computeErasParse.call(this);
  32051. }
  32052. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  32053. }
  32054. function matchEraAbbr(isStrict, locale) {
  32055. return locale.erasAbbrRegex(isStrict);
  32056. }
  32057. function matchEraName(isStrict, locale) {
  32058. return locale.erasNameRegex(isStrict);
  32059. }
  32060. function matchEraNarrow(isStrict, locale) {
  32061. return locale.erasNarrowRegex(isStrict);
  32062. }
  32063. function matchEraYearOrdinal(isStrict, locale) {
  32064. return locale._eraYearOrdinalRegex || matchUnsigned;
  32065. }
  32066. function computeErasParse() {
  32067. var abbrPieces = [],
  32068. namePieces = [],
  32069. narrowPieces = [],
  32070. mixedPieces = [],
  32071. i,
  32072. l,
  32073. eras = this.eras();
  32074. for (i = 0, l = eras.length; i < l; ++i) {
  32075. namePieces.push(regexEscape(eras[i].name));
  32076. abbrPieces.push(regexEscape(eras[i].abbr));
  32077. narrowPieces.push(regexEscape(eras[i].narrow));
  32078. mixedPieces.push(regexEscape(eras[i].name));
  32079. mixedPieces.push(regexEscape(eras[i].abbr));
  32080. mixedPieces.push(regexEscape(eras[i].narrow));
  32081. }
  32082. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  32083. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  32084. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  32085. this._erasNarrowRegex = new RegExp(
  32086. '^(' + narrowPieces.join('|') + ')',
  32087. 'i'
  32088. );
  32089. }
  32090. // FORMATTING
  32091. addFormatToken(0, ['gg', 2], 0, function () {
  32092. return this.weekYear() % 100;
  32093. });
  32094. addFormatToken(0, ['GG', 2], 0, function () {
  32095. return this.isoWeekYear() % 100;
  32096. });
  32097. function addWeekYearFormatToken(token, getter) {
  32098. addFormatToken(0, [token, token.length], 0, getter);
  32099. }
  32100. addWeekYearFormatToken('gggg', 'weekYear');
  32101. addWeekYearFormatToken('ggggg', 'weekYear');
  32102. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  32103. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  32104. // ALIASES
  32105. addUnitAlias('weekYear', 'gg');
  32106. addUnitAlias('isoWeekYear', 'GG');
  32107. // PRIORITY
  32108. addUnitPriority('weekYear', 1);
  32109. addUnitPriority('isoWeekYear', 1);
  32110. // PARSING
  32111. addRegexToken('G', matchSigned);
  32112. addRegexToken('g', matchSigned);
  32113. addRegexToken('GG', match1to2, match2);
  32114. addRegexToken('gg', match1to2, match2);
  32115. addRegexToken('GGGG', match1to4, match4);
  32116. addRegexToken('gggg', match1to4, match4);
  32117. addRegexToken('GGGGG', match1to6, match6);
  32118. addRegexToken('ggggg', match1to6, match6);
  32119. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (
  32120. input,
  32121. week,
  32122. config,
  32123. token
  32124. ) {
  32125. week[token.substr(0, 2)] = toInt(input);
  32126. });
  32127. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  32128. week[token] = hooks.parseTwoDigitYear(input);
  32129. });
  32130. // MOMENTS
  32131. function getSetWeekYear(input) {
  32132. return getSetWeekYearHelper.call(
  32133. this,
  32134. input,
  32135. this.week(),
  32136. this.weekday(),
  32137. this.localeData()._week.dow,
  32138. this.localeData()._week.doy
  32139. );
  32140. }
  32141. function getSetISOWeekYear(input) {
  32142. return getSetWeekYearHelper.call(
  32143. this,
  32144. input,
  32145. this.isoWeek(),
  32146. this.isoWeekday(),
  32147. 1,
  32148. 4
  32149. );
  32150. }
  32151. function getISOWeeksInYear() {
  32152. return weeksInYear(this.year(), 1, 4);
  32153. }
  32154. function getISOWeeksInISOWeekYear() {
  32155. return weeksInYear(this.isoWeekYear(), 1, 4);
  32156. }
  32157. function getWeeksInYear() {
  32158. var weekInfo = this.localeData()._week;
  32159. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  32160. }
  32161. function getWeeksInWeekYear() {
  32162. var weekInfo = this.localeData()._week;
  32163. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  32164. }
  32165. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  32166. var weeksTarget;
  32167. if (input == null) {
  32168. return weekOfYear(this, dow, doy).year;
  32169. } else {
  32170. weeksTarget = weeksInYear(input, dow, doy);
  32171. if (week > weeksTarget) {
  32172. week = weeksTarget;
  32173. }
  32174. return setWeekAll.call(this, input, week, weekday, dow, doy);
  32175. }
  32176. }
  32177. function setWeekAll(weekYear, week, weekday, dow, doy) {
  32178. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  32179. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  32180. this.year(date.getUTCFullYear());
  32181. this.month(date.getUTCMonth());
  32182. this.date(date.getUTCDate());
  32183. return this;
  32184. }
  32185. // FORMATTING
  32186. addFormatToken('Q', 0, 'Qo', 'quarter');
  32187. // ALIASES
  32188. addUnitAlias('quarter', 'Q');
  32189. // PRIORITY
  32190. addUnitPriority('quarter', 7);
  32191. // PARSING
  32192. addRegexToken('Q', match1);
  32193. addParseToken('Q', function (input, array) {
  32194. array[MONTH] = (toInt(input) - 1) * 3;
  32195. });
  32196. // MOMENTS
  32197. function getSetQuarter(input) {
  32198. return input == null
  32199. ? Math.ceil((this.month() + 1) / 3)
  32200. : this.month((input - 1) * 3 + (this.month() % 3));
  32201. }
  32202. // FORMATTING
  32203. addFormatToken('D', ['DD', 2], 'Do', 'date');
  32204. // ALIASES
  32205. addUnitAlias('date', 'D');
  32206. // PRIORITY
  32207. addUnitPriority('date', 9);
  32208. // PARSING
  32209. addRegexToken('D', match1to2);
  32210. addRegexToken('DD', match1to2, match2);
  32211. addRegexToken('Do', function (isStrict, locale) {
  32212. // TODO: Remove "ordinalParse" fallback in next major release.
  32213. return isStrict
  32214. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  32215. : locale._dayOfMonthOrdinalParseLenient;
  32216. });
  32217. addParseToken(['D', 'DD'], DATE);
  32218. addParseToken('Do', function (input, array) {
  32219. array[DATE] = toInt(input.match(match1to2)[0]);
  32220. });
  32221. // MOMENTS
  32222. var getSetDayOfMonth = makeGetSet('Date', true);
  32223. // FORMATTING
  32224. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  32225. // ALIASES
  32226. addUnitAlias('dayOfYear', 'DDD');
  32227. // PRIORITY
  32228. addUnitPriority('dayOfYear', 4);
  32229. // PARSING
  32230. addRegexToken('DDD', match1to3);
  32231. addRegexToken('DDDD', match3);
  32232. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  32233. config._dayOfYear = toInt(input);
  32234. });
  32235. // HELPERS
  32236. // MOMENTS
  32237. function getSetDayOfYear(input) {
  32238. var dayOfYear =
  32239. Math.round(
  32240. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  32241. ) + 1;
  32242. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  32243. }
  32244. // FORMATTING
  32245. addFormatToken('m', ['mm', 2], 0, 'minute');
  32246. // ALIASES
  32247. addUnitAlias('minute', 'm');
  32248. // PRIORITY
  32249. addUnitPriority('minute', 14);
  32250. // PARSING
  32251. addRegexToken('m', match1to2);
  32252. addRegexToken('mm', match1to2, match2);
  32253. addParseToken(['m', 'mm'], MINUTE);
  32254. // MOMENTS
  32255. var getSetMinute = makeGetSet('Minutes', false);
  32256. // FORMATTING
  32257. addFormatToken('s', ['ss', 2], 0, 'second');
  32258. // ALIASES
  32259. addUnitAlias('second', 's');
  32260. // PRIORITY
  32261. addUnitPriority('second', 15);
  32262. // PARSING
  32263. addRegexToken('s', match1to2);
  32264. addRegexToken('ss', match1to2, match2);
  32265. addParseToken(['s', 'ss'], SECOND);
  32266. // MOMENTS
  32267. var getSetSecond = makeGetSet('Seconds', false);
  32268. // FORMATTING
  32269. addFormatToken('S', 0, 0, function () {
  32270. return ~~(this.millisecond() / 100);
  32271. });
  32272. addFormatToken(0, ['SS', 2], 0, function () {
  32273. return ~~(this.millisecond() / 10);
  32274. });
  32275. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  32276. addFormatToken(0, ['SSSS', 4], 0, function () {
  32277. return this.millisecond() * 10;
  32278. });
  32279. addFormatToken(0, ['SSSSS', 5], 0, function () {
  32280. return this.millisecond() * 100;
  32281. });
  32282. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  32283. return this.millisecond() * 1000;
  32284. });
  32285. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  32286. return this.millisecond() * 10000;
  32287. });
  32288. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  32289. return this.millisecond() * 100000;
  32290. });
  32291. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  32292. return this.millisecond() * 1000000;
  32293. });
  32294. // ALIASES
  32295. addUnitAlias('millisecond', 'ms');
  32296. // PRIORITY
  32297. addUnitPriority('millisecond', 16);
  32298. // PARSING
  32299. addRegexToken('S', match1to3, match1);
  32300. addRegexToken('SS', match1to3, match2);
  32301. addRegexToken('SSS', match1to3, match3);
  32302. var token, getSetMillisecond;
  32303. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  32304. addRegexToken(token, matchUnsigned);
  32305. }
  32306. function parseMs(input, array) {
  32307. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  32308. }
  32309. for (token = 'S'; token.length <= 9; token += 'S') {
  32310. addParseToken(token, parseMs);
  32311. }
  32312. getSetMillisecond = makeGetSet('Milliseconds', false);
  32313. // FORMATTING
  32314. addFormatToken('z', 0, 0, 'zoneAbbr');
  32315. addFormatToken('zz', 0, 0, 'zoneName');
  32316. // MOMENTS
  32317. function getZoneAbbr() {
  32318. return this._isUTC ? 'UTC' : '';
  32319. }
  32320. function getZoneName() {
  32321. return this._isUTC ? 'Coordinated Universal Time' : '';
  32322. }
  32323. var proto = Moment.prototype;
  32324. proto.add = add;
  32325. proto.calendar = calendar$1;
  32326. proto.clone = clone;
  32327. proto.diff = diff;
  32328. proto.endOf = endOf;
  32329. proto.format = format;
  32330. proto.from = from;
  32331. proto.fromNow = fromNow;
  32332. proto.to = to;
  32333. proto.toNow = toNow;
  32334. proto.get = stringGet;
  32335. proto.invalidAt = invalidAt;
  32336. proto.isAfter = isAfter;
  32337. proto.isBefore = isBefore;
  32338. proto.isBetween = isBetween;
  32339. proto.isSame = isSame;
  32340. proto.isSameOrAfter = isSameOrAfter;
  32341. proto.isSameOrBefore = isSameOrBefore;
  32342. proto.isValid = isValid$2;
  32343. proto.lang = lang;
  32344. proto.locale = locale;
  32345. proto.localeData = localeData;
  32346. proto.max = prototypeMax;
  32347. proto.min = prototypeMin;
  32348. proto.parsingFlags = parsingFlags;
  32349. proto.set = stringSet;
  32350. proto.startOf = startOf;
  32351. proto.subtract = subtract;
  32352. proto.toArray = toArray;
  32353. proto.toObject = toObject;
  32354. proto.toDate = toDate;
  32355. proto.toISOString = toISOString;
  32356. proto.inspect = inspect;
  32357. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  32358. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  32359. return 'Moment<' + this.format() + '>';
  32360. };
  32361. }
  32362. proto.toJSON = toJSON;
  32363. proto.toString = toString;
  32364. proto.unix = unix;
  32365. proto.valueOf = valueOf;
  32366. proto.creationData = creationData;
  32367. proto.eraName = getEraName;
  32368. proto.eraNarrow = getEraNarrow;
  32369. proto.eraAbbr = getEraAbbr;
  32370. proto.eraYear = getEraYear;
  32371. proto.year = getSetYear;
  32372. proto.isLeapYear = getIsLeapYear;
  32373. proto.weekYear = getSetWeekYear;
  32374. proto.isoWeekYear = getSetISOWeekYear;
  32375. proto.quarter = proto.quarters = getSetQuarter;
  32376. proto.month = getSetMonth;
  32377. proto.daysInMonth = getDaysInMonth;
  32378. proto.week = proto.weeks = getSetWeek;
  32379. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  32380. proto.weeksInYear = getWeeksInYear;
  32381. proto.weeksInWeekYear = getWeeksInWeekYear;
  32382. proto.isoWeeksInYear = getISOWeeksInYear;
  32383. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  32384. proto.date = getSetDayOfMonth;
  32385. proto.day = proto.days = getSetDayOfWeek;
  32386. proto.weekday = getSetLocaleDayOfWeek;
  32387. proto.isoWeekday = getSetISODayOfWeek;
  32388. proto.dayOfYear = getSetDayOfYear;
  32389. proto.hour = proto.hours = getSetHour;
  32390. proto.minute = proto.minutes = getSetMinute;
  32391. proto.second = proto.seconds = getSetSecond;
  32392. proto.millisecond = proto.milliseconds = getSetMillisecond;
  32393. proto.utcOffset = getSetOffset;
  32394. proto.utc = setOffsetToUTC;
  32395. proto.local = setOffsetToLocal;
  32396. proto.parseZone = setOffsetToParsedOffset;
  32397. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  32398. proto.isDST = isDaylightSavingTime;
  32399. proto.isLocal = isLocal;
  32400. proto.isUtcOffset = isUtcOffset;
  32401. proto.isUtc = isUtc;
  32402. proto.isUTC = isUtc;
  32403. proto.zoneAbbr = getZoneAbbr;
  32404. proto.zoneName = getZoneName;
  32405. proto.dates = deprecate(
  32406. 'dates accessor is deprecated. Use date instead.',
  32407. getSetDayOfMonth
  32408. );
  32409. proto.months = deprecate(
  32410. 'months accessor is deprecated. Use month instead',
  32411. getSetMonth
  32412. );
  32413. proto.years = deprecate(
  32414. 'years accessor is deprecated. Use year instead',
  32415. getSetYear
  32416. );
  32417. proto.zone = deprecate(
  32418. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  32419. getSetZone
  32420. );
  32421. proto.isDSTShifted = deprecate(
  32422. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  32423. isDaylightSavingTimeShifted
  32424. );
  32425. function createUnix(input) {
  32426. return createLocal(input * 1000);
  32427. }
  32428. function createInZone() {
  32429. return createLocal.apply(null, arguments).parseZone();
  32430. }
  32431. function preParsePostFormat(string) {
  32432. return string;
  32433. }
  32434. var proto$1 = Locale.prototype;
  32435. proto$1.calendar = calendar;
  32436. proto$1.longDateFormat = longDateFormat;
  32437. proto$1.invalidDate = invalidDate;
  32438. proto$1.ordinal = ordinal;
  32439. proto$1.preparse = preParsePostFormat;
  32440. proto$1.postformat = preParsePostFormat;
  32441. proto$1.relativeTime = relativeTime;
  32442. proto$1.pastFuture = pastFuture;
  32443. proto$1.set = set;
  32444. proto$1.eras = localeEras;
  32445. proto$1.erasParse = localeErasParse;
  32446. proto$1.erasConvertYear = localeErasConvertYear;
  32447. proto$1.erasAbbrRegex = erasAbbrRegex;
  32448. proto$1.erasNameRegex = erasNameRegex;
  32449. proto$1.erasNarrowRegex = erasNarrowRegex;
  32450. proto$1.months = localeMonths;
  32451. proto$1.monthsShort = localeMonthsShort;
  32452. proto$1.monthsParse = localeMonthsParse;
  32453. proto$1.monthsRegex = monthsRegex;
  32454. proto$1.monthsShortRegex = monthsShortRegex;
  32455. proto$1.week = localeWeek;
  32456. proto$1.firstDayOfYear = localeFirstDayOfYear;
  32457. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  32458. proto$1.weekdays = localeWeekdays;
  32459. proto$1.weekdaysMin = localeWeekdaysMin;
  32460. proto$1.weekdaysShort = localeWeekdaysShort;
  32461. proto$1.weekdaysParse = localeWeekdaysParse;
  32462. proto$1.weekdaysRegex = weekdaysRegex;
  32463. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  32464. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  32465. proto$1.isPM = localeIsPM;
  32466. proto$1.meridiem = localeMeridiem;
  32467. function get$1(format, index, field, setter) {
  32468. var locale = getLocale(),
  32469. utc = createUTC().set(setter, index);
  32470. return locale[field](utc, format);
  32471. }
  32472. function listMonthsImpl(format, index, field) {
  32473. if (isNumber(format)) {
  32474. index = format;
  32475. format = undefined;
  32476. }
  32477. format = format || '';
  32478. if (index != null) {
  32479. return get$1(format, index, field, 'month');
  32480. }
  32481. var i,
  32482. out = [];
  32483. for (i = 0; i < 12; i++) {
  32484. out[i] = get$1(format, i, field, 'month');
  32485. }
  32486. return out;
  32487. }
  32488. // ()
  32489. // (5)
  32490. // (fmt, 5)
  32491. // (fmt)
  32492. // (true)
  32493. // (true, 5)
  32494. // (true, fmt, 5)
  32495. // (true, fmt)
  32496. function listWeekdaysImpl(localeSorted, format, index, field) {
  32497. if (typeof localeSorted === 'boolean') {
  32498. if (isNumber(format)) {
  32499. index = format;
  32500. format = undefined;
  32501. }
  32502. format = format || '';
  32503. } else {
  32504. format = localeSorted;
  32505. index = format;
  32506. localeSorted = false;
  32507. if (isNumber(format)) {
  32508. index = format;
  32509. format = undefined;
  32510. }
  32511. format = format || '';
  32512. }
  32513. var locale = getLocale(),
  32514. shift = localeSorted ? locale._week.dow : 0,
  32515. i,
  32516. out = [];
  32517. if (index != null) {
  32518. return get$1(format, (index + shift) % 7, field, 'day');
  32519. }
  32520. for (i = 0; i < 7; i++) {
  32521. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  32522. }
  32523. return out;
  32524. }
  32525. function listMonths(format, index) {
  32526. return listMonthsImpl(format, index, 'months');
  32527. }
  32528. function listMonthsShort(format, index) {
  32529. return listMonthsImpl(format, index, 'monthsShort');
  32530. }
  32531. function listWeekdays(localeSorted, format, index) {
  32532. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  32533. }
  32534. function listWeekdaysShort(localeSorted, format, index) {
  32535. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  32536. }
  32537. function listWeekdaysMin(localeSorted, format, index) {
  32538. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  32539. }
  32540. getSetGlobalLocale('en', {
  32541. eras: [
  32542. {
  32543. since: '0001-01-01',
  32544. until: +Infinity,
  32545. offset: 1,
  32546. name: 'Anno Domini',
  32547. narrow: 'AD',
  32548. abbr: 'AD',
  32549. },
  32550. {
  32551. since: '0000-12-31',
  32552. until: -Infinity,
  32553. offset: 1,
  32554. name: 'Before Christ',
  32555. narrow: 'BC',
  32556. abbr: 'BC',
  32557. },
  32558. ],
  32559. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  32560. ordinal: function (number) {
  32561. var b = number % 10,
  32562. output =
  32563. toInt((number % 100) / 10) === 1
  32564. ? 'th'
  32565. : b === 1
  32566. ? 'st'
  32567. : b === 2
  32568. ? 'nd'
  32569. : b === 3
  32570. ? 'rd'
  32571. : 'th';
  32572. return number + output;
  32573. },
  32574. });
  32575. // Side effect imports
  32576. hooks.lang = deprecate(
  32577. 'moment.lang is deprecated. Use moment.locale instead.',
  32578. getSetGlobalLocale
  32579. );
  32580. hooks.langData = deprecate(
  32581. 'moment.langData is deprecated. Use moment.localeData instead.',
  32582. getLocale
  32583. );
  32584. var mathAbs = Math.abs;
  32585. function abs() {
  32586. var data = this._data;
  32587. this._milliseconds = mathAbs(this._milliseconds);
  32588. this._days = mathAbs(this._days);
  32589. this._months = mathAbs(this._months);
  32590. data.milliseconds = mathAbs(data.milliseconds);
  32591. data.seconds = mathAbs(data.seconds);
  32592. data.minutes = mathAbs(data.minutes);
  32593. data.hours = mathAbs(data.hours);
  32594. data.months = mathAbs(data.months);
  32595. data.years = mathAbs(data.years);
  32596. return this;
  32597. }
  32598. function addSubtract$1(duration, input, value, direction) {
  32599. var other = createDuration(input, value);
  32600. duration._milliseconds += direction * other._milliseconds;
  32601. duration._days += direction * other._days;
  32602. duration._months += direction * other._months;
  32603. return duration._bubble();
  32604. }
  32605. // supports only 2.0-style add(1, 's') or add(duration)
  32606. function add$1(input, value) {
  32607. return addSubtract$1(this, input, value, 1);
  32608. }
  32609. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  32610. function subtract$1(input, value) {
  32611. return addSubtract$1(this, input, value, -1);
  32612. }
  32613. function absCeil(number) {
  32614. if (number < 0) {
  32615. return Math.floor(number);
  32616. } else {
  32617. return Math.ceil(number);
  32618. }
  32619. }
  32620. function bubble() {
  32621. var milliseconds = this._milliseconds,
  32622. days = this._days,
  32623. months = this._months,
  32624. data = this._data,
  32625. seconds,
  32626. minutes,
  32627. hours,
  32628. years,
  32629. monthsFromDays;
  32630. // if we have a mix of positive and negative values, bubble down first
  32631. // check: https://github.com/moment/moment/issues/2166
  32632. if (
  32633. !(
  32634. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  32635. (milliseconds <= 0 && days <= 0 && months <= 0)
  32636. )
  32637. ) {
  32638. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  32639. days = 0;
  32640. months = 0;
  32641. }
  32642. // The following code bubbles up values, see the tests for
  32643. // examples of what that means.
  32644. data.milliseconds = milliseconds % 1000;
  32645. seconds = absFloor(milliseconds / 1000);
  32646. data.seconds = seconds % 60;
  32647. minutes = absFloor(seconds / 60);
  32648. data.minutes = minutes % 60;
  32649. hours = absFloor(minutes / 60);
  32650. data.hours = hours % 24;
  32651. days += absFloor(hours / 24);
  32652. // convert days to months
  32653. monthsFromDays = absFloor(daysToMonths(days));
  32654. months += monthsFromDays;
  32655. days -= absCeil(monthsToDays(monthsFromDays));
  32656. // 12 months -> 1 year
  32657. years = absFloor(months / 12);
  32658. months %= 12;
  32659. data.days = days;
  32660. data.months = months;
  32661. data.years = years;
  32662. return this;
  32663. }
  32664. function daysToMonths(days) {
  32665. // 400 years have 146097 days (taking into account leap year rules)
  32666. // 400 years have 12 months === 4800
  32667. return (days * 4800) / 146097;
  32668. }
  32669. function monthsToDays(months) {
  32670. // the reverse of daysToMonths
  32671. return (months * 146097) / 4800;
  32672. }
  32673. function as(units) {
  32674. if (!this.isValid()) {
  32675. return NaN;
  32676. }
  32677. var days,
  32678. months,
  32679. milliseconds = this._milliseconds;
  32680. units = normalizeUnits(units);
  32681. if (units === 'month' || units === 'quarter' || units === 'year') {
  32682. days = this._days + milliseconds / 864e5;
  32683. months = this._months + daysToMonths(days);
  32684. switch (units) {
  32685. case 'month':
  32686. return months;
  32687. case 'quarter':
  32688. return months / 3;
  32689. case 'year':
  32690. return months / 12;
  32691. }
  32692. } else {
  32693. // handle milliseconds separately because of floating point math errors (issue #1867)
  32694. days = this._days + Math.round(monthsToDays(this._months));
  32695. switch (units) {
  32696. case 'week':
  32697. return days / 7 + milliseconds / 6048e5;
  32698. case 'day':
  32699. return days + milliseconds / 864e5;
  32700. case 'hour':
  32701. return days * 24 + milliseconds / 36e5;
  32702. case 'minute':
  32703. return days * 1440 + milliseconds / 6e4;
  32704. case 'second':
  32705. return days * 86400 + milliseconds / 1000;
  32706. // Math.floor prevents floating point math errors here
  32707. case 'millisecond':
  32708. return Math.floor(days * 864e5) + milliseconds;
  32709. default:
  32710. throw new Error('Unknown unit ' + units);
  32711. }
  32712. }
  32713. }
  32714. // TODO: Use this.as('ms')?
  32715. function valueOf$1() {
  32716. if (!this.isValid()) {
  32717. return NaN;
  32718. }
  32719. return (
  32720. this._milliseconds +
  32721. this._days * 864e5 +
  32722. (this._months % 12) * 2592e6 +
  32723. toInt(this._months / 12) * 31536e6
  32724. );
  32725. }
  32726. function makeAs(alias) {
  32727. return function () {
  32728. return this.as(alias);
  32729. };
  32730. }
  32731. var asMilliseconds = makeAs('ms'),
  32732. asSeconds = makeAs('s'),
  32733. asMinutes = makeAs('m'),
  32734. asHours = makeAs('h'),
  32735. asDays = makeAs('d'),
  32736. asWeeks = makeAs('w'),
  32737. asMonths = makeAs('M'),
  32738. asQuarters = makeAs('Q'),
  32739. asYears = makeAs('y');
  32740. function clone$1() {
  32741. return createDuration(this);
  32742. }
  32743. function get$2(units) {
  32744. units = normalizeUnits(units);
  32745. return this.isValid() ? this[units + 's']() : NaN;
  32746. }
  32747. function makeGetter(name) {
  32748. return function () {
  32749. return this.isValid() ? this._data[name] : NaN;
  32750. };
  32751. }
  32752. var milliseconds = makeGetter('milliseconds'),
  32753. seconds = makeGetter('seconds'),
  32754. minutes = makeGetter('minutes'),
  32755. hours = makeGetter('hours'),
  32756. days = makeGetter('days'),
  32757. months = makeGetter('months'),
  32758. years = makeGetter('years');
  32759. function weeks() {
  32760. return absFloor(this.days() / 7);
  32761. }
  32762. var round = Math.round,
  32763. thresholds = {
  32764. ss: 44, // a few seconds to seconds
  32765. s: 45, // seconds to minute
  32766. m: 45, // minutes to hour
  32767. h: 22, // hours to day
  32768. d: 26, // days to month/week
  32769. w: null, // weeks to month
  32770. M: 11, // months to year
  32771. };
  32772. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  32773. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  32774. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  32775. }
  32776. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  32777. var duration = createDuration(posNegDuration).abs(),
  32778. seconds = round(duration.as('s')),
  32779. minutes = round(duration.as('m')),
  32780. hours = round(duration.as('h')),
  32781. days = round(duration.as('d')),
  32782. months = round(duration.as('M')),
  32783. weeks = round(duration.as('w')),
  32784. years = round(duration.as('y')),
  32785. a =
  32786. (seconds <= thresholds.ss && ['s', seconds]) ||
  32787. (seconds < thresholds.s && ['ss', seconds]) ||
  32788. (minutes <= 1 && ['m']) ||
  32789. (minutes < thresholds.m && ['mm', minutes]) ||
  32790. (hours <= 1 && ['h']) ||
  32791. (hours < thresholds.h && ['hh', hours]) ||
  32792. (days <= 1 && ['d']) ||
  32793. (days < thresholds.d && ['dd', days]);
  32794. if (thresholds.w != null) {
  32795. a =
  32796. a ||
  32797. (weeks <= 1 && ['w']) ||
  32798. (weeks < thresholds.w && ['ww', weeks]);
  32799. }
  32800. a = a ||
  32801. (months <= 1 && ['M']) ||
  32802. (months < thresholds.M && ['MM', months]) ||
  32803. (years <= 1 && ['y']) || ['yy', years];
  32804. a[2] = withoutSuffix;
  32805. a[3] = +posNegDuration > 0;
  32806. a[4] = locale;
  32807. return substituteTimeAgo.apply(null, a);
  32808. }
  32809. // This function allows you to set the rounding function for relative time strings
  32810. function getSetRelativeTimeRounding(roundingFunction) {
  32811. if (roundingFunction === undefined) {
  32812. return round;
  32813. }
  32814. if (typeof roundingFunction === 'function') {
  32815. round = roundingFunction;
  32816. return true;
  32817. }
  32818. return false;
  32819. }
  32820. // This function allows you to set a threshold for relative time strings
  32821. function getSetRelativeTimeThreshold(threshold, limit) {
  32822. if (thresholds[threshold] === undefined) {
  32823. return false;
  32824. }
  32825. if (limit === undefined) {
  32826. return thresholds[threshold];
  32827. }
  32828. thresholds[threshold] = limit;
  32829. if (threshold === 's') {
  32830. thresholds.ss = limit - 1;
  32831. }
  32832. return true;
  32833. }
  32834. function humanize(argWithSuffix, argThresholds) {
  32835. if (!this.isValid()) {
  32836. return this.localeData().invalidDate();
  32837. }
  32838. var withSuffix = false,
  32839. th = thresholds,
  32840. locale,
  32841. output;
  32842. if (typeof argWithSuffix === 'object') {
  32843. argThresholds = argWithSuffix;
  32844. argWithSuffix = false;
  32845. }
  32846. if (typeof argWithSuffix === 'boolean') {
  32847. withSuffix = argWithSuffix;
  32848. }
  32849. if (typeof argThresholds === 'object') {
  32850. th = Object.assign({}, thresholds, argThresholds);
  32851. if (argThresholds.s != null && argThresholds.ss == null) {
  32852. th.ss = argThresholds.s - 1;
  32853. }
  32854. }
  32855. locale = this.localeData();
  32856. output = relativeTime$1(this, !withSuffix, th, locale);
  32857. if (withSuffix) {
  32858. output = locale.pastFuture(+this, output);
  32859. }
  32860. return locale.postformat(output);
  32861. }
  32862. var abs$1 = Math.abs;
  32863. function sign(x) {
  32864. return (x > 0) - (x < 0) || +x;
  32865. }
  32866. function toISOString$1() {
  32867. // for ISO strings we do not use the normal bubbling rules:
  32868. // * milliseconds bubble up until they become hours
  32869. // * days do not bubble at all
  32870. // * months bubble up until they become years
  32871. // This is because there is no context-free conversion between hours and days
  32872. // (think of clock changes)
  32873. // and also not between days and months (28-31 days per month)
  32874. if (!this.isValid()) {
  32875. return this.localeData().invalidDate();
  32876. }
  32877. var seconds = abs$1(this._milliseconds) / 1000,
  32878. days = abs$1(this._days),
  32879. months = abs$1(this._months),
  32880. minutes,
  32881. hours,
  32882. years,
  32883. s,
  32884. total = this.asSeconds(),
  32885. totalSign,
  32886. ymSign,
  32887. daysSign,
  32888. hmsSign;
  32889. if (!total) {
  32890. // this is the same as C#'s (Noda) and python (isodate)...
  32891. // but not other JS (goog.date)
  32892. return 'P0D';
  32893. }
  32894. // 3600 seconds -> 60 minutes -> 1 hour
  32895. minutes = absFloor(seconds / 60);
  32896. hours = absFloor(minutes / 60);
  32897. seconds %= 60;
  32898. minutes %= 60;
  32899. // 12 months -> 1 year
  32900. years = absFloor(months / 12);
  32901. months %= 12;
  32902. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  32903. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  32904. totalSign = total < 0 ? '-' : '';
  32905. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  32906. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  32907. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  32908. return (
  32909. totalSign +
  32910. 'P' +
  32911. (years ? ymSign + years + 'Y' : '') +
  32912. (months ? ymSign + months + 'M' : '') +
  32913. (days ? daysSign + days + 'D' : '') +
  32914. (hours || minutes || seconds ? 'T' : '') +
  32915. (hours ? hmsSign + hours + 'H' : '') +
  32916. (minutes ? hmsSign + minutes + 'M' : '') +
  32917. (seconds ? hmsSign + s + 'S' : '')
  32918. );
  32919. }
  32920. var proto$2 = Duration.prototype;
  32921. proto$2.isValid = isValid$1;
  32922. proto$2.abs = abs;
  32923. proto$2.add = add$1;
  32924. proto$2.subtract = subtract$1;
  32925. proto$2.as = as;
  32926. proto$2.asMilliseconds = asMilliseconds;
  32927. proto$2.asSeconds = asSeconds;
  32928. proto$2.asMinutes = asMinutes;
  32929. proto$2.asHours = asHours;
  32930. proto$2.asDays = asDays;
  32931. proto$2.asWeeks = asWeeks;
  32932. proto$2.asMonths = asMonths;
  32933. proto$2.asQuarters = asQuarters;
  32934. proto$2.asYears = asYears;
  32935. proto$2.valueOf = valueOf$1;
  32936. proto$2._bubble = bubble;
  32937. proto$2.clone = clone$1;
  32938. proto$2.get = get$2;
  32939. proto$2.milliseconds = milliseconds;
  32940. proto$2.seconds = seconds;
  32941. proto$2.minutes = minutes;
  32942. proto$2.hours = hours;
  32943. proto$2.days = days;
  32944. proto$2.weeks = weeks;
  32945. proto$2.months = months;
  32946. proto$2.years = years;
  32947. proto$2.humanize = humanize;
  32948. proto$2.toISOString = toISOString$1;
  32949. proto$2.toString = toISOString$1;
  32950. proto$2.toJSON = toISOString$1;
  32951. proto$2.locale = locale;
  32952. proto$2.localeData = localeData;
  32953. proto$2.toIsoString = deprecate(
  32954. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  32955. toISOString$1
  32956. );
  32957. proto$2.lang = lang;
  32958. // FORMATTING
  32959. addFormatToken('X', 0, 0, 'unix');
  32960. addFormatToken('x', 0, 0, 'valueOf');
  32961. // PARSING
  32962. addRegexToken('x', matchSigned);
  32963. addRegexToken('X', matchTimestamp);
  32964. addParseToken('X', function (input, array, config) {
  32965. config._d = new Date(parseFloat(input) * 1000);
  32966. });
  32967. addParseToken('x', function (input, array, config) {
  32968. config._d = new Date(toInt(input));
  32969. });
  32970. //! moment.js
  32971. hooks.version = '2.29.1';
  32972. setHookCallback(createLocal);
  32973. hooks.fn = proto;
  32974. hooks.min = min;
  32975. hooks.max = max;
  32976. hooks.now = now;
  32977. hooks.utc = createUTC;
  32978. hooks.unix = createUnix;
  32979. hooks.months = listMonths;
  32980. hooks.isDate = isDate;
  32981. hooks.locale = getSetGlobalLocale;
  32982. hooks.invalid = createInvalid;
  32983. hooks.duration = createDuration;
  32984. hooks.isMoment = isMoment;
  32985. hooks.weekdays = listWeekdays;
  32986. hooks.parseZone = createInZone;
  32987. hooks.localeData = getLocale;
  32988. hooks.isDuration = isDuration;
  32989. hooks.monthsShort = listMonthsShort;
  32990. hooks.weekdaysMin = listWeekdaysMin;
  32991. hooks.defineLocale = defineLocale;
  32992. hooks.updateLocale = updateLocale;
  32993. hooks.locales = listLocales;
  32994. hooks.weekdaysShort = listWeekdaysShort;
  32995. hooks.normalizeUnits = normalizeUnits;
  32996. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  32997. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  32998. hooks.calendarFormat = getCalendarFormat;
  32999. hooks.prototype = proto;
  33000. // currently HTML5 input type only supports 24-hour formats
  33001. hooks.HTML5_FMT = {
  33002. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  33003. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  33004. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  33005. DATE: 'YYYY-MM-DD', // <input type="date" />
  33006. TIME: 'HH:mm', // <input type="time" />
  33007. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  33008. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  33009. WEEK: 'GGGG-[W]WW', // <input type="week" />
  33010. MONTH: 'YYYY-MM', // <input type="month" />
  33011. };
  33012. return hooks;
  33013. })));
  33014. });
  33015. /*! *****************************************************************************
  33016. Copyright (c) Microsoft Corporation.
  33017. Permission to use, copy, modify, and/or distribute this software for any
  33018. purpose with or without fee is hereby granted.
  33019. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  33020. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  33021. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  33022. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  33023. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  33024. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33025. PERFORMANCE OF THIS SOFTWARE.
  33026. ***************************************************************************** */
  33027. var __assign = function() {
  33028. __assign = Object.assign || function __assign(t) {
  33029. for (var s, i = 1, n = arguments.length; i < n; i++) {
  33030. s = arguments[i];
  33031. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  33032. }
  33033. return t;
  33034. };
  33035. return __assign.apply(this, arguments);
  33036. };
  33037. function __decorate(decorators, target, key, desc) {
  33038. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  33039. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  33040. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  33041. return c > 3 && r && Object.defineProperty(target, key, r), r;
  33042. }
  33043. function __param(paramIndex, decorator) {
  33044. return function (target, key) { decorator(target, key, paramIndex); }
  33045. }
  33046. function __metadata(metadataKey, metadataValue) {
  33047. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  33048. }
  33049. function __read(o, n) {
  33050. var m = typeof Symbol === "function" && o[Symbol.iterator];
  33051. if (!m) return o;
  33052. var i = m.call(o), r, ar = [], e;
  33053. try {
  33054. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  33055. }
  33056. catch (error) { e = { error: error }; }
  33057. finally {
  33058. try {
  33059. if (r && !r.done && (m = i["return"])) m.call(i);
  33060. }
  33061. finally { if (e) throw e.error; }
  33062. }
  33063. return ar;
  33064. }
  33065. function __spread() {
  33066. for (var ar = [], i = 0; i < arguments.length; i++)
  33067. ar = ar.concat(__read(arguments[i]));
  33068. return ar;
  33069. }
  33070. function toString$1(value) {
  33071. if (typeof value === 'undefined' || value === null) {
  33072. return "";
  33073. }
  33074. if (typeof value === 'number' && isNaN(value)) {
  33075. return "";
  33076. }
  33077. if (value == 'N/A') {
  33078. return "";
  33079. }
  33080. return ("" + value);
  33081. }
  33082. function isEmpty(value) {
  33083. if (typeof value === 'undefined' || value === null) {
  33084. return true;
  33085. }
  33086. if (typeof value === 'number' && isNaN(value)) {
  33087. return true;
  33088. }
  33089. if (value == 'N/A') {
  33090. return true;
  33091. }
  33092. return ("" + value).trim().length <= 0;
  33093. }
  33094. function getRegList() {
  33095. var regList = lodash.get(window, 'yvanLib.regList');
  33096. if (!regList) {
  33097. regList = [];
  33098. lodash.set(window, 'yvanLib.regList', regList);
  33099. }
  33100. return regList;
  33101. }
  33102. function getRegParamList(methodName) {
  33103. var regParamList = lodash.get(window, 'yvanLib.regParamList');
  33104. if (!regParamList) {
  33105. regParamList = {};
  33106. lodash.set(window, 'yvanLib.regParamList', regParamList);
  33107. }
  33108. if (!lodash.has(regParamList, methodName)) {
  33109. regParamList[methodName] = [];
  33110. }
  33111. return regParamList[methodName];
  33112. }
  33113. /**
  33114. * 模拟点击按钮
  33115. */
  33116. function raiseClick(buttonHandle) {
  33117. if (!buttonHandle) {
  33118. return false;
  33119. }
  33120. if (buttonHandle.disabled) {
  33121. // 按钮是禁止状态
  33122. return false;
  33123. }
  33124. if (buttonHandle.hidden) {
  33125. // 按钮是隐藏状态
  33126. return false;
  33127. }
  33128. // 按钮点击
  33129. buttonHandle.click();
  33130. return true;
  33131. }
  33132. /**
  33133. * 标注系统全局函数的参数
  33134. * @param title 函数名称
  33135. * @param type 函数类型
  33136. * @param allowEmpty 可否为空
  33137. */
  33138. function LibParam(title, type, allowEmpty) {
  33139. if (allowEmpty === void 0) { allowEmpty = false; }
  33140. return function (target, methodName, paramsIndex) {
  33141. var systemFnArgs = getRegParamList(methodName);
  33142. systemFnArgs[paramsIndex] = {
  33143. type: type,
  33144. title: title,
  33145. name: methodName,
  33146. allowEmpty: allowEmpty,
  33147. };
  33148. };
  33149. }
  33150. /**
  33151. * 标注函数变成"系统全局函数"
  33152. */
  33153. function Lib(registe) {
  33154. return function (target, propertyKey, descriptor) {
  33155. var libList = getRegList();
  33156. libList.push(__assign(__assign({}, registe), { name: propertyKey, target: target[propertyKey] }));
  33157. if (registe.type === 'system') {
  33158. lodash.set(window, 'yvanLib.system.' + propertyKey, target[propertyKey]);
  33159. }
  33160. else if (registe.type === 'format') {
  33161. lodash.set(window, 'yvanLib.format.' + propertyKey, target[propertyKey]);
  33162. }
  33163. return target;
  33164. };
  33165. }
  33166. /**
  33167. * 解析事件
  33168. * 'scope.私有方法名'
  33169. * 'system.系统函数名'
  33170. * 'format.格式化名'
  33171. */
  33172. function lookupFn(scope, event) {
  33173. if (window["IS_DESIGN_MODE"]) {
  33174. return Ext.emptyFn;
  33175. }
  33176. if (!lodash.startsWith(event, 'scope.') &&
  33177. !lodash.startsWith(event, 'system.') &&
  33178. !lodash.startsWith(event, 'format.')) {
  33179. console.error('无法识别的事件响应类型', event);
  33180. throw new TypeError('无法识别的事件响应类型');
  33181. }
  33182. // 为 eval 准备环境
  33183. var _a = window['yvanLib'], system = _a.system, format = _a.format;
  33184. var data = (scope.viewModel ? scope.viewModel.data : scope.model.data);
  33185. var keys = [];
  33186. var values = [];
  33187. lodash.forOwn(data, function (value, key) {
  33188. var idxKey = key.indexOf('//');
  33189. if (idxKey >= 0) {
  33190. keys.push(key.substr(0, idxKey));
  33191. }
  33192. else {
  33193. keys.push(key);
  33194. }
  33195. values.push(value);
  33196. });
  33197. var func = Function.apply(void 0, __spread(['scope', 'system', 'format'], keys, ['return ' + event]));
  33198. var funcResult = func.apply(void 0, __spread([scope, system, format], values));
  33199. if (typeof funcResult !== 'function') {
  33200. console.error('无法识别的事件响应类型', event, func);
  33201. throw new TypeError('无法识别的事件响应类型');
  33202. }
  33203. return funcResult;
  33204. }
  33205. /**
  33206. * 从 ext.element 获取 scope 对象
  33207. */
  33208. function lookupScope(extHandle) {
  33209. if (!extHandle) {
  33210. // @ts-ignore
  33211. return;
  33212. }
  33213. if (extHandle.isScope) {
  33214. return extHandle;
  33215. }
  33216. if (extHandle.column) {
  33217. // 列上的组件
  33218. return extHandle.column.lookupReferenceHolder().yvanScope;
  33219. }
  33220. var vm = extHandle.lookupViewModel();
  33221. return vm.yvanScope;
  33222. }
  33223. /**
  33224. * 转换内联结构的行,到平面结构
  33225. * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
  33226. *
  33227. * @param array
  33228. * @param flatOption
  33229. * @return {[]}
  33230. */
  33231. function flatRow(array) {
  33232. var ret = [];
  33233. lodash.forEach(array, function (row) {
  33234. var newRow = {};
  33235. flatObject(newRow, '', row);
  33236. ret.push(newRow);
  33237. });
  33238. return ret;
  33239. }
  33240. function flatObject(parentObj, parentProp, obj) {
  33241. lodash.forOwn(obj, function (value, key) {
  33242. var fullKey = parentProp ? parentProp + '_' + key : key;
  33243. if (lodash.isArray(value)) {
  33244. parentObj[fullKey] = lodash.map(value, function (row) {
  33245. var newRow = {};
  33246. flatObject(newRow, '', row);
  33247. return newRow;
  33248. });
  33249. }
  33250. else {
  33251. if (typeof value === 'object') {
  33252. flatObject(parentObj, fullKey, value);
  33253. }
  33254. else {
  33255. parentObj[fullKey] = value;
  33256. }
  33257. }
  33258. });
  33259. }
  33260. var Scope = /** @class */ (function () {
  33261. function Scope(_a) {
  33262. var model = _a.model, vjson = _a.vjson;
  33263. this.scopeTag = '';
  33264. this.allowBack = true;
  33265. /**
  33266. * 业务模块的唯一编号
  33267. */
  33268. this.id = lodash.uniqueId('scope_');
  33269. this._lastShowTime = 0;
  33270. this.model = model;
  33271. this.originalVjson = lodash.cloneDeep(vjson);
  33272. if (vjson.scopeTag) {
  33273. this.scopeTag = vjson.scopeTag;
  33274. }
  33275. this.vjson = this.originalVjson; // this.buildVjson()
  33276. }
  33277. /**
  33278. * 活动回调
  33279. */
  33280. Scope.prototype.activate = function () {
  33281. var _a;
  33282. // @ts-ignore
  33283. if ((_a = window === null || window === void 0 ? void 0 : window.JSInterface) === null || _a === void 0 ? void 0 : _a.setWebViewCanBack) {
  33284. // @ts-ignore
  33285. window.JSInterface.setWebViewCanBack(this.allowBack);
  33286. }
  33287. };
  33288. /**
  33289. * 模块载入完成之后的回调
  33290. */
  33291. Scope.prototype.onLoad = function () {
  33292. };
  33293. /**
  33294. * 组件卸载之后的回调
  33295. */
  33296. Scope.prototype.onDestroy = function () {
  33297. };
  33298. Scope.prototype.onGoBack = function (params) {
  33299. };
  33300. /**
  33301. * 模块载入动画结束之后的回调, 在onload之后
  33302. */
  33303. Scope.prototype.onLoadAnimationEnd = function () {
  33304. };
  33305. Object.defineProperty(Scope.prototype, "isScope", {
  33306. get: function () {
  33307. return true;
  33308. },
  33309. enumerable: true,
  33310. configurable: true
  33311. });
  33312. /**
  33313. * 产生一个当前模块有效的唯一id
  33314. * @param key 唯一编号
  33315. */
  33316. Scope.prototype.uid = function (key) {
  33317. return this.id + key;
  33318. };
  33319. Scope.prototype._onDestroy = function () {
  33320. this.onDestroy();
  33321. };
  33322. Scope.prototype._onLoad = function () {
  33323. };
  33324. Scope.prototype._onLoadAnimationEnd = function () {
  33325. this.onLoad();
  33326. this.onLoadAnimationEnd();
  33327. };
  33328. Scope.prototype._onGoBack = function (params) {
  33329. this.onGoBack(params);
  33330. };
  33331. Scope.prototype.showMainWindow = function () {
  33332. var _a;
  33333. var handle = (_a = window.mainWindow) === null || _a === void 0 ? void 0 : _a._handle;
  33334. if (handle) {
  33335. handle.setStyle({ 'z-index': 1 });
  33336. Ext.Viewport.getLayout().setAnimation({ type: 'slide', direction: 'right', duration: 300 });
  33337. Ext.Viewport.setActiveItem(handle);
  33338. Scope.SHOW_PAGE_STACK.length = 0;
  33339. Scope.SHOW_PAGE_STACK.push(window.mainWindow);
  33340. }
  33341. };
  33342. /**
  33343. * 渲染模块到全屏
  33344. * allowBack 是否允许后退(退出)
  33345. * vjsonOption 界面覆盖选项(可以为空)
  33346. * dataOption 数据覆盖选项(可以为空)
  33347. */
  33348. Scope.prototype.render = function (option) {
  33349. if (option === void 0) { option = {
  33350. allowBack: true,
  33351. vjsonOption: {},
  33352. dataOption: {}
  33353. }; }
  33354. var that = this;
  33355. var has = false;
  33356. Ext.Viewport.getItems().items.forEach(function (item, idx) {
  33357. if (!has && item === that._handle) {
  33358. has = true;
  33359. }
  33360. });
  33361. if (!has) {
  33362. lodash.defaults(option, {
  33363. allowBack: true,
  33364. vjsonOption: {},
  33365. dataOption: {}
  33366. });
  33367. var allowBack = option.allowBack, vjsonOption = option.vjsonOption, dataOption = option.dataOption;
  33368. lodash.defaults(vjsonOption, {
  33369. listeners: {}
  33370. });
  33371. lodash.defaults(vjsonOption['listeners'], {
  33372. activate: "scope.activate"
  33373. });
  33374. this._vjsonOption = vjsonOption;
  33375. this._dataOption = dataOption;
  33376. var vmodel = lodash.defaultsDeep({
  33377. data: {}
  33378. }, dataOption, that.model);
  33379. //this.viewModel = new Ext.app.ViewModel(vmodel);
  33380. //this.viewModel.yvanScope = this
  33381. var config = lodash.defaultsDeep({
  33382. // viewModel: this.viewModel,
  33383. viewModel: vmodel,
  33384. yvanScope: this,
  33385. referenceHolder: true,
  33386. }, vjsonOption, that.vjson, {
  33387. xtype: 'panel',
  33388. });
  33389. that.allowBack = allowBack;
  33390. if (allowBack) {
  33391. var configNew = lodash.defaultsDeep({
  33392. iconCls: 'x-fa fa-angle-left',
  33393. cls: ['navbar'],
  33394. tools: [
  33395. {
  33396. iconCls: 'x-fa fa-home',
  33397. handler: function () {
  33398. that.goHome();
  33399. },
  33400. },
  33401. ],
  33402. }, config);
  33403. if (lodash.isArray(config.cls)) {
  33404. configNew.cls = __spread(configNew.cls, config.cls);
  33405. }
  33406. else if (typeof config.cls === 'string') {
  33407. configNew.cls = __spread(configNew.cls, [
  33408. config.cls
  33409. ]);
  33410. }
  33411. config = configNew;
  33412. }
  33413. that._handle = Ext.create(config);
  33414. this.viewModel = that._handle.getViewModel();
  33415. this.viewModel.yvanScope = this;
  33416. that._handle.on({
  33417. renderedchange: function (sender, item, rendered, opts) {
  33418. // 记录句柄
  33419. if (rendered) {
  33420. that._handle = this;
  33421. window['cp'] = that;
  33422. // 调用onLoad回调
  33423. try {
  33424. that._onLoad();
  33425. }
  33426. catch (e) {
  33427. console.error('errorAt onLoad', e);
  33428. }
  33429. var $back = $(sender.el.dom)
  33430. .find('.navbar>.x-panelheader')
  33431. .find('.x-body-el>.fa-angle-left');
  33432. $back.off('click');
  33433. $back.on('click', function () { return that.goBack(); });
  33434. }
  33435. },
  33436. destroy: function () {
  33437. var _a, _b, _c;
  33438. // 卸载
  33439. window['cp'] = (_c = (_b = (_a = Ext.Viewport.items) === null || _a === void 0 ? void 0 : _a.getAt(Ext.Viewport.items.items.length - 2)) === null || _b === void 0 ? void 0 : _b.getViewModel()) === null || _c === void 0 ? void 0 : _c.yvanScope;
  33440. that._onDestroy();
  33441. },
  33442. });
  33443. }
  33444. else {
  33445. window['cp'] = that;
  33446. // 调用onLoad回调
  33447. try {
  33448. that._onLoad();
  33449. }
  33450. catch (e) {
  33451. console.error('errorAt onLoad', e);
  33452. }
  33453. }
  33454. Ext.Viewport.activeItem = function () {
  33455. debugger;
  33456. };
  33457. Ext.Viewport.add(that._handle);
  33458. // if ((window as any).mainWindow === that || (window as any).loginWindow === that) {
  33459. // Scope.SHOW_PAGE_STACK.length = 0
  33460. // }
  33461. that._handle.setStyle({ 'z-index': 1 });
  33462. var actived = false;
  33463. Ext.Viewport.getItems().items.forEach(function (item, idx) {
  33464. if (!actived && item === that._handle) {
  33465. actived = true;
  33466. Ext.Viewport.getLayout().setAnimation({ type: 'slide', direction: 'left', duration: 300 });
  33467. setTimeout(that._onLoadAnimationEnd.bind(that), 300);
  33468. Ext.Viewport.setActiveItem(idx);
  33469. that._lastShowTime = new Date().getTime();
  33470. Scope.SHOW_PAGE_STACK.push(that);
  33471. }
  33472. });
  33473. return that._handle;
  33474. };
  33475. Scope.prototype.goHome = function () {
  33476. var handle = Ext.Viewport.getActiveItem();
  33477. Scope.SHOW_PAGE_STACK.splice(1);
  33478. var scope = Scope.SHOW_PAGE_STACK[0];
  33479. scope._handle.setStyle({ 'z-index': 1 });
  33480. Ext.Viewport.getLayout().setAnimation({ type: 'slide', direction: 'right', duration: 300 });
  33481. Ext.Viewport.setActiveItem(scope._handle);
  33482. scope._lastShowTime = new Date().getTime();
  33483. scope._onGoBack.bind(scope).apply();
  33484. // 关闭
  33485. handle.setStyle({ 'z-index': 0 });
  33486. // Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
  33487. Ext.Viewport.remove(handle);
  33488. handle.close();
  33489. };
  33490. Scope.prototype.goBack = function (params, scopeTag) {
  33491. // if(this._fullScreenCmp) {
  33492. // this._fullScreenCmp.hide()
  33493. // return
  33494. // }
  33495. // const fullScreenCmp = this._handle?.down('[fullscreen=true]')
  33496. // if(fullScreenCmp?.isVisible()){
  33497. // this._handle?.down('[fullscreen=true]').hide()
  33498. // return
  33499. // }
  33500. if (params === void 0) { params = null; }
  33501. if (scopeTag === void 0) { scopeTag = undefined; }
  33502. var handle = Ext.Viewport.getActiveItem();
  33503. // 被满屏显示的组件,返回按钮的效果,是隐藏这个组件
  33504. var fullScreenCmp = handle === null || handle === void 0 ? void 0 : handle.down('[fullscreen=true]');
  33505. if (fullScreenCmp === null || fullScreenCmp === void 0 ? void 0 : fullScreenCmp.isVisible()) {
  33506. fullScreenCmp.hide();
  33507. return;
  33508. }
  33509. var tagIndex = 0;
  33510. var currentIndex = Scope.SHOW_PAGE_STACK.findIndex(function (scope) { return scope._handle === handle; });
  33511. if (scopeTag) {
  33512. tagIndex = Scope.SHOW_PAGE_STACK.findIndex(function (scope) { return scope.scopeTag === scopeTag; });
  33513. if (tagIndex < 0) {
  33514. return;
  33515. }
  33516. }
  33517. else {
  33518. if (currentIndex > 0) {
  33519. tagIndex = currentIndex - 1;
  33520. }
  33521. }
  33522. // console.log("###### remove", index)
  33523. if (tagIndex >= 0) {
  33524. Scope.SHOW_PAGE_STACK.splice(currentIndex, currentIndex - tagIndex);
  33525. }
  33526. if (Scope.SHOW_PAGE_STACK.length > 0) {
  33527. var scope = Scope.SHOW_PAGE_STACK[Scope.SHOW_PAGE_STACK.length - 1];
  33528. scope._handle.setStyle({ 'z-index': 1 });
  33529. Ext.Viewport.getLayout().setAnimation({ type: 'slide', direction: 'right', duration: 300 });
  33530. Ext.Viewport.setActiveItem(scope._handle);
  33531. scope._lastShowTime = new Date().getTime();
  33532. scope._onGoBack.bind(scope, params).apply();
  33533. // console.log("###### show", (scopeArr.length - 1), Scope.SHOW_PAGE_STACK)
  33534. }
  33535. // 关闭
  33536. handle.setStyle({ 'z-index': 0 });
  33537. // Ext.Viewport.getLayout().setAnimation({type: 'slide', direction: 'right', duration: 300})
  33538. Ext.Viewport.remove(handle);
  33539. handle.close();
  33540. };
  33541. /**
  33542. * 对话框"保存"成功.
  33543. * 关闭对话框,并响应 success 方法
  33544. * @param data 要傳回的數據(可以為空)
  33545. */
  33546. Scope.prototype.dialogSuccess = function (data) {
  33547. this._handle.fireEvent('success', this, data);
  33548. var sender = this._handle.config.animateTarget;
  33549. var scope = lookupScope(sender);
  33550. if (typeof this['success'] === 'function') {
  33551. this['success'].call(scope, sender, data);
  33552. }
  33553. this.close();
  33554. };
  33555. /**
  33556. * 设置等待状态
  33557. * @param value
  33558. * @param msg
  33559. */
  33560. Scope.prototype.setLoading = function (value) {
  33561. var _a, _b;
  33562. var scope = this;
  33563. if (value) {
  33564. (_a = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _a === void 0 ? void 0 : _a.setMasked({ xtype: 'loadmask', message: '请稍等...' });
  33565. }
  33566. else {
  33567. (_b = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _b === void 0 ? void 0 : _b.unmask();
  33568. }
  33569. // scope._handle?.setLoading(value)
  33570. };
  33571. Scope.prototype.showDialog = function (sender, vjsonOption, dataOption) {
  33572. if (vjsonOption === void 0) { vjsonOption = {}; }
  33573. if (dataOption === void 0) { dataOption = {}; }
  33574. var _a;
  33575. var that = this;
  33576. lodash.defaults(vjsonOption, {});
  33577. lodash.defaults(dataOption, {});
  33578. this._vjsonOption = vjsonOption;
  33579. this._dataOption = dataOption;
  33580. var vmodel = lodash.defaultsDeep({
  33581. data: {}
  33582. }, dataOption, that.model);
  33583. var config = lodash.defaultsDeep({
  33584. // viewModel: this.viewModel,
  33585. viewModel: vmodel,
  33586. yvanScope: this,
  33587. referenceHolder: true,
  33588. }, vjsonOption, that.vjson, {
  33589. xtype: 'dialog',
  33590. });
  33591. if (config.height === 'unset') {
  33592. delete config.height;
  33593. }
  33594. if (config.width === 'unset') {
  33595. delete config.width;
  33596. }
  33597. var topScope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  33598. if (topScope) {
  33599. config.constrain = true;
  33600. this.topScope = topScope;
  33601. }
  33602. that._handle = Ext.create(config);
  33603. this.viewModel = that._handle.getViewModel();
  33604. this.viewModel.yvanScope = this;
  33605. that._handle.on({
  33606. show: function (sender, eOpts) {
  33607. that._handle = this;
  33608. window['cw'] = that;
  33609. // 调用onLoad回调
  33610. try {
  33611. //@ts-ignore
  33612. that.onLoad();
  33613. }
  33614. catch (e) {
  33615. console.error('errorAt onLoad', e);
  33616. }
  33617. },
  33618. destroy: function () {
  33619. // 卸载
  33620. that._onDestroy();
  33621. },
  33622. });
  33623. that._handle.show();
  33624. };
  33625. /**
  33626. * 关闭对话框(或标签页)
  33627. */
  33628. Scope.prototype.close = function () {
  33629. this._handle.close();
  33630. };
  33631. Object.defineProperty(Scope.prototype, "data", {
  33632. /**
  33633. * 获取 viewModel 里包含的数据(只读)
  33634. */
  33635. get: function () {
  33636. return this.viewModel.getData();
  33637. },
  33638. enumerable: true,
  33639. configurable: true
  33640. });
  33641. /**
  33642. * 设置 viewModel 中的数据
  33643. * 可以是 key, value 模式
  33644. * 也可以是 {key:value} 模式
  33645. */
  33646. Scope.prototype.set = function (path, value) {
  33647. return this.viewModel.set(path, value);
  33648. };
  33649. /**
  33650. * 寻找模块内所有的 xtype 对应的对象
  33651. * @param xtypeKey
  33652. */
  33653. Scope.prototype.down = function (xtypeKey) {
  33654. return this._handle.down(xtypeKey);
  33655. };
  33656. Object.defineProperty(Scope.prototype, "refs", {
  33657. /**
  33658. * 获取所有设置过 Reference 名称的组件
  33659. */
  33660. get: function () {
  33661. var _a, _b;
  33662. return (_b = (_a = this._handle) === null || _a === void 0 ? void 0 : _a.getReferences()) !== null && _b !== void 0 ? _b : {};
  33663. },
  33664. enumerable: true,
  33665. configurable: true
  33666. });
  33667. Scope.SHOW_PAGE_STACK = [];
  33668. return Scope;
  33669. }());
  33670. /**
  33671. * 全局 ajax 方法
  33672. */
  33673. var ajax = {};
  33674. /**
  33675. * 计算拼音的函数
  33676. */
  33677. var pinyinFunc = function (str) { return (str); };
  33678. exports.scopeOnLoad = null;
  33679. exports.apiConvert = undefined;
  33680. var baseConfigProcessList = [];
  33681. /**
  33682. * 在基类添加 Config 的处理方法
  33683. */
  33684. function baseConfigProcess(option) {
  33685. return function (target, propertyKey) {
  33686. baseConfigProcessList.push(target[propertyKey]);
  33687. };
  33688. }
  33689. var designMode = false;
  33690. function isDesignMode() {
  33691. return designMode;
  33692. }
  33693. function setDesignMode(v) {
  33694. designMode = v;
  33695. }
  33696. /**
  33697. * 将业务定义的 url 转换为调用服务端 groovy 的 url
  33698. */
  33699. function serverInvokeUrlTransform(url, option) {
  33700. return lodash.get(window, '_YvanUI_serverInvokePrefix')(url, option);
  33701. }
  33702. /**
  33703. * 将业务定义的 url 转换为调用服务端 sql 的 Url
  33704. */
  33705. function sqlUrlTransform(url) {
  33706. return lodash.get(window, '_YvanUI_sqlPrefix')(url);
  33707. }
  33708. /**
  33709. * YvanUI 全局扩展配置
  33710. */
  33711. function extend$1(option) {
  33712. if (option.ajax) {
  33713. ajax.func = option.ajax;
  33714. }
  33715. if (option.serverInvokeUrlTransform) {
  33716. lodash.extend(window, { _YvanUI_serverInvokePrefix: option.serverInvokeUrlTransform });
  33717. }
  33718. if (option.sqlUrlTransform) {
  33719. lodash.extend(window, { _YvanUI_sqlPrefix: option.sqlUrlTransform });
  33720. }
  33721. if (option.pinyinFunction) {
  33722. pinyinFunc = option.pinyinFunction;
  33723. }
  33724. if (option.scopeOnLoad) {
  33725. exports.scopeOnLoad = option.scopeOnLoad;
  33726. }
  33727. if (option.apiConvert) {
  33728. exports.apiConvert = option.apiConvert;
  33729. }
  33730. if (typeof option.designMode !== 'undefined') {
  33731. setDesignMode(option.designMode);
  33732. }
  33733. }
  33734. function getApiConvert() {
  33735. return exports.apiConvert;
  33736. }
  33737. function getPinyin(v) {
  33738. return pinyinFunc(v);
  33739. }
  33740. /**
  33741. * 适用于 Select / Tree 等,作筛选的通用方法.
  33742. * 1.首字母模糊匹配(不区分大小写)
  33743. * 2.标识的模糊匹配(不区分大小写)
  33744. * 3.名称的模糊匹配,且支持以逗号(全角或半角)隔开的字词匹配,并自动去空格,如“南京, 物流 ”可以匹配出“南京九州通物流技术开发有限公司”
  33745. */
  33746. function keywordFilter(keyword, label, value) {
  33747. if (!keyword) {
  33748. return true;
  33749. }
  33750. var ws = lodash.trim(keyword).split(/\s+|\.|,|\)|\(|,|。|-|—/g);
  33751. var labelPy = lodash.toLower(getPinyin(label));
  33752. value = lodash.toLower(lodash.trim(value));
  33753. var found = 0;
  33754. lodash.some(ws, function (word) {
  33755. if (labelPy.indexOf(word.toLowerCase()) >= 0 || label.indexOf(word) >= 0) {
  33756. found++;
  33757. return;
  33758. }
  33759. if (value && value.indexOf(word.toLowerCase()) >= 0) {
  33760. found++;
  33761. return;
  33762. }
  33763. });
  33764. return found >= ws.length;
  33765. }
  33766. function initComponent () {
  33767. var ct = Ext.Component.prototype.constructor;
  33768. Ext.Component.override({
  33769. constructor: function (config) {
  33770. var _a, _b;
  33771. if (!window["IS_DESIGN_MODE"] && config) {
  33772. var me_1 = this;
  33773. // 任意组件 Ext.Component 构造时调用的方法, 可以用来在渲染之前加工处理 VJSON
  33774. lodash.each(baseConfigProcessList, function (process) {
  33775. process.call(me_1, me_1, config);
  33776. });
  33777. }
  33778. if (config) {
  33779. if (!config.i18nPath && ((_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.i18nPath)) {
  33780. config.i18nPath = config.$initParent.i18nPath;
  33781. }
  33782. if ((_b = config.$initParent) === null || _b === void 0 ? void 0 : _b.setTitle) {
  33783. var setTitle_1 = config.$initParent.setTitle;
  33784. var handel_1 = config.$initParent;
  33785. config.$initParent.setTitle = function (title) {
  33786. var t = { title: title };
  33787. var WMSTranslate = window["WMSTranslate"];
  33788. if (WMSTranslate) {
  33789. if (typeof window['viewTranslate'] === 'function') {
  33790. window['viewTranslate'](t, title, "title");
  33791. }
  33792. }
  33793. setTitle_1.call(handel_1, t.title);
  33794. }.bind(config.$initParent);
  33795. }
  33796. var WMSTranslate = window["WMSTranslate"];
  33797. if (WMSTranslate) {
  33798. if (typeof window['viewTranslate'] === 'function') {
  33799. window['viewTranslate'](config, config.text, "text");
  33800. window['viewTranslate'](config, config.title, "title");
  33801. window['viewTranslate'](config, config.header, "header");
  33802. window['viewTranslate'](config, config.fieldLabel, "fieldLabel");
  33803. window['viewTranslate'](config, config.label, "label");
  33804. window['viewTranslate'](config, config.boxLabel, "boxLabel");
  33805. window['viewTranslate'](config, config.html, "html");
  33806. window['viewTranslate'](config, config.emptyText, "emptyText");
  33807. }
  33808. }
  33809. }
  33810. ct.call(this, config);
  33811. }
  33812. });
  33813. }
  33814. var labelWidth = 80;
  33815. var date = {
  33816. labelTextAlign: 'right',
  33817. // picker: 'edge',
  33818. picker: {
  33819. xtype: 'datepicker',
  33820. slotOrder: ['year', 'month', 'day'],
  33821. yearFrom: 1990,
  33822. yearTo: 2050,
  33823. },
  33824. clearable: true,
  33825. maxDate: moment('2050-12-31').toDate(),
  33826. minDate: moment('1990-01-01').toDate(),
  33827. // picker: 'floated',
  33828. labelWidth: labelWidth,
  33829. };
  33830. var column = {
  33831. menuDisabled: true
  33832. };
  33833. var grid = {
  33834. border: true,
  33835. columnLines: true,
  33836. rowLines: true,
  33837. scrollable: true,
  33838. plugins: {
  33839. cellediting: {
  33840. clicksToEdit: 1
  33841. },
  33842. gridfilters: true
  33843. },
  33844. multiColumnSort: true,
  33845. viewConfig: {
  33846. enableTextSelection: true,
  33847. sortOnClick: false,
  33848. },
  33849. selModel: {
  33850. type: 'checkboxmodel',
  33851. checkOnly: false
  33852. },
  33853. pagination: false,
  33854. pageSize: 50,
  33855. pageSizeOption: ['20', '50', '100', '200', '300'],
  33856. hideFootbar: false,
  33857. hideRefresh: false,
  33858. hideExport: false,
  33859. hideAutoSize: false,
  33860. hideClearFilter: false,
  33861. hideSaveGridUIConfig: false,
  33862. hideClearGridUIConfig: false,
  33863. autoLoad: true,
  33864. remoteSort: false,
  33865. remoteFilter: false,
  33866. enableLocking: true,
  33867. enableColumnMove: true,
  33868. enableColumnHide: true,
  33869. enableColumnResize: true,
  33870. hidden: false,
  33871. disabled: false,
  33872. exportExcelPageSize: 100,
  33873. exportExcelCurrentPage: 1,
  33874. exportExcelTotal: 0,
  33875. };
  33876. var search = {
  33877. labelAlign: 'left',
  33878. labelWidth: labelWidth,
  33879. };
  33880. var text = {
  33881. labelTextAlign: 'right',
  33882. labelWidth: 80,
  33883. msgTarget: 'qtip',
  33884. };
  33885. var storeAjax = {
  33886. timeout: 60000
  33887. };
  33888. var list = {
  33889. fullscreen: true,
  33890. hidden: true,
  33891. autoLoad: false,
  33892. pagination: true,
  33893. pageSize: 10,
  33894. autoPaging: true,
  33895. plugins: {
  33896. pullrefresh: {
  33897. mergeData: false,
  33898. pullText: '下拉刷新',
  33899. releaseText: '释放后刷新',
  33900. lastUpdatedDateFormat: 'Y-m-d H:i:s',
  33901. lastUpdatedText: '最后更新:',
  33902. loadedText: '加载完成',
  33903. loadingText: '加载中...',
  33904. }
  33905. },
  33906. showAnimation: {
  33907. type: 'slide',
  33908. direction: 'left',
  33909. },
  33910. hideAnimation: {
  33911. type: 'slideOut',
  33912. direction: 'right',
  33913. },
  33914. };
  33915. var cols = {
  33916. defaults: {
  33917. flex: 1
  33918. },
  33919. };
  33920. var rows = {
  33921. defaults: {
  33922. flex: 1
  33923. },
  33924. };
  33925. if (!window["time_offset"]) {
  33926. window["time_offset"] = 0;
  33927. }
  33928. function syncDate(date) {
  33929. if (date && date.setTime && date.getTime) {
  33930. date.setTime(date.getTime() + window["time_offset"]);
  33931. }
  33932. return date;
  33933. }
  33934. function initDate () {
  33935. var cc = Ext.field.Date.prototype.constructor;
  33936. var _a = Ext.field.Date.prototype, initialize = _a.initialize, getValue = _a.getValue, valueToRaw = _a.valueToRaw, onPickerChange = _a.onPickerChange;
  33937. Ext.field.Date.override({
  33938. dateFormat: 'Y-m-d',
  33939. altFormats: 'Y-m-d',
  33940. constructor: function (config) {
  33941. var newConfig = lodash.defaultsDeep({
  33942. // 强制属性
  33943. }, date, config);
  33944. cc.call(this, newConfig);
  33945. },
  33946. getValue: function () {
  33947. var ov = getValue.call(this);
  33948. var nv = Ext.util.Format.date(ov, 'Y-m-d');
  33949. return nv;
  33950. },
  33951. onPickerChange: function (sender, value) {
  33952. var _a, _b, _c;
  33953. onPickerChange.call(this, sender, value);
  33954. value = Ext.util.Format.date(value, 'Y-m-d');
  33955. var scope = lookupScope(this);
  33956. // console.log('cc:', nv, ov)
  33957. if (scope) {
  33958. var bind = '';
  33959. if (typeof ((_a = this.config.bind) === null || _a === void 0 ? void 0 : _a.value) === 'string') {
  33960. bind = (_b = this.config.bind) === null || _b === void 0 ? void 0 : _b.value;
  33961. }
  33962. else if (typeof this.config.bind === 'string') {
  33963. bind = this.config.bind;
  33964. }
  33965. if (bind && lodash.startsWith(bind, '{') && lodash.endsWith(bind, '}')) {
  33966. bind = bind.substr(1, bind.length - 2);
  33967. if (bind) {
  33968. scope.viewModel.set(bind, value);
  33969. (_c = sender.ownerCmp) === null || _c === void 0 ? void 0 : _c.fireEvent('change2', sender, value);
  33970. }
  33971. }
  33972. }
  33973. },
  33974. initialize: function () {
  33975. this.on({
  33976. expand: function (sender, opts) {
  33977. var value = sender.getRawValue();
  33978. if (value) {
  33979. //@ts-ignore
  33980. var dt_1 = moment(value).toDate();
  33981. var picker_1 = sender.getPicker();
  33982. picker_1.setValue(dt_1);
  33983. // 延迟200毫秒后再设定一次值,动画会造成 bug
  33984. setTimeout(function () {
  33985. picker_1.setValue(dt_1);
  33986. }, 200);
  33987. }
  33988. else {
  33989. var dt_2 = syncDate(new Date());
  33990. var picker_2 = sender.getPicker();
  33991. picker_2.setValue(dt_2);
  33992. setTimeout(function () { return picker_2.setValue(dt_2); }, 200);
  33993. }
  33994. },
  33995. });
  33996. initialize.call(this);
  33997. },
  33998. });
  33999. }
  34000. function initText () {
  34001. var cc = Ext.field.Text.prototype.constructor;
  34002. var _a = Ext.field.Text.prototype, initialize = _a.initialize, getValue = _a.getValue, valueToRaw = _a.valueToRaw, onPickerChange = _a.onPickerChange;
  34003. Ext.field.Text.override({
  34004. constructor: function (config) {
  34005. var newConfig = lodash.defaultsDeep({
  34006. // 强制属性
  34007. }, config, text);
  34008. cc.call(this, newConfig);
  34009. },
  34010. initialize: function () {
  34011. var that = this;
  34012. this.on({
  34013. initialize: function () {
  34014. $(this.el.dom).on('keyup', function (e) {
  34015. if ([10, 13, 20, 40].includes(e.keyCode)) {
  34016. // const value = sender.getRawValue()
  34017. // console.log('keyup2', value)
  34018. that.fireEvent('scancode', that, e.target.value);
  34019. }
  34020. });
  34021. $(this.el.dom).on('click', function (e) {
  34022. that.fireEvent('click', that, e);
  34023. });
  34024. }
  34025. });
  34026. initialize.call(this);
  34027. },
  34028. });
  34029. }
  34030. /**
  34031. * 构建所有组件的公共属性
  34032. * @param config 原始config
  34033. * @param dragType 组件模式
  34034. * 不填,代表不能在设计时被拖拽
  34035. * row-container 是一个rows容器
  34036. * col-container 是一个cols容器
  34037. * col-item cols中的一个格子(非容器),比如 textfield / combofield 等等
  34038. * row-item rows中的一行,比如 tree / grid / panel 等等
  34039. */
  34040. function baseConfig(config, dragType) {
  34041. if (config && config.designMode && dragType) {
  34042. var cc = '';
  34043. switch (dragType) {
  34044. case "cols-container":
  34045. cc = 'design_cols_container';
  34046. break;
  34047. case "col-item":
  34048. cc = 'design_col_item';
  34049. break;
  34050. case "rows-container":
  34051. cc = 'design_rows_container';
  34052. break;
  34053. case "row-item":
  34054. cc = 'design_row_item';
  34055. break;
  34056. }
  34057. if (typeof config.cls === 'string') {
  34058. lodash.extend(config, {
  34059. cls: [config.cls, 'yvan_design', cc]
  34060. });
  34061. }
  34062. else if (lodash.isArray(config.cls)) {
  34063. lodash.extend(config, {
  34064. cls: __spread(config.cls, ['yvan_design', cc])
  34065. });
  34066. }
  34067. else {
  34068. lodash.extend(config, {
  34069. cls: ['yvan_design', cc]
  34070. });
  34071. }
  34072. }
  34073. return config;
  34074. }
  34075. function prompt(message, multiLine, value) {
  34076. if (value === void 0) { value = ''; }
  34077. return new Promise(function (resolve, reject) {
  34078. Ext.Msg.show({
  34079. title: message,
  34080. message: null,
  34081. buttons: Ext.MessageBox.OKCANCEL,
  34082. prompt: true,
  34083. defaultFocus: 'textfield',
  34084. // multiLine: multiLine,
  34085. cls: 'laberHidden',
  34086. showAnimation: false,
  34087. hideAnimation: false,
  34088. value: value,
  34089. fn: function (okcancel, value) {
  34090. if (okcancel === 'ok') {
  34091. resolve(value);
  34092. }
  34093. else {
  34094. reject();
  34095. }
  34096. }
  34097. });
  34098. });
  34099. }
  34100. function confirm(message) {
  34101. return new Promise(function (resolve, reject) {
  34102. return Ext.Msg.show({
  34103. title: '',
  34104. message: message || null,
  34105. buttons: Ext.MessageBox.YESNO,
  34106. defaultFocus: '#yes',
  34107. prompt: false,
  34108. showAnimation: false,
  34109. hideAnimation: false,
  34110. fn: function (yesno) {
  34111. if (yesno === 'yes') {
  34112. resolve();
  34113. }
  34114. }
  34115. });
  34116. });
  34117. }
  34118. function showInfoDialog(msg, fn) {
  34119. console.error(msg);
  34120. Ext.Msg.show({
  34121. title: '提示',
  34122. message: msg,
  34123. showAnimation: false,
  34124. hideAnimation: false,
  34125. defaultFocus: '#ok',
  34126. prompt: false,
  34127. fn: fn,
  34128. });
  34129. }
  34130. /**
  34131. * 显示错误异常信息
  34132. * @param msg 错误内容
  34133. * @param fn 确定之后的回调
  34134. */
  34135. function showErrorDialog(msg, fn) {
  34136. console.error(msg);
  34137. Ext.Msg.show({
  34138. title: '错误',
  34139. message: msg,
  34140. showAnimation: false,
  34141. hideAnimation: false,
  34142. defaultFocus: '#ok',
  34143. prompt: false,
  34144. fn: fn,
  34145. });
  34146. }
  34147. function msgError(msg, fn) {
  34148. showErrorDialog(msg, fn);
  34149. }
  34150. /**
  34151. * 中间灰底白字提示
  34152. */
  34153. function msg(message) {
  34154. console.log(message);
  34155. var $body = jquery('body');
  34156. $body.find('[xtype=tooltip]').remove();
  34157. var $w = jquery('<div xtype="tooltip" class="yvan-msg yvan-anim yvan-anim-00">' +
  34158. ' <div class="yvan-msg-content">' +
  34159. lodash.escape(message) +
  34160. '</div></div>');
  34161. $body.append($w);
  34162. var iframeWidth = $w.parent().width();
  34163. var iframeHeight = $w.parent().height();
  34164. var windowWidth = $w.width();
  34165. var windowHeight = $w.height();
  34166. var setWidth = (iframeWidth - windowWidth) / 2;
  34167. var setHeight = (iframeHeight - windowHeight) / 2;
  34168. if (iframeHeight < windowHeight || setHeight < 0) {
  34169. setHeight = 0;
  34170. }
  34171. if (iframeWidth < windowWidth || setWidth < 0) {
  34172. setWidth = 0;
  34173. }
  34174. $w.css({ left: setWidth, top: setHeight });
  34175. setTimeout(function () {
  34176. $w.remove();
  34177. }, 3000);
  34178. }
  34179. var SIMPLE_RE = /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i;
  34180. /**
  34181. * 替换内部结构中,所有 N/A
  34182. */
  34183. function replaceNA(obj) {
  34184. if (obj === 'N/A') {
  34185. return '';
  34186. }
  34187. if (typeof obj === "string" && /^-?\d*\.?\d+$/.test(obj)) {
  34188. return parseFloat(obj) + "";
  34189. }
  34190. if (lodash.isArray(obj)) {
  34191. lodash.forEach(obj, function (value, idx) {
  34192. if (value === 'N/A') {
  34193. obj[idx] = '';
  34194. }
  34195. else {
  34196. replaceNA(value);
  34197. }
  34198. });
  34199. }
  34200. else if (lodash.isPlainObject(obj)) {
  34201. lodash.forOwn(obj, function (value, key) {
  34202. if (value === 'N/A') {
  34203. obj[key] = '';
  34204. }
  34205. else {
  34206. replaceNA(value);
  34207. }
  34208. });
  34209. }
  34210. }
  34211. /**
  34212. * 对某个表达式进行求值
  34213. * a:{query.a},b:{query.b} -> a:aValue,b:bValue
  34214. *
  34215. * @example
  34216. * calcExpress(cc.viewModel.data, "WH_ID:{query.WH_ID},C:{theGrid.selection.data.WH_ID}")
  34217. * 计算出来的值是: "WH_ID:queryWhId,C:JH000000001"
  34218. *
  34219. * @param data 数据环境对象
  34220. * @param express 表达式对象
  34221. */
  34222. function calcExpress(data, express) {
  34223. var result = express;
  34224. if (SIMPLE_RE.test(express)) {
  34225. // '{foo}' 简单表达式
  34226. var path = express.substring(1, express.length - 1);
  34227. var ret = lodash.get(data, path);
  34228. return (ret === null || ret === void 0 ? void 0 : ret.isModel) ? ret.data : ret;
  34229. }
  34230. while (true) {
  34231. var mlist = result.match(/{(.*?)}/);
  34232. if (!mlist) {
  34233. break;
  34234. }
  34235. var pathC = mlist[0]; // {query.a}
  34236. var path = mlist[1]; // query.a
  34237. var value = lodash.get(data, path);
  34238. result = result.replaceAll(pathC, value || '');
  34239. }
  34240. return result;
  34241. }
  34242. /**
  34243. * 对个对象进行表达式求值,不用回调
  34244. * @example
  34245. * calcObjectFlat({query:{a:'aValue',b1:'b1Value',b2:'b2Value',d1:1,d2:2}}, { a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}'] })
  34246. *
  34247. * {
  34248. * a: '{query.a}',
  34249. * b: {
  34250. * b1: '{query.b1}',
  34251. * b2: '{query.b2}',
  34252. * },
  34253. * c: 'aa',
  34254. * d: [
  34255. * '{query.d1}',
  34256. * '{query.d2}'
  34257. * ]
  34258. * }
  34259. *
  34260. * 计算结果为
  34261. * {
  34262. * a: 'aValue',
  34263. * b: {
  34264. * b1: 'b1Value',
  34265. * b2: 'b2Value'
  34266. * },
  34267. * c: 'aa'
  34268. * d: [
  34269. * '1',
  34270. * '2'
  34271. * ]
  34272. * }
  34273. *
  34274. * @param data
  34275. * @param paramObject
  34276. */
  34277. function calcObjectFlat(data, paramObject) {
  34278. var result = lodash.cloneDeep(paramObject);
  34279. if (typeof paramObject === 'string') {
  34280. return calcExpress(data, paramObject);
  34281. }
  34282. var trav = function (param) {
  34283. lodash.forOwn(param, function (value, key) {
  34284. if (lodash.isPlainObject(value)) {
  34285. // 深度递归,对子对象进行求解
  34286. trav(value);
  34287. }
  34288. else if (lodash.isString(value)) {
  34289. // 字符串直接用 calcExpress 表达式求解
  34290. param[key] = calcExpress(data, param[key]);
  34291. }
  34292. else if (lodash.isArray(value)) {
  34293. // 数组求解
  34294. lodash.each(value, function (v, idx) {
  34295. value[idx] = calcExpress(data, v);
  34296. });
  34297. }
  34298. });
  34299. };
  34300. trav(result);
  34301. return result;
  34302. }
  34303. /**
  34304. * 合併 data 到當前的 ViewModel 對象
  34305. */
  34306. function mergeViewModel(viewModel, propertyName, data) {
  34307. var newRow = {};
  34308. flatObject$1(newRow, '', data);
  34309. lodash.forOwn(newRow, function (value, key) {
  34310. viewModel.set(propertyName + "." + key, value);
  34311. });
  34312. }
  34313. /**
  34314. * 转换内联结构的行,到平面结构
  34315. * company: { name:'公司1', id:'编号1' } => { company_id:'编号1', company_name:'公司1' }
  34316. *
  34317. * @param array
  34318. * @param flatOption
  34319. * @return {[]}
  34320. */
  34321. function flatRow$1(array) {
  34322. var ret = [];
  34323. lodash.forEach(array, function (row) {
  34324. var newRow = {};
  34325. flatObject$1(newRow, '', row);
  34326. ret.push(newRow);
  34327. });
  34328. return ret;
  34329. }
  34330. function flatObject$1(parentObj, parentProp, obj) {
  34331. lodash.forOwn(obj, function (value, key) {
  34332. var fullKey = parentProp ? parentProp + '_' + key : key;
  34333. if (lodash.isArray(value)) {
  34334. parentObj[fullKey] = lodash.map(value, function (row) {
  34335. var newRow = {};
  34336. flatObject$1(newRow, '', row);
  34337. return newRow;
  34338. });
  34339. }
  34340. else {
  34341. if (typeof value === 'object') {
  34342. flatObject$1(parentObj, fullKey, value);
  34343. }
  34344. else {
  34345. parentObj[fullKey] = value;
  34346. }
  34347. }
  34348. });
  34349. }
  34350. /**
  34351. * 根据表达式进入写值
  34352. * express="{query.a}" 写值就是 viewModel.set('query.a', value)
  34353. * express="test-{query.a}" 写值就会失败
  34354. *
  34355. * @example
  34356. * tryWriteByExpress(cc.viewModel, "{query.WH_ID}", "111")
  34357. * 写值成功
  34358. *
  34359. * tryWriteByExpress(cc.viewModel, "test-{query.WH_ID}", "111")
  34360. * 写值失败
  34361. *
  34362. * @param viewModel VM对象
  34363. * @param express 表达式对象
  34364. * @param value 目标值
  34365. */
  34366. function tryWriteByExpress(viewModel, express, value) {
  34367. if (SIMPLE_RE.test(express)) {
  34368. // '{foo}' 简单表达式
  34369. express = express.substring(1, express.length - 1);
  34370. viewModel.set(express, value);
  34371. }
  34372. }
  34373. /**
  34374. * 尝试根据含表达式的对象回写, calcObjectFlat 的逆向方法
  34375. * @example
  34376. * tryWriteObject({ a:'{query.a}', b:{b1:'{query.b1}', b2:'{query.b2}'},c:'aa',d:['{query.d1}','{query.d2}']}, {a:'aValue', b:{b1:'b1Value', b2:'b2Value'}, c:'aa', d:[1,2]})
  34377. *
  34378. * expressObject:
  34379. * {
  34380. * a: '{query.a}',
  34381. * b: {
  34382. * b1: '{query.b1}',
  34383. * b2: '{query.b2}',
  34384. * },
  34385. * c: 'aa',
  34386. * d: [
  34387. * '{query.a}',
  34388. * '{query.b2}'
  34389. * ]
  34390. * }
  34391. *
  34392. * valueObject:
  34393. * {
  34394. * a: 'aValue',
  34395. * b: {
  34396. * b1: 'b1Value',
  34397. * b2: 'b2Value'
  34398. * },
  34399. * c: 'aa'
  34400. * c: [
  34401. * 'aValue',
  34402. * 'b2Value'
  34403. * ]
  34404. * }
  34405. *
  34406. * 系统会尝试回写
  34407. * viewModel.set('query.a', 'aValue')
  34408. * viewModel.set('query.b1', 'b1Value')
  34409. * viewModel.set('query.b2', 'b2Value')
  34410. *
  34411. * @param expressObject 含表达式的对象
  34412. * @param valueObject 表达式计算完成之后的结果对象
  34413. * @param writeFn 写入的方法 (path, value)=>void
  34414. */
  34415. function tryWriteObject(expressObject, valueObject, writeFn) {
  34416. var trav = function (pathPrefix) {
  34417. var parent = expressObject;
  34418. if (lodash.size(pathPrefix) > 1) {
  34419. parent = lodash.get(parent, pathPrefix.substring(1));
  34420. }
  34421. lodash.forOwn(parent, function (value, key) {
  34422. if (lodash.isPlainObject(value)) {
  34423. // 深度递归,对子对象进行求解
  34424. trav(pathPrefix + "." + key);
  34425. }
  34426. else if (lodash.isString(value)) {
  34427. // 字符串直接用 calcExpress 表达式求解
  34428. if (SIMPLE_RE.test(value)) {
  34429. // If we have '{foo}' alone it is a literal 简单表达式
  34430. var targetPath = value.substring(1, value.length - 1);
  34431. var targetValue = lodash.get(valueObject, (pathPrefix + "." + key).substr(1));
  34432. if (!writeFn) {
  34433. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  34434. }
  34435. else {
  34436. writeFn(targetPath, targetValue);
  34437. }
  34438. }
  34439. }
  34440. else if (lodash.isArray(value)) {
  34441. lodash.each(value, function (v, idx) {
  34442. if (SIMPLE_RE.test(v)) {
  34443. var targetPath = (pathPrefix + "." + key).substr(1) + "[" + idx + "]";
  34444. var targetValue = lodash.get(valueObject, (pathPrefix + "." + key).substr(1) + "[" + idx + "]");
  34445. if (!writeFn) {
  34446. console.log("viewModel.set('" + targetPath + "', '" + targetValue + "')");
  34447. }
  34448. else {
  34449. writeFn(targetPath, targetValue);
  34450. }
  34451. }
  34452. });
  34453. }
  34454. });
  34455. };
  34456. trav("");
  34457. }
  34458. /**
  34459. * 尝试去掉变量两边括号
  34460. * {a} => a
  34461. * a => a
  34462. */
  34463. function tryVarSimple(value) {
  34464. if (SIMPLE_RE.test(value)) {
  34465. // If we have '{foo}' alone it is a literal 简单表达式
  34466. return value.substring(1, value.length - 1);
  34467. }
  34468. return value;
  34469. }
  34470. /**
  34471. * 对多个表达式进行求值. 异步回调的方式返回
  34472. * {
  34473. * a: 1,
  34474. * b: '{someBind}',
  34475. * c: ['a', 'b', 'c'],
  34476. * d: ['a', 'b', '{someBind}'],
  34477. * e: {
  34478. * y: 1,
  34479. * z: 2
  34480. * },
  34481. * f: {
  34482. * y: 1,
  34483. * z: '{someBind}'
  34484. * }
  34485. * }
  34486. *
  34487. * // Will produce
  34488. * {
  34489. * b: value,
  34490. * d: ['a', 'b', value],
  34491. * f: {
  34492. * y: 1,
  34493. * z: value
  34494. * }
  34495. * }
  34496. * @param viewModel scope.viewModel对象
  34497. * @param paramObject 求值对象
  34498. */
  34499. function calcObject(viewModel, paramObject) {
  34500. // new Ext.app.bind.Multi({a:'1',b:'ddd{query.WH_ID}'},currentScope.viewModel,function(v){console.log(v)},currentScope, {single: true})
  34501. return new Promise(function (resolve) {
  34502. var schedule = new Ext.app.bind.Multi(paramObject, viewModel, function (ret) {
  34503. schedule.destroy();
  34504. // 从 Ext.data.Model 对象转换为 js-object 对象
  34505. ret = toPlainObject(ret);
  34506. resolve(ret);
  34507. }, viewModel, { single: true });
  34508. });
  34509. }
  34510. /**
  34511. * 用于任意组件 Ext.Component 构造时,获取当前组件对应的表格(如果不是 grid.columns 对象就会返回 undefined)
  34512. * @param config 组件构造函数传入的 config 配置文件
  34513. */
  34514. function getParentGrid(config) {
  34515. var _a;
  34516. return (_a = config.$initParent) === null || _a === void 0 ? void 0 : _a.grid;
  34517. }
  34518. /**
  34519. * 解析
  34520. * {
  34521. * condition: "{skuId}",
  34522. * errorMsg: "无法编辑",
  34523. * notice: 'msg'
  34524. * }
  34525. */
  34526. function tryEnable(data, enableSetting) {
  34527. if (!enableSetting) {
  34528. // 没有这一段配置,可以编辑
  34529. return true;
  34530. }
  34531. var condition = enableSetting.condition, errorMsg = enableSetting.errorMsg, notice = enableSetting.notice;
  34532. if (!evalFunction(data, condition)) {
  34533. // 没有达成 condition 条件
  34534. // 计算 msg 消息内容
  34535. var msgContent = calcExpress(data, errorMsg);
  34536. if (msgContent) {
  34537. if (!notice || notice === 'msg') {
  34538. // 进行提示
  34539. msg$1(msgContent);
  34540. }
  34541. }
  34542. return false;
  34543. }
  34544. return true;
  34545. }
  34546. /**
  34547. * 动态的为 combo 或 columns.combo 设置下拉框的值
  34548. * @param sender 目标对象
  34549. * @param config 目标对象的配置(在构造函数之前也可以)
  34550. * @param getDictFn 获取字典的方法
  34551. * @param bizKey 传入字典的参数
  34552. * @param multiValueSeparator 多个字典值的分割符号
  34553. */
  34554. function setComboStore(sender, config, getDictFn, bizKey, multiValueSeparator) {
  34555. // sender 和 config为空的时候获取值、
  34556. if (!sender) {
  34557. return new Promise(function (resolve, reject) {
  34558. getDictFn(bizKey, function (r) {
  34559. resolve({ config: config, r: r });
  34560. });
  34561. });
  34562. }
  34563. if (sender.$className === 'Ext.field.Select') {
  34564. getDictFn(bizKey, function (r) {
  34565. var _a, _b;
  34566. // const options = r.data
  34567. var options = lodash.map(r.data, function (r) {
  34568. return {
  34569. value: r.id,
  34570. text: r.text,
  34571. };
  34572. });
  34573. if (sender.getStore()) {
  34574. // 异步回传
  34575. sender.setStore(options);
  34576. // 这里有个bug, 异步回传完毕之后, 需要强制刷新一下
  34577. // 否则在 forceSelection 的模式下。displayField 不会强制做变更
  34578. var realValue = (_b = (_a = sender.bind) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.getValue();
  34579. if (typeof realValue !== 'undefined') {
  34580. sender.setValue(realValue);
  34581. }
  34582. }
  34583. else {
  34584. // 同步回传
  34585. if (sender.isRendered()) {
  34586. sender.setOptions(options);
  34587. }
  34588. else {
  34589. // setOptions 会出现 reference not define 的bug,需要连续3次 defer 才能解决
  34590. lodash.defer(function () {
  34591. if (sender.isRendered()) {
  34592. sender.setOptions(options);
  34593. }
  34594. else {
  34595. lodash.defer(function () {
  34596. if (sender.isRendered()) {
  34597. sender.setOptions(options);
  34598. }
  34599. else {
  34600. lodash.defer(function () {
  34601. sender.setOptions(options);
  34602. });
  34603. }
  34604. });
  34605. }
  34606. });
  34607. }
  34608. // sender.setStore(options)
  34609. }
  34610. });
  34611. return;
  34612. }
  34613. throw new TypeError("无法识别的组件类型");
  34614. }
  34615. /**
  34616. * 调用服务器 Ajax
  34617. */
  34618. function invokeServer(url) {
  34619. var args = [];
  34620. for (var _i = 1; _i < arguments.length; _i++) {
  34621. args[_i - 1] = arguments[_i];
  34622. }
  34623. // @ts-ignore
  34624. return ajax.func({
  34625. url: url,
  34626. method: 'invoke',
  34627. args: args
  34628. });
  34629. }
  34630. function clearViewModelValues(viewModel, propertyName) {
  34631. if (!propertyName) {
  34632. var dd_1 = viewModel.getData();
  34633. lodash.forOwn(dd_1, function (value, key) {
  34634. viewModel.set(key, '');
  34635. });
  34636. return;
  34637. }
  34638. var dd = lodash.get(viewModel.getData(), propertyName);
  34639. lodash.forOwn(dd, function (value, key) {
  34640. viewModel.set(propertyName + '.' + key, '');
  34641. });
  34642. }
  34643. function reloadGrid(scope, gridRefName) {
  34644. var _a;
  34645. (_a = scope.refs[gridRefName]) === null || _a === void 0 ? void 0 : _a.reload();
  34646. }
  34647. /**
  34648. * 将 Ext.data.Model 对象 (及子属性) 转换为 js.object 对象
  34649. */
  34650. function toPlainObject(obj) {
  34651. if (obj.isModel) {
  34652. obj = obj.data;
  34653. }
  34654. lodash.forOwn(obj, function (v, k) {
  34655. // Ext.data.Model.constructor
  34656. if (!v) {
  34657. return;
  34658. }
  34659. if (v.isModel) {
  34660. v = v.data;
  34661. }
  34662. if (typeof v === 'object') {
  34663. obj[k] = toPlainObject(v);
  34664. }
  34665. else {
  34666. obj[k] = v;
  34667. }
  34668. });
  34669. return obj;
  34670. }
  34671. function deepTravJson(obj, resolver) {
  34672. if (lodash.isArray(obj)) {
  34673. lodash.forEach(obj, function (value, idx) {
  34674. if (typeof value === 'string') {
  34675. resolver(obj, value, idx);
  34676. }
  34677. else {
  34678. deepTravJson(value, resolver);
  34679. }
  34680. });
  34681. }
  34682. else if (lodash.isPlainObject(obj)) {
  34683. lodash.forOwn(obj, function (value, key) {
  34684. if (typeof value === 'string') {
  34685. resolver(obj, value, key);
  34686. }
  34687. else {
  34688. deepTravJson(value, resolver);
  34689. }
  34690. });
  34691. }
  34692. }
  34693. function confirm$1(msg, sender) {
  34694. return new Promise(function (resolve, reject) {
  34695. var _a, _b;
  34696. var scope = (_a = lookupScope(sender)) === null || _a === void 0 ? void 0 : _a.topScope;
  34697. var t = { msg: msg };
  34698. var WMSTranslate = window["WMSTranslate"];
  34699. if (WMSTranslate) {
  34700. if (typeof window['viewTranslate'] === 'function') {
  34701. window['viewTranslate'](t, msg, "msg");
  34702. }
  34703. }
  34704. var config = {
  34705. title: '请确认',
  34706. icon: Ext.Msg.QUESTION,
  34707. modal: true,
  34708. animateTarget: sender,
  34709. // resizable: false,
  34710. // constrainHeader: true,
  34711. // constrain: true,
  34712. // constrainTo: scope._handle?.el?.dom || Ext.getBody(),
  34713. items: [
  34714. {
  34715. html: "<div style=\"max-width: 200px; min-width: 100px; min-height: 110px; font-size: 15px\">" + lodash.escape(t.msg) + "</div>"
  34716. }
  34717. ],
  34718. buttons: [
  34719. '->',
  34720. {
  34721. xtype: 'button', text: '取消', iconCls: 'x-fa fa-times',
  34722. width: 90,
  34723. handler: function () {
  34724. reject();
  34725. win.close();
  34726. }
  34727. },
  34728. '->',
  34729. {
  34730. xtype: 'button', text: '确定', iconCls: 'x-fa fa-check',
  34731. width: 90,
  34732. handler: function () {
  34733. resolve();
  34734. win.close();
  34735. }
  34736. },
  34737. '->',
  34738. ]
  34739. };
  34740. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  34741. config.constrain = true;
  34742. }
  34743. var win = new Ext.Window(config);
  34744. if (scope === null || scope === void 0 ? void 0 : scope._handle) {
  34745. (_b = scope === null || scope === void 0 ? void 0 : scope._handle) === null || _b === void 0 ? void 0 : _b.add(win);
  34746. }
  34747. win.show();
  34748. });
  34749. }
  34750. /**
  34751. * 任何符号字符串都替换成下换线
  34752. */
  34753. function normId(value) {
  34754. return lodash.replace(value, /[^\w]/g, '_');
  34755. }
  34756. /**
  34757. *
  34758. * @param sender
  34759. * @param propertyName
  34760. * @param gridRefName
  34761. */
  34762. function clearViewModelReloadGrid(sender, propertyName, gridRefName) {
  34763. var _a, _b;
  34764. var scope = lookupScope(sender);
  34765. clearViewModelValues(scope.viewModel, propertyName);
  34766. if (!gridRefName) {
  34767. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  34768. }
  34769. else {
  34770. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  34771. }
  34772. }
  34773. var SystemEventFu = /** @class */ (function () {
  34774. function SystemEventFu() {
  34775. }
  34776. SystemEventFu.prototype.confirm = function (text, fn) {
  34777. return function (sender) {
  34778. var scope = lookupScope(sender);
  34779. var msg = calcExpress(scope.viewModel.data, text);
  34780. confirm$1(msg, sender).then(function () {
  34781. fn.call(scope, sender);
  34782. });
  34783. };
  34784. };
  34785. SystemEventFu.prototype.gridRemoveCurrentRow = function (gridRefName) {
  34786. return function (sender) {
  34787. var scope = lookupScope(sender);
  34788. var grid = scope.refs[gridRefName];
  34789. if (grid) {
  34790. var records = grid.getSelectionModel().getLastSelected();
  34791. grid.store.remove(records);
  34792. }
  34793. };
  34794. };
  34795. SystemEventFu.prototype.loadForm = function (invokeUrl, invokeParam,
  34796. //可以是 scope.XX / system.XX / string / lookup表达式
  34797. writeTarget) {
  34798. return function (sender) {
  34799. if (!invokeUrl) {
  34800. return;
  34801. }
  34802. var scope = lookupScope(sender);
  34803. scope.setLoading(true);
  34804. var data = scope.viewModel.data;
  34805. if (invokeParam) {
  34806. data = calcObjectFlat(data, invokeParam);
  34807. }
  34808. invokeServer(invokeUrl, data).then(function (res) {
  34809. if (res.success) {
  34810. if (typeof writeTarget === "string") {
  34811. lodash.forOwn(res.data, function (v, k) {
  34812. scope.viewModel.set(writeTarget + "." + k, v);
  34813. });
  34814. }
  34815. else if (typeof writeTarget === 'function') {
  34816. writeTarget.call(scope, res.data);
  34817. }
  34818. else if (typeof writeTarget === 'object') {
  34819. var ret = calcObjectFlat(res.data, writeTarget);
  34820. lodash.forOwn(ret, function (v, k) {
  34821. scope.viewModel.set(k, v);
  34822. });
  34823. }
  34824. }
  34825. else {
  34826. showErrorDialog$1(res.msg || '未知错误', sender);
  34827. }
  34828. }).catch(function (e) {
  34829. var _a, _b;
  34830. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  34831. showErrorDialog$1(msg || e.toString(), sender);
  34832. }).finally(function () {
  34833. scope.setLoading(false);
  34834. });
  34835. };
  34836. };
  34837. SystemEventFu.prototype.commit = function (groovyUrl, arg0, successCallback) {
  34838. return function (sender) {
  34839. var scope = lookupScope(sender);
  34840. scope.setLoading(true);
  34841. var data = scope.viewModel.data;
  34842. if (arg0) {
  34843. data = calcObjectFlat(data, arg0);
  34844. }
  34845. invokeServer(groovyUrl, data).then(function (res) {
  34846. if (res.success) {
  34847. if (res.msg) {
  34848. msg(res.msg);
  34849. }
  34850. if (typeof successCallback === 'function') {
  34851. successCallback.call(scope, sender, res.data);
  34852. }
  34853. }
  34854. else {
  34855. showErrorDialog$1(res.msg || '未知错误', sender);
  34856. }
  34857. }).catch(function (e) {
  34858. var _a, _b;
  34859. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  34860. showErrorDialog$1(msg || e.toString(), sender);
  34861. }).finally(function () {
  34862. scope.setLoading(false);
  34863. });
  34864. };
  34865. };
  34866. SystemEventFu.prototype.formCommit = function (groovyUrl, arg0) {
  34867. return function (sender) {
  34868. var scope = lookupScope(sender);
  34869. var form = scope.down('form');
  34870. if (form) {
  34871. // 如果下级有表单,就做表单校验
  34872. var valid = form.isValid();
  34873. if (!valid) {
  34874. return;
  34875. }
  34876. }
  34877. scope.setLoading(true);
  34878. var data = scope.viewModel.data;
  34879. if (arg0) {
  34880. data = calcObjectFlat(data, arg0);
  34881. }
  34882. invokeServer(groovyUrl, data).then(function (res) {
  34883. if (res.success) {
  34884. if (res.msg) {
  34885. msg(res.msg);
  34886. }
  34887. scope.dialogSuccess(res);
  34888. }
  34889. else {
  34890. showErrorDialog$1(res.msg || '未知错误', sender);
  34891. }
  34892. }).catch(function (e) {
  34893. var _a, _b;
  34894. var msg = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.msg;
  34895. showErrorDialog$1(msg || e.toString(), sender);
  34896. }).finally(function () {
  34897. scope.setLoading(false);
  34898. });
  34899. };
  34900. };
  34901. SystemEventFu.prototype.dialogSuccess = function (lookupObject) {
  34902. return function (sender) {
  34903. var scope = lookupScope(sender);
  34904. if (lookupObject) {
  34905. scope.dialogSuccess(calcObjectFlat(scope.viewModel.data, lookupObject));
  34906. }
  34907. else {
  34908. scope.dialogSuccess();
  34909. }
  34910. };
  34911. };
  34912. SystemEventFu.prototype.clearViewModelValues = function (propertyName) {
  34913. return function (sender) {
  34914. var scope = lookupScope(sender);
  34915. clearViewModelValues(scope.viewModel, propertyName);
  34916. };
  34917. };
  34918. SystemEventFu.prototype.getGrid = function (url) {
  34919. return function (sender, config) {
  34920. if (config.xtype == "combogridmulti") {
  34921. // @ts-ignore
  34922. require([url], function (grid) {
  34923. lodash.forOwn(grid.default, function (v, k) {
  34924. sender[k] = v;
  34925. sender.config[k] = v;
  34926. if (sender.rendered) {
  34927. // 已经渲染出来了,重新调用 reload 强制刷新
  34928. sender.reload();
  34929. }
  34930. });
  34931. });
  34932. }
  34933. else {
  34934. // @ts-ignore
  34935. require([url], function (grid) {
  34936. sender.grid = grid.default;
  34937. config.grid = grid.default;
  34938. });
  34939. }
  34940. };
  34941. };
  34942. SystemEventFu.prototype.clearViewModelReloadGrid = function (propertyName, gridRefName) {
  34943. return function (sender) {
  34944. clearViewModelReloadGrid(sender, propertyName, gridRefName);
  34945. };
  34946. };
  34947. SystemEventFu.prototype.reloadGrid = function (gridRefName) {
  34948. return function (sender) {
  34949. var _a, _b;
  34950. var scope = lookupScope(sender);
  34951. if (!gridRefName) {
  34952. (_a = scope.down('grid')) === null || _a === void 0 ? void 0 : _a.reload();
  34953. }
  34954. else {
  34955. (_b = scope.refs[gridRefName]) === null || _b === void 0 ? void 0 : _b.reload();
  34956. }
  34957. };
  34958. };
  34959. SystemEventFu.prototype.showDialog = function (url, lookupForData, successCallback) {
  34960. return function (sender) {
  34961. var scope = lookupScope(sender);
  34962. var data = scope.viewModel.data;
  34963. var param = calcObjectFlat(data, lookupForData);
  34964. // @ts-ignore
  34965. require([url], function (module) {
  34966. var ScopeClass = module.default;
  34967. var scope = new ScopeClass();
  34968. scope.success = successCallback;
  34969. scope.showDialog(sender, {}, { data: param });
  34970. });
  34971. };
  34972. };
  34973. SystemEventFu.prototype.showWidget = function (widgetUrl, lookup) {
  34974. return function (sender, queryValue) {
  34975. showWidget(widgetUrl, lookup, sender, queryValue);
  34976. };
  34977. };
  34978. SystemEventFu.prototype.clearViewModelByLookup = function (lookup) {
  34979. return function (sender) {
  34980. clearViewModelByLookup(sender, lookup);
  34981. };
  34982. };
  34983. SystemEventFu.prototype.closeMe = function (callBack) {
  34984. return function (sender) {
  34985. var scope = lookupScope(sender);
  34986. scope.close();
  34987. if (callBack) {
  34988. callBack.call(sender);
  34989. }
  34990. };
  34991. };
  34992. __decorate([
  34993. Lib({
  34994. title: '弹出确认对话框,回答 YES 之后调用某方法',
  34995. author: '罗一帆',
  34996. createAt: '2021-07-06',
  34997. updateAt: '2021-07-06',
  34998. type: 'system',
  34999. category: '对话框',
  35000. }),
  35001. __param(0, LibParam('对话框的确认文字', 'string')),
  35002. __param(1, LibParam('确认之后的调用的方法', 'event')),
  35003. __metadata("design:type", Function),
  35004. __metadata("design:paramtypes", [Object, Object]),
  35005. __metadata("design:returntype", void 0)
  35006. ], SystemEventFu.prototype, "confirm", null);
  35007. __decorate([
  35008. Lib({
  35009. title: '删除表格当前的选中行(前端删除)',
  35010. author: '罗一帆',
  35011. createAt: '2021-07-08',
  35012. updateAt: '2021-07-08',
  35013. type: 'system',
  35014. category: '表格',
  35015. }),
  35016. __param(0, LibParam('表格引用名', 'refs')),
  35017. __metadata("design:type", Function),
  35018. __metadata("design:paramtypes", [Object]),
  35019. __metadata("design:returntype", void 0)
  35020. ], SystemEventFu.prototype, "gridRemoveCurrentRow", null);
  35021. __decorate([
  35022. Lib({
  35023. title: '查询表单,如果 url 为空值,就取消查询',
  35024. author: '罗一帆',
  35025. createAt: '2021-07-06',
  35026. updateAt: '2021-07-06',
  35027. type: 'system',
  35028. category: '表单',
  35029. }),
  35030. __param(0, LibParam('后端服务路径', 'string')),
  35031. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  35032. __param(2, LibParam('提交成功后的回调', 'viewModel', true)),
  35033. __metadata("design:type", Function),
  35034. __metadata("design:paramtypes", [String, Object, Object]),
  35035. __metadata("design:returntype", void 0)
  35036. ], SystemEventFu.prototype, "loadForm", null);
  35037. __decorate([
  35038. Lib({
  35039. title: '提交(不做校验、不关闭窗体)',
  35040. author: '罗一帆',
  35041. createAt: '2021-07-02',
  35042. updateAt: '2021-07-02',
  35043. type: 'system',
  35044. category: '表单',
  35045. }),
  35046. __param(0, LibParam('后端服务路径', 'string')),
  35047. __param(1, LibParam('后端需要的数据,默认情况提交所有', 'lookup', true)),
  35048. __param(2, LibParam('提交成功后的回调', 'event', true)),
  35049. __metadata("design:type", Function),
  35050. __metadata("design:paramtypes", [String, Object, Object]),
  35051. __metadata("design:returntype", void 0)
  35052. ], SystemEventFu.prototype, "commit", null);
  35053. __decorate([
  35054. Lib({
  35055. title: '提交表单',
  35056. author: '罗一帆',
  35057. createAt: '2021-07-02',
  35058. updateAt: '2021-07-02',
  35059. type: 'system',
  35060. category: '表单',
  35061. }),
  35062. __param(0, LibParam('后端服务路径', 'string')),
  35063. __param(1, LibParam('后端需要的参数,默认情况提交所有', 'lookup', true)),
  35064. __metadata("design:type", Function),
  35065. __metadata("design:paramtypes", [String, Object]),
  35066. __metadata("design:returntype", void 0)
  35067. ], SystemEventFu.prototype, "formCommit", null);
  35068. __decorate([
  35069. Lib({
  35070. title: '对话框成功回调',
  35071. author: '罗一帆',
  35072. createAt: '2021-07-02',
  35073. updateAt: '2021-07-02',
  35074. type: 'system',
  35075. category: '对话框',
  35076. }),
  35077. __param(0, LibParam('传回给父窗口的成功参数对象', 'lookup', true)),
  35078. __metadata("design:type", Function),
  35079. __metadata("design:paramtypes", [Object]),
  35080. __metadata("design:returntype", void 0)
  35081. ], SystemEventFu.prototype, "dialogSuccess", null);
  35082. __decorate([
  35083. Lib({
  35084. title: '清空 viewModel 某个属性',
  35085. author: '罗一帆',
  35086. createAt: '2021-07-02',
  35087. updateAt: '2021-07-02',
  35088. type: 'system',
  35089. category: '表单',
  35090. }),
  35091. __param(0, LibParam('属性路径', 'viewModel', true)),
  35092. __metadata("design:type", Function),
  35093. __metadata("design:paramtypes", [String]),
  35094. __metadata("design:returntype", void 0)
  35095. ], SystemEventFu.prototype, "clearViewModelValues", null);
  35096. __decorate([
  35097. Lib({
  35098. title: '从其他资源获取表格设置',
  35099. author: '罗一帆',
  35100. createAt: '2021-07-02',
  35101. updateAt: '2021-07-02',
  35102. type: 'system',
  35103. category: '表单',
  35104. }),
  35105. __param(0, LibParam('定义文件', 'module')),
  35106. __metadata("design:type", Function),
  35107. __metadata("design:paramtypes", [Object]),
  35108. __metadata("design:returntype", void 0)
  35109. ], SystemEventFu.prototype, "getGrid", null);
  35110. __decorate([
  35111. Lib({
  35112. title: '清空 viewModel 某个属性,并刷新表格',
  35113. author: '罗一帆',
  35114. createAt: '2021-07-02',
  35115. updateAt: '2021-07-02',
  35116. type: 'system',
  35117. category: '表单',
  35118. }),
  35119. __param(0, LibParam('清空的属性', 'viewModel')),
  35120. __param(1, LibParam('要刷新的表格', 'refs', true)),
  35121. __metadata("design:type", Function),
  35122. __metadata("design:paramtypes", [String, String]),
  35123. __metadata("design:returntype", void 0)
  35124. ], SystemEventFu.prototype, "clearViewModelReloadGrid", null);
  35125. __decorate([
  35126. Lib({
  35127. title: '刷新表格',
  35128. author: '罗一帆',
  35129. createAt: '2021-07-02',
  35130. updateAt: '2021-07-02',
  35131. type: 'system',
  35132. category: '表单',
  35133. }),
  35134. __param(0, LibParam('表格对象,不填的情况下就是第一个表格', 'refs', true)),
  35135. __metadata("design:type", Function),
  35136. __metadata("design:paramtypes", [String]),
  35137. __metadata("design:returntype", void 0)
  35138. ], SystemEventFu.prototype, "reloadGrid", null);
  35139. __decorate([
  35140. Lib({
  35141. title: '显示对话框',
  35142. author: '罗一帆',
  35143. createAt: '2021-07-02',
  35144. updateAt: '2021-07-02',
  35145. type: 'system',
  35146. category: '对话框',
  35147. }),
  35148. __param(0, LibParam('业务模块名', 'module')),
  35149. __param(1, LibParam('参数数据 lookup 表达式', 'lookup', true)),
  35150. __param(2, LibParam('成功回调(对话框成功结束后的回调方法)', 'event', true)),
  35151. __metadata("design:type", Function),
  35152. __metadata("design:paramtypes", [String, Object, Object]),
  35153. __metadata("design:returntype", void 0)
  35154. ], SystemEventFu.prototype, "showDialog", null);
  35155. __decorate([
  35156. Lib({
  35157. title: '弹出查找框(不借助 search)',
  35158. author: '罗一帆',
  35159. createAt: '2021-07-02',
  35160. updateAt: '2021-07-02',
  35161. type: 'system',
  35162. category: '对话框',
  35163. }),
  35164. __param(0, LibParam('模块名 (WidgetDialog)', 'module')),
  35165. __param(1, LibParam('lookup 映射关系', 'lookup', true)),
  35166. __metadata("design:type", Function),
  35167. __metadata("design:paramtypes", [Object, Object]),
  35168. __metadata("design:returntype", void 0)
  35169. ], SystemEventFu.prototype, "showWidget", null);
  35170. __decorate([
  35171. Lib({
  35172. title: '根据 lookup 清空 viewModel',
  35173. author: '罗一帆',
  35174. createAt: '2021-07-05',
  35175. updateAt: '2021-07-05',
  35176. type: 'system',
  35177. category: '表单',
  35178. }),
  35179. __param(0, LibParam('设值表达式', 'lookup')),
  35180. __metadata("design:type", Function),
  35181. __metadata("design:paramtypes", [Object]),
  35182. __metadata("design:returntype", void 0)
  35183. ], SystemEventFu.prototype, "clearViewModelByLookup", null);
  35184. __decorate([
  35185. Lib({
  35186. title: '关闭对话框',
  35187. author: '罗一帆',
  35188. createAt: '2021-07-05',
  35189. updateAt: '2021-07-05',
  35190. type: 'system',
  35191. category: '对话框',
  35192. }),
  35193. __param(0, LibParam('对话框的返回值回调', 'event', true)),
  35194. __metadata("design:type", Function),
  35195. __metadata("design:paramtypes", [Object]),
  35196. __metadata("design:returntype", void 0)
  35197. ], SystemEventFu.prototype, "closeMe", null);
  35198. return SystemEventFu;
  35199. }());
  35200. /**
  35201. * 清空 viewmodel 里下属的所有属性
  35202. * @param viewModel VM对象
  35203. * @param propertyKey 要清空的属性,可以是 "a.b.c" 这种表达模式
  35204. * @param ignoreProps 要忽略清空的属性名集合, 比如 ["a.b","b"]
  35205. */
  35206. function clearViewModel(viewModel, propertyKey, ignoreProps) {
  35207. var data = viewModel.data;
  35208. if (propertyKey) {
  35209. data = lodash.get(data, propertyKey);
  35210. }
  35211. lodash.forOwn(data, function (value, key) {
  35212. var targetKey = propertyKey ? propertyKey + "." + key : key;
  35213. if (ignoreProps && lodash.indexOf(ignoreProps, targetKey) >= 0) {
  35214. return;
  35215. }
  35216. viewModel.set(targetKey, '');
  35217. });
  35218. }
  35219. function clearViewModelByLookup(sender, lookup) {
  35220. if (lodash.isPlainObject(lookup)) {
  35221. var parentScope_1 = lookupScope(sender);
  35222. lodash.forOwn(lookup, function (value, key) {
  35223. if (SIMPLE_RE.test(value)) {
  35224. // '{foo}' 简单表达式
  35225. var path = value.substring(1, value.length - 1);
  35226. if (path !== 'queryValue') {
  35227. parentScope_1.viewModel.set(path, '');
  35228. }
  35229. }
  35230. });
  35231. }
  35232. }
  35233. function showWidget(widgetUrl, lookup, sender, queryValue, vjson) {
  35234. if (vjson === void 0) { vjson = {}; }
  35235. var parentScope = lookupScope(sender);
  35236. var me = sender;
  35237. // @ts-ignore
  35238. require([widgetUrl], function (widgetScope) {
  35239. var WidgetScopeClass = widgetScope.default;
  35240. widgetScope = new WidgetScopeClass();
  35241. // 传递进 widget.model 的数据
  35242. var widgetDialogData = calcObjectFlat(__assign({ queryValue: queryValue }, parentScope.viewModel.data), lookup);
  35243. widgetScope.parentScope = parentScope;
  35244. widgetScope.searchWidgetSuccess = function (data) {
  35245. if (typeof lookup === 'string') {
  35246. // lookup 是字符串的情况下,就是取某个列作为 value 值
  35247. me.setValue(data[lookup]);
  35248. return;
  35249. }
  35250. /**
  35251. * lookup: {
  35252. * // 扩展到 viewModel 的值做更改
  35253. * WH_CODE: "{queryValue}",
  35254. * WH_NAME: "{query.WH_NAME}",
  35255. * }
  35256. */
  35257. if (lodash.isPlainObject(lookup)) {
  35258. var parentScope_2 = lookupScope(sender);
  35259. tryWriteObject(lookup, data, function (path, value) {
  35260. if (path === 'queryValue') {
  35261. me.setValue(value);
  35262. }
  35263. else {
  35264. parentScope_2.viewModel.set(path, value);
  35265. }
  35266. });
  35267. }
  35268. return true;
  35269. };
  35270. widgetScope.showDialog(sender, vjson, { data: widgetDialogData });
  35271. });
  35272. }
  35273. /**
  35274. * 停止事件的默认行为
  35275. * @param e
  35276. */
  35277. function stopEvent(e) {
  35278. e.preventDefault();
  35279. e.stopPropagation();
  35280. // @ts-ignore
  35281. window.event.cancelBubble = true;
  35282. e.returnValue = false;
  35283. e.cancelBubble = true;
  35284. }
  35285. /**
  35286. * 屏幕中央显示一个黑框提示
  35287. */
  35288. function msg$1(content) {
  35289. var t = { content: content };
  35290. var WMSTranslate = window["WMSTranslate"];
  35291. if (WMSTranslate) {
  35292. if (typeof window['viewTranslate'] === 'function') {
  35293. window['viewTranslate'](t, content, "content");
  35294. }
  35295. }
  35296. msg(t.content);
  35297. }
  35298. /**
  35299. * 错误对话框的强提醒
  35300. */
  35301. function showErrorDialog$1(msg, sender) {
  35302. showErrorDialog(msg, sender);
  35303. }
  35304. /**
  35305. * 用于计算 express 表达式
  35306. */
  35307. function evalFunction(data, express) {
  35308. var keys = [];
  35309. var values = [];
  35310. lodash.forOwn(data, function (value, key) {
  35311. var match = key.match(/\-|\*|\\|\/|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)/i);
  35312. if (match) {
  35313. key = key.substring(0, match.index);
  35314. }
  35315. keys.push(key);
  35316. values.push(value);
  35317. });
  35318. var func = Function.apply(void 0, __spread(keys, ['return ' + express]));
  35319. try {
  35320. return func.apply(void 0, __spread(values));
  35321. }
  35322. catch (e) {
  35323. return;
  35324. }
  35325. }
  35326. /**
  35327. * 获取表格编辑的行数据
  35328. */
  35329. function getGridEditRows(grid) {
  35330. var store = grid.getStore();
  35331. var rows = [];
  35332. var modifyRows = [];
  35333. var newRows = [];
  35334. var err = "";
  35335. var records = store.getModifiedRecords();
  35336. var newRecords = store.getNewRecords();
  35337. var removeRecords = [];
  35338. lodash.forEach(store.getRemovedRecords(), function (row) {
  35339. removeRecords.push(row.data);
  35340. });
  35341. lodash.forEach(records, function (record) {
  35342. var colums = grid.columns;
  35343. var errFunc = undefined;
  35344. lodash.forEach(colums, function (col) {
  35345. var name = col.dataIndex;
  35346. var value = record.data[name];
  35347. var colIndex = col.getIndex(); //获得列号
  35348. var rowIndex = store.indexOfId(record.id); //获得行号
  35349. var editor = col.getEditor(); //使用的编辑器
  35350. var tmpErrFunc = function () {
  35351. grid.findPlugin('cellediting').startEdit(rowIndex, colIndex - 1); //如果不通过激活当前编辑状态
  35352. };
  35353. if (editor && !editor.allowBlank && !value) {
  35354. errFunc = tmpErrFunc;
  35355. return false;
  35356. }
  35357. if (editor && value && !editor.validateValue(value)) {
  35358. errFunc = tmpErrFunc;
  35359. return false;
  35360. }
  35361. });
  35362. if (errFunc) {
  35363. err = "1";
  35364. lodash.remove(rows, function (n) {
  35365. return true;
  35366. });
  35367. msg$1("请确保输入的数据正确");
  35368. errFunc();
  35369. // Ext.Msg.alert('提示', '请确保输入的数据正确', errFunc)
  35370. return false;
  35371. }
  35372. else {
  35373. if (lodash.findIndex(newRecords, function (item) {
  35374. return item === record;
  35375. }) >= 0) {
  35376. newRows.push(record.data);
  35377. }
  35378. else {
  35379. modifyRows.push(record.data);
  35380. }
  35381. rows.push(record.data);
  35382. }
  35383. });
  35384. return {
  35385. rows: rows,
  35386. newRows: newRows,
  35387. modifyRows: modifyRows,
  35388. removeRecords: removeRecords,
  35389. err: err
  35390. };
  35391. }
  35392. var SystemLib = /*#__PURE__*/Object.freeze({
  35393. __proto__: null,
  35394. SIMPLE_RE: SIMPLE_RE,
  35395. replaceNA: replaceNA,
  35396. calcExpress: calcExpress,
  35397. calcObjectFlat: calcObjectFlat,
  35398. mergeViewModel: mergeViewModel,
  35399. flatRow: flatRow$1,
  35400. tryWriteByExpress: tryWriteByExpress,
  35401. tryWriteObject: tryWriteObject,
  35402. tryVarSimple: tryVarSimple,
  35403. calcObject: calcObject,
  35404. getParentGrid: getParentGrid,
  35405. tryEnable: tryEnable,
  35406. setComboStore: setComboStore,
  35407. invokeServer: invokeServer,
  35408. clearViewModelValues: clearViewModelValues,
  35409. reloadGrid: reloadGrid,
  35410. toPlainObject: toPlainObject,
  35411. deepTravJson: deepTravJson,
  35412. confirm: confirm$1,
  35413. normId: normId,
  35414. clearViewModelReloadGrid: clearViewModelReloadGrid,
  35415. SystemEventFu: SystemEventFu,
  35416. clearViewModel: clearViewModel,
  35417. clearViewModelByLookup: clearViewModelByLookup,
  35418. showWidget: showWidget,
  35419. stopEvent: stopEvent,
  35420. msg: msg$1,
  35421. showErrorDialog: showErrorDialog$1,
  35422. evalFunction: evalFunction,
  35423. getGridEditRows: getGridEditRows
  35424. });
  35425. function initMultipleSearch () {
  35426. var _a = Ext.field.Text.prototype, initialize = _a.initialize, getValue = _a.getValue, valueToRaw = _a.valueToRaw, onPickerChange = _a.onPickerChange;
  35427. Ext.define('Yvan.MultipleSearch', {
  35428. extend: 'Ext.field.Text',
  35429. xtype: 'multiplesearch',
  35430. bindTargert: '',
  35431. constructor: function (config) {
  35432. var _a, _b, _c, _d;
  35433. var self = this;
  35434. var newConfig = lodash.defaultsDeep({
  35435. // 强制性属性
  35436. triggers: {
  35437. clear: {
  35438. weight: 0,
  35439. cls: Ext.baseCSSPrefix + 'form-clear-trigger',
  35440. hidden: true,
  35441. handler: 'onClearClick',
  35442. }
  35443. },
  35444. transformRawValue: function (o) {
  35445. return o;
  35446. },
  35447. listeners: {
  35448. specialkey: function (sender, e) {
  35449. var me = this;
  35450. if (e.getKey() === e.ENTER) {
  35451. me.fireEvent('search', me, e);
  35452. }
  35453. },
  35454. },
  35455. }, baseConfig(config, 'col-item'), config, search);
  35456. this.superclass.constructor.call(self, newConfig);
  35457. var vv = (_d = (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.bind) === null || _b === void 0 ? void 0 : _b.value) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.bind))) !== null && _d !== void 0 ? _d : '';
  35458. vv = lodash.replace(vv, "{", "");
  35459. vv = lodash.replace(vv, "}", "");
  35460. this.bindTargert = vv;
  35461. this.bindTargert = lodash.trim(this.bindTargert);
  35462. },
  35463. initialize: function () {
  35464. var that = this;
  35465. this.on({
  35466. initialize: function () {
  35467. that.replaceRawInputEvent();
  35468. }
  35469. });
  35470. initialize.call(this);
  35471. },
  35472. setBindValue: function (arrValue) {
  35473. if (this.bindTargert) {
  35474. this.lookupViewModel().yvanScope.viewModel.set(this.bindTargert, arrValue);
  35475. }
  35476. },
  35477. replaceRawInputEvent: function () {
  35478. var me = this;
  35479. var $dom = $(me.el.dom);
  35480. $dom.on('input', function (e) {
  35481. var _a, _b, _c, _d, _e;
  35482. if ((_a = e.target.value) === null || _a === void 0 ? void 0 : _a.endsWith(" ")) {
  35483. var a = lodash.trimEnd((_b = e.target) === null || _b === void 0 ? void 0 : _b.value);
  35484. if (!a.endsWith(",") && a.length > 0) {
  35485. e.target.value = a + ",";
  35486. }
  35487. else {
  35488. e.target.value = a;
  35489. }
  35490. }
  35491. e.target.value = (_c = e.target.value) === null || _c === void 0 ? void 0 : _c.replaceAll(",,", ",");
  35492. var arr = (_e = (_d = e.target) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.split(",");
  35493. lodash.remove(arr, function (it) {
  35494. return !it;
  35495. });
  35496. me.setBindValue(arr);
  35497. stopEvent(e);
  35498. });
  35499. $dom.on('keyup', function (e) {
  35500. me.fireEvent('keyup', me, e);
  35501. // invokeMethod(me.config.listeners?.keyup, me, e)
  35502. stopEvent(e);
  35503. });
  35504. $dom.on('keydown', function (e) {
  35505. me.fireEvent('keydown', me, e);
  35506. // invokeMethod(me.config.listeners?.keydown, me, e)
  35507. //stopEvent(e)
  35508. });
  35509. $dom.on('change', function (e) {
  35510. stopEvent(e);
  35511. });
  35512. $dom.on('paste', function (e) {
  35513. var _a, _b;
  35514. // @ts-ignore
  35515. var clipdata = e.originalEvent.clipboardData || window.clipboardData;
  35516. var text = clipdata.getData("text/plain");
  35517. var spliter = ',';
  35518. text = text.replaceAll("\r", "");
  35519. text = text.replaceAll("\n", spliter);
  35520. text = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) + "," + text;
  35521. var arr = text.split(spliter);
  35522. if (arr && Array.isArray(arr)) {
  35523. for (var i = 0; i < arr.length; i++) {
  35524. arr[i] = lodash.trim(arr[i]);
  35525. }
  35526. }
  35527. lodash.remove(arr, function (it) {
  35528. return !it;
  35529. });
  35530. me.setBindValue(arr);
  35531. if ((_b = e.target) === null || _b === void 0 ? void 0 : _b.value) {
  35532. e.target.value = text;
  35533. }
  35534. stopEvent(e);
  35535. });
  35536. },
  35537. onChange: function (newVal, oldVal) {
  35538. var me = this;
  35539. var value = newVal;
  35540. if (value) {
  35541. me.getTrigger('clear').show();
  35542. me.updateLayout();
  35543. }
  35544. else {
  35545. me.getTrigger('clear').hide();
  35546. me.updateLayout();
  35547. }
  35548. },
  35549. /**
  35550. * 清空所有值
  35551. */
  35552. onClearClick: function (sender, e) {
  35553. var me = this;
  35554. var config = me.config;
  35555. var lookup = config.lookup;
  35556. me.setValue('');
  35557. clearViewModelByLookup(sender, lookup);
  35558. }
  35559. });
  35560. }
  35561. /**
  35562. * 构建一个 grid 支持的 dataSource
  35563. */
  35564. function gridInvokeBuild(scope, grid, config, dataSource, reloadParams) {
  35565. if (reloadParams === void 0) { reloadParams = {}; }
  35566. var _a;
  35567. var me = grid;
  35568. var params = calcObjectFlat(scope.viewModel.data, dataSource.params);
  35569. var storeOption = {};
  35570. if (dataSource.method === 'invoke') {
  35571. var fields_1 = [];
  35572. lodash.forEach(config.columns, function (col) {
  35573. var c = {};
  35574. if (col.dataIndex) {
  35575. c.name = col.dataIndex;
  35576. fields_1.push(c);
  35577. }
  35578. if (col.dataType) {
  35579. c.type = col.dataType;
  35580. }
  35581. });
  35582. // 默认支持 gridInvoke
  35583. storeOption = {
  35584. fields: fields_1,
  35585. // remoteSort: config.remoteSort, 虚拟store的方式不能设置此属性
  35586. // remoteFilter: config.remoteFilter, 虚拟store的方式不能设置此属性
  35587. autoLoad: true,
  35588. pageSize: ((_a = me.store) === null || _a === void 0 ? void 0 : _a.pageSize) || config.pageSize,
  35589. proxy: {
  35590. type: 'jsonAjax',
  35591. $owner: me,
  35592. url: serverInvokeUrlTransform(dataSource.url, { scope: scope, grid: grid }),
  35593. extraParams: lodash.defaultsDeep({}, reloadParams, params),
  35594. reader: {
  35595. type: 'json',
  35596. rootProperty: 'data',
  35597. totalProperty: 'pagination.total',
  35598. successProperty: 'success',
  35599. messageProperty: 'msg',
  35600. transform: function (data) {
  35601. if (typeof window['ajaxProcess'] === 'function') {
  35602. window['ajaxProcess'](data);
  35603. }
  35604. if (typeof window['apiTranslate'] === 'function') {
  35605. window['apiTranslate'](data, dataSource.url);
  35606. }
  35607. if (typeof grid._transform === 'function') {
  35608. // 系统转换函数
  35609. grid._transform(data.data);
  35610. }
  35611. var pagination = lodash.get(data, 'pagination');
  35612. if (pagination) {
  35613. var current = pagination.current, firstRowNum = pagination.firstRowNum, lastRowNum = pagination.lastRowNum, size = pagination.size, total = pagination.total;
  35614. // console.log('pagination', pagination)
  35615. grid.store.pageCount = Math.ceil(total / size);
  35616. grid.store.firstRowNum = firstRowNum;
  35617. grid.store.lastRowNum = lastRowNum;
  35618. grid.store.total = total;
  35619. }
  35620. if (grid.dataTransform) {
  35621. if (typeof grid.dataTransform === 'string') {
  35622. grid.dataTransform = lookupFn(lookupScope(grid), grid.dataTransform);
  35623. }
  35624. return grid.dataTransform.call(scope, grid, data);
  35625. }
  35626. return data;
  35627. }
  35628. }
  35629. },
  35630. listeners: {
  35631. load: function (store, records, successful, operation) {
  35632. me.fireEvent('dataLoadComplete', me, successful, records);
  35633. }
  35634. }
  35635. };
  35636. }
  35637. else if (exports.apiConvert) {
  35638. // 外部扩展的 apiConvert
  35639. storeOption = exports.apiConvert.gridInvokeBuild(scope, grid, config, dataSource, params, reloadParams);
  35640. }
  35641. else {
  35642. throw new TypeError("不支持的 API 请求方式");
  35643. }
  35644. // me.setStore(new Ext.data.virtual.Store(storeOption))
  35645. me.setStore(new Ext.data.Store(storeOption));
  35646. }
  35647. function initStores () {
  35648. Ext.define('Yvan.JsonAjaxProxy', {
  35649. extend: 'Ext.data.proxy.Ajax',
  35650. alias: 'proxy.jsonAjax',
  35651. actionMethods: {
  35652. create: "POST",
  35653. read: "POST",
  35654. update: "POST",
  35655. destroy: "POST"
  35656. },
  35657. timeout: storeAjax.timeout,
  35658. buildRequest: function (operation) {
  35659. // 参考源码 ext-all-debug.js:71468 method:buildRequest
  35660. var me = this;
  35661. var $owner = me.$owner; // 在 grid.initComponent 中赋值 $owner
  35662. var scope = lookupScope($owner);
  35663. var gridParam = me.getParams(operation);
  35664. var customParam = {};
  35665. // 提取 srot 元素
  35666. if (gridParam.sort) {
  35667. var sort = JSON.parse(gridParam.sort);
  35668. // 字符串 [{"property":"BRANCHID","direction":"ASC"}]
  35669. // 转换为对象 [{colId: "BRANCHID", sort: "asc"}]
  35670. customParam.sortModel = [];
  35671. lodash.forEach(sort, function (s) {
  35672. customParam.sortModel.push({
  35673. colId: s.property,
  35674. sort: lodash.toLower(s.direction)
  35675. });
  35676. });
  35677. delete gridParam.sort;
  35678. }
  35679. delete gridParam.filter;
  35680. // 被 grid.constructor 作为方法存在
  35681. var extraParams = lodash.cloneDeep(me.getExtraParams());
  35682. var params = lodash.defaultsDeep(gridParam, extraParams);
  35683. var request = new Ext.data.Request({
  35684. params: {},
  35685. action: operation.getAction(),
  35686. records: operation.getRecords(),
  35687. url: me.buildUrl(),
  35688. jsonData: __assign({ args: [
  35689. params
  35690. ] }, customParam),
  35691. proxy: me
  35692. });
  35693. operation.setRequest(request);
  35694. return request;
  35695. },
  35696. afterRequest: function (req, res) {
  35697. // Extend.afterExtRequest(req, res)
  35698. }
  35699. });
  35700. }
  35701. function initList () {
  35702. Ext.define('Yvan.List', {
  35703. extend: 'Ext.dataview.List',
  35704. xtype: 'yvlist',
  35705. constructor: function (config) {
  35706. var newConfig = lodash.defaultsDeep({
  35707. // 强制性属性 bug.
  35708. // lock 属性会造成 Cannot read properties of undefined (reading 'els')
  35709. // enableLocking: false,
  35710. // syncRowHeight: false,
  35711. }, baseConfig(config, 'row-item'), config, list);
  35712. // 在面板上的组件
  35713. var scope = newConfig.$initParent.yvanScope || newConfig.$initParent.lookupReferenceHolder().yvanScope;
  35714. if (newConfig.pagination) {
  35715. // 分页支持
  35716. lodash.extend(newConfig.plugins, {
  35717. listpaging: {
  35718. autoPaging: newConfig.autoPaging,
  35719. bufferZone: 0,
  35720. },
  35721. });
  35722. }
  35723. this.superclass.constructor.call(this, newConfig);
  35724. },
  35725. reload: function (reloadParams) {
  35726. if (reloadParams === void 0) { reloadParams = {}; }
  35727. var me = this;
  35728. var config = me.config;
  35729. if (config.dataSourceCallbackFn) {
  35730. // 函数请求刷新
  35731. var scope = lookupScope(this);
  35732. lodash.defer(function () {
  35733. me.setLoading(true);
  35734. });
  35735. config.dataSourceCallbackFn.call(scope, me, {
  35736. successCallback: function (value) {
  35737. me._setDataReal(value);
  35738. lodash.defer(function () {
  35739. me.setLoading(false);
  35740. });
  35741. me.fireEvent('dataLoadComplete', me, true, value);
  35742. },
  35743. failCallback: function (error) {
  35744. lodash.defer(function () {
  35745. me.setLoading(false);
  35746. });
  35747. me.fireEvent('dataLoadComplete', me, false, error);
  35748. }
  35749. });
  35750. return;
  35751. }
  35752. // if (this.store) {
  35753. // this.store.reload({aaaa: 1, bbbb: 2})
  35754. // }
  35755. var dataSource = config.dataSource;
  35756. if (lodash.isPlainObject(dataSource) && !window["IS_DESIGN_MODE"]) {
  35757. var scope = lookupScope(me);
  35758. gridInvokeBuild(scope, me, config, dataSource, reloadParams);
  35759. }
  35760. },
  35761. itemclick: lodash.throttle(function (sender, location, eOpts) {
  35762. sender.fireEvent('itemclick', sender, location.record, location);
  35763. }, 1000, {
  35764. leading: true,
  35765. trailing: false,
  35766. }),
  35767. initialize: function () {
  35768. var _a, _b, _c, _d;
  35769. var me = this;
  35770. var config = me.config;
  35771. // const scope = lookupScope(this)
  35772. var scope = (_c = ((_b = (_a = this.$initParent) === null || _a === void 0 ? void 0 : _a.lookupReferenceHolder()) === null || _b === void 0 ? void 0 : _b.yvanScope)) !== null && _c !== void 0 ? _c : lookupScope(this);
  35773. if (!window["IS_DESIGN_MODE"]) {
  35774. // 转换 dataSource 属性
  35775. convertDataSource(me, scope, config);
  35776. }
  35777. this.on({
  35778. childtap: function (sender, location, eOpts) {
  35779. this.itemclick(sender, location, eOpts);
  35780. },
  35781. });
  35782. if ((_d = this.store) === null || _d === void 0 ? void 0 : _d.proxy) {
  35783. // 为 stores.proxy.buildRequest 做准备
  35784. this.store.proxy.$owner = this;
  35785. }
  35786. this.superclass.initialize.call(this);
  35787. },
  35788. afterRender: function () {
  35789. var me = this;
  35790. var config = this.config;
  35791. var dataSource = config.dataSource;
  35792. if (config.autoLoad) {
  35793. if (config.dataSourceCallbackFn) {
  35794. me.reload();
  35795. }
  35796. else if (lodash.isPlainObject(dataSource)) {
  35797. me.reload();
  35798. }
  35799. }
  35800. this.superclass.afterRender.call(this);
  35801. },
  35802. });
  35803. }
  35804. function convertDataSource(sender, scope, newConfig) {
  35805. if (typeof newConfig.store !== 'undefined') {
  35806. // 有 store 属性的情况下,不做任何事
  35807. return;
  35808. }
  35809. if (typeof newConfig.dataSource === 'undefined') {
  35810. // 没有定义 dataSource 的情况下,不做任何事
  35811. return;
  35812. }
  35813. if (lodash.isArray(newConfig.data)) {
  35814. // 有 data 属性赋值的情况下
  35815. newConfig.store = {
  35816. fields: [],
  35817. data: newConfig.data
  35818. };
  35819. delete newConfig.data;
  35820. return;
  35821. }
  35822. var dataSource = newConfig.dataSource;
  35823. if (typeof dataSource === 'string') {
  35824. // dataSource 是字符串的情况下,找到成员函数
  35825. dataSource = lookupFn(scope, dataSource);
  35826. }
  35827. if (typeof dataSource === 'function') {
  35828. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  35829. newConfig.store = new Ext.data.Store({
  35830. fields: [],
  35831. // data: [],
  35832. autoLoad: true,
  35833. proxy: {
  35834. type: 'memory',
  35835. data: [],
  35836. }
  35837. });
  35838. newConfig.dataSourceCallbackFn = dataSource;
  35839. return;
  35840. }
  35841. // throw new TypeError('无法识别的调用方法')
  35842. }
  35843. function initCols () {
  35844. Ext.define('Yvan.Cols', {
  35845. extend: 'Ext.container.Container',
  35846. xtype: 'cols',
  35847. constructor: function (config) {
  35848. var self = this;
  35849. var newConfig = lodash.defaultsDeep({
  35850. // 强制性属性
  35851. layout: 'hbox',
  35852. minHeight: config.designMode ? 32 : 0
  35853. }, baseConfig(config, 'cols-container'), config, cols);
  35854. this.superclass.constructor.call(self, newConfig);
  35855. },
  35856. });
  35857. }
  35858. function initRows () {
  35859. Ext.define('Yvan.Rows', {
  35860. extend: 'Ext.container.Container',
  35861. xtype: 'rows',
  35862. constructor: function (config) {
  35863. var self = this;
  35864. var newConfig = lodash.defaultsDeep({
  35865. // 强制性属性
  35866. layout: 'vbox', border: false,
  35867. defaults: {
  35868. border: false, anchor: '100%',
  35869. margin: '0 0 5 0',
  35870. },
  35871. }, baseConfig(config, 'rows-container'), config, rows);
  35872. this.superclass.constructor.call(self, newConfig);
  35873. },
  35874. });
  35875. }
  35876. var PropertyDescription = /** @class */ (function () {
  35877. function PropertyDescription() {
  35878. var _this = this;
  35879. var args = [];
  35880. for (var _i = 0; _i < arguments.length; _i++) {
  35881. args[_i] = arguments[_i];
  35882. }
  35883. this.propertyes = {
  35884. props: [],
  35885. events: []
  35886. };
  35887. lodash.each(args, function (arg) {
  35888. _this.merge(arg);
  35889. });
  35890. }
  35891. PropertyDescription.prototype.merge = function (pd) {
  35892. this.propertyes.props = (lodash.uniqBy(__spread(this.propertyes.props, pd.props), 'name'));
  35893. if (pd.events) {
  35894. if (this.propertyes.events) {
  35895. this.propertyes.events = (lodash.uniqBy(__spread(this.propertyes.events, pd.events), 'name'));
  35896. }
  35897. else {
  35898. this.propertyes.events = lodash.uniqBy(__spread(pd.events), 'name');
  35899. }
  35900. }
  35901. };
  35902. /**
  35903. * 根据分组名 获取属性定义
  35904. */
  35905. PropertyDescription.prototype.getPropsByGroup = function (name) {
  35906. return lodash.filter(this.propertyes.props, function (i) { return i.group === name; });
  35907. };
  35908. /**
  35909. * 获取全部事件
  35910. */
  35911. PropertyDescription.prototype.getEvents = function () {
  35912. return this.propertyes.events;
  35913. };
  35914. return PropertyDescription;
  35915. }());
  35916. var PropertyDescriptionTable = new Map();
  35917. PropertyDescriptionTable.set('tabCell', new PropertyDescription({
  35918. props: [
  35919. {
  35920. name: 'header',
  35921. default: '',
  35922. group: 'common',
  35923. desc: '选项卡名称',
  35924. type: 'string'
  35925. },
  35926. {
  35927. name: 'close',
  35928. default: '',
  35929. group: 'common',
  35930. desc: '是否允许关闭',
  35931. type: 'boolean'
  35932. },
  35933. ]
  35934. }));
  35935. var width = {
  35936. name: 'width',
  35937. default: '',
  35938. group: 'common',
  35939. desc: '宽',
  35940. type: 'number'
  35941. };
  35942. var height = {
  35943. name: 'height',
  35944. default: '',
  35945. group: 'common',
  35946. desc: '高',
  35947. type: 'number'
  35948. };
  35949. var fieldLabel = {
  35950. name: 'fieldLabel',
  35951. default: '',
  35952. group: 'common',
  35953. desc: '文本描述',
  35954. type: 'string',
  35955. expr: true,
  35956. };
  35957. var gravity = {
  35958. name: 'gravity',
  35959. default: 1,
  35960. group: 'common',
  35961. desc: '占位权重',
  35962. type: 'number'
  35963. };
  35964. var disabled = {
  35965. name: 'disabled',
  35966. default: false,
  35967. group: 'common',
  35968. desc: '禁用',
  35969. type: 'boolean',
  35970. expr: true,
  35971. };
  35972. var value = {
  35973. name: 'value',
  35974. default: '',
  35975. group: 'common',
  35976. desc: '字段值',
  35977. type: 'string',
  35978. expr: true,
  35979. };
  35980. var metaId = {
  35981. name: 'metaId',
  35982. default: '',
  35983. group: 'bind',
  35984. desc: '元数据ID',
  35985. type: 'string'
  35986. };
  35987. var template = {
  35988. name: 'template',
  35989. default: '',
  35990. group: 'common',
  35991. desc: 'HTML内容',
  35992. type: 'string',
  35993. expr: true,
  35994. };
  35995. var tooltip = {
  35996. name: 'tooltip',
  35997. default: '',
  35998. group: 'common',
  35999. desc: '悬停提示',
  36000. type: 'string'
  36001. };
  36002. PropertyDescriptionTable.set('rows', new PropertyDescription({
  36003. props: [
  36004. gravity,
  36005. width
  36006. ]
  36007. }));
  36008. PropertyDescriptionTable.set('cols', new PropertyDescription({
  36009. props: [
  36010. gravity,
  36011. height
  36012. ]
  36013. }));
  36014. PropertyDescriptionTable.set('window', new PropertyDescription({
  36015. props: [
  36016. {
  36017. name: '_designMode',
  36018. default: 'module',
  36019. group: 'common',
  36020. desc: '设计类型',
  36021. type: ['none', 'dialog', 'scroll-dialog']
  36022. },
  36023. {
  36024. name: 'title',
  36025. default: '',
  36026. group: 'common',
  36027. desc: '对话框标题',
  36028. type: 'string'
  36029. },
  36030. {
  36031. name: 'modal',
  36032. default: '',
  36033. group: 'common',
  36034. desc: '是否模态',
  36035. type: 'boolean'
  36036. },
  36037. lodash.merge(lodash.cloneDeep(width), { default: 200 }),
  36038. lodash.merge(lodash.cloneDeep(height), { default: 200 }),
  36039. {
  36040. name: 'top',
  36041. default: 200,
  36042. group: 'common',
  36043. desc: '顶像素',
  36044. type: 'number'
  36045. },
  36046. {
  36047. name: 'left',
  36048. default: 200,
  36049. group: 'common',
  36050. desc: '左像素',
  36051. type: 'number'
  36052. }
  36053. ]
  36054. }));
  36055. PropertyDescriptionTable.set('layout', new PropertyDescription({
  36056. props: [
  36057. {
  36058. name: 'borderless',
  36059. default: true,
  36060. group: 'css',
  36061. desc: '有无边框',
  36062. type: 'boolean'
  36063. },
  36064. {
  36065. name: 'type',
  36066. default: '',
  36067. group: 'css',
  36068. desc: '布局类型',
  36069. type: ['line', 'clean', 'wide', 'space', 'form']
  36070. },
  36071. {
  36072. name: '_designMode',
  36073. default: 'module',
  36074. group: 'common',
  36075. desc: '设计类型',
  36076. type: ['none', 'module', 'scroll-module']
  36077. }
  36078. ]
  36079. }));
  36080. var YvBase = {
  36081. props: [
  36082. {
  36083. name: 'bind',
  36084. default: '',
  36085. group: 'bind',
  36086. desc: '实体类名',
  36087. type: 'string'
  36088. },
  36089. {
  36090. name: 'ref',
  36091. default: '',
  36092. group: 'bind',
  36093. desc: '控件名',
  36094. type: 'string'
  36095. },
  36096. {
  36097. name: 'css',
  36098. default: '',
  36099. group: 'css',
  36100. desc: '样式类名',
  36101. type: 'string'
  36102. },
  36103. {
  36104. name: 'hidden',
  36105. default: false,
  36106. group: 'common',
  36107. desc: '是否显示',
  36108. type: 'boolean'
  36109. },
  36110. {
  36111. name: 'padding',
  36112. default: undefined,
  36113. group: 'css',
  36114. desc: '内边距',
  36115. type: 'object'
  36116. },
  36117. {
  36118. name: 'margin',
  36119. default: undefined,
  36120. group: 'css',
  36121. desc: '外边距',
  36122. type: 'object'
  36123. },
  36124. {
  36125. name: 'ff',
  36126. default: 0,
  36127. group: 'common',
  36128. desc: '自动定焦时间',
  36129. type: 'number'
  36130. },
  36131. width, height,
  36132. {
  36133. name: 'autowidth',
  36134. default: false,
  36135. group: 'common',
  36136. desc: '自动计算宽度',
  36137. type: 'boolean'
  36138. },
  36139. {
  36140. name: 'autoheight',
  36141. default: false,
  36142. group: 'common',
  36143. desc: '自动计算高度',
  36144. type: 'boolean'
  36145. },
  36146. ],
  36147. events: [
  36148. { name: 'onRender', desc: '第一次控件被渲染时触发' }
  36149. ]
  36150. };
  36151. PropertyDescriptionTable.set('template', new PropertyDescription(YvBase, {
  36152. props: [
  36153. template
  36154. ]
  36155. }));
  36156. PropertyDescriptionTable.set('fieldset', new PropertyDescription(YvBase, {
  36157. props: [
  36158. {
  36159. name: 'label',
  36160. default: '',
  36161. group: 'common',
  36162. desc: '字段组标题',
  36163. type: 'string'
  36164. }
  36165. ]
  36166. }));
  36167. PropertyDescriptionTable.set('iframe', new PropertyDescription(YvBase, {
  36168. props: [
  36169. {
  36170. name: 'src',
  36171. default: '',
  36172. group: 'common',
  36173. desc: '地址路径',
  36174. type: 'string'
  36175. }
  36176. ]
  36177. }));
  36178. PropertyDescriptionTable.set('uploader', new PropertyDescription(YvBase, {
  36179. props: [
  36180. width, height,
  36181. {
  36182. name: 'value',
  36183. default: '上传',
  36184. group: 'common',
  36185. desc: '文本描述',
  36186. type: 'string'
  36187. },
  36188. {
  36189. name: 'upload',
  36190. default: '/upload',
  36191. group: 'common',
  36192. desc: '上传地址',
  36193. type: 'string'
  36194. },
  36195. ],
  36196. events: [
  36197. { name: 'onFileUpload', desc: '文件上传成功结束时触发' },
  36198. { name: 'onFileUploadError', desc: '在上传过程中发生服务器端错误时触发' },
  36199. ]
  36200. }));
  36201. PropertyDescriptionTable.set('viewer', new PropertyDescription(YvBase, {
  36202. props: [
  36203. value,
  36204. gravity,
  36205. {
  36206. name: 'imgWidth',
  36207. default: '',
  36208. group: 'common',
  36209. desc: '图片宽',
  36210. type: 'string'
  36211. },
  36212. {
  36213. name: 'imgHeight',
  36214. default: '',
  36215. group: 'common',
  36216. desc: '图片高',
  36217. type: 'string'
  36218. }
  36219. ]
  36220. }));
  36221. PropertyDescriptionTable.set('image', new PropertyDescription(YvBase, {
  36222. props: [
  36223. value,
  36224. gravity,
  36225. {
  36226. name: 'imgWidth',
  36227. default: '',
  36228. group: 'common',
  36229. desc: '图片宽',
  36230. type: 'string'
  36231. },
  36232. {
  36233. name: 'imgHeight',
  36234. default: '',
  36235. group: 'common',
  36236. desc: '图片高',
  36237. type: 'string'
  36238. }
  36239. ]
  36240. }));
  36241. PropertyDescriptionTable.set('scrollview', new PropertyDescription(YvBase, {
  36242. props: [
  36243. width, height
  36244. ]
  36245. }));
  36246. function initGrid () {
  36247. Ext.define('Yvan.Grid', {
  36248. extend: 'Ext.grid.Grid',
  36249. xtype: 'yvgrid',
  36250. constructor: function (config) {
  36251. var _a;
  36252. var me = this;
  36253. var dataSource = config.dataSource;
  36254. if (!window["IS_DESIGN_MODE"]) {
  36255. this.columnConfigCacheKey = this.makeColumnConfigCacheKey(config);
  36256. if (Array.isArray(config.columns) && config.columns.length > 0) {
  36257. var cacheData = this.getColumnConfigCache();
  36258. if (Array.isArray(cacheData) && cacheData.length > 0) {
  36259. var newColumns = [];
  36260. for (var j = 0; j < cacheData.length; j++) {
  36261. var itData = cacheData[j];
  36262. for (var i = 0; i < config.columns.length; i++) {
  36263. var column = config.columns[i];
  36264. if (itData.dataIndex === column.dataIndex) {
  36265. if (itData.width) {
  36266. column.width = itData.width;
  36267. }
  36268. column.hidden = itData.hidden;
  36269. column.locked = itData.locked;
  36270. newColumns.push(column);
  36271. break;
  36272. }
  36273. }
  36274. }
  36275. config.columns = newColumns;
  36276. }
  36277. }
  36278. }
  36279. var newConfig = lodash.defaultsDeep({
  36280. // 强制性属性 bug.
  36281. // lock 属性会造成 Cannot read properties of undefined (reading 'els')
  36282. // enableLocking: false,
  36283. // syncRowHeight: false,
  36284. }, baseConfig(config, 'row-item'), config, grid);
  36285. // 在面板上的组件
  36286. var scope = newConfig.$initParent.yvanScope || newConfig.$initParent.lookupReferenceHolder().yvanScope;
  36287. var getRowClass = newConfig.getRowClass;
  36288. if (typeof getRowClass === 'string' && (lodash.startsWith(getRowClass, "scope.") ||
  36289. lodash.startsWith(getRowClass, "system."))) {
  36290. var fn = lookupFn(scope, getRowClass);
  36291. lodash.set(newConfig, 'viewConfig.getRowClass', fn);
  36292. }
  36293. if (newConfig.pagination) {
  36294. newConfig.items = (_a = newConfig.items) !== null && _a !== void 0 ? _a : [];
  36295. newConfig.items.push({
  36296. docked: 'bottom',
  36297. cls: 'yvgrid-paging',
  36298. layout: {
  36299. type: 'hbox'
  36300. },
  36301. items: [
  36302. {
  36303. xtype: 'button',
  36304. text: '前一页',
  36305. key: 'btnPre',
  36306. iconCls: 'x-fa fa-angle-left',
  36307. handler: function () {
  36308. me.prePage();
  36309. }
  36310. },
  36311. {
  36312. html: '第 0-50 / 151 行',
  36313. cls: 'paging-text',
  36314. key: 'lblPage',
  36315. flex: 1,
  36316. },
  36317. {
  36318. xtype: 'button',
  36319. text: '后一页',
  36320. key: 'btnNext',
  36321. iconCls: 'x-fa fa-angle-right',
  36322. iconAlign: 'right',
  36323. textAlign: 'left',
  36324. handler: function () {
  36325. me.nextPage();
  36326. }
  36327. }
  36328. ]
  36329. });
  36330. }
  36331. lodash.each(newConfig.columns, function (c) {
  36332. var renderer = c.renderer;
  36333. if (typeof renderer === 'string' && (lodash.startsWith(renderer, "scope.") ||
  36334. lodash.startsWith(renderer, "system."))) {
  36335. if (newConfig.$initParent) {
  36336. if (scope) {
  36337. var rendererFn = lookupFn(scope, renderer);
  36338. c.renderer = rendererFn;
  36339. }
  36340. }
  36341. }
  36342. });
  36343. this.superclass.constructor.call(this, newConfig);
  36344. // this.store.pageSize = newConfig.pageSize
  36345. },
  36346. prePage: function () {
  36347. this.store.loadPage(this.store.currentPage - 1);
  36348. },
  36349. nextPage: function () {
  36350. this.store.loadPage(this.store.currentPage + 1);
  36351. },
  36352. setData: function (value) {
  36353. var me = this;
  36354. me._setDataReal(value);
  36355. },
  36356. /**
  36357. * 添加行,并进入编辑状态
  36358. * @param record 新行的属性集
  36359. * @param editRowCol 要编辑的列序号,或 dataIndex 的名称
  36360. */
  36361. appendEditRow: function (record, editRowCol) {
  36362. var records = this.getStore().add(record);
  36363. var recNew = records[0];
  36364. this.setSelection(records);
  36365. if (typeof editRowCol === 'string' && editRowCol) {
  36366. editRowCol = this.columns.findIndex(function (c) { return c.dataIndex === editRowCol; });
  36367. }
  36368. if (typeof editRowCol === 'number') {
  36369. var ce = this.findPlugin('cellediting');
  36370. this.editingPlugin = ce;
  36371. ce.startEdit(recNew, editRowCol);
  36372. }
  36373. },
  36374. /**
  36375. * 移除行
  36376. * @param record 如果记录传空,就是当前选中的行
  36377. */
  36378. removeEditRow: function (record) {
  36379. if (!record) {
  36380. record = this.selection;
  36381. }
  36382. if (!record) {
  36383. msg('请选中要删除的行');
  36384. return;
  36385. }
  36386. this.getStore().remove(record);
  36387. },
  36388. /**
  36389. * 获取全部原始数据
  36390. */
  36391. getDataRows: function () {
  36392. return this.getStore().data.items.map(function (r) { return r.data; });
  36393. },
  36394. getEditRecord: function () {
  36395. var _a, _b;
  36396. var me = this;
  36397. var editingPlugin = me.editingPlugin || me.ownerGrid.editingPlugin;
  36398. var rowIdx = (_b = (_a = editingPlugin === null || editingPlugin === void 0 ? void 0 : editingPlugin.activeEditor) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.rowIdx;
  36399. var record;
  36400. if (!rowIdx) {
  36401. record = me.getSelectionModel().getLastSelected();
  36402. }
  36403. else {
  36404. record = me.store.getAt(rowIdx);
  36405. }
  36406. return record;
  36407. },
  36408. getEditRow: function () {
  36409. var _a;
  36410. var me = this;
  36411. return (_a = me.getEditRecord()) === null || _a === void 0 ? void 0 : _a.data;
  36412. },
  36413. setEditRow: function (rowValues) {
  36414. var me = this;
  36415. var record = me.getEditRecord();
  36416. if (record) {
  36417. lodash.forOwn(rowValues, function (v, k) {
  36418. record.set(k, v);
  36419. });
  36420. }
  36421. },
  36422. _transform: function (data) {
  36423. // 无论是 grid._setDataReal 还是 stores.gridInvokeBuild 都会走这个函数,设值前都可以改变表格值
  36424. lodash.forEach(data, function (row) {
  36425. row._origin = lodash.clone(row);
  36426. });
  36427. },
  36428. _setDataReal: function (value) {
  36429. var me = this;
  36430. this._transform(value);
  36431. me.setStore(new Ext.data.Store({
  36432. fields: getFileds(this),
  36433. data: value
  36434. }));
  36435. },
  36436. setStore: function (store) {
  36437. var me = this;
  36438. if (lodash.isArray(store)) {
  36439. var value_1 = store;
  36440. this._transform(value_1);
  36441. var storeOpt = {
  36442. fields: getFileds(this),
  36443. data: value_1,
  36444. };
  36445. if (this.groupField) {
  36446. storeOpt.groupField = this.groupField;
  36447. }
  36448. store = new Ext.data.Store(storeOpt);
  36449. }
  36450. me.superclass.setStore.call(this, store);
  36451. if (store) {
  36452. store.on({
  36453. add: function (store, records, index, eOpts) {
  36454. me._raiseChange(store, 'add');
  36455. },
  36456. remove: function (store, records, index, isMove, eOpts) {
  36457. me._raiseChange(store, 'remove');
  36458. },
  36459. datachanged: function (sender, opt) {
  36460. me._raiseChange(store, 'datachanged');
  36461. },
  36462. refresh: function (sender, opt) {
  36463. me._raiseChange(store, 'refresh');
  36464. },
  36465. clear: function (sender, opt) {
  36466. me._raiseChange(store, 'clear');
  36467. },
  36468. });
  36469. }
  36470. },
  36471. _raiseChange: function (store, type) {
  36472. var btnPre = this.down('[key=btnPre]');
  36473. var lblPage = this.down('[key=lblPage]');
  36474. var btnNext = this.down('[key=btnNext]');
  36475. if (!btnPre || !lblPage || !btnNext) {
  36476. return;
  36477. }
  36478. if (!this.store) {
  36479. btnPre.disable();
  36480. btnNext.disable();
  36481. lblPage.setHtml('无效数据源');
  36482. return;
  36483. }
  36484. var _a = this.store, pageCount = _a.pageCount, firstRowNum = _a.firstRowNum, lastRowNum = _a.lastRowNum, total = _a.total, currentPage = _a.currentPage;
  36485. if (currentPage > 1) {
  36486. btnPre.enable();
  36487. }
  36488. else {
  36489. btnPre.disable();
  36490. }
  36491. if (currentPage < pageCount) {
  36492. btnNext.enable();
  36493. }
  36494. else {
  36495. btnNext.disable();
  36496. }
  36497. lblPage.setHtml("\u7B2C" + toString$1(firstRowNum) + "-" + toString$1(lastRowNum) + "/" + toString$1(total) + "\u884C");
  36498. },
  36499. /**
  36500. * 轻量级刷新
  36501. */
  36502. refreshData: function () {
  36503. var store = this.getStore();
  36504. if (store) {
  36505. store.reload();
  36506. }
  36507. },
  36508. /**
  36509. * 为表格强制设置焦点
  36510. * @param seq 顺序号
  36511. */
  36512. focusRow: function (seq) {
  36513. this.setSelection(this.store.getAt(seq));
  36514. this.getView().focusRow(seq);
  36515. },
  36516. /**
  36517. * 重新载入数据(重新计算参数)
  36518. */
  36519. reload: function (reloadParams) {
  36520. if (reloadParams === void 0) { reloadParams = {}; }
  36521. var me = this;
  36522. var config = me.config;
  36523. if (config.dataSourceCallbackFn) {
  36524. // 函数请求刷新
  36525. var scope = lookupScope(this);
  36526. lodash.defer(function () {
  36527. me.setLoading(true);
  36528. });
  36529. config.dataSourceCallbackFn.call(scope, me, {
  36530. successCallback: function (value) {
  36531. me._setDataReal(value);
  36532. lodash.defer(function () {
  36533. me.setLoading(false);
  36534. });
  36535. me.fireEvent('dataLoadComplete', me, true, value);
  36536. },
  36537. failCallback: function (error) {
  36538. lodash.defer(function () {
  36539. me.setLoading(false);
  36540. });
  36541. me.fireEvent('dataLoadComplete', me, false, error);
  36542. }
  36543. });
  36544. return;
  36545. }
  36546. // if (this.store) {
  36547. // this.store.reload({aaaa: 1, bbbb: 2})
  36548. // }
  36549. var dataSource = config.dataSource;
  36550. if (lodash.isPlainObject(dataSource) && !window["IS_DESIGN_MODE"]) {
  36551. var scope = lookupScope(me);
  36552. gridInvokeBuild(scope, me, config, dataSource, reloadParams);
  36553. }
  36554. },
  36555. itemclick: lodash.throttle(function (sender, location, eOpts) {
  36556. sender.fireEvent('itemclick', sender, location.record, location);
  36557. }, 1000, {
  36558. leading: true,
  36559. trailing: false,
  36560. }),
  36561. initialize: function () {
  36562. var _a;
  36563. var me = this;
  36564. var config = me.config;
  36565. var scope = lookupScope(this);
  36566. if (!window["IS_DESIGN_MODE"]) {
  36567. // 转换 dataSource 属性
  36568. convertDataSource$1(me, scope, config);
  36569. }
  36570. this.on({
  36571. childtap: function (sender, location, eOpts) {
  36572. this.itemclick(me, location, eOpts);
  36573. },
  36574. });
  36575. if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.proxy) {
  36576. // 为 stores.proxy.buildRequest 做准备
  36577. this.store.proxy.$owner = this;
  36578. }
  36579. this.superclass.initialize.call(this);
  36580. },
  36581. afterRender: function () {
  36582. var me = this;
  36583. var config = this.config;
  36584. var dataSource = config.dataSource;
  36585. if (config.autoLoad) {
  36586. if (config.dataSourceCallbackFn) {
  36587. me.reload();
  36588. }
  36589. else if (lodash.isPlainObject(dataSource)) {
  36590. me.reload();
  36591. }
  36592. }
  36593. },
  36594. // 生成列自定义的缓存key
  36595. makeColumnConfigCacheKey: function (config) {
  36596. var scope = config.$initParent.yvanScope || config.$initParent.lookupReferenceHolder().yvanScope;
  36597. var key = "gridColumnCache-" + scope.scopeKey + "-";
  36598. if (config.reference) {
  36599. key += config.reference;
  36600. }
  36601. else {
  36602. var subKey = "";
  36603. for (var i = 0; i < config.columns.length; i++) {
  36604. var column = config.columns[i];
  36605. if (column.dataIndex) {
  36606. subKey += column.dataIndex;
  36607. }
  36608. }
  36609. key += subKey;
  36610. }
  36611. return key;
  36612. },
  36613. getColumnConfigCache: function () {
  36614. var key = this.columnConfigCacheKey;
  36615. var dataStr = localStorage.getItem(key);
  36616. if (dataStr) {
  36617. return JSON.parse(dataStr);
  36618. }
  36619. return "";
  36620. },
  36621. setColumnConfigCache: function () {
  36622. var key = this.columnConfigCacheKey;
  36623. var cacheData = [];
  36624. var columns = this.headerCt.getGridColumns();
  36625. var index = 0;
  36626. for (var i = 0; i < columns.length; i++) {
  36627. var column = columns[i];
  36628. if (column.dataIndex) {
  36629. cacheData.push({
  36630. dataIndex: column.dataIndex,
  36631. width: column.width,
  36632. hidden: column.hidden,
  36633. locked: column.locked,
  36634. index: index
  36635. });
  36636. index++;
  36637. }
  36638. }
  36639. localStorage.setItem(key, JSON.stringify(cacheData));
  36640. },
  36641. autoSizeColumns: function (sender) {
  36642. var grid = sender.up('grid');
  36643. // const columns = grid.columns;
  36644. // for (let i = 0; i < columns.length; i++) {
  36645. // const column = columns[i];
  36646. // grid.getView().autoSizeColumn(column);
  36647. // column.setWidth(column.getWidth() + 5);
  36648. // }
  36649. for (var i = 1; i < grid.headerCt.getColumnCount(); i++) {
  36650. grid.headerCt.getGridColumns()[i].autoSize(i);
  36651. grid.headerCt.getGridColumns()[i].setWidth(grid.headerCt.getGridColumns()[i].getWidth() + 15);
  36652. }
  36653. },
  36654. clearFilter: function (sender) {
  36655. var grid = sender.up('grid');
  36656. grid.filters.clearFilters();
  36657. grid.getStore().sorters.removeAll();
  36658. // grid.getStore().reload()
  36659. },
  36660. setLoading: function (value) {
  36661. if (value) {
  36662. this.mask('读取中');
  36663. }
  36664. else {
  36665. this.unmask();
  36666. }
  36667. },
  36668. });
  36669. PropertyDescriptionTable.set('yvgrid', new PropertyDescription(YvBase, {
  36670. props: [
  36671. fieldLabel, value, disabled,
  36672. gravity, tooltip, metaId, width, height
  36673. ],
  36674. }));
  36675. }
  36676. /**
  36677. * 获取 columns 中所有的 dataIndex
  36678. */
  36679. function getFileds(newConfig) {
  36680. var fields = [];
  36681. lodash.forEach(newConfig.columns || newConfig._columns, function (c) {
  36682. if (c.dataIndex) {
  36683. fields.push(c.dataIndex);
  36684. }
  36685. });
  36686. return fields;
  36687. }
  36688. function convertDataSource$1(sender, scope, newConfig) {
  36689. if (typeof newConfig.store !== 'undefined') {
  36690. // 有 store 属性的情况下,不做任何事
  36691. return;
  36692. }
  36693. if (typeof newConfig.dataSource === 'undefined') {
  36694. // 没有定义 dataSource 的情况下,不做任何事
  36695. return;
  36696. }
  36697. if (lodash.isArray(newConfig.data)) {
  36698. // 有 data 属性赋值的情况下
  36699. newConfig.store = {
  36700. fields: getFileds(newConfig),
  36701. data: newConfig.data
  36702. };
  36703. delete newConfig.data;
  36704. return;
  36705. }
  36706. var dataSource = newConfig.dataSource;
  36707. if (typeof dataSource === 'string') {
  36708. // dataSource 是字符串的情况下,找到成员函数
  36709. dataSource = lookupFn(scope, dataSource);
  36710. }
  36711. if (typeof dataSource === 'function') {
  36712. // dataSource 是函数的情况下,在 afterrender 之后进行回调
  36713. newConfig.store = new Ext.data.Store({
  36714. fields: getFileds(newConfig),
  36715. // data: [],
  36716. autoLoad: true,
  36717. proxy: {
  36718. type: 'memory',
  36719. data: [],
  36720. }
  36721. });
  36722. newConfig.dataSourceCallbackFn = dataSource;
  36723. return;
  36724. }
  36725. // throw new TypeError('无法识别的调用方法')
  36726. }
  36727. function initGridColumn () {
  36728. var ct = Ext.grid.column.Column.prototype.constructor;
  36729. Ext.grid.column.Column.override({
  36730. constructor: function (config) {
  36731. var newConfig = lodash.defaults({}, config, column);
  36732. if (newConfig.header && !newConfig.text) {
  36733. newConfig.text = newConfig.header;
  36734. }
  36735. ct.call(this, newConfig);
  36736. }
  36737. });
  36738. // 227573
  36739. // const {onTitleElClick} = Ext.grid.column.Column.prototype
  36740. // Ext.define('Yvan.ColumnOverride', {
  36741. // override: 'Ext.grid.column.Column',
  36742. //
  36743. // config: {
  36744. // enableSortOnClick: false,
  36745. // },
  36746. //
  36747. // // /**@Overrides*/
  36748. // onTitleElClick: function (e, t, sortOnClick) {
  36749. // // return this.callParent([e, t, this.enableSortOnClick && sortOnClick]);
  36750. // if (!$(e.target).is('.x-column-header-trigger')) {
  36751. // // 不是点击菜单的情况下,让列自适应宽度
  36752. // this.autoSize()
  36753. // }
  36754. // return onTitleElClick.call(this, e, t, false)
  36755. // }
  36756. // });
  36757. }
  36758. function initLocale() {
  36759. Ext.define('Ext.locale.zh_CN.Panel', {
  36760. override: 'Ext.Panel',
  36761. config: {
  36762. standardButtons: {
  36763. ok: {
  36764. text: '确定'
  36765. },
  36766. }
  36767. },
  36768. });
  36769. Ext.define('Ext.locale.zh_CN.picker.Date', {
  36770. override: 'Ext.picker.Date',
  36771. config: {
  36772. doneButton: '完成',
  36773. }
  36774. });
  36775. Ext.define('Ext.locale.zh_CN.picker.Picker', {
  36776. override: 'Ext.picker.Picker',
  36777. config: {
  36778. doneButton: '完成',
  36779. }
  36780. });
  36781. var _getStandardButtons = Ext.MessageBox.prototype.getStandardButtons;
  36782. Ext.MessageBox.override({
  36783. getStandardButtons: function () {
  36784. var ret = _getStandardButtons.apply(this, arguments);
  36785. ret.ok.text = "确定";
  36786. return ret;
  36787. }
  36788. });
  36789. // Ext.define('Ext.locale.zh_CN.MessageBox', {
  36790. // override: 'Ext.MessageBox',
  36791. // config: {
  36792. // standardButtons: {
  36793. // ok: {
  36794. // text: '确定'
  36795. // },
  36796. // }
  36797. // }
  36798. // });
  36799. }
  36800. var FixClass = /** @class */ (function () {
  36801. function FixClass() {
  36802. }
  36803. FixClass.prototype.fix = function (me, config) {
  36804. var _this = this;
  36805. var _a;
  36806. var fix = config.fix;
  36807. if (!fix) {
  36808. return;
  36809. }
  36810. delete config.fix;
  36811. // 这里有个 bug
  36812. // 但凡是调用了 this.lookupViewModel() 就会出现绑定不了的情况
  36813. // const scope = config.$initParent.lookupReferenceHolder().yvanScope //lookupScope(me)
  36814. var scope;
  36815. if (config.$initParent) {
  36816. // 在面板上的组件
  36817. scope = (_a = config.$initParent.lookupReferenceHolder()) === null || _a === void 0 ? void 0 : _a.yvanScope; //lookupScope(me)
  36818. if (!scope) {
  36819. scope = config.$initParent.yvanScope;
  36820. }
  36821. }
  36822. else if (config.column) {
  36823. // 在列上的组件
  36824. scope = config.column.lookupReferenceHolder().yvanScope; //lookupScope(me)
  36825. }
  36826. if (lodash.isArray(fix)) {
  36827. lodash.each(fix, function (f) {
  36828. var fn = lookupFn(scope, f);
  36829. fn.call(_this, me, config);
  36830. });
  36831. }
  36832. else if (lodash.isString(fix)) {
  36833. var fn = lookupFn(scope, fix);
  36834. fn.call(this, me, config);
  36835. }
  36836. };
  36837. __decorate([
  36838. baseConfigProcess(),
  36839. __metadata("design:type", Function),
  36840. __metadata("design:paramtypes", [Object, Object]),
  36841. __metadata("design:returntype", void 0)
  36842. ], FixClass.prototype, "fix", null);
  36843. return FixClass;
  36844. }());
  36845. function init() {
  36846. Ext.util.Format.defaultDateFormat = 'Y-m-d';
  36847. /**
  36848. * 改变事件的触发方式
  36849. */
  36850. var _getFireInfo = Ext.util.Event.prototype.getFireInfo;
  36851. Ext.util.Event.prototype.getFireInfo = function (listener, fromWrapped) {
  36852. var observable = this.observable, fireFn = listener.fireFn, scope = listener.scope, namedScope = listener.namedScope, fn;
  36853. fn = fromWrapped ? listener.fn : fireFn;
  36854. if (typeof fn === 'string' &&
  36855. (lodash.startsWith(fn, 'scope.') ||
  36856. lodash.startsWith(fn, 'system.') ||
  36857. lodash.startsWith(fn, 'format.'))) {
  36858. if (window["IS_DESIGN_MODE"]) {
  36859. fn = Ext.emptyFn;
  36860. }
  36861. else {
  36862. scope = lookupScope(observable);
  36863. fn = lookupFn(scope, fn);
  36864. }
  36865. return { scope: scope, fn: fn };
  36866. }
  36867. return _getFireInfo.call(this, listener, fromWrapped);
  36868. };
  36869. // const _addListener = Ext.mixin.Observable.prototype.addListener
  36870. // Ext.mixin.Observable.prototype.addListener = function (eventName, fn, scope, options, order, caller) {
  36871. // console.log('addListener', eventName, fn, scope, options, order, caller)
  36872. // // const scope = lookupScope(this)
  36873. // // const fn = lookupFn(scope, fn)
  36874. //
  36875. // return _addListener.call(this, eventName, fn, scope, options, order, caller)
  36876. // }
  36877. /**
  36878. * 改变事件的获取方式.
  36879. * 具体见: ext-all-debug.js:23216 addListener
  36880. * https://docs.sencha.com/extjs/6.6.0/classic/Ext.util.Observable.html#method-addListener
  36881. * https://docs.sencha.com/extjs/6.6.0/classic/src/Observable.js.html#Ext.mixin.Observable-method-addListener
  36882. */
  36883. // const _doAddListener = Ext.mixin.Observable.prototype.doAddListener
  36884. // Ext.mixin.Observable.prototype.doAddListener = function (ename, fn, scope, options, order, caller, manager) {
  36885. // console.log('doAddListener', ename, fn, scope)
  36886. // if (typeof fn === 'string' &&
  36887. // (_.startsWith(fn, 'scope.') ||
  36888. // _.startsWith(fn, 'system.') ||
  36889. // _.startsWith(fn, 'format.')
  36890. // )) {
  36891. //
  36892. // if (window["IS_DESIGN_MODE"]) {
  36893. // fn = Ext.emptyFn
  36894. // } else {
  36895. // // console.log('doAddListener', ename, fn, scope, options, order, caller, manager)
  36896. // // const vm = this.lookupViewModel()
  36897. // // if (vm && vm.yvanScope) {
  36898. // // scope = vm.yvanScope
  36899. // // fn = scope[fn.substr('scope.'.length)]
  36900. // // }
  36901. // scope = lookupScope(this)
  36902. // fn = lookupFn(scope, fn)
  36903. // }
  36904. // }
  36905. //
  36906. // _doAddListener.call(this, ename, fn, scope, options, order, caller, manager)
  36907. // }
  36908. // 将 SystemLib 扩展到 window.system 下
  36909. if (!window['system']) {
  36910. window['system'] = {};
  36911. }
  36912. lodash.extend(window['system'], SystemLib);
  36913. initComponent();
  36914. initDate();
  36915. initText();
  36916. initMultipleSearch();
  36917. initList();
  36918. initCols();
  36919. initRows();
  36920. initLocale();
  36921. initGridColumn();
  36922. initGrid();
  36923. initStores();
  36924. }
  36925. /**
  36926. * 创建一个 Ajax 客户端
  36927. */
  36928. function createAjax(createOption) {
  36929. if (createOption.baseUrl) {
  36930. axios$1.defaults.baseURL = createOption.baseUrl;
  36931. axios$1.defaults.timeout = createOption.timeout;
  36932. axios$1.defaults.timeoutErrorMessage = '网络超时';
  36933. }
  36934. return function (option) {
  36935. //@ts-ignore
  36936. option.method = (option.method || 'get').toLocaleLowerCase();
  36937. //@ts-ignore
  36938. var ax = __assign({}, option);
  36939. switch (option.method) {
  36940. case 'get':
  36941. ax.method = 'GET';
  36942. ax.params = option.param;
  36943. ax.headers = __assign({}, option.headers);
  36944. break;
  36945. case 'post':
  36946. ax.method = 'POST';
  36947. ax.headers = __assign({ 'Content-Type': 'application/x-www-form-urlencoded' }, option.headers);
  36948. ax.params = option.param;
  36949. ax.data = lib.stringify(option.data);
  36950. break;
  36951. case 'put':
  36952. case 'patch':
  36953. case 'delete':
  36954. ax.method = option.method;
  36955. ax.headers = option.headers;
  36956. ax.params = option.param;
  36957. ax.data = lib.stringify(option.data);
  36958. break;
  36959. case 'download':
  36960. downLoad(createOption.baseUrl + option.url, option.fileName || 'file', option.data, option.headers);
  36961. return new Promise(function (resolver, reject) {
  36962. });
  36963. case "invoke":
  36964. ax.url = serverInvokeUrlTransform(option.url, option);
  36965. ax.method = 'POST';
  36966. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  36967. if (typeof option.args === 'object') {
  36968. ax.data = JSON.stringify({
  36969. args: option.args,
  36970. });
  36971. }
  36972. else {
  36973. ax.data = JSON.stringify({
  36974. args: [
  36975. __assign(__assign({}, option.data), option.param)
  36976. ],
  36977. filterModel: option.filterModel,
  36978. sortModel: option.sortModel
  36979. });
  36980. }
  36981. break;
  36982. case 'post-json':
  36983. ax.method = 'POST';
  36984. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  36985. ax.data = JSON.stringify(__assign(__assign({}, option.data), { filterModel: option.filterModel, sortModel: option.sortModel }));
  36986. break;
  36987. case 'post-raw':
  36988. ax.method = 'POST';
  36989. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  36990. ax.data = option.data;
  36991. break;
  36992. case 'post-file':
  36993. //TODO 刘壮. 上传文件
  36994. var forms = new FormData();
  36995. ax.headers = __assign({ 'Content-Type': 'multipart/form-data' }, option.headers);
  36996. lodash.forOwn(option.data, function (value, key) {
  36997. if (key === 'files') {
  36998. var i_1 = 0;
  36999. lodash.each(value, function (f) {
  37000. // @ts-ignore
  37001. forms.append('file' + (++i_1), f);
  37002. });
  37003. }
  37004. else {
  37005. forms.append(key, value);
  37006. }
  37007. });
  37008. ax.data = forms;
  37009. ax.method = 'POST';
  37010. break;
  37011. case "sql":
  37012. ax.url = sqlUrlTransform(option.url);
  37013. ax.method = 'POST';
  37014. ax.headers = __assign({ 'Content-Type': 'application/json' }, option.headers);
  37015. ax.data = JSON.stringify({
  37016. args: [option.data],
  37017. db: option.db,
  37018. filterModel: option.filterModel,
  37019. sortModel: option.sortModel
  37020. });
  37021. break;
  37022. default:
  37023. throw new Error('not implements');
  37024. }
  37025. return new Promise(function (resolver, reject) {
  37026. axios$1(ax).then(function (resolverRaw) {
  37027. var apiResult = {
  37028. rawData: resolverRaw.data,
  37029. status: resolverRaw.status,
  37030. success: (resolverRaw.data && resolverRaw.data.success),
  37031. data: resolverRaw.data.data,
  37032. pagination: resolverRaw.data.pagination,
  37033. msg: (resolverRaw.data.msg),
  37034. errors: resolverRaw.data.errors,
  37035. headers: resolverRaw.headers
  37036. };
  37037. if (typeof window['apiTranslate'] === 'function') {
  37038. window['apiTranslate'](apiResult.rawData, option.url);
  37039. }
  37040. resolver(apiResult);
  37041. }).catch(function (reason) {
  37042. reject(reason);
  37043. });
  37044. });
  37045. };
  37046. }
  37047. function downLoad(downLoadUrl, filename, data, header, isJson) {
  37048. if (isJson === void 0) { isJson = false; }
  37049. var YvanUI = lodash.get(window, 'YvanUI');
  37050. YvanUI.loading();
  37051. var createObjectURL = function (object) {
  37052. return (window.URL) ? window.URL.createObjectURL(object) : lodash.get(window, 'webkitURL').createObjectURL(object);
  37053. };
  37054. // const formData = new FormData();
  37055. // _.forOwn(data, (v, k) => {
  37056. // formData.append(k, v);
  37057. // });
  37058. var formData = '';
  37059. var xhr = new XMLHttpRequest();
  37060. xhr.open('POST', downLoadUrl);
  37061. xhr.responseType = 'blob';
  37062. // xhr.setRequestHeader('Authorization', $.cookie('auth'))
  37063. if (isJson) {
  37064. formData = data ? JSON.stringify(data) : '';
  37065. xhr.setRequestHeader('Content-Type', 'application/json');
  37066. }
  37067. else {
  37068. formData = data ? lib.stringify(data) : '';
  37069. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  37070. }
  37071. //
  37072. if (header) {
  37073. lodash.forOwn(header, function (v, k) {
  37074. xhr.setRequestHeader(k, v);
  37075. });
  37076. }
  37077. xhr.onload = function (e) {
  37078. if (this.status === 200) {
  37079. var blob = this.response;
  37080. if (lodash.hasIn(window, 'navigator.msSaveOrOpenBlob')) {
  37081. navigator.msSaveBlob(blob, filename);
  37082. YvanUI.clearLoading();
  37083. }
  37084. else {
  37085. var a = document.createElement('a');
  37086. var url = createObjectURL(blob);
  37087. a.href = url;
  37088. a.download = filename;
  37089. document.append(a);
  37090. a.click();
  37091. a.remove();
  37092. window.URL.revokeObjectURL(url);
  37093. YvanUI.clearLoading();
  37094. }
  37095. }
  37096. };
  37097. xhr.send(formData);
  37098. }
  37099. exports.Lib = Lib;
  37100. exports.LibParam = LibParam;
  37101. exports.Scope = Scope;
  37102. exports.ajax = ajax;
  37103. exports.axios = index;
  37104. exports.baseConfigProcess = baseConfigProcess;
  37105. exports.baseConfigProcessList = baseConfigProcessList;
  37106. exports.confirm = confirm;
  37107. exports.createAjax = createAjax;
  37108. exports.downLoad = downLoad;
  37109. exports.extend = extend$1;
  37110. exports.flatRow = flatRow;
  37111. exports.getApiConvert = getApiConvert;
  37112. exports.getPinyin = getPinyin;
  37113. exports.getRegList = getRegList;
  37114. exports.getRegParamList = getRegParamList;
  37115. exports.init = init;
  37116. exports.invokeServer = invokeServer;
  37117. exports.isDesignMode = isDesignMode;
  37118. exports.isEmpty = isEmpty;
  37119. exports.jquery = jquery;
  37120. exports.json5 = dist;
  37121. exports.keywordFilter = keywordFilter;
  37122. exports.lodash = lodash;
  37123. exports.lookupFn = lookupFn;
  37124. exports.lookupScope = lookupScope;
  37125. exports.moment = moment;
  37126. exports.msg = msg;
  37127. exports.msgError = msgError;
  37128. exports.prompt = prompt;
  37129. exports.qs = lib;
  37130. exports.raiseClick = raiseClick;
  37131. exports.serverInvokeUrlTransform = serverInvokeUrlTransform;
  37132. exports.setComboStore = setComboStore;
  37133. exports.setDesignMode = setDesignMode;
  37134. exports.showErrorDialog = showErrorDialog;
  37135. exports.showInfoDialog = showInfoDialog;
  37136. exports.sqlUrlTransform = sqlUrlTransform;
  37137. exports.toString = toString$1;
  37138. Object.defineProperty(exports, '__esModule', { value: true });
  37139. });
  37140. //# sourceMappingURL=yvan-ext-mobile.js.map