app.js 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/after/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/after/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports) {
  94. module.exports = after
  95. function after(count, callback, err_cb) {
  96. var bail = false
  97. err_cb = err_cb || noop
  98. proxy.count = count
  99. return (count === 0) ? callback() : proxy
  100. function proxy(err, result) {
  101. if (proxy.count <= 0) {
  102. throw new Error('after called too many times')
  103. }
  104. --proxy.count
  105. // after first error, rest are passed to err_cb
  106. if (err) {
  107. bail = true
  108. callback(err)
  109. // future error callbacks will go to error handler
  110. callback = err_cb
  111. } else if (proxy.count === 0 && !bail) {
  112. callback(null, result)
  113. }
  114. }
  115. }
  116. function noop() {}
  117. /***/ }),
  118. /***/ "./node_modules/arraybuffer.slice/index.js":
  119. /*!*************************************************!*\
  120. !*** ./node_modules/arraybuffer.slice/index.js ***!
  121. \*************************************************/
  122. /*! no static exports found */
  123. /***/ (function(module, exports) {
  124. /**
  125. * An abstraction for slicing an arraybuffer even when
  126. * ArrayBuffer.prototype.slice is not supported
  127. *
  128. * @api public
  129. */
  130. module.exports = function(arraybuffer, start, end) {
  131. var bytes = arraybuffer.byteLength;
  132. start = start || 0;
  133. end = end || bytes;
  134. if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
  135. if (start < 0) { start += bytes; }
  136. if (end < 0) { end += bytes; }
  137. if (end > bytes) { end = bytes; }
  138. if (start >= bytes || start >= end || bytes === 0) {
  139. return new ArrayBuffer(0);
  140. }
  141. var abv = new Uint8Array(arraybuffer);
  142. var result = new Uint8Array(end - start);
  143. for (var i = start, ii = 0; i < end; i++, ii++) {
  144. result[ii] = abv[i];
  145. }
  146. return result.buffer;
  147. };
  148. /***/ }),
  149. /***/ "./node_modules/axios/index.js":
  150. /*!*************************************!*\
  151. !*** ./node_modules/axios/index.js ***!
  152. \*************************************/
  153. /*! no static exports found */
  154. /***/ (function(module, exports, __webpack_require__) {
  155. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  156. /***/ }),
  157. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  158. /*!************************************************!*\
  159. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  160. \************************************************/
  161. /*! no static exports found */
  162. /***/ (function(module, exports, __webpack_require__) {
  163. "use strict";
  164. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  165. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  166. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  167. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  168. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  169. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  170. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  171. module.exports = function xhrAdapter(config) {
  172. return new Promise(function dispatchXhrRequest(resolve, reject) {
  173. var requestData = config.data;
  174. var requestHeaders = config.headers;
  175. if (utils.isFormData(requestData)) {
  176. delete requestHeaders['Content-Type']; // Let the browser set it
  177. }
  178. var request = new XMLHttpRequest();
  179. // HTTP basic authentication
  180. if (config.auth) {
  181. var username = config.auth.username || '';
  182. var password = config.auth.password || '';
  183. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  184. }
  185. var fullPath = buildFullPath(config.baseURL, config.url);
  186. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  187. // Set the request timeout in MS
  188. request.timeout = config.timeout;
  189. // Listen for ready state
  190. request.onreadystatechange = function handleLoad() {
  191. if (!request || request.readyState !== 4) {
  192. return;
  193. }
  194. // The request errored out and we didn't get a response, this will be
  195. // handled by onerror instead
  196. // With one exception: request that using file: protocol, most browsers
  197. // will return status as 0 even though it's a successful request
  198. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  199. return;
  200. }
  201. // Prepare the response
  202. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  203. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  204. var response = {
  205. data: responseData,
  206. status: request.status,
  207. statusText: request.statusText,
  208. headers: responseHeaders,
  209. config: config,
  210. request: request
  211. };
  212. settle(resolve, reject, response);
  213. // Clean up request
  214. request = null;
  215. };
  216. // Handle browser request cancellation (as opposed to a manual cancellation)
  217. request.onabort = function handleAbort() {
  218. if (!request) {
  219. return;
  220. }
  221. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  222. // Clean up request
  223. request = null;
  224. };
  225. // Handle low level network errors
  226. request.onerror = function handleError() {
  227. // Real errors are hidden from us by the browser
  228. // onerror should only fire if it's a network error
  229. reject(createError('Network Error', config, null, request));
  230. // Clean up request
  231. request = null;
  232. };
  233. // Handle timeout
  234. request.ontimeout = function handleTimeout() {
  235. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  236. if (config.timeoutErrorMessage) {
  237. timeoutErrorMessage = config.timeoutErrorMessage;
  238. }
  239. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  240. request));
  241. // Clean up request
  242. request = null;
  243. };
  244. // Add xsrf header
  245. // This is only done if running in a standard browser environment.
  246. // Specifically not if we're in a web worker, or react-native.
  247. if (utils.isStandardBrowserEnv()) {
  248. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  249. // Add xsrf header
  250. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  251. cookies.read(config.xsrfCookieName) :
  252. undefined;
  253. if (xsrfValue) {
  254. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  255. }
  256. }
  257. // Add headers to the request
  258. if ('setRequestHeader' in request) {
  259. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  260. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  261. // Remove Content-Type if data is undefined
  262. delete requestHeaders[key];
  263. } else {
  264. // Otherwise add header to the request
  265. request.setRequestHeader(key, val);
  266. }
  267. });
  268. }
  269. // Add withCredentials to request if needed
  270. if (!utils.isUndefined(config.withCredentials)) {
  271. request.withCredentials = !!config.withCredentials;
  272. }
  273. // Add responseType to request if needed
  274. if (config.responseType) {
  275. try {
  276. request.responseType = config.responseType;
  277. } catch (e) {
  278. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  279. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  280. if (config.responseType !== 'json') {
  281. throw e;
  282. }
  283. }
  284. }
  285. // Handle progress if needed
  286. if (typeof config.onDownloadProgress === 'function') {
  287. request.addEventListener('progress', config.onDownloadProgress);
  288. }
  289. // Not all browsers support upload events
  290. if (typeof config.onUploadProgress === 'function' && request.upload) {
  291. request.upload.addEventListener('progress', config.onUploadProgress);
  292. }
  293. if (config.cancelToken) {
  294. // Handle cancellation
  295. config.cancelToken.promise.then(function onCanceled(cancel) {
  296. if (!request) {
  297. return;
  298. }
  299. request.abort();
  300. reject(cancel);
  301. // Clean up request
  302. request = null;
  303. });
  304. }
  305. if (requestData === undefined) {
  306. requestData = null;
  307. }
  308. // Send the request
  309. request.send(requestData);
  310. });
  311. };
  312. /***/ }),
  313. /***/ "./node_modules/axios/lib/axios.js":
  314. /*!*****************************************!*\
  315. !*** ./node_modules/axios/lib/axios.js ***!
  316. \*****************************************/
  317. /*! no static exports found */
  318. /***/ (function(module, exports, __webpack_require__) {
  319. "use strict";
  320. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  321. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  322. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  323. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  324. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  325. /**
  326. * Create an instance of Axios
  327. *
  328. * @param {Object} defaultConfig The default config for the instance
  329. * @return {Axios} A new instance of Axios
  330. */
  331. function createInstance(defaultConfig) {
  332. var context = new Axios(defaultConfig);
  333. var instance = bind(Axios.prototype.request, context);
  334. // Copy axios.prototype to instance
  335. utils.extend(instance, Axios.prototype, context);
  336. // Copy context to instance
  337. utils.extend(instance, context);
  338. return instance;
  339. }
  340. // Create the default instance to be exported
  341. var axios = createInstance(defaults);
  342. // Expose Axios class to allow class inheritance
  343. axios.Axios = Axios;
  344. // Factory for creating new instances
  345. axios.create = function create(instanceConfig) {
  346. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  347. };
  348. // Expose Cancel & CancelToken
  349. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  350. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  351. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  352. // Expose all/spread
  353. axios.all = function all(promises) {
  354. return Promise.all(promises);
  355. };
  356. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  357. module.exports = axios;
  358. // Allow use of default import syntax in TypeScript
  359. module.exports.default = axios;
  360. /***/ }),
  361. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  362. /*!*************************************************!*\
  363. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  364. \*************************************************/
  365. /*! no static exports found */
  366. /***/ (function(module, exports, __webpack_require__) {
  367. "use strict";
  368. /**
  369. * A `Cancel` is an object that is thrown when an operation is canceled.
  370. *
  371. * @class
  372. * @param {string=} message The message.
  373. */
  374. function Cancel(message) {
  375. this.message = message;
  376. }
  377. Cancel.prototype.toString = function toString() {
  378. return 'Cancel' + (this.message ? ': ' + this.message : '');
  379. };
  380. Cancel.prototype.__CANCEL__ = true;
  381. module.exports = Cancel;
  382. /***/ }),
  383. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  384. /*!******************************************************!*\
  385. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  386. \******************************************************/
  387. /*! no static exports found */
  388. /***/ (function(module, exports, __webpack_require__) {
  389. "use strict";
  390. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  391. /**
  392. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  393. *
  394. * @class
  395. * @param {Function} executor The executor function.
  396. */
  397. function CancelToken(executor) {
  398. if (typeof executor !== 'function') {
  399. throw new TypeError('executor must be a function.');
  400. }
  401. var resolvePromise;
  402. this.promise = new Promise(function promiseExecutor(resolve) {
  403. resolvePromise = resolve;
  404. });
  405. var token = this;
  406. executor(function cancel(message) {
  407. if (token.reason) {
  408. // Cancellation has already been requested
  409. return;
  410. }
  411. token.reason = new Cancel(message);
  412. resolvePromise(token.reason);
  413. });
  414. }
  415. /**
  416. * Throws a `Cancel` if cancellation has been requested.
  417. */
  418. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  419. if (this.reason) {
  420. throw this.reason;
  421. }
  422. };
  423. /**
  424. * Returns an object that contains a new `CancelToken` and a function that, when called,
  425. * cancels the `CancelToken`.
  426. */
  427. CancelToken.source = function source() {
  428. var cancel;
  429. var token = new CancelToken(function executor(c) {
  430. cancel = c;
  431. });
  432. return {
  433. token: token,
  434. cancel: cancel
  435. };
  436. };
  437. module.exports = CancelToken;
  438. /***/ }),
  439. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  440. /*!***************************************************!*\
  441. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  442. \***************************************************/
  443. /*! no static exports found */
  444. /***/ (function(module, exports, __webpack_require__) {
  445. "use strict";
  446. module.exports = function isCancel(value) {
  447. return !!(value && value.__CANCEL__);
  448. };
  449. /***/ }),
  450. /***/ "./node_modules/axios/lib/core/Axios.js":
  451. /*!**********************************************!*\
  452. !*** ./node_modules/axios/lib/core/Axios.js ***!
  453. \**********************************************/
  454. /*! no static exports found */
  455. /***/ (function(module, exports, __webpack_require__) {
  456. "use strict";
  457. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  458. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  459. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  460. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  461. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  462. /**
  463. * Create a new instance of Axios
  464. *
  465. * @param {Object} instanceConfig The default config for the instance
  466. */
  467. function Axios(instanceConfig) {
  468. this.defaults = instanceConfig;
  469. this.interceptors = {
  470. request: new InterceptorManager(),
  471. response: new InterceptorManager()
  472. };
  473. }
  474. /**
  475. * Dispatch a request
  476. *
  477. * @param {Object} config The config specific for this request (merged with this.defaults)
  478. */
  479. Axios.prototype.request = function request(config) {
  480. /*eslint no-param-reassign:0*/
  481. // Allow for axios('example/url'[, config]) a la fetch API
  482. if (typeof config === 'string') {
  483. config = arguments[1] || {};
  484. config.url = arguments[0];
  485. } else {
  486. config = config || {};
  487. }
  488. config = mergeConfig(this.defaults, config);
  489. // Set config.method
  490. if (config.method) {
  491. config.method = config.method.toLowerCase();
  492. } else if (this.defaults.method) {
  493. config.method = this.defaults.method.toLowerCase();
  494. } else {
  495. config.method = 'get';
  496. }
  497. // Hook up interceptors middleware
  498. var chain = [dispatchRequest, undefined];
  499. var promise = Promise.resolve(config);
  500. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  501. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  502. });
  503. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  504. chain.push(interceptor.fulfilled, interceptor.rejected);
  505. });
  506. while (chain.length) {
  507. promise = promise.then(chain.shift(), chain.shift());
  508. }
  509. return promise;
  510. };
  511. Axios.prototype.getUri = function getUri(config) {
  512. config = mergeConfig(this.defaults, config);
  513. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  514. };
  515. // Provide aliases for supported request methods
  516. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  517. /*eslint func-names:0*/
  518. Axios.prototype[method] = function(url, config) {
  519. return this.request(utils.merge(config || {}, {
  520. method: method,
  521. url: url
  522. }));
  523. };
  524. });
  525. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  526. /*eslint func-names:0*/
  527. Axios.prototype[method] = function(url, data, config) {
  528. return this.request(utils.merge(config || {}, {
  529. method: method,
  530. url: url,
  531. data: data
  532. }));
  533. };
  534. });
  535. module.exports = Axios;
  536. /***/ }),
  537. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  538. /*!***********************************************************!*\
  539. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  540. \***********************************************************/
  541. /*! no static exports found */
  542. /***/ (function(module, exports, __webpack_require__) {
  543. "use strict";
  544. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  545. function InterceptorManager() {
  546. this.handlers = [];
  547. }
  548. /**
  549. * Add a new interceptor to the stack
  550. *
  551. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  552. * @param {Function} rejected The function to handle `reject` for a `Promise`
  553. *
  554. * @return {Number} An ID used to remove interceptor later
  555. */
  556. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  557. this.handlers.push({
  558. fulfilled: fulfilled,
  559. rejected: rejected
  560. });
  561. return this.handlers.length - 1;
  562. };
  563. /**
  564. * Remove an interceptor from the stack
  565. *
  566. * @param {Number} id The ID that was returned by `use`
  567. */
  568. InterceptorManager.prototype.eject = function eject(id) {
  569. if (this.handlers[id]) {
  570. this.handlers[id] = null;
  571. }
  572. };
  573. /**
  574. * Iterate over all the registered interceptors
  575. *
  576. * This method is particularly useful for skipping over any
  577. * interceptors that may have become `null` calling `eject`.
  578. *
  579. * @param {Function} fn The function to call for each interceptor
  580. */
  581. InterceptorManager.prototype.forEach = function forEach(fn) {
  582. utils.forEach(this.handlers, function forEachHandler(h) {
  583. if (h !== null) {
  584. fn(h);
  585. }
  586. });
  587. };
  588. module.exports = InterceptorManager;
  589. /***/ }),
  590. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  591. /*!******************************************************!*\
  592. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  593. \******************************************************/
  594. /*! no static exports found */
  595. /***/ (function(module, exports, __webpack_require__) {
  596. "use strict";
  597. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  598. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  599. /**
  600. * Creates a new URL by combining the baseURL with the requestedURL,
  601. * only when the requestedURL is not already an absolute URL.
  602. * If the requestURL is absolute, this function returns the requestedURL untouched.
  603. *
  604. * @param {string} baseURL The base URL
  605. * @param {string} requestedURL Absolute or relative URL to combine
  606. * @returns {string} The combined full path
  607. */
  608. module.exports = function buildFullPath(baseURL, requestedURL) {
  609. if (baseURL && !isAbsoluteURL(requestedURL)) {
  610. return combineURLs(baseURL, requestedURL);
  611. }
  612. return requestedURL;
  613. };
  614. /***/ }),
  615. /***/ "./node_modules/axios/lib/core/createError.js":
  616. /*!****************************************************!*\
  617. !*** ./node_modules/axios/lib/core/createError.js ***!
  618. \****************************************************/
  619. /*! no static exports found */
  620. /***/ (function(module, exports, __webpack_require__) {
  621. "use strict";
  622. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  623. /**
  624. * Create an Error with the specified message, config, error code, request and response.
  625. *
  626. * @param {string} message The error message.
  627. * @param {Object} config The config.
  628. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  629. * @param {Object} [request] The request.
  630. * @param {Object} [response] The response.
  631. * @returns {Error} The created error.
  632. */
  633. module.exports = function createError(message, config, code, request, response) {
  634. var error = new Error(message);
  635. return enhanceError(error, config, code, request, response);
  636. };
  637. /***/ }),
  638. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  639. /*!********************************************************!*\
  640. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  641. \********************************************************/
  642. /*! no static exports found */
  643. /***/ (function(module, exports, __webpack_require__) {
  644. "use strict";
  645. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  646. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  647. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  648. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  649. /**
  650. * Throws a `Cancel` if cancellation has been requested.
  651. */
  652. function throwIfCancellationRequested(config) {
  653. if (config.cancelToken) {
  654. config.cancelToken.throwIfRequested();
  655. }
  656. }
  657. /**
  658. * Dispatch a request to the server using the configured adapter.
  659. *
  660. * @param {object} config The config that is to be used for the request
  661. * @returns {Promise} The Promise to be fulfilled
  662. */
  663. module.exports = function dispatchRequest(config) {
  664. throwIfCancellationRequested(config);
  665. // Ensure headers exist
  666. config.headers = config.headers || {};
  667. // Transform request data
  668. config.data = transformData(
  669. config.data,
  670. config.headers,
  671. config.transformRequest
  672. );
  673. // Flatten headers
  674. config.headers = utils.merge(
  675. config.headers.common || {},
  676. config.headers[config.method] || {},
  677. config.headers
  678. );
  679. utils.forEach(
  680. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  681. function cleanHeaderConfig(method) {
  682. delete config.headers[method];
  683. }
  684. );
  685. var adapter = config.adapter || defaults.adapter;
  686. return adapter(config).then(function onAdapterResolution(response) {
  687. throwIfCancellationRequested(config);
  688. // Transform response data
  689. response.data = transformData(
  690. response.data,
  691. response.headers,
  692. config.transformResponse
  693. );
  694. return response;
  695. }, function onAdapterRejection(reason) {
  696. if (!isCancel(reason)) {
  697. throwIfCancellationRequested(config);
  698. // Transform response data
  699. if (reason && reason.response) {
  700. reason.response.data = transformData(
  701. reason.response.data,
  702. reason.response.headers,
  703. config.transformResponse
  704. );
  705. }
  706. }
  707. return Promise.reject(reason);
  708. });
  709. };
  710. /***/ }),
  711. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  712. /*!*****************************************************!*\
  713. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  714. \*****************************************************/
  715. /*! no static exports found */
  716. /***/ (function(module, exports, __webpack_require__) {
  717. "use strict";
  718. /**
  719. * Update an Error with the specified config, error code, and response.
  720. *
  721. * @param {Error} error The error to update.
  722. * @param {Object} config The config.
  723. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  724. * @param {Object} [request] The request.
  725. * @param {Object} [response] The response.
  726. * @returns {Error} The error.
  727. */
  728. module.exports = function enhanceError(error, config, code, request, response) {
  729. error.config = config;
  730. if (code) {
  731. error.code = code;
  732. }
  733. error.request = request;
  734. error.response = response;
  735. error.isAxiosError = true;
  736. error.toJSON = function() {
  737. return {
  738. // Standard
  739. message: this.message,
  740. name: this.name,
  741. // Microsoft
  742. description: this.description,
  743. number: this.number,
  744. // Mozilla
  745. fileName: this.fileName,
  746. lineNumber: this.lineNumber,
  747. columnNumber: this.columnNumber,
  748. stack: this.stack,
  749. // Axios
  750. config: this.config,
  751. code: this.code
  752. };
  753. };
  754. return error;
  755. };
  756. /***/ }),
  757. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  758. /*!****************************************************!*\
  759. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  760. \****************************************************/
  761. /*! no static exports found */
  762. /***/ (function(module, exports, __webpack_require__) {
  763. "use strict";
  764. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  765. /**
  766. * Config-specific merge-function which creates a new config-object
  767. * by merging two configuration objects together.
  768. *
  769. * @param {Object} config1
  770. * @param {Object} config2
  771. * @returns {Object} New object resulting from merging config2 to config1
  772. */
  773. module.exports = function mergeConfig(config1, config2) {
  774. // eslint-disable-next-line no-param-reassign
  775. config2 = config2 || {};
  776. var config = {};
  777. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  778. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  779. var defaultToConfig2Keys = [
  780. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  781. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  782. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  783. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  784. 'httpsAgent', 'cancelToken', 'socketPath'
  785. ];
  786. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  787. if (typeof config2[prop] !== 'undefined') {
  788. config[prop] = config2[prop];
  789. }
  790. });
  791. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  792. if (utils.isObject(config2[prop])) {
  793. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  794. } else if (typeof config2[prop] !== 'undefined') {
  795. config[prop] = config2[prop];
  796. } else if (utils.isObject(config1[prop])) {
  797. config[prop] = utils.deepMerge(config1[prop]);
  798. } else if (typeof config1[prop] !== 'undefined') {
  799. config[prop] = config1[prop];
  800. }
  801. });
  802. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  803. if (typeof config2[prop] !== 'undefined') {
  804. config[prop] = config2[prop];
  805. } else if (typeof config1[prop] !== 'undefined') {
  806. config[prop] = config1[prop];
  807. }
  808. });
  809. var axiosKeys = valueFromConfig2Keys
  810. .concat(mergeDeepPropertiesKeys)
  811. .concat(defaultToConfig2Keys);
  812. var otherKeys = Object
  813. .keys(config2)
  814. .filter(function filterAxiosKeys(key) {
  815. return axiosKeys.indexOf(key) === -1;
  816. });
  817. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  818. if (typeof config2[prop] !== 'undefined') {
  819. config[prop] = config2[prop];
  820. } else if (typeof config1[prop] !== 'undefined') {
  821. config[prop] = config1[prop];
  822. }
  823. });
  824. return config;
  825. };
  826. /***/ }),
  827. /***/ "./node_modules/axios/lib/core/settle.js":
  828. /*!***********************************************!*\
  829. !*** ./node_modules/axios/lib/core/settle.js ***!
  830. \***********************************************/
  831. /*! no static exports found */
  832. /***/ (function(module, exports, __webpack_require__) {
  833. "use strict";
  834. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  835. /**
  836. * Resolve or reject a Promise based on response status.
  837. *
  838. * @param {Function} resolve A function that resolves the promise.
  839. * @param {Function} reject A function that rejects the promise.
  840. * @param {object} response The response.
  841. */
  842. module.exports = function settle(resolve, reject, response) {
  843. var validateStatus = response.config.validateStatus;
  844. if (!validateStatus || validateStatus(response.status)) {
  845. resolve(response);
  846. } else {
  847. reject(createError(
  848. 'Request failed with status code ' + response.status,
  849. response.config,
  850. null,
  851. response.request,
  852. response
  853. ));
  854. }
  855. };
  856. /***/ }),
  857. /***/ "./node_modules/axios/lib/core/transformData.js":
  858. /*!******************************************************!*\
  859. !*** ./node_modules/axios/lib/core/transformData.js ***!
  860. \******************************************************/
  861. /*! no static exports found */
  862. /***/ (function(module, exports, __webpack_require__) {
  863. "use strict";
  864. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  865. /**
  866. * Transform the data for a request or a response
  867. *
  868. * @param {Object|String} data The data to be transformed
  869. * @param {Array} headers The headers for the request or response
  870. * @param {Array|Function} fns A single function or Array of functions
  871. * @returns {*} The resulting transformed data
  872. */
  873. module.exports = function transformData(data, headers, fns) {
  874. /*eslint no-param-reassign:0*/
  875. utils.forEach(fns, function transform(fn) {
  876. data = fn(data, headers);
  877. });
  878. return data;
  879. };
  880. /***/ }),
  881. /***/ "./node_modules/axios/lib/defaults.js":
  882. /*!********************************************!*\
  883. !*** ./node_modules/axios/lib/defaults.js ***!
  884. \********************************************/
  885. /*! no static exports found */
  886. /***/ (function(module, exports, __webpack_require__) {
  887. "use strict";
  888. /* WEBPACK VAR INJECTION */(function(process) {
  889. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  890. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  891. var DEFAULT_CONTENT_TYPE = {
  892. 'Content-Type': 'application/x-www-form-urlencoded'
  893. };
  894. function setContentTypeIfUnset(headers, value) {
  895. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  896. headers['Content-Type'] = value;
  897. }
  898. }
  899. function getDefaultAdapter() {
  900. var adapter;
  901. if (typeof XMLHttpRequest !== 'undefined') {
  902. // For browsers use XHR adapter
  903. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  904. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  905. // For node use HTTP adapter
  906. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  907. }
  908. return adapter;
  909. }
  910. var defaults = {
  911. adapter: getDefaultAdapter(),
  912. transformRequest: [function transformRequest(data, headers) {
  913. normalizeHeaderName(headers, 'Accept');
  914. normalizeHeaderName(headers, 'Content-Type');
  915. if (utils.isFormData(data) ||
  916. utils.isArrayBuffer(data) ||
  917. utils.isBuffer(data) ||
  918. utils.isStream(data) ||
  919. utils.isFile(data) ||
  920. utils.isBlob(data)
  921. ) {
  922. return data;
  923. }
  924. if (utils.isArrayBufferView(data)) {
  925. return data.buffer;
  926. }
  927. if (utils.isURLSearchParams(data)) {
  928. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  929. return data.toString();
  930. }
  931. if (utils.isObject(data)) {
  932. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  933. return JSON.stringify(data);
  934. }
  935. return data;
  936. }],
  937. transformResponse: [function transformResponse(data) {
  938. /*eslint no-param-reassign:0*/
  939. if (typeof data === 'string') {
  940. try {
  941. data = JSON.parse(data);
  942. } catch (e) { /* Ignore */ }
  943. }
  944. return data;
  945. }],
  946. /**
  947. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  948. * timeout is not created.
  949. */
  950. timeout: 0,
  951. xsrfCookieName: 'XSRF-TOKEN',
  952. xsrfHeaderName: 'X-XSRF-TOKEN',
  953. maxContentLength: -1,
  954. validateStatus: function validateStatus(status) {
  955. return status >= 200 && status < 300;
  956. }
  957. };
  958. defaults.headers = {
  959. common: {
  960. 'Accept': 'application/json, text/plain, */*'
  961. }
  962. };
  963. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  964. defaults.headers[method] = {};
  965. });
  966. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  967. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  968. });
  969. module.exports = defaults;
  970. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  971. /***/ }),
  972. /***/ "./node_modules/axios/lib/helpers/bind.js":
  973. /*!************************************************!*\
  974. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  975. \************************************************/
  976. /*! no static exports found */
  977. /***/ (function(module, exports, __webpack_require__) {
  978. "use strict";
  979. module.exports = function bind(fn, thisArg) {
  980. return function wrap() {
  981. var args = new Array(arguments.length);
  982. for (var i = 0; i < args.length; i++) {
  983. args[i] = arguments[i];
  984. }
  985. return fn.apply(thisArg, args);
  986. };
  987. };
  988. /***/ }),
  989. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  990. /*!****************************************************!*\
  991. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  992. \****************************************************/
  993. /*! no static exports found */
  994. /***/ (function(module, exports, __webpack_require__) {
  995. "use strict";
  996. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  997. function encode(val) {
  998. return encodeURIComponent(val).
  999. replace(/%40/gi, '@').
  1000. replace(/%3A/gi, ':').
  1001. replace(/%24/g, '$').
  1002. replace(/%2C/gi, ',').
  1003. replace(/%20/g, '+').
  1004. replace(/%5B/gi, '[').
  1005. replace(/%5D/gi, ']');
  1006. }
  1007. /**
  1008. * Build a URL by appending params to the end
  1009. *
  1010. * @param {string} url The base of the url (e.g., http://www.google.com)
  1011. * @param {object} [params] The params to be appended
  1012. * @returns {string} The formatted url
  1013. */
  1014. module.exports = function buildURL(url, params, paramsSerializer) {
  1015. /*eslint no-param-reassign:0*/
  1016. if (!params) {
  1017. return url;
  1018. }
  1019. var serializedParams;
  1020. if (paramsSerializer) {
  1021. serializedParams = paramsSerializer(params);
  1022. } else if (utils.isURLSearchParams(params)) {
  1023. serializedParams = params.toString();
  1024. } else {
  1025. var parts = [];
  1026. utils.forEach(params, function serialize(val, key) {
  1027. if (val === null || typeof val === 'undefined') {
  1028. return;
  1029. }
  1030. if (utils.isArray(val)) {
  1031. key = key + '[]';
  1032. } else {
  1033. val = [val];
  1034. }
  1035. utils.forEach(val, function parseValue(v) {
  1036. if (utils.isDate(v)) {
  1037. v = v.toISOString();
  1038. } else if (utils.isObject(v)) {
  1039. v = JSON.stringify(v);
  1040. }
  1041. parts.push(encode(key) + '=' + encode(v));
  1042. });
  1043. });
  1044. serializedParams = parts.join('&');
  1045. }
  1046. if (serializedParams) {
  1047. var hashmarkIndex = url.indexOf('#');
  1048. if (hashmarkIndex !== -1) {
  1049. url = url.slice(0, hashmarkIndex);
  1050. }
  1051. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1052. }
  1053. return url;
  1054. };
  1055. /***/ }),
  1056. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  1057. /*!*******************************************************!*\
  1058. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  1059. \*******************************************************/
  1060. /*! no static exports found */
  1061. /***/ (function(module, exports, __webpack_require__) {
  1062. "use strict";
  1063. /**
  1064. * Creates a new URL by combining the specified URLs
  1065. *
  1066. * @param {string} baseURL The base URL
  1067. * @param {string} relativeURL The relative URL
  1068. * @returns {string} The combined URL
  1069. */
  1070. module.exports = function combineURLs(baseURL, relativeURL) {
  1071. return relativeURL
  1072. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1073. : baseURL;
  1074. };
  1075. /***/ }),
  1076. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1077. /*!***************************************************!*\
  1078. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1079. \***************************************************/
  1080. /*! no static exports found */
  1081. /***/ (function(module, exports, __webpack_require__) {
  1082. "use strict";
  1083. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1084. module.exports = (
  1085. utils.isStandardBrowserEnv() ?
  1086. // Standard browser envs support document.cookie
  1087. (function standardBrowserEnv() {
  1088. return {
  1089. write: function write(name, value, expires, path, domain, secure) {
  1090. var cookie = [];
  1091. cookie.push(name + '=' + encodeURIComponent(value));
  1092. if (utils.isNumber(expires)) {
  1093. cookie.push('expires=' + new Date(expires).toGMTString());
  1094. }
  1095. if (utils.isString(path)) {
  1096. cookie.push('path=' + path);
  1097. }
  1098. if (utils.isString(domain)) {
  1099. cookie.push('domain=' + domain);
  1100. }
  1101. if (secure === true) {
  1102. cookie.push('secure');
  1103. }
  1104. document.cookie = cookie.join('; ');
  1105. },
  1106. read: function read(name) {
  1107. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1108. return (match ? decodeURIComponent(match[3]) : null);
  1109. },
  1110. remove: function remove(name) {
  1111. this.write(name, '', Date.now() - 86400000);
  1112. }
  1113. };
  1114. })() :
  1115. // Non standard browser env (web workers, react-native) lack needed support.
  1116. (function nonStandardBrowserEnv() {
  1117. return {
  1118. write: function write() {},
  1119. read: function read() { return null; },
  1120. remove: function remove() {}
  1121. };
  1122. })()
  1123. );
  1124. /***/ }),
  1125. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1126. /*!*********************************************************!*\
  1127. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1128. \*********************************************************/
  1129. /*! no static exports found */
  1130. /***/ (function(module, exports, __webpack_require__) {
  1131. "use strict";
  1132. /**
  1133. * Determines whether the specified URL is absolute
  1134. *
  1135. * @param {string} url The URL to test
  1136. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1137. */
  1138. module.exports = function isAbsoluteURL(url) {
  1139. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1140. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1141. // by any combination of letters, digits, plus, period, or hyphen.
  1142. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1143. };
  1144. /***/ }),
  1145. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1146. /*!***********************************************************!*\
  1147. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1148. \***********************************************************/
  1149. /*! no static exports found */
  1150. /***/ (function(module, exports, __webpack_require__) {
  1151. "use strict";
  1152. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1153. module.exports = (
  1154. utils.isStandardBrowserEnv() ?
  1155. // Standard browser envs have full support of the APIs needed to test
  1156. // whether the request URL is of the same origin as current location.
  1157. (function standardBrowserEnv() {
  1158. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1159. var urlParsingNode = document.createElement('a');
  1160. var originURL;
  1161. /**
  1162. * Parse a URL to discover it's components
  1163. *
  1164. * @param {String} url The URL to be parsed
  1165. * @returns {Object}
  1166. */
  1167. function resolveURL(url) {
  1168. var href = url;
  1169. if (msie) {
  1170. // IE needs attribute set twice to normalize properties
  1171. urlParsingNode.setAttribute('href', href);
  1172. href = urlParsingNode.href;
  1173. }
  1174. urlParsingNode.setAttribute('href', href);
  1175. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1176. return {
  1177. href: urlParsingNode.href,
  1178. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1179. host: urlParsingNode.host,
  1180. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1181. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1182. hostname: urlParsingNode.hostname,
  1183. port: urlParsingNode.port,
  1184. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1185. urlParsingNode.pathname :
  1186. '/' + urlParsingNode.pathname
  1187. };
  1188. }
  1189. originURL = resolveURL(window.location.href);
  1190. /**
  1191. * Determine if a URL shares the same origin as the current location
  1192. *
  1193. * @param {String} requestURL The URL to test
  1194. * @returns {boolean} True if URL shares the same origin, otherwise false
  1195. */
  1196. return function isURLSameOrigin(requestURL) {
  1197. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1198. return (parsed.protocol === originURL.protocol &&
  1199. parsed.host === originURL.host);
  1200. };
  1201. })() :
  1202. // Non standard browser envs (web workers, react-native) lack needed support.
  1203. (function nonStandardBrowserEnv() {
  1204. return function isURLSameOrigin() {
  1205. return true;
  1206. };
  1207. })()
  1208. );
  1209. /***/ }),
  1210. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1211. /*!***************************************************************!*\
  1212. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1213. \***************************************************************/
  1214. /*! no static exports found */
  1215. /***/ (function(module, exports, __webpack_require__) {
  1216. "use strict";
  1217. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1218. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1219. utils.forEach(headers, function processHeader(value, name) {
  1220. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1221. headers[normalizedName] = value;
  1222. delete headers[name];
  1223. }
  1224. });
  1225. };
  1226. /***/ }),
  1227. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1228. /*!********************************************************!*\
  1229. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1230. \********************************************************/
  1231. /*! no static exports found */
  1232. /***/ (function(module, exports, __webpack_require__) {
  1233. "use strict";
  1234. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1235. // Headers whose duplicates are ignored by node
  1236. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1237. var ignoreDuplicateOf = [
  1238. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1239. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1240. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1241. 'referer', 'retry-after', 'user-agent'
  1242. ];
  1243. /**
  1244. * Parse headers into an object
  1245. *
  1246. * ```
  1247. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1248. * Content-Type: application/json
  1249. * Connection: keep-alive
  1250. * Transfer-Encoding: chunked
  1251. * ```
  1252. *
  1253. * @param {String} headers Headers needing to be parsed
  1254. * @returns {Object} Headers parsed into an object
  1255. */
  1256. module.exports = function parseHeaders(headers) {
  1257. var parsed = {};
  1258. var key;
  1259. var val;
  1260. var i;
  1261. if (!headers) { return parsed; }
  1262. utils.forEach(headers.split('\n'), function parser(line) {
  1263. i = line.indexOf(':');
  1264. key = utils.trim(line.substr(0, i)).toLowerCase();
  1265. val = utils.trim(line.substr(i + 1));
  1266. if (key) {
  1267. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1268. return;
  1269. }
  1270. if (key === 'set-cookie') {
  1271. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1272. } else {
  1273. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1274. }
  1275. }
  1276. });
  1277. return parsed;
  1278. };
  1279. /***/ }),
  1280. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1281. /*!**************************************************!*\
  1282. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1283. \**************************************************/
  1284. /*! no static exports found */
  1285. /***/ (function(module, exports, __webpack_require__) {
  1286. "use strict";
  1287. /**
  1288. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1289. *
  1290. * Common use case would be to use `Function.prototype.apply`.
  1291. *
  1292. * ```js
  1293. * function f(x, y, z) {}
  1294. * var args = [1, 2, 3];
  1295. * f.apply(null, args);
  1296. * ```
  1297. *
  1298. * With `spread` this example can be re-written.
  1299. *
  1300. * ```js
  1301. * spread(function(x, y, z) {})([1, 2, 3]);
  1302. * ```
  1303. *
  1304. * @param {Function} callback
  1305. * @returns {Function}
  1306. */
  1307. module.exports = function spread(callback) {
  1308. return function wrap(arr) {
  1309. return callback.apply(null, arr);
  1310. };
  1311. };
  1312. /***/ }),
  1313. /***/ "./node_modules/axios/lib/utils.js":
  1314. /*!*****************************************!*\
  1315. !*** ./node_modules/axios/lib/utils.js ***!
  1316. \*****************************************/
  1317. /*! no static exports found */
  1318. /***/ (function(module, exports, __webpack_require__) {
  1319. "use strict";
  1320. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1321. /*global toString:true*/
  1322. // utils is a library of generic helper functions non-specific to axios
  1323. var toString = Object.prototype.toString;
  1324. /**
  1325. * Determine if a value is an Array
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is an Array, otherwise false
  1329. */
  1330. function isArray(val) {
  1331. return toString.call(val) === '[object Array]';
  1332. }
  1333. /**
  1334. * Determine if a value is undefined
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if the value is undefined, otherwise false
  1338. */
  1339. function isUndefined(val) {
  1340. return typeof val === 'undefined';
  1341. }
  1342. /**
  1343. * Determine if a value is a Buffer
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is a Buffer, otherwise false
  1347. */
  1348. function isBuffer(val) {
  1349. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1350. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1351. }
  1352. /**
  1353. * Determine if a value is an ArrayBuffer
  1354. *
  1355. * @param {Object} val The value to test
  1356. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1357. */
  1358. function isArrayBuffer(val) {
  1359. return toString.call(val) === '[object ArrayBuffer]';
  1360. }
  1361. /**
  1362. * Determine if a value is a FormData
  1363. *
  1364. * @param {Object} val The value to test
  1365. * @returns {boolean} True if value is an FormData, otherwise false
  1366. */
  1367. function isFormData(val) {
  1368. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1369. }
  1370. /**
  1371. * Determine if a value is a view on an ArrayBuffer
  1372. *
  1373. * @param {Object} val The value to test
  1374. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1375. */
  1376. function isArrayBufferView(val) {
  1377. var result;
  1378. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1379. result = ArrayBuffer.isView(val);
  1380. } else {
  1381. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1382. }
  1383. return result;
  1384. }
  1385. /**
  1386. * Determine if a value is a String
  1387. *
  1388. * @param {Object} val The value to test
  1389. * @returns {boolean} True if value is a String, otherwise false
  1390. */
  1391. function isString(val) {
  1392. return typeof val === 'string';
  1393. }
  1394. /**
  1395. * Determine if a value is a Number
  1396. *
  1397. * @param {Object} val The value to test
  1398. * @returns {boolean} True if value is a Number, otherwise false
  1399. */
  1400. function isNumber(val) {
  1401. return typeof val === 'number';
  1402. }
  1403. /**
  1404. * Determine if a value is an Object
  1405. *
  1406. * @param {Object} val The value to test
  1407. * @returns {boolean} True if value is an Object, otherwise false
  1408. */
  1409. function isObject(val) {
  1410. return val !== null && typeof val === 'object';
  1411. }
  1412. /**
  1413. * Determine if a value is a Date
  1414. *
  1415. * @param {Object} val The value to test
  1416. * @returns {boolean} True if value is a Date, otherwise false
  1417. */
  1418. function isDate(val) {
  1419. return toString.call(val) === '[object Date]';
  1420. }
  1421. /**
  1422. * Determine if a value is a File
  1423. *
  1424. * @param {Object} val The value to test
  1425. * @returns {boolean} True if value is a File, otherwise false
  1426. */
  1427. function isFile(val) {
  1428. return toString.call(val) === '[object File]';
  1429. }
  1430. /**
  1431. * Determine if a value is a Blob
  1432. *
  1433. * @param {Object} val The value to test
  1434. * @returns {boolean} True if value is a Blob, otherwise false
  1435. */
  1436. function isBlob(val) {
  1437. return toString.call(val) === '[object Blob]';
  1438. }
  1439. /**
  1440. * Determine if a value is a Function
  1441. *
  1442. * @param {Object} val The value to test
  1443. * @returns {boolean} True if value is a Function, otherwise false
  1444. */
  1445. function isFunction(val) {
  1446. return toString.call(val) === '[object Function]';
  1447. }
  1448. /**
  1449. * Determine if a value is a Stream
  1450. *
  1451. * @param {Object} val The value to test
  1452. * @returns {boolean} True if value is a Stream, otherwise false
  1453. */
  1454. function isStream(val) {
  1455. return isObject(val) && isFunction(val.pipe);
  1456. }
  1457. /**
  1458. * Determine if a value is a URLSearchParams object
  1459. *
  1460. * @param {Object} val The value to test
  1461. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1462. */
  1463. function isURLSearchParams(val) {
  1464. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1465. }
  1466. /**
  1467. * Trim excess whitespace off the beginning and end of a string
  1468. *
  1469. * @param {String} str The String to trim
  1470. * @returns {String} The String freed of excess whitespace
  1471. */
  1472. function trim(str) {
  1473. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1474. }
  1475. /**
  1476. * Determine if we're running in a standard browser environment
  1477. *
  1478. * This allows axios to run in a web worker, and react-native.
  1479. * Both environments support XMLHttpRequest, but not fully standard globals.
  1480. *
  1481. * web workers:
  1482. * typeof window -> undefined
  1483. * typeof document -> undefined
  1484. *
  1485. * react-native:
  1486. * navigator.product -> 'ReactNative'
  1487. * nativescript
  1488. * navigator.product -> 'NativeScript' or 'NS'
  1489. */
  1490. function isStandardBrowserEnv() {
  1491. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1492. navigator.product === 'NativeScript' ||
  1493. navigator.product === 'NS')) {
  1494. return false;
  1495. }
  1496. return (
  1497. typeof window !== 'undefined' &&
  1498. typeof document !== 'undefined'
  1499. );
  1500. }
  1501. /**
  1502. * Iterate over an Array or an Object invoking a function for each item.
  1503. *
  1504. * If `obj` is an Array callback will be called passing
  1505. * the value, index, and complete array for each item.
  1506. *
  1507. * If 'obj' is an Object callback will be called passing
  1508. * the value, key, and complete object for each property.
  1509. *
  1510. * @param {Object|Array} obj The object to iterate
  1511. * @param {Function} fn The callback to invoke for each item
  1512. */
  1513. function forEach(obj, fn) {
  1514. // Don't bother if no value provided
  1515. if (obj === null || typeof obj === 'undefined') {
  1516. return;
  1517. }
  1518. // Force an array if not already something iterable
  1519. if (typeof obj !== 'object') {
  1520. /*eslint no-param-reassign:0*/
  1521. obj = [obj];
  1522. }
  1523. if (isArray(obj)) {
  1524. // Iterate over array values
  1525. for (var i = 0, l = obj.length; i < l; i++) {
  1526. fn.call(null, obj[i], i, obj);
  1527. }
  1528. } else {
  1529. // Iterate over object keys
  1530. for (var key in obj) {
  1531. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1532. fn.call(null, obj[key], key, obj);
  1533. }
  1534. }
  1535. }
  1536. }
  1537. /**
  1538. * Accepts varargs expecting each argument to be an object, then
  1539. * immutably merges the properties of each object and returns result.
  1540. *
  1541. * When multiple objects contain the same key the later object in
  1542. * the arguments list will take precedence.
  1543. *
  1544. * Example:
  1545. *
  1546. * ```js
  1547. * var result = merge({foo: 123}, {foo: 456});
  1548. * console.log(result.foo); // outputs 456
  1549. * ```
  1550. *
  1551. * @param {Object} obj1 Object to merge
  1552. * @returns {Object} Result of all merge properties
  1553. */
  1554. function merge(/* obj1, obj2, obj3, ... */) {
  1555. var result = {};
  1556. function assignValue(val, key) {
  1557. if (typeof result[key] === 'object' && typeof val === 'object') {
  1558. result[key] = merge(result[key], val);
  1559. } else {
  1560. result[key] = val;
  1561. }
  1562. }
  1563. for (var i = 0, l = arguments.length; i < l; i++) {
  1564. forEach(arguments[i], assignValue);
  1565. }
  1566. return result;
  1567. }
  1568. /**
  1569. * Function equal to merge with the difference being that no reference
  1570. * to original objects is kept.
  1571. *
  1572. * @see merge
  1573. * @param {Object} obj1 Object to merge
  1574. * @returns {Object} Result of all merge properties
  1575. */
  1576. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1577. var result = {};
  1578. function assignValue(val, key) {
  1579. if (typeof result[key] === 'object' && typeof val === 'object') {
  1580. result[key] = deepMerge(result[key], val);
  1581. } else if (typeof val === 'object') {
  1582. result[key] = deepMerge({}, val);
  1583. } else {
  1584. result[key] = val;
  1585. }
  1586. }
  1587. for (var i = 0, l = arguments.length; i < l; i++) {
  1588. forEach(arguments[i], assignValue);
  1589. }
  1590. return result;
  1591. }
  1592. /**
  1593. * Extends object a by mutably adding to it the properties of object b.
  1594. *
  1595. * @param {Object} a The object to be extended
  1596. * @param {Object} b The object to copy properties from
  1597. * @param {Object} thisArg The object to bind function to
  1598. * @return {Object} The resulting value of object a
  1599. */
  1600. function extend(a, b, thisArg) {
  1601. forEach(b, function assignValue(val, key) {
  1602. if (thisArg && typeof val === 'function') {
  1603. a[key] = bind(val, thisArg);
  1604. } else {
  1605. a[key] = val;
  1606. }
  1607. });
  1608. return a;
  1609. }
  1610. module.exports = {
  1611. isArray: isArray,
  1612. isArrayBuffer: isArrayBuffer,
  1613. isBuffer: isBuffer,
  1614. isFormData: isFormData,
  1615. isArrayBufferView: isArrayBufferView,
  1616. isString: isString,
  1617. isNumber: isNumber,
  1618. isObject: isObject,
  1619. isUndefined: isUndefined,
  1620. isDate: isDate,
  1621. isFile: isFile,
  1622. isBlob: isBlob,
  1623. isFunction: isFunction,
  1624. isStream: isStream,
  1625. isURLSearchParams: isURLSearchParams,
  1626. isStandardBrowserEnv: isStandardBrowserEnv,
  1627. forEach: forEach,
  1628. merge: merge,
  1629. deepMerge: deepMerge,
  1630. extend: extend,
  1631. trim: trim
  1632. };
  1633. /***/ }),
  1634. /***/ "./node_modules/backo2/index.js":
  1635. /*!**************************************!*\
  1636. !*** ./node_modules/backo2/index.js ***!
  1637. \**************************************/
  1638. /*! no static exports found */
  1639. /***/ (function(module, exports) {
  1640. /**
  1641. * Expose `Backoff`.
  1642. */
  1643. module.exports = Backoff;
  1644. /**
  1645. * Initialize backoff timer with `opts`.
  1646. *
  1647. * - `min` initial timeout in milliseconds [100]
  1648. * - `max` max timeout [10000]
  1649. * - `jitter` [0]
  1650. * - `factor` [2]
  1651. *
  1652. * @param {Object} opts
  1653. * @api public
  1654. */
  1655. function Backoff(opts) {
  1656. opts = opts || {};
  1657. this.ms = opts.min || 100;
  1658. this.max = opts.max || 10000;
  1659. this.factor = opts.factor || 2;
  1660. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  1661. this.attempts = 0;
  1662. }
  1663. /**
  1664. * Return the backoff duration.
  1665. *
  1666. * @return {Number}
  1667. * @api public
  1668. */
  1669. Backoff.prototype.duration = function(){
  1670. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  1671. if (this.jitter) {
  1672. var rand = Math.random();
  1673. var deviation = Math.floor(rand * this.jitter * ms);
  1674. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  1675. }
  1676. return Math.min(ms, this.max) | 0;
  1677. };
  1678. /**
  1679. * Reset the number of attempts.
  1680. *
  1681. * @api public
  1682. */
  1683. Backoff.prototype.reset = function(){
  1684. this.attempts = 0;
  1685. };
  1686. /**
  1687. * Set the minimum duration
  1688. *
  1689. * @api public
  1690. */
  1691. Backoff.prototype.setMin = function(min){
  1692. this.ms = min;
  1693. };
  1694. /**
  1695. * Set the maximum duration
  1696. *
  1697. * @api public
  1698. */
  1699. Backoff.prototype.setMax = function(max){
  1700. this.max = max;
  1701. };
  1702. /**
  1703. * Set the jitter
  1704. *
  1705. * @api public
  1706. */
  1707. Backoff.prototype.setJitter = function(jitter){
  1708. this.jitter = jitter;
  1709. };
  1710. /***/ }),
  1711. /***/ "./node_modules/base64-arraybuffer/lib/base64-arraybuffer.js":
  1712. /*!*******************************************************************!*\
  1713. !*** ./node_modules/base64-arraybuffer/lib/base64-arraybuffer.js ***!
  1714. \*******************************************************************/
  1715. /*! no static exports found */
  1716. /***/ (function(module, exports) {
  1717. /*
  1718. * base64-arraybuffer
  1719. * https://github.com/niklasvh/base64-arraybuffer
  1720. *
  1721. * Copyright (c) 2012 Niklas von Hertzen
  1722. * Licensed under the MIT license.
  1723. */
  1724. (function(){
  1725. "use strict";
  1726. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  1727. // Use a lookup table to find the index.
  1728. var lookup = new Uint8Array(256);
  1729. for (var i = 0; i < chars.length; i++) {
  1730. lookup[chars.charCodeAt(i)] = i;
  1731. }
  1732. exports.encode = function(arraybuffer) {
  1733. var bytes = new Uint8Array(arraybuffer),
  1734. i, len = bytes.length, base64 = "";
  1735. for (i = 0; i < len; i+=3) {
  1736. base64 += chars[bytes[i] >> 2];
  1737. base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
  1738. base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
  1739. base64 += chars[bytes[i + 2] & 63];
  1740. }
  1741. if ((len % 3) === 2) {
  1742. base64 = base64.substring(0, base64.length - 1) + "=";
  1743. } else if (len % 3 === 1) {
  1744. base64 = base64.substring(0, base64.length - 2) + "==";
  1745. }
  1746. return base64;
  1747. };
  1748. exports.decode = function(base64) {
  1749. var bufferLength = base64.length * 0.75,
  1750. len = base64.length, i, p = 0,
  1751. encoded1, encoded2, encoded3, encoded4;
  1752. if (base64[base64.length - 1] === "=") {
  1753. bufferLength--;
  1754. if (base64[base64.length - 2] === "=") {
  1755. bufferLength--;
  1756. }
  1757. }
  1758. var arraybuffer = new ArrayBuffer(bufferLength),
  1759. bytes = new Uint8Array(arraybuffer);
  1760. for (i = 0; i < len; i+=4) {
  1761. encoded1 = lookup[base64.charCodeAt(i)];
  1762. encoded2 = lookup[base64.charCodeAt(i+1)];
  1763. encoded3 = lookup[base64.charCodeAt(i+2)];
  1764. encoded4 = lookup[base64.charCodeAt(i+3)];
  1765. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  1766. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  1767. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  1768. }
  1769. return arraybuffer;
  1770. };
  1771. })();
  1772. /***/ }),
  1773. /***/ "./node_modules/base64-js/index.js":
  1774. /*!*****************************************!*\
  1775. !*** ./node_modules/base64-js/index.js ***!
  1776. \*****************************************/
  1777. /*! no static exports found */
  1778. /***/ (function(module, exports, __webpack_require__) {
  1779. "use strict";
  1780. exports.byteLength = byteLength
  1781. exports.toByteArray = toByteArray
  1782. exports.fromByteArray = fromByteArray
  1783. var lookup = []
  1784. var revLookup = []
  1785. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1786. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1787. for (var i = 0, len = code.length; i < len; ++i) {
  1788. lookup[i] = code[i]
  1789. revLookup[code.charCodeAt(i)] = i
  1790. }
  1791. // Support decoding URL-safe base64 strings, as Node.js does.
  1792. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1793. revLookup['-'.charCodeAt(0)] = 62
  1794. revLookup['_'.charCodeAt(0)] = 63
  1795. function getLens (b64) {
  1796. var len = b64.length
  1797. if (len % 4 > 0) {
  1798. throw new Error('Invalid string. Length must be a multiple of 4')
  1799. }
  1800. // Trim off extra bytes after placeholder bytes are found
  1801. // See: https://github.com/beatgammit/base64-js/issues/42
  1802. var validLen = b64.indexOf('=')
  1803. if (validLen === -1) validLen = len
  1804. var placeHoldersLen = validLen === len
  1805. ? 0
  1806. : 4 - (validLen % 4)
  1807. return [validLen, placeHoldersLen]
  1808. }
  1809. // base64 is 4/3 + up to two characters of the original data
  1810. function byteLength (b64) {
  1811. var lens = getLens(b64)
  1812. var validLen = lens[0]
  1813. var placeHoldersLen = lens[1]
  1814. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1815. }
  1816. function _byteLength (b64, validLen, placeHoldersLen) {
  1817. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1818. }
  1819. function toByteArray (b64) {
  1820. var tmp
  1821. var lens = getLens(b64)
  1822. var validLen = lens[0]
  1823. var placeHoldersLen = lens[1]
  1824. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1825. var curByte = 0
  1826. // if there are placeholders, only get up to the last complete 4 chars
  1827. var len = placeHoldersLen > 0
  1828. ? validLen - 4
  1829. : validLen
  1830. var i
  1831. for (i = 0; i < len; i += 4) {
  1832. tmp =
  1833. (revLookup[b64.charCodeAt(i)] << 18) |
  1834. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1835. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1836. revLookup[b64.charCodeAt(i + 3)]
  1837. arr[curByte++] = (tmp >> 16) & 0xFF
  1838. arr[curByte++] = (tmp >> 8) & 0xFF
  1839. arr[curByte++] = tmp & 0xFF
  1840. }
  1841. if (placeHoldersLen === 2) {
  1842. tmp =
  1843. (revLookup[b64.charCodeAt(i)] << 2) |
  1844. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1845. arr[curByte++] = tmp & 0xFF
  1846. }
  1847. if (placeHoldersLen === 1) {
  1848. tmp =
  1849. (revLookup[b64.charCodeAt(i)] << 10) |
  1850. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1851. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1852. arr[curByte++] = (tmp >> 8) & 0xFF
  1853. arr[curByte++] = tmp & 0xFF
  1854. }
  1855. return arr
  1856. }
  1857. function tripletToBase64 (num) {
  1858. return lookup[num >> 18 & 0x3F] +
  1859. lookup[num >> 12 & 0x3F] +
  1860. lookup[num >> 6 & 0x3F] +
  1861. lookup[num & 0x3F]
  1862. }
  1863. function encodeChunk (uint8, start, end) {
  1864. var tmp
  1865. var output = []
  1866. for (var i = start; i < end; i += 3) {
  1867. tmp =
  1868. ((uint8[i] << 16) & 0xFF0000) +
  1869. ((uint8[i + 1] << 8) & 0xFF00) +
  1870. (uint8[i + 2] & 0xFF)
  1871. output.push(tripletToBase64(tmp))
  1872. }
  1873. return output.join('')
  1874. }
  1875. function fromByteArray (uint8) {
  1876. var tmp
  1877. var len = uint8.length
  1878. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1879. var parts = []
  1880. var maxChunkLength = 16383 // must be multiple of 3
  1881. // go through the array every three bytes, we'll deal with trailing stuff later
  1882. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1883. parts.push(encodeChunk(
  1884. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1885. ))
  1886. }
  1887. // pad the end with zeros, but make sure to not forget the extra bytes
  1888. if (extraBytes === 1) {
  1889. tmp = uint8[len - 1]
  1890. parts.push(
  1891. lookup[tmp >> 2] +
  1892. lookup[(tmp << 4) & 0x3F] +
  1893. '=='
  1894. )
  1895. } else if (extraBytes === 2) {
  1896. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1897. parts.push(
  1898. lookup[tmp >> 10] +
  1899. lookup[(tmp >> 4) & 0x3F] +
  1900. lookup[(tmp << 2) & 0x3F] +
  1901. '='
  1902. )
  1903. }
  1904. return parts.join('')
  1905. }
  1906. /***/ }),
  1907. /***/ "./node_modules/blob/index.js":
  1908. /*!************************************!*\
  1909. !*** ./node_modules/blob/index.js ***!
  1910. \************************************/
  1911. /*! no static exports found */
  1912. /***/ (function(module, exports) {
  1913. /**
  1914. * Create a blob builder even when vendor prefixes exist
  1915. */
  1916. var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
  1917. typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
  1918. typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
  1919. typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
  1920. false;
  1921. /**
  1922. * Check if Blob constructor is supported
  1923. */
  1924. var blobSupported = (function() {
  1925. try {
  1926. var a = new Blob(['hi']);
  1927. return a.size === 2;
  1928. } catch(e) {
  1929. return false;
  1930. }
  1931. })();
  1932. /**
  1933. * Check if Blob constructor supports ArrayBufferViews
  1934. * Fails in Safari 6, so we need to map to ArrayBuffers there.
  1935. */
  1936. var blobSupportsArrayBufferView = blobSupported && (function() {
  1937. try {
  1938. var b = new Blob([new Uint8Array([1,2])]);
  1939. return b.size === 2;
  1940. } catch(e) {
  1941. return false;
  1942. }
  1943. })();
  1944. /**
  1945. * Check if BlobBuilder is supported
  1946. */
  1947. var blobBuilderSupported = BlobBuilder
  1948. && BlobBuilder.prototype.append
  1949. && BlobBuilder.prototype.getBlob;
  1950. /**
  1951. * Helper function that maps ArrayBufferViews to ArrayBuffers
  1952. * Used by BlobBuilder constructor and old browsers that didn't
  1953. * support it in the Blob constructor.
  1954. */
  1955. function mapArrayBufferViews(ary) {
  1956. return ary.map(function(chunk) {
  1957. if (chunk.buffer instanceof ArrayBuffer) {
  1958. var buf = chunk.buffer;
  1959. // if this is a subarray, make a copy so we only
  1960. // include the subarray region from the underlying buffer
  1961. if (chunk.byteLength !== buf.byteLength) {
  1962. var copy = new Uint8Array(chunk.byteLength);
  1963. copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
  1964. buf = copy.buffer;
  1965. }
  1966. return buf;
  1967. }
  1968. return chunk;
  1969. });
  1970. }
  1971. function BlobBuilderConstructor(ary, options) {
  1972. options = options || {};
  1973. var bb = new BlobBuilder();
  1974. mapArrayBufferViews(ary).forEach(function(part) {
  1975. bb.append(part);
  1976. });
  1977. return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
  1978. };
  1979. function BlobConstructor(ary, options) {
  1980. return new Blob(mapArrayBufferViews(ary), options || {});
  1981. };
  1982. if (typeof Blob !== 'undefined') {
  1983. BlobBuilderConstructor.prototype = Blob.prototype;
  1984. BlobConstructor.prototype = Blob.prototype;
  1985. }
  1986. module.exports = (function() {
  1987. if (blobSupported) {
  1988. return blobSupportsArrayBufferView ? Blob : BlobConstructor;
  1989. } else if (blobBuilderSupported) {
  1990. return BlobBuilderConstructor;
  1991. } else {
  1992. return undefined;
  1993. }
  1994. })();
  1995. /***/ }),
  1996. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1997. /*!*****************************************************!*\
  1998. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1999. \*****************************************************/
  2000. /*! no static exports found */
  2001. /***/ (function(module, exports, __webpack_require__) {
  2002. /*!
  2003. * Bootstrap v4.5.0 (https://getbootstrap.com/)
  2004. * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  2005. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2006. */
  2007. (function (global, factory) {
  2008. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  2009. undefined;
  2010. }(this, (function (exports, $, Popper) { 'use strict';
  2011. $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
  2012. Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
  2013. function _defineProperties(target, props) {
  2014. for (var i = 0; i < props.length; i++) {
  2015. var descriptor = props[i];
  2016. descriptor.enumerable = descriptor.enumerable || false;
  2017. descriptor.configurable = true;
  2018. if ("value" in descriptor) descriptor.writable = true;
  2019. Object.defineProperty(target, descriptor.key, descriptor);
  2020. }
  2021. }
  2022. function _createClass(Constructor, protoProps, staticProps) {
  2023. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  2024. if (staticProps) _defineProperties(Constructor, staticProps);
  2025. return Constructor;
  2026. }
  2027. function _defineProperty(obj, key, value) {
  2028. if (key in obj) {
  2029. Object.defineProperty(obj, key, {
  2030. value: value,
  2031. enumerable: true,
  2032. configurable: true,
  2033. writable: true
  2034. });
  2035. } else {
  2036. obj[key] = value;
  2037. }
  2038. return obj;
  2039. }
  2040. function ownKeys(object, enumerableOnly) {
  2041. var keys = Object.keys(object);
  2042. if (Object.getOwnPropertySymbols) {
  2043. var symbols = Object.getOwnPropertySymbols(object);
  2044. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  2045. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  2046. });
  2047. keys.push.apply(keys, symbols);
  2048. }
  2049. return keys;
  2050. }
  2051. function _objectSpread2(target) {
  2052. for (var i = 1; i < arguments.length; i++) {
  2053. var source = arguments[i] != null ? arguments[i] : {};
  2054. if (i % 2) {
  2055. ownKeys(Object(source), true).forEach(function (key) {
  2056. _defineProperty(target, key, source[key]);
  2057. });
  2058. } else if (Object.getOwnPropertyDescriptors) {
  2059. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  2060. } else {
  2061. ownKeys(Object(source)).forEach(function (key) {
  2062. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  2063. });
  2064. }
  2065. }
  2066. return target;
  2067. }
  2068. function _inheritsLoose(subClass, superClass) {
  2069. subClass.prototype = Object.create(superClass.prototype);
  2070. subClass.prototype.constructor = subClass;
  2071. subClass.__proto__ = superClass;
  2072. }
  2073. /**
  2074. * --------------------------------------------------------------------------
  2075. * Bootstrap (v4.5.0): util.js
  2076. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  2077. * --------------------------------------------------------------------------
  2078. */
  2079. /**
  2080. * ------------------------------------------------------------------------
  2081. * Private TransitionEnd Helpers
  2082. * ------------------------------------------------------------------------
  2083. */
  2084. var TRANSITION_END = 'transitionend';
  2085. var MAX_UID = 1000000;
  2086. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  2087. function toType(obj) {
  2088. if (obj === null || typeof obj === 'undefined') {
  2089. return "" + obj;
  2090. }
  2091. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  2092. }
  2093. function getSpecialTransitionEndEvent() {
  2094. return {
  2095. bindType: TRANSITION_END,
  2096. delegateType: TRANSITION_END,
  2097. handle: function handle(event) {
  2098. if ($(event.target).is(this)) {
  2099. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  2100. }
  2101. return undefined;
  2102. }
  2103. };
  2104. }
  2105. function transitionEndEmulator(duration) {
  2106. var _this = this;
  2107. var called = false;
  2108. $(this).one(Util.TRANSITION_END, function () {
  2109. called = true;
  2110. });
  2111. setTimeout(function () {
  2112. if (!called) {
  2113. Util.triggerTransitionEnd(_this);
  2114. }
  2115. }, duration);
  2116. return this;
  2117. }
  2118. function setTransitionEndSupport() {
  2119. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2120. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2121. }
  2122. /**
  2123. * --------------------------------------------------------------------------
  2124. * Public Util Api
  2125. * --------------------------------------------------------------------------
  2126. */
  2127. var Util = {
  2128. TRANSITION_END: 'bsTransitionEnd',
  2129. getUID: function getUID(prefix) {
  2130. do {
  2131. // eslint-disable-next-line no-bitwise
  2132. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2133. } while (document.getElementById(prefix));
  2134. return prefix;
  2135. },
  2136. getSelectorFromElement: function getSelectorFromElement(element) {
  2137. var selector = element.getAttribute('data-target');
  2138. if (!selector || selector === '#') {
  2139. var hrefAttr = element.getAttribute('href');
  2140. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2141. }
  2142. try {
  2143. return document.querySelector(selector) ? selector : null;
  2144. } catch (err) {
  2145. return null;
  2146. }
  2147. },
  2148. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2149. if (!element) {
  2150. return 0;
  2151. } // Get transition-duration of the element
  2152. var transitionDuration = $(element).css('transition-duration');
  2153. var transitionDelay = $(element).css('transition-delay');
  2154. var floatTransitionDuration = parseFloat(transitionDuration);
  2155. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2156. if (!floatTransitionDuration && !floatTransitionDelay) {
  2157. return 0;
  2158. } // If multiple durations are defined, take the first
  2159. transitionDuration = transitionDuration.split(',')[0];
  2160. transitionDelay = transitionDelay.split(',')[0];
  2161. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2162. },
  2163. reflow: function reflow(element) {
  2164. return element.offsetHeight;
  2165. },
  2166. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2167. $(element).trigger(TRANSITION_END);
  2168. },
  2169. // TODO: Remove in v5
  2170. supportsTransitionEnd: function supportsTransitionEnd() {
  2171. return Boolean(TRANSITION_END);
  2172. },
  2173. isElement: function isElement(obj) {
  2174. return (obj[0] || obj).nodeType;
  2175. },
  2176. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2177. for (var property in configTypes) {
  2178. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2179. var expectedTypes = configTypes[property];
  2180. var value = config[property];
  2181. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2182. if (!new RegExp(expectedTypes).test(valueType)) {
  2183. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2184. }
  2185. }
  2186. }
  2187. },
  2188. findShadowRoot: function findShadowRoot(element) {
  2189. if (!document.documentElement.attachShadow) {
  2190. return null;
  2191. } // Can find the shadow root otherwise it'll return the document
  2192. if (typeof element.getRootNode === 'function') {
  2193. var root = element.getRootNode();
  2194. return root instanceof ShadowRoot ? root : null;
  2195. }
  2196. if (element instanceof ShadowRoot) {
  2197. return element;
  2198. } // when we don't find a shadow root
  2199. if (!element.parentNode) {
  2200. return null;
  2201. }
  2202. return Util.findShadowRoot(element.parentNode);
  2203. },
  2204. jQueryDetection: function jQueryDetection() {
  2205. if (typeof $ === 'undefined') {
  2206. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2207. }
  2208. var version = $.fn.jquery.split(' ')[0].split('.');
  2209. var minMajor = 1;
  2210. var ltMajor = 2;
  2211. var minMinor = 9;
  2212. var minPatch = 1;
  2213. var maxMajor = 4;
  2214. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2215. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2216. }
  2217. }
  2218. };
  2219. Util.jQueryDetection();
  2220. setTransitionEndSupport();
  2221. /**
  2222. * ------------------------------------------------------------------------
  2223. * Constants
  2224. * ------------------------------------------------------------------------
  2225. */
  2226. var NAME = 'alert';
  2227. var VERSION = '4.5.0';
  2228. var DATA_KEY = 'bs.alert';
  2229. var EVENT_KEY = "." + DATA_KEY;
  2230. var DATA_API_KEY = '.data-api';
  2231. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2232. var SELECTOR_DISMISS = '[data-dismiss="alert"]';
  2233. var EVENT_CLOSE = "close" + EVENT_KEY;
  2234. var EVENT_CLOSED = "closed" + EVENT_KEY;
  2235. var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
  2236. var CLASS_NAME_ALERT = 'alert';
  2237. var CLASS_NAME_FADE = 'fade';
  2238. var CLASS_NAME_SHOW = 'show';
  2239. /**
  2240. * ------------------------------------------------------------------------
  2241. * Class Definition
  2242. * ------------------------------------------------------------------------
  2243. */
  2244. var Alert = /*#__PURE__*/function () {
  2245. function Alert(element) {
  2246. this._element = element;
  2247. } // Getters
  2248. var _proto = Alert.prototype;
  2249. // Public
  2250. _proto.close = function close(element) {
  2251. var rootElement = this._element;
  2252. if (element) {
  2253. rootElement = this._getRootElement(element);
  2254. }
  2255. var customEvent = this._triggerCloseEvent(rootElement);
  2256. if (customEvent.isDefaultPrevented()) {
  2257. return;
  2258. }
  2259. this._removeElement(rootElement);
  2260. };
  2261. _proto.dispose = function dispose() {
  2262. $.removeData(this._element, DATA_KEY);
  2263. this._element = null;
  2264. } // Private
  2265. ;
  2266. _proto._getRootElement = function _getRootElement(element) {
  2267. var selector = Util.getSelectorFromElement(element);
  2268. var parent = false;
  2269. if (selector) {
  2270. parent = document.querySelector(selector);
  2271. }
  2272. if (!parent) {
  2273. parent = $(element).closest("." + CLASS_NAME_ALERT)[0];
  2274. }
  2275. return parent;
  2276. };
  2277. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2278. var closeEvent = $.Event(EVENT_CLOSE);
  2279. $(element).trigger(closeEvent);
  2280. return closeEvent;
  2281. };
  2282. _proto._removeElement = function _removeElement(element) {
  2283. var _this = this;
  2284. $(element).removeClass(CLASS_NAME_SHOW);
  2285. if (!$(element).hasClass(CLASS_NAME_FADE)) {
  2286. this._destroyElement(element);
  2287. return;
  2288. }
  2289. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2290. $(element).one(Util.TRANSITION_END, function (event) {
  2291. return _this._destroyElement(element, event);
  2292. }).emulateTransitionEnd(transitionDuration);
  2293. };
  2294. _proto._destroyElement = function _destroyElement(element) {
  2295. $(element).detach().trigger(EVENT_CLOSED).remove();
  2296. } // Static
  2297. ;
  2298. Alert._jQueryInterface = function _jQueryInterface(config) {
  2299. return this.each(function () {
  2300. var $element = $(this);
  2301. var data = $element.data(DATA_KEY);
  2302. if (!data) {
  2303. data = new Alert(this);
  2304. $element.data(DATA_KEY, data);
  2305. }
  2306. if (config === 'close') {
  2307. data[config](this);
  2308. }
  2309. });
  2310. };
  2311. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2312. return function (event) {
  2313. if (event) {
  2314. event.preventDefault();
  2315. }
  2316. alertInstance.close(this);
  2317. };
  2318. };
  2319. _createClass(Alert, null, [{
  2320. key: "VERSION",
  2321. get: function get() {
  2322. return VERSION;
  2323. }
  2324. }]);
  2325. return Alert;
  2326. }();
  2327. /**
  2328. * ------------------------------------------------------------------------
  2329. * Data Api implementation
  2330. * ------------------------------------------------------------------------
  2331. */
  2332. $(document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert()));
  2333. /**
  2334. * ------------------------------------------------------------------------
  2335. * jQuery
  2336. * ------------------------------------------------------------------------
  2337. */
  2338. $.fn[NAME] = Alert._jQueryInterface;
  2339. $.fn[NAME].Constructor = Alert;
  2340. $.fn[NAME].noConflict = function () {
  2341. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2342. return Alert._jQueryInterface;
  2343. };
  2344. /**
  2345. * ------------------------------------------------------------------------
  2346. * Constants
  2347. * ------------------------------------------------------------------------
  2348. */
  2349. var NAME$1 = 'button';
  2350. var VERSION$1 = '4.5.0';
  2351. var DATA_KEY$1 = 'bs.button';
  2352. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2353. var DATA_API_KEY$1 = '.data-api';
  2354. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2355. var CLASS_NAME_ACTIVE = 'active';
  2356. var CLASS_NAME_BUTTON = 'btn';
  2357. var CLASS_NAME_FOCUS = 'focus';
  2358. var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]';
  2359. var SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]';
  2360. var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
  2361. var SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn';
  2362. var SELECTOR_INPUT = 'input:not([type="hidden"])';
  2363. var SELECTOR_ACTIVE = '.active';
  2364. var SELECTOR_BUTTON = '.btn';
  2365. var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1;
  2366. var EVENT_FOCUS_BLUR_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1);
  2367. var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$1 + DATA_API_KEY$1;
  2368. /**
  2369. * ------------------------------------------------------------------------
  2370. * Class Definition
  2371. * ------------------------------------------------------------------------
  2372. */
  2373. var Button = /*#__PURE__*/function () {
  2374. function Button(element) {
  2375. this._element = element;
  2376. } // Getters
  2377. var _proto = Button.prototype;
  2378. // Public
  2379. _proto.toggle = function toggle() {
  2380. var triggerChangeEvent = true;
  2381. var addAriaPressed = true;
  2382. var rootElement = $(this._element).closest(SELECTOR_DATA_TOGGLES)[0];
  2383. if (rootElement) {
  2384. var input = this._element.querySelector(SELECTOR_INPUT);
  2385. if (input) {
  2386. if (input.type === 'radio') {
  2387. if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) {
  2388. triggerChangeEvent = false;
  2389. } else {
  2390. var activeElement = rootElement.querySelector(SELECTOR_ACTIVE);
  2391. if (activeElement) {
  2392. $(activeElement).removeClass(CLASS_NAME_ACTIVE);
  2393. }
  2394. }
  2395. }
  2396. if (triggerChangeEvent) {
  2397. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2398. if (input.type === 'checkbox' || input.type === 'radio') {
  2399. input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE);
  2400. }
  2401. $(input).trigger('change');
  2402. }
  2403. input.focus();
  2404. addAriaPressed = false;
  2405. }
  2406. }
  2407. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2408. if (addAriaPressed) {
  2409. this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE));
  2410. }
  2411. if (triggerChangeEvent) {
  2412. $(this._element).toggleClass(CLASS_NAME_ACTIVE);
  2413. }
  2414. }
  2415. };
  2416. _proto.dispose = function dispose() {
  2417. $.removeData(this._element, DATA_KEY$1);
  2418. this._element = null;
  2419. } // Static
  2420. ;
  2421. Button._jQueryInterface = function _jQueryInterface(config) {
  2422. return this.each(function () {
  2423. var data = $(this).data(DATA_KEY$1);
  2424. if (!data) {
  2425. data = new Button(this);
  2426. $(this).data(DATA_KEY$1, data);
  2427. }
  2428. if (config === 'toggle') {
  2429. data[config]();
  2430. }
  2431. });
  2432. };
  2433. _createClass(Button, null, [{
  2434. key: "VERSION",
  2435. get: function get() {
  2436. return VERSION$1;
  2437. }
  2438. }]);
  2439. return Button;
  2440. }();
  2441. /**
  2442. * ------------------------------------------------------------------------
  2443. * Data Api implementation
  2444. * ------------------------------------------------------------------------
  2445. */
  2446. $(document).on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  2447. var button = event.target;
  2448. var initialButton = button;
  2449. if (!$(button).hasClass(CLASS_NAME_BUTTON)) {
  2450. button = $(button).closest(SELECTOR_BUTTON)[0];
  2451. }
  2452. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2453. event.preventDefault(); // work around Firefox bug #1540995
  2454. } else {
  2455. var inputBtn = button.querySelector(SELECTOR_INPUT);
  2456. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2457. event.preventDefault(); // work around Firefox bug #1540995
  2458. return;
  2459. }
  2460. if (initialButton.tagName === 'LABEL' && inputBtn && inputBtn.type === 'checkbox') {
  2461. event.preventDefault(); // work around event sent to label and input
  2462. }
  2463. Button._jQueryInterface.call($(button), 'toggle');
  2464. }
  2465. }).on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  2466. var button = $(event.target).closest(SELECTOR_BUTTON)[0];
  2467. $(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type));
  2468. });
  2469. $(window).on(EVENT_LOAD_DATA_API, function () {
  2470. // ensure correct active class is set to match the controls' actual values/states
  2471. // find all checkboxes/readio buttons inside data-toggle groups
  2472. var buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS));
  2473. for (var i = 0, len = buttons.length; i < len; i++) {
  2474. var button = buttons[i];
  2475. var input = button.querySelector(SELECTOR_INPUT);
  2476. if (input.checked || input.hasAttribute('checked')) {
  2477. button.classList.add(CLASS_NAME_ACTIVE);
  2478. } else {
  2479. button.classList.remove(CLASS_NAME_ACTIVE);
  2480. }
  2481. } // find all button toggles
  2482. buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE));
  2483. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2484. var _button = buttons[_i];
  2485. if (_button.getAttribute('aria-pressed') === 'true') {
  2486. _button.classList.add(CLASS_NAME_ACTIVE);
  2487. } else {
  2488. _button.classList.remove(CLASS_NAME_ACTIVE);
  2489. }
  2490. }
  2491. });
  2492. /**
  2493. * ------------------------------------------------------------------------
  2494. * jQuery
  2495. * ------------------------------------------------------------------------
  2496. */
  2497. $.fn[NAME$1] = Button._jQueryInterface;
  2498. $.fn[NAME$1].Constructor = Button;
  2499. $.fn[NAME$1].noConflict = function () {
  2500. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2501. return Button._jQueryInterface;
  2502. };
  2503. /**
  2504. * ------------------------------------------------------------------------
  2505. * Constants
  2506. * ------------------------------------------------------------------------
  2507. */
  2508. var NAME$2 = 'carousel';
  2509. var VERSION$2 = '4.5.0';
  2510. var DATA_KEY$2 = 'bs.carousel';
  2511. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2512. var DATA_API_KEY$2 = '.data-api';
  2513. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2514. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2515. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2516. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2517. var SWIPE_THRESHOLD = 40;
  2518. var Default = {
  2519. interval: 5000,
  2520. keyboard: true,
  2521. slide: false,
  2522. pause: 'hover',
  2523. wrap: true,
  2524. touch: true
  2525. };
  2526. var DefaultType = {
  2527. interval: '(number|boolean)',
  2528. keyboard: 'boolean',
  2529. slide: '(boolean|string)',
  2530. pause: '(string|boolean)',
  2531. wrap: 'boolean',
  2532. touch: 'boolean'
  2533. };
  2534. var DIRECTION_NEXT = 'next';
  2535. var DIRECTION_PREV = 'prev';
  2536. var DIRECTION_LEFT = 'left';
  2537. var DIRECTION_RIGHT = 'right';
  2538. var EVENT_SLIDE = "slide" + EVENT_KEY$2;
  2539. var EVENT_SLID = "slid" + EVENT_KEY$2;
  2540. var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2;
  2541. var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2;
  2542. var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2;
  2543. var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2;
  2544. var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2;
  2545. var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2;
  2546. var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2;
  2547. var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2;
  2548. var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2;
  2549. var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$2 + DATA_API_KEY$2;
  2550. var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2;
  2551. var CLASS_NAME_CAROUSEL = 'carousel';
  2552. var CLASS_NAME_ACTIVE$1 = 'active';
  2553. var CLASS_NAME_SLIDE = 'slide';
  2554. var CLASS_NAME_RIGHT = 'carousel-item-right';
  2555. var CLASS_NAME_LEFT = 'carousel-item-left';
  2556. var CLASS_NAME_NEXT = 'carousel-item-next';
  2557. var CLASS_NAME_PREV = 'carousel-item-prev';
  2558. var CLASS_NAME_POINTER_EVENT = 'pointer-event';
  2559. var SELECTOR_ACTIVE$1 = '.active';
  2560. var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  2561. var SELECTOR_ITEM = '.carousel-item';
  2562. var SELECTOR_ITEM_IMG = '.carousel-item img';
  2563. var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  2564. var SELECTOR_INDICATORS = '.carousel-indicators';
  2565. var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
  2566. var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
  2567. var PointerType = {
  2568. TOUCH: 'touch',
  2569. PEN: 'pen'
  2570. };
  2571. /**
  2572. * ------------------------------------------------------------------------
  2573. * Class Definition
  2574. * ------------------------------------------------------------------------
  2575. */
  2576. var Carousel = /*#__PURE__*/function () {
  2577. function Carousel(element, config) {
  2578. this._items = null;
  2579. this._interval = null;
  2580. this._activeElement = null;
  2581. this._isPaused = false;
  2582. this._isSliding = false;
  2583. this.touchTimeout = null;
  2584. this.touchStartX = 0;
  2585. this.touchDeltaX = 0;
  2586. this._config = this._getConfig(config);
  2587. this._element = element;
  2588. this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
  2589. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2590. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2591. this._addEventListeners();
  2592. } // Getters
  2593. var _proto = Carousel.prototype;
  2594. // Public
  2595. _proto.next = function next() {
  2596. if (!this._isSliding) {
  2597. this._slide(DIRECTION_NEXT);
  2598. }
  2599. };
  2600. _proto.nextWhenVisible = function nextWhenVisible() {
  2601. // Don't call next when the page isn't visible
  2602. // or the carousel or its parent isn't visible
  2603. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2604. this.next();
  2605. }
  2606. };
  2607. _proto.prev = function prev() {
  2608. if (!this._isSliding) {
  2609. this._slide(DIRECTION_PREV);
  2610. }
  2611. };
  2612. _proto.pause = function pause(event) {
  2613. if (!event) {
  2614. this._isPaused = true;
  2615. }
  2616. if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
  2617. Util.triggerTransitionEnd(this._element);
  2618. this.cycle(true);
  2619. }
  2620. clearInterval(this._interval);
  2621. this._interval = null;
  2622. };
  2623. _proto.cycle = function cycle(event) {
  2624. if (!event) {
  2625. this._isPaused = false;
  2626. }
  2627. if (this._interval) {
  2628. clearInterval(this._interval);
  2629. this._interval = null;
  2630. }
  2631. if (this._config.interval && !this._isPaused) {
  2632. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2633. }
  2634. };
  2635. _proto.to = function to(index) {
  2636. var _this = this;
  2637. this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  2638. var activeIndex = this._getItemIndex(this._activeElement);
  2639. if (index > this._items.length - 1 || index < 0) {
  2640. return;
  2641. }
  2642. if (this._isSliding) {
  2643. $(this._element).one(EVENT_SLID, function () {
  2644. return _this.to(index);
  2645. });
  2646. return;
  2647. }
  2648. if (activeIndex === index) {
  2649. this.pause();
  2650. this.cycle();
  2651. return;
  2652. }
  2653. var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
  2654. this._slide(direction, this._items[index]);
  2655. };
  2656. _proto.dispose = function dispose() {
  2657. $(this._element).off(EVENT_KEY$2);
  2658. $.removeData(this._element, DATA_KEY$2);
  2659. this._items = null;
  2660. this._config = null;
  2661. this._element = null;
  2662. this._interval = null;
  2663. this._isPaused = null;
  2664. this._isSliding = null;
  2665. this._activeElement = null;
  2666. this._indicatorsElement = null;
  2667. } // Private
  2668. ;
  2669. _proto._getConfig = function _getConfig(config) {
  2670. config = _objectSpread2(_objectSpread2({}, Default), config);
  2671. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2672. return config;
  2673. };
  2674. _proto._handleSwipe = function _handleSwipe() {
  2675. var absDeltax = Math.abs(this.touchDeltaX);
  2676. if (absDeltax <= SWIPE_THRESHOLD) {
  2677. return;
  2678. }
  2679. var direction = absDeltax / this.touchDeltaX;
  2680. this.touchDeltaX = 0; // swipe left
  2681. if (direction > 0) {
  2682. this.prev();
  2683. } // swipe right
  2684. if (direction < 0) {
  2685. this.next();
  2686. }
  2687. };
  2688. _proto._addEventListeners = function _addEventListeners() {
  2689. var _this2 = this;
  2690. if (this._config.keyboard) {
  2691. $(this._element).on(EVENT_KEYDOWN, function (event) {
  2692. return _this2._keydown(event);
  2693. });
  2694. }
  2695. if (this._config.pause === 'hover') {
  2696. $(this._element).on(EVENT_MOUSEENTER, function (event) {
  2697. return _this2.pause(event);
  2698. }).on(EVENT_MOUSELEAVE, function (event) {
  2699. return _this2.cycle(event);
  2700. });
  2701. }
  2702. if (this._config.touch) {
  2703. this._addTouchEventListeners();
  2704. }
  2705. };
  2706. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2707. var _this3 = this;
  2708. if (!this._touchSupported) {
  2709. return;
  2710. }
  2711. var start = function start(event) {
  2712. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2713. _this3.touchStartX = event.originalEvent.clientX;
  2714. } else if (!_this3._pointerEvent) {
  2715. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2716. }
  2717. };
  2718. var move = function move(event) {
  2719. // ensure swiping with one touch and not pinching
  2720. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2721. _this3.touchDeltaX = 0;
  2722. } else {
  2723. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2724. }
  2725. };
  2726. var end = function end(event) {
  2727. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2728. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2729. }
  2730. _this3._handleSwipe();
  2731. if (_this3._config.pause === 'hover') {
  2732. // If it's a touch-enabled device, mouseenter/leave are fired as
  2733. // part of the mouse compatibility events on first tap - the carousel
  2734. // would stop cycling until user tapped out of it;
  2735. // here, we listen for touchend, explicitly pause the carousel
  2736. // (as if it's the second time we tap on it, mouseenter compat event
  2737. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2738. // events to fire) we explicitly restart cycling
  2739. _this3.pause();
  2740. if (_this3.touchTimeout) {
  2741. clearTimeout(_this3.touchTimeout);
  2742. }
  2743. _this3.touchTimeout = setTimeout(function (event) {
  2744. return _this3.cycle(event);
  2745. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2746. }
  2747. };
  2748. $(this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
  2749. return e.preventDefault();
  2750. });
  2751. if (this._pointerEvent) {
  2752. $(this._element).on(EVENT_POINTERDOWN, function (event) {
  2753. return start(event);
  2754. });
  2755. $(this._element).on(EVENT_POINTERUP, function (event) {
  2756. return end(event);
  2757. });
  2758. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  2759. } else {
  2760. $(this._element).on(EVENT_TOUCHSTART, function (event) {
  2761. return start(event);
  2762. });
  2763. $(this._element).on(EVENT_TOUCHMOVE, function (event) {
  2764. return move(event);
  2765. });
  2766. $(this._element).on(EVENT_TOUCHEND, function (event) {
  2767. return end(event);
  2768. });
  2769. }
  2770. };
  2771. _proto._keydown = function _keydown(event) {
  2772. if (/input|textarea/i.test(event.target.tagName)) {
  2773. return;
  2774. }
  2775. switch (event.which) {
  2776. case ARROW_LEFT_KEYCODE:
  2777. event.preventDefault();
  2778. this.prev();
  2779. break;
  2780. case ARROW_RIGHT_KEYCODE:
  2781. event.preventDefault();
  2782. this.next();
  2783. break;
  2784. }
  2785. };
  2786. _proto._getItemIndex = function _getItemIndex(element) {
  2787. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
  2788. return this._items.indexOf(element);
  2789. };
  2790. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2791. var isNextDirection = direction === DIRECTION_NEXT;
  2792. var isPrevDirection = direction === DIRECTION_PREV;
  2793. var activeIndex = this._getItemIndex(activeElement);
  2794. var lastItemIndex = this._items.length - 1;
  2795. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2796. if (isGoingToWrap && !this._config.wrap) {
  2797. return activeElement;
  2798. }
  2799. var delta = direction === DIRECTION_PREV ? -1 : 1;
  2800. var itemIndex = (activeIndex + delta) % this._items.length;
  2801. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2802. };
  2803. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2804. var targetIndex = this._getItemIndex(relatedTarget);
  2805. var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
  2806. var slideEvent = $.Event(EVENT_SLIDE, {
  2807. relatedTarget: relatedTarget,
  2808. direction: eventDirectionName,
  2809. from: fromIndex,
  2810. to: targetIndex
  2811. });
  2812. $(this._element).trigger(slideEvent);
  2813. return slideEvent;
  2814. };
  2815. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2816. if (this._indicatorsElement) {
  2817. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE$1));
  2818. $(indicators).removeClass(CLASS_NAME_ACTIVE$1);
  2819. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2820. if (nextIndicator) {
  2821. $(nextIndicator).addClass(CLASS_NAME_ACTIVE$1);
  2822. }
  2823. }
  2824. };
  2825. _proto._slide = function _slide(direction, element) {
  2826. var _this4 = this;
  2827. var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  2828. var activeElementIndex = this._getItemIndex(activeElement);
  2829. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2830. var nextElementIndex = this._getItemIndex(nextElement);
  2831. var isCycling = Boolean(this._interval);
  2832. var directionalClassName;
  2833. var orderClassName;
  2834. var eventDirectionName;
  2835. if (direction === DIRECTION_NEXT) {
  2836. directionalClassName = CLASS_NAME_LEFT;
  2837. orderClassName = CLASS_NAME_NEXT;
  2838. eventDirectionName = DIRECTION_LEFT;
  2839. } else {
  2840. directionalClassName = CLASS_NAME_RIGHT;
  2841. orderClassName = CLASS_NAME_PREV;
  2842. eventDirectionName = DIRECTION_RIGHT;
  2843. }
  2844. if (nextElement && $(nextElement).hasClass(CLASS_NAME_ACTIVE$1)) {
  2845. this._isSliding = false;
  2846. return;
  2847. }
  2848. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2849. if (slideEvent.isDefaultPrevented()) {
  2850. return;
  2851. }
  2852. if (!activeElement || !nextElement) {
  2853. // Some weirdness is happening, so we bail
  2854. return;
  2855. }
  2856. this._isSliding = true;
  2857. if (isCycling) {
  2858. this.pause();
  2859. }
  2860. this._setActiveIndicatorElement(nextElement);
  2861. var slidEvent = $.Event(EVENT_SLID, {
  2862. relatedTarget: nextElement,
  2863. direction: eventDirectionName,
  2864. from: activeElementIndex,
  2865. to: nextElementIndex
  2866. });
  2867. if ($(this._element).hasClass(CLASS_NAME_SLIDE)) {
  2868. $(nextElement).addClass(orderClassName);
  2869. Util.reflow(nextElement);
  2870. $(activeElement).addClass(directionalClassName);
  2871. $(nextElement).addClass(directionalClassName);
  2872. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2873. if (nextElementInterval) {
  2874. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2875. this._config.interval = nextElementInterval;
  2876. } else {
  2877. this._config.interval = this._config.defaultInterval || this._config.interval;
  2878. }
  2879. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2880. $(activeElement).one(Util.TRANSITION_END, function () {
  2881. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE$1);
  2882. $(activeElement).removeClass(CLASS_NAME_ACTIVE$1 + " " + orderClassName + " " + directionalClassName);
  2883. _this4._isSliding = false;
  2884. setTimeout(function () {
  2885. return $(_this4._element).trigger(slidEvent);
  2886. }, 0);
  2887. }).emulateTransitionEnd(transitionDuration);
  2888. } else {
  2889. $(activeElement).removeClass(CLASS_NAME_ACTIVE$1);
  2890. $(nextElement).addClass(CLASS_NAME_ACTIVE$1);
  2891. this._isSliding = false;
  2892. $(this._element).trigger(slidEvent);
  2893. }
  2894. if (isCycling) {
  2895. this.cycle();
  2896. }
  2897. } // Static
  2898. ;
  2899. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2900. return this.each(function () {
  2901. var data = $(this).data(DATA_KEY$2);
  2902. var _config = _objectSpread2(_objectSpread2({}, Default), $(this).data());
  2903. if (typeof config === 'object') {
  2904. _config = _objectSpread2(_objectSpread2({}, _config), config);
  2905. }
  2906. var action = typeof config === 'string' ? config : _config.slide;
  2907. if (!data) {
  2908. data = new Carousel(this, _config);
  2909. $(this).data(DATA_KEY$2, data);
  2910. }
  2911. if (typeof config === 'number') {
  2912. data.to(config);
  2913. } else if (typeof action === 'string') {
  2914. if (typeof data[action] === 'undefined') {
  2915. throw new TypeError("No method named \"" + action + "\"");
  2916. }
  2917. data[action]();
  2918. } else if (_config.interval && _config.ride) {
  2919. data.pause();
  2920. data.cycle();
  2921. }
  2922. });
  2923. };
  2924. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2925. var selector = Util.getSelectorFromElement(this);
  2926. if (!selector) {
  2927. return;
  2928. }
  2929. var target = $(selector)[0];
  2930. if (!target || !$(target).hasClass(CLASS_NAME_CAROUSEL)) {
  2931. return;
  2932. }
  2933. var config = _objectSpread2(_objectSpread2({}, $(target).data()), $(this).data());
  2934. var slideIndex = this.getAttribute('data-slide-to');
  2935. if (slideIndex) {
  2936. config.interval = false;
  2937. }
  2938. Carousel._jQueryInterface.call($(target), config);
  2939. if (slideIndex) {
  2940. $(target).data(DATA_KEY$2).to(slideIndex);
  2941. }
  2942. event.preventDefault();
  2943. };
  2944. _createClass(Carousel, null, [{
  2945. key: "VERSION",
  2946. get: function get() {
  2947. return VERSION$2;
  2948. }
  2949. }, {
  2950. key: "Default",
  2951. get: function get() {
  2952. return Default;
  2953. }
  2954. }]);
  2955. return Carousel;
  2956. }();
  2957. /**
  2958. * ------------------------------------------------------------------------
  2959. * Data Api implementation
  2960. * ------------------------------------------------------------------------
  2961. */
  2962. $(document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
  2963. $(window).on(EVENT_LOAD_DATA_API$1, function () {
  2964. var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
  2965. for (var i = 0, len = carousels.length; i < len; i++) {
  2966. var $carousel = $(carousels[i]);
  2967. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2968. }
  2969. });
  2970. /**
  2971. * ------------------------------------------------------------------------
  2972. * jQuery
  2973. * ------------------------------------------------------------------------
  2974. */
  2975. $.fn[NAME$2] = Carousel._jQueryInterface;
  2976. $.fn[NAME$2].Constructor = Carousel;
  2977. $.fn[NAME$2].noConflict = function () {
  2978. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2979. return Carousel._jQueryInterface;
  2980. };
  2981. /**
  2982. * ------------------------------------------------------------------------
  2983. * Constants
  2984. * ------------------------------------------------------------------------
  2985. */
  2986. var NAME$3 = 'collapse';
  2987. var VERSION$3 = '4.5.0';
  2988. var DATA_KEY$3 = 'bs.collapse';
  2989. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2990. var DATA_API_KEY$3 = '.data-api';
  2991. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2992. var Default$1 = {
  2993. toggle: true,
  2994. parent: ''
  2995. };
  2996. var DefaultType$1 = {
  2997. toggle: 'boolean',
  2998. parent: '(string|element)'
  2999. };
  3000. var EVENT_SHOW = "show" + EVENT_KEY$3;
  3001. var EVENT_SHOWN = "shown" + EVENT_KEY$3;
  3002. var EVENT_HIDE = "hide" + EVENT_KEY$3;
  3003. var EVENT_HIDDEN = "hidden" + EVENT_KEY$3;
  3004. var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3;
  3005. var CLASS_NAME_SHOW$1 = 'show';
  3006. var CLASS_NAME_COLLAPSE = 'collapse';
  3007. var CLASS_NAME_COLLAPSING = 'collapsing';
  3008. var CLASS_NAME_COLLAPSED = 'collapsed';
  3009. var DIMENSION_WIDTH = 'width';
  3010. var DIMENSION_HEIGHT = 'height';
  3011. var SELECTOR_ACTIVES = '.show, .collapsing';
  3012. var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]';
  3013. /**
  3014. * ------------------------------------------------------------------------
  3015. * Class Definition
  3016. * ------------------------------------------------------------------------
  3017. */
  3018. var Collapse = /*#__PURE__*/function () {
  3019. function Collapse(element, config) {
  3020. this._isTransitioning = false;
  3021. this._element = element;
  3022. this._config = this._getConfig(config);
  3023. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  3024. var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1));
  3025. for (var i = 0, len = toggleList.length; i < len; i++) {
  3026. var elem = toggleList[i];
  3027. var selector = Util.getSelectorFromElement(elem);
  3028. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  3029. return foundElem === element;
  3030. });
  3031. if (selector !== null && filterElement.length > 0) {
  3032. this._selector = selector;
  3033. this._triggerArray.push(elem);
  3034. }
  3035. }
  3036. this._parent = this._config.parent ? this._getParent() : null;
  3037. if (!this._config.parent) {
  3038. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  3039. }
  3040. if (this._config.toggle) {
  3041. this.toggle();
  3042. }
  3043. } // Getters
  3044. var _proto = Collapse.prototype;
  3045. // Public
  3046. _proto.toggle = function toggle() {
  3047. if ($(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  3048. this.hide();
  3049. } else {
  3050. this.show();
  3051. }
  3052. };
  3053. _proto.show = function show() {
  3054. var _this = this;
  3055. if (this._isTransitioning || $(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  3056. return;
  3057. }
  3058. var actives;
  3059. var activesData;
  3060. if (this._parent) {
  3061. actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) {
  3062. if (typeof _this._config.parent === 'string') {
  3063. return elem.getAttribute('data-parent') === _this._config.parent;
  3064. }
  3065. return elem.classList.contains(CLASS_NAME_COLLAPSE);
  3066. });
  3067. if (actives.length === 0) {
  3068. actives = null;
  3069. }
  3070. }
  3071. if (actives) {
  3072. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3073. if (activesData && activesData._isTransitioning) {
  3074. return;
  3075. }
  3076. }
  3077. var startEvent = $.Event(EVENT_SHOW);
  3078. $(this._element).trigger(startEvent);
  3079. if (startEvent.isDefaultPrevented()) {
  3080. return;
  3081. }
  3082. if (actives) {
  3083. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3084. if (!activesData) {
  3085. $(actives).data(DATA_KEY$3, null);
  3086. }
  3087. }
  3088. var dimension = this._getDimension();
  3089. $(this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING);
  3090. this._element.style[dimension] = 0;
  3091. if (this._triggerArray.length) {
  3092. $(this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true);
  3093. }
  3094. this.setTransitioning(true);
  3095. var complete = function complete() {
  3096. $(_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  3097. _this._element.style[dimension] = '';
  3098. _this.setTransitioning(false);
  3099. $(_this._element).trigger(EVENT_SHOWN);
  3100. };
  3101. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3102. var scrollSize = "scroll" + capitalizedDimension;
  3103. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3104. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3105. this._element.style[dimension] = this._element[scrollSize] + "px";
  3106. };
  3107. _proto.hide = function hide() {
  3108. var _this2 = this;
  3109. if (this._isTransitioning || !$(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  3110. return;
  3111. }
  3112. var startEvent = $.Event(EVENT_HIDE);
  3113. $(this._element).trigger(startEvent);
  3114. if (startEvent.isDefaultPrevented()) {
  3115. return;
  3116. }
  3117. var dimension = this._getDimension();
  3118. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3119. Util.reflow(this._element);
  3120. $(this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  3121. var triggerArrayLength = this._triggerArray.length;
  3122. if (triggerArrayLength > 0) {
  3123. for (var i = 0; i < triggerArrayLength; i++) {
  3124. var trigger = this._triggerArray[i];
  3125. var selector = Util.getSelectorFromElement(trigger);
  3126. if (selector !== null) {
  3127. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3128. if (!$elem.hasClass(CLASS_NAME_SHOW$1)) {
  3129. $(trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false);
  3130. }
  3131. }
  3132. }
  3133. }
  3134. this.setTransitioning(true);
  3135. var complete = function complete() {
  3136. _this2.setTransitioning(false);
  3137. $(_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN);
  3138. };
  3139. this._element.style[dimension] = '';
  3140. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3141. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3142. };
  3143. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3144. this._isTransitioning = isTransitioning;
  3145. };
  3146. _proto.dispose = function dispose() {
  3147. $.removeData(this._element, DATA_KEY$3);
  3148. this._config = null;
  3149. this._parent = null;
  3150. this._element = null;
  3151. this._triggerArray = null;
  3152. this._isTransitioning = null;
  3153. } // Private
  3154. ;
  3155. _proto._getConfig = function _getConfig(config) {
  3156. config = _objectSpread2(_objectSpread2({}, Default$1), config);
  3157. config.toggle = Boolean(config.toggle); // Coerce string values
  3158. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3159. return config;
  3160. };
  3161. _proto._getDimension = function _getDimension() {
  3162. var hasWidth = $(this._element).hasClass(DIMENSION_WIDTH);
  3163. return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT;
  3164. };
  3165. _proto._getParent = function _getParent() {
  3166. var _this3 = this;
  3167. var parent;
  3168. if (Util.isElement(this._config.parent)) {
  3169. parent = this._config.parent; // It's a jQuery object
  3170. if (typeof this._config.parent.jquery !== 'undefined') {
  3171. parent = this._config.parent[0];
  3172. }
  3173. } else {
  3174. parent = document.querySelector(this._config.parent);
  3175. }
  3176. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3177. var children = [].slice.call(parent.querySelectorAll(selector));
  3178. $(children).each(function (i, element) {
  3179. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3180. });
  3181. return parent;
  3182. };
  3183. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3184. var isOpen = $(element).hasClass(CLASS_NAME_SHOW$1);
  3185. if (triggerArray.length) {
  3186. $(triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3187. }
  3188. } // Static
  3189. ;
  3190. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3191. var selector = Util.getSelectorFromElement(element);
  3192. return selector ? document.querySelector(selector) : null;
  3193. };
  3194. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3195. return this.each(function () {
  3196. var $this = $(this);
  3197. var data = $this.data(DATA_KEY$3);
  3198. var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$1), $this.data()), typeof config === 'object' && config ? config : {});
  3199. if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
  3200. _config.toggle = false;
  3201. }
  3202. if (!data) {
  3203. data = new Collapse(this, _config);
  3204. $this.data(DATA_KEY$3, data);
  3205. }
  3206. if (typeof config === 'string') {
  3207. if (typeof data[config] === 'undefined') {
  3208. throw new TypeError("No method named \"" + config + "\"");
  3209. }
  3210. data[config]();
  3211. }
  3212. });
  3213. };
  3214. _createClass(Collapse, null, [{
  3215. key: "VERSION",
  3216. get: function get() {
  3217. return VERSION$3;
  3218. }
  3219. }, {
  3220. key: "Default",
  3221. get: function get() {
  3222. return Default$1;
  3223. }
  3224. }]);
  3225. return Collapse;
  3226. }();
  3227. /**
  3228. * ------------------------------------------------------------------------
  3229. * Data Api implementation
  3230. * ------------------------------------------------------------------------
  3231. */
  3232. $(document).on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
  3233. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3234. if (event.currentTarget.tagName === 'A') {
  3235. event.preventDefault();
  3236. }
  3237. var $trigger = $(this);
  3238. var selector = Util.getSelectorFromElement(this);
  3239. var selectors = [].slice.call(document.querySelectorAll(selector));
  3240. $(selectors).each(function () {
  3241. var $target = $(this);
  3242. var data = $target.data(DATA_KEY$3);
  3243. var config = data ? 'toggle' : $trigger.data();
  3244. Collapse._jQueryInterface.call($target, config);
  3245. });
  3246. });
  3247. /**
  3248. * ------------------------------------------------------------------------
  3249. * jQuery
  3250. * ------------------------------------------------------------------------
  3251. */
  3252. $.fn[NAME$3] = Collapse._jQueryInterface;
  3253. $.fn[NAME$3].Constructor = Collapse;
  3254. $.fn[NAME$3].noConflict = function () {
  3255. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3256. return Collapse._jQueryInterface;
  3257. };
  3258. /**
  3259. * ------------------------------------------------------------------------
  3260. * Constants
  3261. * ------------------------------------------------------------------------
  3262. */
  3263. var NAME$4 = 'dropdown';
  3264. var VERSION$4 = '4.5.0';
  3265. var DATA_KEY$4 = 'bs.dropdown';
  3266. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3267. var DATA_API_KEY$4 = '.data-api';
  3268. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3269. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3270. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3271. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3272. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3273. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3274. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3275. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3276. var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
  3277. var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
  3278. var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
  3279. var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
  3280. var EVENT_CLICK = "click" + EVENT_KEY$4;
  3281. var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
  3282. var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
  3283. var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
  3284. var CLASS_NAME_DISABLED = 'disabled';
  3285. var CLASS_NAME_SHOW$2 = 'show';
  3286. var CLASS_NAME_DROPUP = 'dropup';
  3287. var CLASS_NAME_DROPRIGHT = 'dropright';
  3288. var CLASS_NAME_DROPLEFT = 'dropleft';
  3289. var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
  3290. var CLASS_NAME_POSITION_STATIC = 'position-static';
  3291. var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
  3292. var SELECTOR_FORM_CHILD = '.dropdown form';
  3293. var SELECTOR_MENU = '.dropdown-menu';
  3294. var SELECTOR_NAVBAR_NAV = '.navbar-nav';
  3295. var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  3296. var PLACEMENT_TOP = 'top-start';
  3297. var PLACEMENT_TOPEND = 'top-end';
  3298. var PLACEMENT_BOTTOM = 'bottom-start';
  3299. var PLACEMENT_BOTTOMEND = 'bottom-end';
  3300. var PLACEMENT_RIGHT = 'right-start';
  3301. var PLACEMENT_LEFT = 'left-start';
  3302. var Default$2 = {
  3303. offset: 0,
  3304. flip: true,
  3305. boundary: 'scrollParent',
  3306. reference: 'toggle',
  3307. display: 'dynamic',
  3308. popperConfig: null
  3309. };
  3310. var DefaultType$2 = {
  3311. offset: '(number|string|function)',
  3312. flip: 'boolean',
  3313. boundary: '(string|element)',
  3314. reference: '(string|element)',
  3315. display: 'string',
  3316. popperConfig: '(null|object)'
  3317. };
  3318. /**
  3319. * ------------------------------------------------------------------------
  3320. * Class Definition
  3321. * ------------------------------------------------------------------------
  3322. */
  3323. var Dropdown = /*#__PURE__*/function () {
  3324. function Dropdown(element, config) {
  3325. this._element = element;
  3326. this._popper = null;
  3327. this._config = this._getConfig(config);
  3328. this._menu = this._getMenuElement();
  3329. this._inNavbar = this._detectNavbar();
  3330. this._addEventListeners();
  3331. } // Getters
  3332. var _proto = Dropdown.prototype;
  3333. // Public
  3334. _proto.toggle = function toggle() {
  3335. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED)) {
  3336. return;
  3337. }
  3338. var isActive = $(this._menu).hasClass(CLASS_NAME_SHOW$2);
  3339. Dropdown._clearMenus();
  3340. if (isActive) {
  3341. return;
  3342. }
  3343. this.show(true);
  3344. };
  3345. _proto.show = function show(usePopper) {
  3346. if (usePopper === void 0) {
  3347. usePopper = false;
  3348. }
  3349. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || $(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  3350. return;
  3351. }
  3352. var relatedTarget = {
  3353. relatedTarget: this._element
  3354. };
  3355. var showEvent = $.Event(EVENT_SHOW$1, relatedTarget);
  3356. var parent = Dropdown._getParentFromElement(this._element);
  3357. $(parent).trigger(showEvent);
  3358. if (showEvent.isDefaultPrevented()) {
  3359. return;
  3360. } // Disable totally Popper.js for Dropdown in Navbar
  3361. if (!this._inNavbar && usePopper) {
  3362. /**
  3363. * Check for Popper dependency
  3364. * Popper - https://popper.js.org
  3365. */
  3366. if (typeof Popper === 'undefined') {
  3367. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3368. }
  3369. var referenceElement = this._element;
  3370. if (this._config.reference === 'parent') {
  3371. referenceElement = parent;
  3372. } else if (Util.isElement(this._config.reference)) {
  3373. referenceElement = this._config.reference; // Check if it's jQuery element
  3374. if (typeof this._config.reference.jquery !== 'undefined') {
  3375. referenceElement = this._config.reference[0];
  3376. }
  3377. } // If boundary is not `scrollParent`, then set position to `static`
  3378. // to allow the menu to "escape" the scroll parent's boundaries
  3379. // https://github.com/twbs/bootstrap/issues/24251
  3380. if (this._config.boundary !== 'scrollParent') {
  3381. $(parent).addClass(CLASS_NAME_POSITION_STATIC);
  3382. }
  3383. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3384. } // If this is a touch-enabled device we add extra
  3385. // empty mouseover listeners to the body's immediate children;
  3386. // only needed because of broken event delegation on iOS
  3387. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3388. if ('ontouchstart' in document.documentElement && $(parent).closest(SELECTOR_NAVBAR_NAV).length === 0) {
  3389. $(document.body).children().on('mouseover', null, $.noop);
  3390. }
  3391. this._element.focus();
  3392. this._element.setAttribute('aria-expanded', true);
  3393. $(this._menu).toggleClass(CLASS_NAME_SHOW$2);
  3394. $(parent).toggleClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_SHOWN$1, relatedTarget));
  3395. };
  3396. _proto.hide = function hide() {
  3397. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || !$(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  3398. return;
  3399. }
  3400. var relatedTarget = {
  3401. relatedTarget: this._element
  3402. };
  3403. var hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
  3404. var parent = Dropdown._getParentFromElement(this._element);
  3405. $(parent).trigger(hideEvent);
  3406. if (hideEvent.isDefaultPrevented()) {
  3407. return;
  3408. }
  3409. if (this._popper) {
  3410. this._popper.destroy();
  3411. }
  3412. $(this._menu).toggleClass(CLASS_NAME_SHOW$2);
  3413. $(parent).toggleClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
  3414. };
  3415. _proto.dispose = function dispose() {
  3416. $.removeData(this._element, DATA_KEY$4);
  3417. $(this._element).off(EVENT_KEY$4);
  3418. this._element = null;
  3419. this._menu = null;
  3420. if (this._popper !== null) {
  3421. this._popper.destroy();
  3422. this._popper = null;
  3423. }
  3424. };
  3425. _proto.update = function update() {
  3426. this._inNavbar = this._detectNavbar();
  3427. if (this._popper !== null) {
  3428. this._popper.scheduleUpdate();
  3429. }
  3430. } // Private
  3431. ;
  3432. _proto._addEventListeners = function _addEventListeners() {
  3433. var _this = this;
  3434. $(this._element).on(EVENT_CLICK, function (event) {
  3435. event.preventDefault();
  3436. event.stopPropagation();
  3437. _this.toggle();
  3438. });
  3439. };
  3440. _proto._getConfig = function _getConfig(config) {
  3441. config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), $(this._element).data()), config);
  3442. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3443. return config;
  3444. };
  3445. _proto._getMenuElement = function _getMenuElement() {
  3446. if (!this._menu) {
  3447. var parent = Dropdown._getParentFromElement(this._element);
  3448. if (parent) {
  3449. this._menu = parent.querySelector(SELECTOR_MENU);
  3450. }
  3451. }
  3452. return this._menu;
  3453. };
  3454. _proto._getPlacement = function _getPlacement() {
  3455. var $parentDropdown = $(this._element.parentNode);
  3456. var placement = PLACEMENT_BOTTOM; // Handle dropup
  3457. if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) {
  3458. placement = $(this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3459. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) {
  3460. placement = PLACEMENT_RIGHT;
  3461. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) {
  3462. placement = PLACEMENT_LEFT;
  3463. } else if ($(this._menu).hasClass(CLASS_NAME_MENURIGHT)) {
  3464. placement = PLACEMENT_BOTTOMEND;
  3465. }
  3466. return placement;
  3467. };
  3468. _proto._detectNavbar = function _detectNavbar() {
  3469. return $(this._element).closest('.navbar').length > 0;
  3470. };
  3471. _proto._getOffset = function _getOffset() {
  3472. var _this2 = this;
  3473. var offset = {};
  3474. if (typeof this._config.offset === 'function') {
  3475. offset.fn = function (data) {
  3476. data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this2._config.offset(data.offsets, _this2._element) || {});
  3477. return data;
  3478. };
  3479. } else {
  3480. offset.offset = this._config.offset;
  3481. }
  3482. return offset;
  3483. };
  3484. _proto._getPopperConfig = function _getPopperConfig() {
  3485. var popperConfig = {
  3486. placement: this._getPlacement(),
  3487. modifiers: {
  3488. offset: this._getOffset(),
  3489. flip: {
  3490. enabled: this._config.flip
  3491. },
  3492. preventOverflow: {
  3493. boundariesElement: this._config.boundary
  3494. }
  3495. }
  3496. }; // Disable Popper.js if we have a static display
  3497. if (this._config.display === 'static') {
  3498. popperConfig.modifiers.applyStyle = {
  3499. enabled: false
  3500. };
  3501. }
  3502. return _objectSpread2(_objectSpread2({}, popperConfig), this._config.popperConfig);
  3503. } // Static
  3504. ;
  3505. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3506. return this.each(function () {
  3507. var data = $(this).data(DATA_KEY$4);
  3508. var _config = typeof config === 'object' ? config : null;
  3509. if (!data) {
  3510. data = new Dropdown(this, _config);
  3511. $(this).data(DATA_KEY$4, data);
  3512. }
  3513. if (typeof config === 'string') {
  3514. if (typeof data[config] === 'undefined') {
  3515. throw new TypeError("No method named \"" + config + "\"");
  3516. }
  3517. data[config]();
  3518. }
  3519. });
  3520. };
  3521. Dropdown._clearMenus = function _clearMenus(event) {
  3522. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3523. return;
  3524. }
  3525. var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2));
  3526. for (var i = 0, len = toggles.length; i < len; i++) {
  3527. var parent = Dropdown._getParentFromElement(toggles[i]);
  3528. var context = $(toggles[i]).data(DATA_KEY$4);
  3529. var relatedTarget = {
  3530. relatedTarget: toggles[i]
  3531. };
  3532. if (event && event.type === 'click') {
  3533. relatedTarget.clickEvent = event;
  3534. }
  3535. if (!context) {
  3536. continue;
  3537. }
  3538. var dropdownMenu = context._menu;
  3539. if (!$(parent).hasClass(CLASS_NAME_SHOW$2)) {
  3540. continue;
  3541. }
  3542. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3543. continue;
  3544. }
  3545. var hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
  3546. $(parent).trigger(hideEvent);
  3547. if (hideEvent.isDefaultPrevented()) {
  3548. continue;
  3549. } // If this is a touch-enabled device we remove the extra
  3550. // empty mouseover listeners we added for iOS support
  3551. if ('ontouchstart' in document.documentElement) {
  3552. $(document.body).children().off('mouseover', null, $.noop);
  3553. }
  3554. toggles[i].setAttribute('aria-expanded', 'false');
  3555. if (context._popper) {
  3556. context._popper.destroy();
  3557. }
  3558. $(dropdownMenu).removeClass(CLASS_NAME_SHOW$2);
  3559. $(parent).removeClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
  3560. }
  3561. };
  3562. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3563. var parent;
  3564. var selector = Util.getSelectorFromElement(element);
  3565. if (selector) {
  3566. parent = document.querySelector(selector);
  3567. }
  3568. return parent || element.parentNode;
  3569. } // eslint-disable-next-line complexity
  3570. ;
  3571. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3572. // If not input/textarea:
  3573. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3574. // If input/textarea:
  3575. // - If space key => not a dropdown command
  3576. // - If key is other than escape
  3577. // - If key is not up or down => not a dropdown command
  3578. // - If trigger inside the menu => not a dropdown command
  3579. if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  3580. return;
  3581. }
  3582. if (this.disabled || $(this).hasClass(CLASS_NAME_DISABLED)) {
  3583. return;
  3584. }
  3585. var parent = Dropdown._getParentFromElement(this);
  3586. var isActive = $(parent).hasClass(CLASS_NAME_SHOW$2);
  3587. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3588. return;
  3589. }
  3590. event.preventDefault();
  3591. event.stopPropagation();
  3592. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3593. if (event.which === ESCAPE_KEYCODE) {
  3594. $(parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus');
  3595. }
  3596. $(this).trigger('click');
  3597. return;
  3598. }
  3599. var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) {
  3600. return $(item).is(':visible');
  3601. });
  3602. if (items.length === 0) {
  3603. return;
  3604. }
  3605. var index = items.indexOf(event.target);
  3606. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3607. // Up
  3608. index--;
  3609. }
  3610. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3611. // Down
  3612. index++;
  3613. }
  3614. if (index < 0) {
  3615. index = 0;
  3616. }
  3617. items[index].focus();
  3618. };
  3619. _createClass(Dropdown, null, [{
  3620. key: "VERSION",
  3621. get: function get() {
  3622. return VERSION$4;
  3623. }
  3624. }, {
  3625. key: "Default",
  3626. get: function get() {
  3627. return Default$2;
  3628. }
  3629. }, {
  3630. key: "DefaultType",
  3631. get: function get() {
  3632. return DefaultType$2;
  3633. }
  3634. }]);
  3635. return Dropdown;
  3636. }();
  3637. /**
  3638. * ------------------------------------------------------------------------
  3639. * Data Api implementation
  3640. * ------------------------------------------------------------------------
  3641. */
  3642. $(document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API$4 + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) {
  3643. event.preventDefault();
  3644. event.stopPropagation();
  3645. Dropdown._jQueryInterface.call($(this), 'toggle');
  3646. }).on(EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) {
  3647. e.stopPropagation();
  3648. });
  3649. /**
  3650. * ------------------------------------------------------------------------
  3651. * jQuery
  3652. * ------------------------------------------------------------------------
  3653. */
  3654. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3655. $.fn[NAME$4].Constructor = Dropdown;
  3656. $.fn[NAME$4].noConflict = function () {
  3657. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3658. return Dropdown._jQueryInterface;
  3659. };
  3660. /**
  3661. * ------------------------------------------------------------------------
  3662. * Constants
  3663. * ------------------------------------------------------------------------
  3664. */
  3665. var NAME$5 = 'modal';
  3666. var VERSION$5 = '4.5.0';
  3667. var DATA_KEY$5 = 'bs.modal';
  3668. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3669. var DATA_API_KEY$5 = '.data-api';
  3670. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3671. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3672. var Default$3 = {
  3673. backdrop: true,
  3674. keyboard: true,
  3675. focus: true,
  3676. show: true
  3677. };
  3678. var DefaultType$3 = {
  3679. backdrop: '(boolean|string)',
  3680. keyboard: 'boolean',
  3681. focus: 'boolean',
  3682. show: 'boolean'
  3683. };
  3684. var EVENT_HIDE$2 = "hide" + EVENT_KEY$5;
  3685. var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5;
  3686. var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5;
  3687. var EVENT_SHOW$2 = "show" + EVENT_KEY$5;
  3688. var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5;
  3689. var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5;
  3690. var EVENT_RESIZE = "resize" + EVENT_KEY$5;
  3691. var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5;
  3692. var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5;
  3693. var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5;
  3694. var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
  3695. var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
  3696. var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
  3697. var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
  3698. var CLASS_NAME_BACKDROP = 'modal-backdrop';
  3699. var CLASS_NAME_OPEN = 'modal-open';
  3700. var CLASS_NAME_FADE$1 = 'fade';
  3701. var CLASS_NAME_SHOW$3 = 'show';
  3702. var CLASS_NAME_STATIC = 'modal-static';
  3703. var SELECTOR_DIALOG = '.modal-dialog';
  3704. var SELECTOR_MODAL_BODY = '.modal-body';
  3705. var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
  3706. var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
  3707. var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  3708. var SELECTOR_STICKY_CONTENT = '.sticky-top';
  3709. /**
  3710. * ------------------------------------------------------------------------
  3711. * Class Definition
  3712. * ------------------------------------------------------------------------
  3713. */
  3714. var Modal = /*#__PURE__*/function () {
  3715. function Modal(element, config) {
  3716. this._config = this._getConfig(config);
  3717. this._element = element;
  3718. this._dialog = element.querySelector(SELECTOR_DIALOG);
  3719. this._backdrop = null;
  3720. this._isShown = false;
  3721. this._isBodyOverflowing = false;
  3722. this._ignoreBackdropClick = false;
  3723. this._isTransitioning = false;
  3724. this._scrollbarWidth = 0;
  3725. } // Getters
  3726. var _proto = Modal.prototype;
  3727. // Public
  3728. _proto.toggle = function toggle(relatedTarget) {
  3729. return this._isShown ? this.hide() : this.show(relatedTarget);
  3730. };
  3731. _proto.show = function show(relatedTarget) {
  3732. var _this = this;
  3733. if (this._isShown || this._isTransitioning) {
  3734. return;
  3735. }
  3736. if ($(this._element).hasClass(CLASS_NAME_FADE$1)) {
  3737. this._isTransitioning = true;
  3738. }
  3739. var showEvent = $.Event(EVENT_SHOW$2, {
  3740. relatedTarget: relatedTarget
  3741. });
  3742. $(this._element).trigger(showEvent);
  3743. if (this._isShown || showEvent.isDefaultPrevented()) {
  3744. return;
  3745. }
  3746. this._isShown = true;
  3747. this._checkScrollbar();
  3748. this._setScrollbar();
  3749. this._adjustDialog();
  3750. this._setEscapeEvent();
  3751. this._setResizeEvent();
  3752. $(this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
  3753. return _this.hide(event);
  3754. });
  3755. $(this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () {
  3756. $(_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) {
  3757. if ($(event.target).is(_this._element)) {
  3758. _this._ignoreBackdropClick = true;
  3759. }
  3760. });
  3761. });
  3762. this._showBackdrop(function () {
  3763. return _this._showElement(relatedTarget);
  3764. });
  3765. };
  3766. _proto.hide = function hide(event) {
  3767. var _this2 = this;
  3768. if (event) {
  3769. event.preventDefault();
  3770. }
  3771. if (!this._isShown || this._isTransitioning) {
  3772. return;
  3773. }
  3774. var hideEvent = $.Event(EVENT_HIDE$2);
  3775. $(this._element).trigger(hideEvent);
  3776. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3777. return;
  3778. }
  3779. this._isShown = false;
  3780. var transition = $(this._element).hasClass(CLASS_NAME_FADE$1);
  3781. if (transition) {
  3782. this._isTransitioning = true;
  3783. }
  3784. this._setEscapeEvent();
  3785. this._setResizeEvent();
  3786. $(document).off(EVENT_FOCUSIN);
  3787. $(this._element).removeClass(CLASS_NAME_SHOW$3);
  3788. $(this._element).off(EVENT_CLICK_DISMISS);
  3789. $(this._dialog).off(EVENT_MOUSEDOWN_DISMISS);
  3790. if (transition) {
  3791. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3792. $(this._element).one(Util.TRANSITION_END, function (event) {
  3793. return _this2._hideModal(event);
  3794. }).emulateTransitionEnd(transitionDuration);
  3795. } else {
  3796. this._hideModal();
  3797. }
  3798. };
  3799. _proto.dispose = function dispose() {
  3800. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3801. return $(htmlElement).off(EVENT_KEY$5);
  3802. });
  3803. /**
  3804. * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
  3805. * Do not move `document` in `htmlElements` array
  3806. * It will remove `EVENT_CLICK_DATA_API` event that should remain
  3807. */
  3808. $(document).off(EVENT_FOCUSIN);
  3809. $.removeData(this._element, DATA_KEY$5);
  3810. this._config = null;
  3811. this._element = null;
  3812. this._dialog = null;
  3813. this._backdrop = null;
  3814. this._isShown = null;
  3815. this._isBodyOverflowing = null;
  3816. this._ignoreBackdropClick = null;
  3817. this._isTransitioning = null;
  3818. this._scrollbarWidth = null;
  3819. };
  3820. _proto.handleUpdate = function handleUpdate() {
  3821. this._adjustDialog();
  3822. } // Private
  3823. ;
  3824. _proto._getConfig = function _getConfig(config) {
  3825. config = _objectSpread2(_objectSpread2({}, Default$3), config);
  3826. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3827. return config;
  3828. };
  3829. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3830. var _this3 = this;
  3831. if (this._config.backdrop === 'static') {
  3832. var hideEventPrevented = $.Event(EVENT_HIDE_PREVENTED);
  3833. $(this._element).trigger(hideEventPrevented);
  3834. if (hideEventPrevented.defaultPrevented) {
  3835. return;
  3836. }
  3837. this._element.classList.add(CLASS_NAME_STATIC);
  3838. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3839. $(this._element).one(Util.TRANSITION_END, function () {
  3840. _this3._element.classList.remove(CLASS_NAME_STATIC);
  3841. }).emulateTransitionEnd(modalTransitionDuration);
  3842. this._element.focus();
  3843. } else {
  3844. this.hide();
  3845. }
  3846. };
  3847. _proto._showElement = function _showElement(relatedTarget) {
  3848. var _this4 = this;
  3849. var transition = $(this._element).hasClass(CLASS_NAME_FADE$1);
  3850. var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
  3851. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3852. // Don't move modal's DOM position
  3853. document.body.appendChild(this._element);
  3854. }
  3855. this._element.style.display = 'block';
  3856. this._element.removeAttribute('aria-hidden');
  3857. this._element.setAttribute('aria-modal', true);
  3858. if ($(this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) {
  3859. modalBody.scrollTop = 0;
  3860. } else {
  3861. this._element.scrollTop = 0;
  3862. }
  3863. if (transition) {
  3864. Util.reflow(this._element);
  3865. }
  3866. $(this._element).addClass(CLASS_NAME_SHOW$3);
  3867. if (this._config.focus) {
  3868. this._enforceFocus();
  3869. }
  3870. var shownEvent = $.Event(EVENT_SHOWN$2, {
  3871. relatedTarget: relatedTarget
  3872. });
  3873. var transitionComplete = function transitionComplete() {
  3874. if (_this4._config.focus) {
  3875. _this4._element.focus();
  3876. }
  3877. _this4._isTransitioning = false;
  3878. $(_this4._element).trigger(shownEvent);
  3879. };
  3880. if (transition) {
  3881. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3882. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3883. } else {
  3884. transitionComplete();
  3885. }
  3886. };
  3887. _proto._enforceFocus = function _enforceFocus() {
  3888. var _this5 = this;
  3889. $(document).off(EVENT_FOCUSIN) // Guard against infinite focus loop
  3890. .on(EVENT_FOCUSIN, function (event) {
  3891. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3892. _this5._element.focus();
  3893. }
  3894. });
  3895. };
  3896. _proto._setEscapeEvent = function _setEscapeEvent() {
  3897. var _this6 = this;
  3898. if (this._isShown) {
  3899. $(this._element).on(EVENT_KEYDOWN_DISMISS, function (event) {
  3900. if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  3901. event.preventDefault();
  3902. _this6.hide();
  3903. } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  3904. _this6._triggerBackdropTransition();
  3905. }
  3906. });
  3907. } else if (!this._isShown) {
  3908. $(this._element).off(EVENT_KEYDOWN_DISMISS);
  3909. }
  3910. };
  3911. _proto._setResizeEvent = function _setResizeEvent() {
  3912. var _this7 = this;
  3913. if (this._isShown) {
  3914. $(window).on(EVENT_RESIZE, function (event) {
  3915. return _this7.handleUpdate(event);
  3916. });
  3917. } else {
  3918. $(window).off(EVENT_RESIZE);
  3919. }
  3920. };
  3921. _proto._hideModal = function _hideModal() {
  3922. var _this8 = this;
  3923. this._element.style.display = 'none';
  3924. this._element.setAttribute('aria-hidden', true);
  3925. this._element.removeAttribute('aria-modal');
  3926. this._isTransitioning = false;
  3927. this._showBackdrop(function () {
  3928. $(document.body).removeClass(CLASS_NAME_OPEN);
  3929. _this8._resetAdjustments();
  3930. _this8._resetScrollbar();
  3931. $(_this8._element).trigger(EVENT_HIDDEN$2);
  3932. });
  3933. };
  3934. _proto._removeBackdrop = function _removeBackdrop() {
  3935. if (this._backdrop) {
  3936. $(this._backdrop).remove();
  3937. this._backdrop = null;
  3938. }
  3939. };
  3940. _proto._showBackdrop = function _showBackdrop(callback) {
  3941. var _this9 = this;
  3942. var animate = $(this._element).hasClass(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : '';
  3943. if (this._isShown && this._config.backdrop) {
  3944. this._backdrop = document.createElement('div');
  3945. this._backdrop.className = CLASS_NAME_BACKDROP;
  3946. if (animate) {
  3947. this._backdrop.classList.add(animate);
  3948. }
  3949. $(this._backdrop).appendTo(document.body);
  3950. $(this._element).on(EVENT_CLICK_DISMISS, function (event) {
  3951. if (_this9._ignoreBackdropClick) {
  3952. _this9._ignoreBackdropClick = false;
  3953. return;
  3954. }
  3955. if (event.target !== event.currentTarget) {
  3956. return;
  3957. }
  3958. _this9._triggerBackdropTransition();
  3959. });
  3960. if (animate) {
  3961. Util.reflow(this._backdrop);
  3962. }
  3963. $(this._backdrop).addClass(CLASS_NAME_SHOW$3);
  3964. if (!callback) {
  3965. return;
  3966. }
  3967. if (!animate) {
  3968. callback();
  3969. return;
  3970. }
  3971. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3972. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3973. } else if (!this._isShown && this._backdrop) {
  3974. $(this._backdrop).removeClass(CLASS_NAME_SHOW$3);
  3975. var callbackRemove = function callbackRemove() {
  3976. _this9._removeBackdrop();
  3977. if (callback) {
  3978. callback();
  3979. }
  3980. };
  3981. if ($(this._element).hasClass(CLASS_NAME_FADE$1)) {
  3982. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3983. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3984. } else {
  3985. callbackRemove();
  3986. }
  3987. } else if (callback) {
  3988. callback();
  3989. }
  3990. } // ----------------------------------------------------------------------
  3991. // the following methods are used to handle overflowing modals
  3992. // todo (fat): these should probably be refactored out of modal.js
  3993. // ----------------------------------------------------------------------
  3994. ;
  3995. _proto._adjustDialog = function _adjustDialog() {
  3996. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3997. if (!this._isBodyOverflowing && isModalOverflowing) {
  3998. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3999. }
  4000. if (this._isBodyOverflowing && !isModalOverflowing) {
  4001. this._element.style.paddingRight = this._scrollbarWidth + "px";
  4002. }
  4003. };
  4004. _proto._resetAdjustments = function _resetAdjustments() {
  4005. this._element.style.paddingLeft = '';
  4006. this._element.style.paddingRight = '';
  4007. };
  4008. _proto._checkScrollbar = function _checkScrollbar() {
  4009. var rect = document.body.getBoundingClientRect();
  4010. this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
  4011. this._scrollbarWidth = this._getScrollbarWidth();
  4012. };
  4013. _proto._setScrollbar = function _setScrollbar() {
  4014. var _this10 = this;
  4015. if (this._isBodyOverflowing) {
  4016. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  4017. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  4018. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  4019. var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding
  4020. $(fixedContent).each(function (index, element) {
  4021. var actualPadding = element.style.paddingRight;
  4022. var calculatedPadding = $(element).css('padding-right');
  4023. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  4024. }); // Adjust sticky content margin
  4025. $(stickyContent).each(function (index, element) {
  4026. var actualMargin = element.style.marginRight;
  4027. var calculatedMargin = $(element).css('margin-right');
  4028. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  4029. }); // Adjust body padding
  4030. var actualPadding = document.body.style.paddingRight;
  4031. var calculatedPadding = $(document.body).css('padding-right');
  4032. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  4033. }
  4034. $(document.body).addClass(CLASS_NAME_OPEN);
  4035. };
  4036. _proto._resetScrollbar = function _resetScrollbar() {
  4037. // Restore fixed content padding
  4038. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  4039. $(fixedContent).each(function (index, element) {
  4040. var padding = $(element).data('padding-right');
  4041. $(element).removeData('padding-right');
  4042. element.style.paddingRight = padding ? padding : '';
  4043. }); // Restore sticky content
  4044. var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT));
  4045. $(elements).each(function (index, element) {
  4046. var margin = $(element).data('margin-right');
  4047. if (typeof margin !== 'undefined') {
  4048. $(element).css('margin-right', margin).removeData('margin-right');
  4049. }
  4050. }); // Restore body padding
  4051. var padding = $(document.body).data('padding-right');
  4052. $(document.body).removeData('padding-right');
  4053. document.body.style.paddingRight = padding ? padding : '';
  4054. };
  4055. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4056. // thx d.walsh
  4057. var scrollDiv = document.createElement('div');
  4058. scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
  4059. document.body.appendChild(scrollDiv);
  4060. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4061. document.body.removeChild(scrollDiv);
  4062. return scrollbarWidth;
  4063. } // Static
  4064. ;
  4065. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4066. return this.each(function () {
  4067. var data = $(this).data(DATA_KEY$5);
  4068. var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$3), $(this).data()), typeof config === 'object' && config ? config : {});
  4069. if (!data) {
  4070. data = new Modal(this, _config);
  4071. $(this).data(DATA_KEY$5, data);
  4072. }
  4073. if (typeof config === 'string') {
  4074. if (typeof data[config] === 'undefined') {
  4075. throw new TypeError("No method named \"" + config + "\"");
  4076. }
  4077. data[config](relatedTarget);
  4078. } else if (_config.show) {
  4079. data.show(relatedTarget);
  4080. }
  4081. });
  4082. };
  4083. _createClass(Modal, null, [{
  4084. key: "VERSION",
  4085. get: function get() {
  4086. return VERSION$5;
  4087. }
  4088. }, {
  4089. key: "Default",
  4090. get: function get() {
  4091. return Default$3;
  4092. }
  4093. }]);
  4094. return Modal;
  4095. }();
  4096. /**
  4097. * ------------------------------------------------------------------------
  4098. * Data Api implementation
  4099. * ------------------------------------------------------------------------
  4100. */
  4101. $(document).on(EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) {
  4102. var _this11 = this;
  4103. var target;
  4104. var selector = Util.getSelectorFromElement(this);
  4105. if (selector) {
  4106. target = document.querySelector(selector);
  4107. }
  4108. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2(_objectSpread2({}, $(target).data()), $(this).data());
  4109. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4110. event.preventDefault();
  4111. }
  4112. var $target = $(target).one(EVENT_SHOW$2, function (showEvent) {
  4113. if (showEvent.isDefaultPrevented()) {
  4114. // Only register focus restorer if modal will actually get shown
  4115. return;
  4116. }
  4117. $target.one(EVENT_HIDDEN$2, function () {
  4118. if ($(_this11).is(':visible')) {
  4119. _this11.focus();
  4120. }
  4121. });
  4122. });
  4123. Modal._jQueryInterface.call($(target), config, this);
  4124. });
  4125. /**
  4126. * ------------------------------------------------------------------------
  4127. * jQuery
  4128. * ------------------------------------------------------------------------
  4129. */
  4130. $.fn[NAME$5] = Modal._jQueryInterface;
  4131. $.fn[NAME$5].Constructor = Modal;
  4132. $.fn[NAME$5].noConflict = function () {
  4133. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4134. return Modal._jQueryInterface;
  4135. };
  4136. /**
  4137. * --------------------------------------------------------------------------
  4138. * Bootstrap (v4.5.0): tools/sanitizer.js
  4139. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4140. * --------------------------------------------------------------------------
  4141. */
  4142. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4143. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4144. var DefaultWhitelist = {
  4145. // Global attributes allowed on any supplied element below.
  4146. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4147. a: ['target', 'href', 'title', 'rel'],
  4148. area: [],
  4149. b: [],
  4150. br: [],
  4151. col: [],
  4152. code: [],
  4153. div: [],
  4154. em: [],
  4155. hr: [],
  4156. h1: [],
  4157. h2: [],
  4158. h3: [],
  4159. h4: [],
  4160. h5: [],
  4161. h6: [],
  4162. i: [],
  4163. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  4164. li: [],
  4165. ol: [],
  4166. p: [],
  4167. pre: [],
  4168. s: [],
  4169. small: [],
  4170. span: [],
  4171. sub: [],
  4172. sup: [],
  4173. strong: [],
  4174. u: [],
  4175. ul: []
  4176. };
  4177. /**
  4178. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4179. *
  4180. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4181. */
  4182. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
  4183. /**
  4184. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4185. *
  4186. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4187. */
  4188. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  4189. function allowedAttribute(attr, allowedAttributeList) {
  4190. var attrName = attr.nodeName.toLowerCase();
  4191. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4192. if (uriAttrs.indexOf(attrName) !== -1) {
  4193. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4194. }
  4195. return true;
  4196. }
  4197. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4198. return attrRegex instanceof RegExp;
  4199. }); // Check if a regular expression validates the attribute.
  4200. for (var i = 0, len = regExp.length; i < len; i++) {
  4201. if (attrName.match(regExp[i])) {
  4202. return true;
  4203. }
  4204. }
  4205. return false;
  4206. }
  4207. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4208. if (unsafeHtml.length === 0) {
  4209. return unsafeHtml;
  4210. }
  4211. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4212. return sanitizeFn(unsafeHtml);
  4213. }
  4214. var domParser = new window.DOMParser();
  4215. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4216. var whitelistKeys = Object.keys(whiteList);
  4217. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4218. var _loop = function _loop(i, len) {
  4219. var el = elements[i];
  4220. var elName = el.nodeName.toLowerCase();
  4221. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4222. el.parentNode.removeChild(el);
  4223. return "continue";
  4224. }
  4225. var attributeList = [].slice.call(el.attributes);
  4226. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4227. attributeList.forEach(function (attr) {
  4228. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4229. el.removeAttribute(attr.nodeName);
  4230. }
  4231. });
  4232. };
  4233. for (var i = 0, len = elements.length; i < len; i++) {
  4234. var _ret = _loop(i);
  4235. if (_ret === "continue") continue;
  4236. }
  4237. return createdDocument.body.innerHTML;
  4238. }
  4239. /**
  4240. * ------------------------------------------------------------------------
  4241. * Constants
  4242. * ------------------------------------------------------------------------
  4243. */
  4244. var NAME$6 = 'tooltip';
  4245. var VERSION$6 = '4.5.0';
  4246. var DATA_KEY$6 = 'bs.tooltip';
  4247. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4248. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4249. var CLASS_PREFIX = 'bs-tooltip';
  4250. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4251. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4252. var DefaultType$4 = {
  4253. animation: 'boolean',
  4254. template: 'string',
  4255. title: '(string|element|function)',
  4256. trigger: 'string',
  4257. delay: '(number|object)',
  4258. html: 'boolean',
  4259. selector: '(string|boolean)',
  4260. placement: '(string|function)',
  4261. offset: '(number|string|function)',
  4262. container: '(string|element|boolean)',
  4263. fallbackPlacement: '(string|array)',
  4264. boundary: '(string|element)',
  4265. sanitize: 'boolean',
  4266. sanitizeFn: '(null|function)',
  4267. whiteList: 'object',
  4268. popperConfig: '(null|object)'
  4269. };
  4270. var AttachmentMap = {
  4271. AUTO: 'auto',
  4272. TOP: 'top',
  4273. RIGHT: 'right',
  4274. BOTTOM: 'bottom',
  4275. LEFT: 'left'
  4276. };
  4277. var Default$4 = {
  4278. animation: true,
  4279. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4280. trigger: 'hover focus',
  4281. title: '',
  4282. delay: 0,
  4283. html: false,
  4284. selector: false,
  4285. placement: 'top',
  4286. offset: 0,
  4287. container: false,
  4288. fallbackPlacement: 'flip',
  4289. boundary: 'scrollParent',
  4290. sanitize: true,
  4291. sanitizeFn: null,
  4292. whiteList: DefaultWhitelist,
  4293. popperConfig: null
  4294. };
  4295. var HOVER_STATE_SHOW = 'show';
  4296. var HOVER_STATE_OUT = 'out';
  4297. var Event = {
  4298. HIDE: "hide" + EVENT_KEY$6,
  4299. HIDDEN: "hidden" + EVENT_KEY$6,
  4300. SHOW: "show" + EVENT_KEY$6,
  4301. SHOWN: "shown" + EVENT_KEY$6,
  4302. INSERTED: "inserted" + EVENT_KEY$6,
  4303. CLICK: "click" + EVENT_KEY$6,
  4304. FOCUSIN: "focusin" + EVENT_KEY$6,
  4305. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4306. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4307. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4308. };
  4309. var CLASS_NAME_FADE$2 = 'fade';
  4310. var CLASS_NAME_SHOW$4 = 'show';
  4311. var SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  4312. var SELECTOR_ARROW = '.arrow';
  4313. var TRIGGER_HOVER = 'hover';
  4314. var TRIGGER_FOCUS = 'focus';
  4315. var TRIGGER_CLICK = 'click';
  4316. var TRIGGER_MANUAL = 'manual';
  4317. /**
  4318. * ------------------------------------------------------------------------
  4319. * Class Definition
  4320. * ------------------------------------------------------------------------
  4321. */
  4322. var Tooltip = /*#__PURE__*/function () {
  4323. function Tooltip(element, config) {
  4324. if (typeof Popper === 'undefined') {
  4325. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4326. } // private
  4327. this._isEnabled = true;
  4328. this._timeout = 0;
  4329. this._hoverState = '';
  4330. this._activeTrigger = {};
  4331. this._popper = null; // Protected
  4332. this.element = element;
  4333. this.config = this._getConfig(config);
  4334. this.tip = null;
  4335. this._setListeners();
  4336. } // Getters
  4337. var _proto = Tooltip.prototype;
  4338. // Public
  4339. _proto.enable = function enable() {
  4340. this._isEnabled = true;
  4341. };
  4342. _proto.disable = function disable() {
  4343. this._isEnabled = false;
  4344. };
  4345. _proto.toggleEnabled = function toggleEnabled() {
  4346. this._isEnabled = !this._isEnabled;
  4347. };
  4348. _proto.toggle = function toggle(event) {
  4349. if (!this._isEnabled) {
  4350. return;
  4351. }
  4352. if (event) {
  4353. var dataKey = this.constructor.DATA_KEY;
  4354. var context = $(event.currentTarget).data(dataKey);
  4355. if (!context) {
  4356. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4357. $(event.currentTarget).data(dataKey, context);
  4358. }
  4359. context._activeTrigger.click = !context._activeTrigger.click;
  4360. if (context._isWithActiveTrigger()) {
  4361. context._enter(null, context);
  4362. } else {
  4363. context._leave(null, context);
  4364. }
  4365. } else {
  4366. if ($(this.getTipElement()).hasClass(CLASS_NAME_SHOW$4)) {
  4367. this._leave(null, this);
  4368. return;
  4369. }
  4370. this._enter(null, this);
  4371. }
  4372. };
  4373. _proto.dispose = function dispose() {
  4374. clearTimeout(this._timeout);
  4375. $.removeData(this.element, this.constructor.DATA_KEY);
  4376. $(this.element).off(this.constructor.EVENT_KEY);
  4377. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4378. if (this.tip) {
  4379. $(this.tip).remove();
  4380. }
  4381. this._isEnabled = null;
  4382. this._timeout = null;
  4383. this._hoverState = null;
  4384. this._activeTrigger = null;
  4385. if (this._popper) {
  4386. this._popper.destroy();
  4387. }
  4388. this._popper = null;
  4389. this.element = null;
  4390. this.config = null;
  4391. this.tip = null;
  4392. };
  4393. _proto.show = function show() {
  4394. var _this = this;
  4395. if ($(this.element).css('display') === 'none') {
  4396. throw new Error('Please use show on visible elements');
  4397. }
  4398. var showEvent = $.Event(this.constructor.Event.SHOW);
  4399. if (this.isWithContent() && this._isEnabled) {
  4400. $(this.element).trigger(showEvent);
  4401. var shadowRoot = Util.findShadowRoot(this.element);
  4402. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4403. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4404. return;
  4405. }
  4406. var tip = this.getTipElement();
  4407. var tipId = Util.getUID(this.constructor.NAME);
  4408. tip.setAttribute('id', tipId);
  4409. this.element.setAttribute('aria-describedby', tipId);
  4410. this.setContent();
  4411. if (this.config.animation) {
  4412. $(tip).addClass(CLASS_NAME_FADE$2);
  4413. }
  4414. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4415. var attachment = this._getAttachment(placement);
  4416. this.addAttachmentClass(attachment);
  4417. var container = this._getContainer();
  4418. $(tip).data(this.constructor.DATA_KEY, this);
  4419. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4420. $(tip).appendTo(container);
  4421. }
  4422. $(this.element).trigger(this.constructor.Event.INSERTED);
  4423. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4424. $(tip).addClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we add extra
  4425. // empty mouseover listeners to the body's immediate children;
  4426. // only needed because of broken event delegation on iOS
  4427. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4428. if ('ontouchstart' in document.documentElement) {
  4429. $(document.body).children().on('mouseover', null, $.noop);
  4430. }
  4431. var complete = function complete() {
  4432. if (_this.config.animation) {
  4433. _this._fixTransition();
  4434. }
  4435. var prevHoverState = _this._hoverState;
  4436. _this._hoverState = null;
  4437. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4438. if (prevHoverState === HOVER_STATE_OUT) {
  4439. _this._leave(null, _this);
  4440. }
  4441. };
  4442. if ($(this.tip).hasClass(CLASS_NAME_FADE$2)) {
  4443. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4444. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4445. } else {
  4446. complete();
  4447. }
  4448. }
  4449. };
  4450. _proto.hide = function hide(callback) {
  4451. var _this2 = this;
  4452. var tip = this.getTipElement();
  4453. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4454. var complete = function complete() {
  4455. if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
  4456. tip.parentNode.removeChild(tip);
  4457. }
  4458. _this2._cleanTipClass();
  4459. _this2.element.removeAttribute('aria-describedby');
  4460. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4461. if (_this2._popper !== null) {
  4462. _this2._popper.destroy();
  4463. }
  4464. if (callback) {
  4465. callback();
  4466. }
  4467. };
  4468. $(this.element).trigger(hideEvent);
  4469. if (hideEvent.isDefaultPrevented()) {
  4470. return;
  4471. }
  4472. $(tip).removeClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra
  4473. // empty mouseover listeners we added for iOS support
  4474. if ('ontouchstart' in document.documentElement) {
  4475. $(document.body).children().off('mouseover', null, $.noop);
  4476. }
  4477. this._activeTrigger[TRIGGER_CLICK] = false;
  4478. this._activeTrigger[TRIGGER_FOCUS] = false;
  4479. this._activeTrigger[TRIGGER_HOVER] = false;
  4480. if ($(this.tip).hasClass(CLASS_NAME_FADE$2)) {
  4481. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4482. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4483. } else {
  4484. complete();
  4485. }
  4486. this._hoverState = '';
  4487. };
  4488. _proto.update = function update() {
  4489. if (this._popper !== null) {
  4490. this._popper.scheduleUpdate();
  4491. }
  4492. } // Protected
  4493. ;
  4494. _proto.isWithContent = function isWithContent() {
  4495. return Boolean(this.getTitle());
  4496. };
  4497. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4498. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4499. };
  4500. _proto.getTipElement = function getTipElement() {
  4501. this.tip = this.tip || $(this.config.template)[0];
  4502. return this.tip;
  4503. };
  4504. _proto.setContent = function setContent() {
  4505. var tip = this.getTipElement();
  4506. this.setElementContent($(tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle());
  4507. $(tip).removeClass(CLASS_NAME_FADE$2 + " " + CLASS_NAME_SHOW$4);
  4508. };
  4509. _proto.setElementContent = function setElementContent($element, content) {
  4510. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4511. // Content is a DOM node or a jQuery
  4512. if (this.config.html) {
  4513. if (!$(content).parent().is($element)) {
  4514. $element.empty().append(content);
  4515. }
  4516. } else {
  4517. $element.text($(content).text());
  4518. }
  4519. return;
  4520. }
  4521. if (this.config.html) {
  4522. if (this.config.sanitize) {
  4523. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4524. }
  4525. $element.html(content);
  4526. } else {
  4527. $element.text(content);
  4528. }
  4529. };
  4530. _proto.getTitle = function getTitle() {
  4531. var title = this.element.getAttribute('data-original-title');
  4532. if (!title) {
  4533. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4534. }
  4535. return title;
  4536. } // Private
  4537. ;
  4538. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4539. var _this3 = this;
  4540. var defaultBsConfig = {
  4541. placement: attachment,
  4542. modifiers: {
  4543. offset: this._getOffset(),
  4544. flip: {
  4545. behavior: this.config.fallbackPlacement
  4546. },
  4547. arrow: {
  4548. element: SELECTOR_ARROW
  4549. },
  4550. preventOverflow: {
  4551. boundariesElement: this.config.boundary
  4552. }
  4553. },
  4554. onCreate: function onCreate(data) {
  4555. if (data.originalPlacement !== data.placement) {
  4556. _this3._handlePopperPlacementChange(data);
  4557. }
  4558. },
  4559. onUpdate: function onUpdate(data) {
  4560. return _this3._handlePopperPlacementChange(data);
  4561. }
  4562. };
  4563. return _objectSpread2(_objectSpread2({}, defaultBsConfig), this.config.popperConfig);
  4564. };
  4565. _proto._getOffset = function _getOffset() {
  4566. var _this4 = this;
  4567. var offset = {};
  4568. if (typeof this.config.offset === 'function') {
  4569. offset.fn = function (data) {
  4570. data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this4.config.offset(data.offsets, _this4.element) || {});
  4571. return data;
  4572. };
  4573. } else {
  4574. offset.offset = this.config.offset;
  4575. }
  4576. return offset;
  4577. };
  4578. _proto._getContainer = function _getContainer() {
  4579. if (this.config.container === false) {
  4580. return document.body;
  4581. }
  4582. if (Util.isElement(this.config.container)) {
  4583. return $(this.config.container);
  4584. }
  4585. return $(document).find(this.config.container);
  4586. };
  4587. _proto._getAttachment = function _getAttachment(placement) {
  4588. return AttachmentMap[placement.toUpperCase()];
  4589. };
  4590. _proto._setListeners = function _setListeners() {
  4591. var _this5 = this;
  4592. var triggers = this.config.trigger.split(' ');
  4593. triggers.forEach(function (trigger) {
  4594. if (trigger === 'click') {
  4595. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4596. return _this5.toggle(event);
  4597. });
  4598. } else if (trigger !== TRIGGER_MANUAL) {
  4599. var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4600. var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4601. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4602. return _this5._enter(event);
  4603. }).on(eventOut, _this5.config.selector, function (event) {
  4604. return _this5._leave(event);
  4605. });
  4606. }
  4607. });
  4608. this._hideModalHandler = function () {
  4609. if (_this5.element) {
  4610. _this5.hide();
  4611. }
  4612. };
  4613. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4614. if (this.config.selector) {
  4615. this.config = _objectSpread2(_objectSpread2({}, this.config), {}, {
  4616. trigger: 'manual',
  4617. selector: ''
  4618. });
  4619. } else {
  4620. this._fixTitle();
  4621. }
  4622. };
  4623. _proto._fixTitle = function _fixTitle() {
  4624. var titleType = typeof this.element.getAttribute('data-original-title');
  4625. if (this.element.getAttribute('title') || titleType !== 'string') {
  4626. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4627. this.element.setAttribute('title', '');
  4628. }
  4629. };
  4630. _proto._enter = function _enter(event, context) {
  4631. var dataKey = this.constructor.DATA_KEY;
  4632. context = context || $(event.currentTarget).data(dataKey);
  4633. if (!context) {
  4634. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4635. $(event.currentTarget).data(dataKey, context);
  4636. }
  4637. if (event) {
  4638. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  4639. }
  4640. if ($(context.getTipElement()).hasClass(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) {
  4641. context._hoverState = HOVER_STATE_SHOW;
  4642. return;
  4643. }
  4644. clearTimeout(context._timeout);
  4645. context._hoverState = HOVER_STATE_SHOW;
  4646. if (!context.config.delay || !context.config.delay.show) {
  4647. context.show();
  4648. return;
  4649. }
  4650. context._timeout = setTimeout(function () {
  4651. if (context._hoverState === HOVER_STATE_SHOW) {
  4652. context.show();
  4653. }
  4654. }, context.config.delay.show);
  4655. };
  4656. _proto._leave = function _leave(event, context) {
  4657. var dataKey = this.constructor.DATA_KEY;
  4658. context = context || $(event.currentTarget).data(dataKey);
  4659. if (!context) {
  4660. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4661. $(event.currentTarget).data(dataKey, context);
  4662. }
  4663. if (event) {
  4664. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
  4665. }
  4666. if (context._isWithActiveTrigger()) {
  4667. return;
  4668. }
  4669. clearTimeout(context._timeout);
  4670. context._hoverState = HOVER_STATE_OUT;
  4671. if (!context.config.delay || !context.config.delay.hide) {
  4672. context.hide();
  4673. return;
  4674. }
  4675. context._timeout = setTimeout(function () {
  4676. if (context._hoverState === HOVER_STATE_OUT) {
  4677. context.hide();
  4678. }
  4679. }, context.config.delay.hide);
  4680. };
  4681. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4682. for (var trigger in this._activeTrigger) {
  4683. if (this._activeTrigger[trigger]) {
  4684. return true;
  4685. }
  4686. }
  4687. return false;
  4688. };
  4689. _proto._getConfig = function _getConfig(config) {
  4690. var dataAttributes = $(this.element).data();
  4691. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4692. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4693. delete dataAttributes[dataAttr];
  4694. }
  4695. });
  4696. config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), dataAttributes), typeof config === 'object' && config ? config : {});
  4697. if (typeof config.delay === 'number') {
  4698. config.delay = {
  4699. show: config.delay,
  4700. hide: config.delay
  4701. };
  4702. }
  4703. if (typeof config.title === 'number') {
  4704. config.title = config.title.toString();
  4705. }
  4706. if (typeof config.content === 'number') {
  4707. config.content = config.content.toString();
  4708. }
  4709. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4710. if (config.sanitize) {
  4711. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4712. }
  4713. return config;
  4714. };
  4715. _proto._getDelegateConfig = function _getDelegateConfig() {
  4716. var config = {};
  4717. if (this.config) {
  4718. for (var key in this.config) {
  4719. if (this.constructor.Default[key] !== this.config[key]) {
  4720. config[key] = this.config[key];
  4721. }
  4722. }
  4723. }
  4724. return config;
  4725. };
  4726. _proto._cleanTipClass = function _cleanTipClass() {
  4727. var $tip = $(this.getTipElement());
  4728. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4729. if (tabClass !== null && tabClass.length) {
  4730. $tip.removeClass(tabClass.join(''));
  4731. }
  4732. };
  4733. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4734. this.tip = popperData.instance.popper;
  4735. this._cleanTipClass();
  4736. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4737. };
  4738. _proto._fixTransition = function _fixTransition() {
  4739. var tip = this.getTipElement();
  4740. var initConfigAnimation = this.config.animation;
  4741. if (tip.getAttribute('x-placement') !== null) {
  4742. return;
  4743. }
  4744. $(tip).removeClass(CLASS_NAME_FADE$2);
  4745. this.config.animation = false;
  4746. this.hide();
  4747. this.show();
  4748. this.config.animation = initConfigAnimation;
  4749. } // Static
  4750. ;
  4751. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4752. return this.each(function () {
  4753. var data = $(this).data(DATA_KEY$6);
  4754. var _config = typeof config === 'object' && config;
  4755. if (!data && /dispose|hide/.test(config)) {
  4756. return;
  4757. }
  4758. if (!data) {
  4759. data = new Tooltip(this, _config);
  4760. $(this).data(DATA_KEY$6, data);
  4761. }
  4762. if (typeof config === 'string') {
  4763. if (typeof data[config] === 'undefined') {
  4764. throw new TypeError("No method named \"" + config + "\"");
  4765. }
  4766. data[config]();
  4767. }
  4768. });
  4769. };
  4770. _createClass(Tooltip, null, [{
  4771. key: "VERSION",
  4772. get: function get() {
  4773. return VERSION$6;
  4774. }
  4775. }, {
  4776. key: "Default",
  4777. get: function get() {
  4778. return Default$4;
  4779. }
  4780. }, {
  4781. key: "NAME",
  4782. get: function get() {
  4783. return NAME$6;
  4784. }
  4785. }, {
  4786. key: "DATA_KEY",
  4787. get: function get() {
  4788. return DATA_KEY$6;
  4789. }
  4790. }, {
  4791. key: "Event",
  4792. get: function get() {
  4793. return Event;
  4794. }
  4795. }, {
  4796. key: "EVENT_KEY",
  4797. get: function get() {
  4798. return EVENT_KEY$6;
  4799. }
  4800. }, {
  4801. key: "DefaultType",
  4802. get: function get() {
  4803. return DefaultType$4;
  4804. }
  4805. }]);
  4806. return Tooltip;
  4807. }();
  4808. /**
  4809. * ------------------------------------------------------------------------
  4810. * jQuery
  4811. * ------------------------------------------------------------------------
  4812. */
  4813. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4814. $.fn[NAME$6].Constructor = Tooltip;
  4815. $.fn[NAME$6].noConflict = function () {
  4816. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4817. return Tooltip._jQueryInterface;
  4818. };
  4819. /**
  4820. * ------------------------------------------------------------------------
  4821. * Constants
  4822. * ------------------------------------------------------------------------
  4823. */
  4824. var NAME$7 = 'popover';
  4825. var VERSION$7 = '4.5.0';
  4826. var DATA_KEY$7 = 'bs.popover';
  4827. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4828. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4829. var CLASS_PREFIX$1 = 'bs-popover';
  4830. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4831. var Default$5 = _objectSpread2(_objectSpread2({}, Tooltip.Default), {}, {
  4832. placement: 'right',
  4833. trigger: 'click',
  4834. content: '',
  4835. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4836. });
  4837. var DefaultType$5 = _objectSpread2(_objectSpread2({}, Tooltip.DefaultType), {}, {
  4838. content: '(string|element|function)'
  4839. });
  4840. var CLASS_NAME_FADE$3 = 'fade';
  4841. var CLASS_NAME_SHOW$5 = 'show';
  4842. var SELECTOR_TITLE = '.popover-header';
  4843. var SELECTOR_CONTENT = '.popover-body';
  4844. var Event$1 = {
  4845. HIDE: "hide" + EVENT_KEY$7,
  4846. HIDDEN: "hidden" + EVENT_KEY$7,
  4847. SHOW: "show" + EVENT_KEY$7,
  4848. SHOWN: "shown" + EVENT_KEY$7,
  4849. INSERTED: "inserted" + EVENT_KEY$7,
  4850. CLICK: "click" + EVENT_KEY$7,
  4851. FOCUSIN: "focusin" + EVENT_KEY$7,
  4852. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4853. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4854. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4855. };
  4856. /**
  4857. * ------------------------------------------------------------------------
  4858. * Class Definition
  4859. * ------------------------------------------------------------------------
  4860. */
  4861. var Popover = /*#__PURE__*/function (_Tooltip) {
  4862. _inheritsLoose(Popover, _Tooltip);
  4863. function Popover() {
  4864. return _Tooltip.apply(this, arguments) || this;
  4865. }
  4866. var _proto = Popover.prototype;
  4867. // Overrides
  4868. _proto.isWithContent = function isWithContent() {
  4869. return this.getTitle() || this._getContent();
  4870. };
  4871. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4872. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4873. };
  4874. _proto.getTipElement = function getTipElement() {
  4875. this.tip = this.tip || $(this.config.template)[0];
  4876. return this.tip;
  4877. };
  4878. _proto.setContent = function setContent() {
  4879. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4880. this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle());
  4881. var content = this._getContent();
  4882. if (typeof content === 'function') {
  4883. content = content.call(this.element);
  4884. }
  4885. this.setElementContent($tip.find(SELECTOR_CONTENT), content);
  4886. $tip.removeClass(CLASS_NAME_FADE$3 + " " + CLASS_NAME_SHOW$5);
  4887. } // Private
  4888. ;
  4889. _proto._getContent = function _getContent() {
  4890. return this.element.getAttribute('data-content') || this.config.content;
  4891. };
  4892. _proto._cleanTipClass = function _cleanTipClass() {
  4893. var $tip = $(this.getTipElement());
  4894. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4895. if (tabClass !== null && tabClass.length > 0) {
  4896. $tip.removeClass(tabClass.join(''));
  4897. }
  4898. } // Static
  4899. ;
  4900. Popover._jQueryInterface = function _jQueryInterface(config) {
  4901. return this.each(function () {
  4902. var data = $(this).data(DATA_KEY$7);
  4903. var _config = typeof config === 'object' ? config : null;
  4904. if (!data && /dispose|hide/.test(config)) {
  4905. return;
  4906. }
  4907. if (!data) {
  4908. data = new Popover(this, _config);
  4909. $(this).data(DATA_KEY$7, data);
  4910. }
  4911. if (typeof config === 'string') {
  4912. if (typeof data[config] === 'undefined') {
  4913. throw new TypeError("No method named \"" + config + "\"");
  4914. }
  4915. data[config]();
  4916. }
  4917. });
  4918. };
  4919. _createClass(Popover, null, [{
  4920. key: "VERSION",
  4921. // Getters
  4922. get: function get() {
  4923. return VERSION$7;
  4924. }
  4925. }, {
  4926. key: "Default",
  4927. get: function get() {
  4928. return Default$5;
  4929. }
  4930. }, {
  4931. key: "NAME",
  4932. get: function get() {
  4933. return NAME$7;
  4934. }
  4935. }, {
  4936. key: "DATA_KEY",
  4937. get: function get() {
  4938. return DATA_KEY$7;
  4939. }
  4940. }, {
  4941. key: "Event",
  4942. get: function get() {
  4943. return Event$1;
  4944. }
  4945. }, {
  4946. key: "EVENT_KEY",
  4947. get: function get() {
  4948. return EVENT_KEY$7;
  4949. }
  4950. }, {
  4951. key: "DefaultType",
  4952. get: function get() {
  4953. return DefaultType$5;
  4954. }
  4955. }]);
  4956. return Popover;
  4957. }(Tooltip);
  4958. /**
  4959. * ------------------------------------------------------------------------
  4960. * jQuery
  4961. * ------------------------------------------------------------------------
  4962. */
  4963. $.fn[NAME$7] = Popover._jQueryInterface;
  4964. $.fn[NAME$7].Constructor = Popover;
  4965. $.fn[NAME$7].noConflict = function () {
  4966. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4967. return Popover._jQueryInterface;
  4968. };
  4969. /**
  4970. * ------------------------------------------------------------------------
  4971. * Constants
  4972. * ------------------------------------------------------------------------
  4973. */
  4974. var NAME$8 = 'scrollspy';
  4975. var VERSION$8 = '4.5.0';
  4976. var DATA_KEY$8 = 'bs.scrollspy';
  4977. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4978. var DATA_API_KEY$6 = '.data-api';
  4979. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4980. var Default$6 = {
  4981. offset: 10,
  4982. method: 'auto',
  4983. target: ''
  4984. };
  4985. var DefaultType$6 = {
  4986. offset: 'number',
  4987. method: 'string',
  4988. target: '(string|element)'
  4989. };
  4990. var EVENT_ACTIVATE = "activate" + EVENT_KEY$8;
  4991. var EVENT_SCROLL = "scroll" + EVENT_KEY$8;
  4992. var EVENT_LOAD_DATA_API$2 = "load" + EVENT_KEY$8 + DATA_API_KEY$6;
  4993. var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  4994. var CLASS_NAME_ACTIVE$2 = 'active';
  4995. var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
  4996. var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  4997. var SELECTOR_NAV_LINKS = '.nav-link';
  4998. var SELECTOR_NAV_ITEMS = '.nav-item';
  4999. var SELECTOR_LIST_ITEMS = '.list-group-item';
  5000. var SELECTOR_DROPDOWN = '.dropdown';
  5001. var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item';
  5002. var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  5003. var METHOD_OFFSET = 'offset';
  5004. var METHOD_POSITION = 'position';
  5005. /**
  5006. * ------------------------------------------------------------------------
  5007. * Class Definition
  5008. * ------------------------------------------------------------------------
  5009. */
  5010. var ScrollSpy = /*#__PURE__*/function () {
  5011. function ScrollSpy(element, config) {
  5012. var _this = this;
  5013. this._element = element;
  5014. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5015. this._config = this._getConfig(config);
  5016. this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + "," + (this._config.target + " " + SELECTOR_LIST_ITEMS + ",") + (this._config.target + " " + SELECTOR_DROPDOWN_ITEMS);
  5017. this._offsets = [];
  5018. this._targets = [];
  5019. this._activeTarget = null;
  5020. this._scrollHeight = 0;
  5021. $(this._scrollElement).on(EVENT_SCROLL, function (event) {
  5022. return _this._process(event);
  5023. });
  5024. this.refresh();
  5025. this._process();
  5026. } // Getters
  5027. var _proto = ScrollSpy.prototype;
  5028. // Public
  5029. _proto.refresh = function refresh() {
  5030. var _this2 = this;
  5031. var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
  5032. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5033. var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
  5034. this._offsets = [];
  5035. this._targets = [];
  5036. this._scrollHeight = this._getScrollHeight();
  5037. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5038. targets.map(function (element) {
  5039. var target;
  5040. var targetSelector = Util.getSelectorFromElement(element);
  5041. if (targetSelector) {
  5042. target = document.querySelector(targetSelector);
  5043. }
  5044. if (target) {
  5045. var targetBCR = target.getBoundingClientRect();
  5046. if (targetBCR.width || targetBCR.height) {
  5047. // TODO (fat): remove sketch reliance on jQuery position/offset
  5048. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5049. }
  5050. }
  5051. return null;
  5052. }).filter(function (item) {
  5053. return item;
  5054. }).sort(function (a, b) {
  5055. return a[0] - b[0];
  5056. }).forEach(function (item) {
  5057. _this2._offsets.push(item[0]);
  5058. _this2._targets.push(item[1]);
  5059. });
  5060. };
  5061. _proto.dispose = function dispose() {
  5062. $.removeData(this._element, DATA_KEY$8);
  5063. $(this._scrollElement).off(EVENT_KEY$8);
  5064. this._element = null;
  5065. this._scrollElement = null;
  5066. this._config = null;
  5067. this._selector = null;
  5068. this._offsets = null;
  5069. this._targets = null;
  5070. this._activeTarget = null;
  5071. this._scrollHeight = null;
  5072. } // Private
  5073. ;
  5074. _proto._getConfig = function _getConfig(config) {
  5075. config = _objectSpread2(_objectSpread2({}, Default$6), typeof config === 'object' && config ? config : {});
  5076. if (typeof config.target !== 'string' && Util.isElement(config.target)) {
  5077. var id = $(config.target).attr('id');
  5078. if (!id) {
  5079. id = Util.getUID(NAME$8);
  5080. $(config.target).attr('id', id);
  5081. }
  5082. config.target = "#" + id;
  5083. }
  5084. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5085. return config;
  5086. };
  5087. _proto._getScrollTop = function _getScrollTop() {
  5088. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5089. };
  5090. _proto._getScrollHeight = function _getScrollHeight() {
  5091. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5092. };
  5093. _proto._getOffsetHeight = function _getOffsetHeight() {
  5094. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5095. };
  5096. _proto._process = function _process() {
  5097. var scrollTop = this._getScrollTop() + this._config.offset;
  5098. var scrollHeight = this._getScrollHeight();
  5099. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5100. if (this._scrollHeight !== scrollHeight) {
  5101. this.refresh();
  5102. }
  5103. if (scrollTop >= maxScroll) {
  5104. var target = this._targets[this._targets.length - 1];
  5105. if (this._activeTarget !== target) {
  5106. this._activate(target);
  5107. }
  5108. return;
  5109. }
  5110. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5111. this._activeTarget = null;
  5112. this._clear();
  5113. return;
  5114. }
  5115. for (var i = this._offsets.length; i--;) {
  5116. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5117. if (isActiveTarget) {
  5118. this._activate(this._targets[i]);
  5119. }
  5120. }
  5121. };
  5122. _proto._activate = function _activate(target) {
  5123. this._activeTarget = target;
  5124. this._clear();
  5125. var queries = this._selector.split(',').map(function (selector) {
  5126. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5127. });
  5128. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5129. if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) {
  5130. $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE$2);
  5131. $link.addClass(CLASS_NAME_ACTIVE$2);
  5132. } else {
  5133. // Set triggered link as active
  5134. $link.addClass(CLASS_NAME_ACTIVE$2); // Set triggered links parents as active
  5135. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5136. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).addClass(CLASS_NAME_ACTIVE$2); // Handle special case when .nav-link is inside .nav-item
  5137. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE$2);
  5138. }
  5139. $(this._scrollElement).trigger(EVENT_ACTIVATE, {
  5140. relatedTarget: target
  5141. });
  5142. };
  5143. _proto._clear = function _clear() {
  5144. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5145. return node.classList.contains(CLASS_NAME_ACTIVE$2);
  5146. }).forEach(function (node) {
  5147. return node.classList.remove(CLASS_NAME_ACTIVE$2);
  5148. });
  5149. } // Static
  5150. ;
  5151. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5152. return this.each(function () {
  5153. var data = $(this).data(DATA_KEY$8);
  5154. var _config = typeof config === 'object' && config;
  5155. if (!data) {
  5156. data = new ScrollSpy(this, _config);
  5157. $(this).data(DATA_KEY$8, data);
  5158. }
  5159. if (typeof config === 'string') {
  5160. if (typeof data[config] === 'undefined') {
  5161. throw new TypeError("No method named \"" + config + "\"");
  5162. }
  5163. data[config]();
  5164. }
  5165. });
  5166. };
  5167. _createClass(ScrollSpy, null, [{
  5168. key: "VERSION",
  5169. get: function get() {
  5170. return VERSION$8;
  5171. }
  5172. }, {
  5173. key: "Default",
  5174. get: function get() {
  5175. return Default$6;
  5176. }
  5177. }]);
  5178. return ScrollSpy;
  5179. }();
  5180. /**
  5181. * ------------------------------------------------------------------------
  5182. * Data Api implementation
  5183. * ------------------------------------------------------------------------
  5184. */
  5185. $(window).on(EVENT_LOAD_DATA_API$2, function () {
  5186. var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY));
  5187. var scrollSpysLength = scrollSpys.length;
  5188. for (var i = scrollSpysLength; i--;) {
  5189. var $spy = $(scrollSpys[i]);
  5190. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5191. }
  5192. });
  5193. /**
  5194. * ------------------------------------------------------------------------
  5195. * jQuery
  5196. * ------------------------------------------------------------------------
  5197. */
  5198. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5199. $.fn[NAME$8].Constructor = ScrollSpy;
  5200. $.fn[NAME$8].noConflict = function () {
  5201. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5202. return ScrollSpy._jQueryInterface;
  5203. };
  5204. /**
  5205. * ------------------------------------------------------------------------
  5206. * Constants
  5207. * ------------------------------------------------------------------------
  5208. */
  5209. var NAME$9 = 'tab';
  5210. var VERSION$9 = '4.5.0';
  5211. var DATA_KEY$9 = 'bs.tab';
  5212. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5213. var DATA_API_KEY$7 = '.data-api';
  5214. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5215. var EVENT_HIDE$3 = "hide" + EVENT_KEY$9;
  5216. var EVENT_HIDDEN$3 = "hidden" + EVENT_KEY$9;
  5217. var EVENT_SHOW$3 = "show" + EVENT_KEY$9;
  5218. var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9;
  5219. var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7;
  5220. var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
  5221. var CLASS_NAME_ACTIVE$3 = 'active';
  5222. var CLASS_NAME_DISABLED$1 = 'disabled';
  5223. var CLASS_NAME_FADE$4 = 'fade';
  5224. var CLASS_NAME_SHOW$6 = 'show';
  5225. var SELECTOR_DROPDOWN$1 = '.dropdown';
  5226. var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group';
  5227. var SELECTOR_ACTIVE$2 = '.active';
  5228. var SELECTOR_ACTIVE_UL = '> li > .active';
  5229. var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]';
  5230. var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  5231. var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active';
  5232. /**
  5233. * ------------------------------------------------------------------------
  5234. * Class Definition
  5235. * ------------------------------------------------------------------------
  5236. */
  5237. var Tab = /*#__PURE__*/function () {
  5238. function Tab(element) {
  5239. this._element = element;
  5240. } // Getters
  5241. var _proto = Tab.prototype;
  5242. // Public
  5243. _proto.show = function show() {
  5244. var _this = this;
  5245. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(CLASS_NAME_ACTIVE$3) || $(this._element).hasClass(CLASS_NAME_DISABLED$1)) {
  5246. return;
  5247. }
  5248. var target;
  5249. var previous;
  5250. var listElement = $(this._element).closest(SELECTOR_NAV_LIST_GROUP$1)[0];
  5251. var selector = Util.getSelectorFromElement(this._element);
  5252. if (listElement) {
  5253. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$2;
  5254. previous = $.makeArray($(listElement).find(itemSelector));
  5255. previous = previous[previous.length - 1];
  5256. }
  5257. var hideEvent = $.Event(EVENT_HIDE$3, {
  5258. relatedTarget: this._element
  5259. });
  5260. var showEvent = $.Event(EVENT_SHOW$3, {
  5261. relatedTarget: previous
  5262. });
  5263. if (previous) {
  5264. $(previous).trigger(hideEvent);
  5265. }
  5266. $(this._element).trigger(showEvent);
  5267. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5268. return;
  5269. }
  5270. if (selector) {
  5271. target = document.querySelector(selector);
  5272. }
  5273. this._activate(this._element, listElement);
  5274. var complete = function complete() {
  5275. var hiddenEvent = $.Event(EVENT_HIDDEN$3, {
  5276. relatedTarget: _this._element
  5277. });
  5278. var shownEvent = $.Event(EVENT_SHOWN$3, {
  5279. relatedTarget: previous
  5280. });
  5281. $(previous).trigger(hiddenEvent);
  5282. $(_this._element).trigger(shownEvent);
  5283. };
  5284. if (target) {
  5285. this._activate(target, target.parentNode, complete);
  5286. } else {
  5287. complete();
  5288. }
  5289. };
  5290. _proto.dispose = function dispose() {
  5291. $.removeData(this._element, DATA_KEY$9);
  5292. this._element = null;
  5293. } // Private
  5294. ;
  5295. _proto._activate = function _activate(element, container, callback) {
  5296. var _this2 = this;
  5297. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(SELECTOR_ACTIVE_UL) : $(container).children(SELECTOR_ACTIVE$2);
  5298. var active = activeElements[0];
  5299. var isTransitioning = callback && active && $(active).hasClass(CLASS_NAME_FADE$4);
  5300. var complete = function complete() {
  5301. return _this2._transitionComplete(element, active, callback);
  5302. };
  5303. if (active && isTransitioning) {
  5304. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5305. $(active).removeClass(CLASS_NAME_SHOW$6).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5306. } else {
  5307. complete();
  5308. }
  5309. };
  5310. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5311. if (active) {
  5312. $(active).removeClass(CLASS_NAME_ACTIVE$3);
  5313. var dropdownChild = $(active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0];
  5314. if (dropdownChild) {
  5315. $(dropdownChild).removeClass(CLASS_NAME_ACTIVE$3);
  5316. }
  5317. if (active.getAttribute('role') === 'tab') {
  5318. active.setAttribute('aria-selected', false);
  5319. }
  5320. }
  5321. $(element).addClass(CLASS_NAME_ACTIVE$3);
  5322. if (element.getAttribute('role') === 'tab') {
  5323. element.setAttribute('aria-selected', true);
  5324. }
  5325. Util.reflow(element);
  5326. if (element.classList.contains(CLASS_NAME_FADE$4)) {
  5327. element.classList.add(CLASS_NAME_SHOW$6);
  5328. }
  5329. if (element.parentNode && $(element.parentNode).hasClass(CLASS_NAME_DROPDOWN_MENU)) {
  5330. var dropdownElement = $(element).closest(SELECTOR_DROPDOWN$1)[0];
  5331. if (dropdownElement) {
  5332. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE$1));
  5333. $(dropdownToggleList).addClass(CLASS_NAME_ACTIVE$3);
  5334. }
  5335. element.setAttribute('aria-expanded', true);
  5336. }
  5337. if (callback) {
  5338. callback();
  5339. }
  5340. } // Static
  5341. ;
  5342. Tab._jQueryInterface = function _jQueryInterface(config) {
  5343. return this.each(function () {
  5344. var $this = $(this);
  5345. var data = $this.data(DATA_KEY$9);
  5346. if (!data) {
  5347. data = new Tab(this);
  5348. $this.data(DATA_KEY$9, data);
  5349. }
  5350. if (typeof config === 'string') {
  5351. if (typeof data[config] === 'undefined') {
  5352. throw new TypeError("No method named \"" + config + "\"");
  5353. }
  5354. data[config]();
  5355. }
  5356. });
  5357. };
  5358. _createClass(Tab, null, [{
  5359. key: "VERSION",
  5360. get: function get() {
  5361. return VERSION$9;
  5362. }
  5363. }]);
  5364. return Tab;
  5365. }();
  5366. /**
  5367. * ------------------------------------------------------------------------
  5368. * Data Api implementation
  5369. * ------------------------------------------------------------------------
  5370. */
  5371. $(document).on(EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$4, function (event) {
  5372. event.preventDefault();
  5373. Tab._jQueryInterface.call($(this), 'show');
  5374. });
  5375. /**
  5376. * ------------------------------------------------------------------------
  5377. * jQuery
  5378. * ------------------------------------------------------------------------
  5379. */
  5380. $.fn[NAME$9] = Tab._jQueryInterface;
  5381. $.fn[NAME$9].Constructor = Tab;
  5382. $.fn[NAME$9].noConflict = function () {
  5383. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5384. return Tab._jQueryInterface;
  5385. };
  5386. /**
  5387. * ------------------------------------------------------------------------
  5388. * Constants
  5389. * ------------------------------------------------------------------------
  5390. */
  5391. var NAME$a = 'toast';
  5392. var VERSION$a = '4.5.0';
  5393. var DATA_KEY$a = 'bs.toast';
  5394. var EVENT_KEY$a = "." + DATA_KEY$a;
  5395. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5396. var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a;
  5397. var EVENT_HIDE$4 = "hide" + EVENT_KEY$a;
  5398. var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a;
  5399. var EVENT_SHOW$4 = "show" + EVENT_KEY$a;
  5400. var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a;
  5401. var CLASS_NAME_FADE$5 = 'fade';
  5402. var CLASS_NAME_HIDE = 'hide';
  5403. var CLASS_NAME_SHOW$7 = 'show';
  5404. var CLASS_NAME_SHOWING = 'showing';
  5405. var DefaultType$7 = {
  5406. animation: 'boolean',
  5407. autohide: 'boolean',
  5408. delay: 'number'
  5409. };
  5410. var Default$7 = {
  5411. animation: true,
  5412. autohide: true,
  5413. delay: 500
  5414. };
  5415. var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]';
  5416. /**
  5417. * ------------------------------------------------------------------------
  5418. * Class Definition
  5419. * ------------------------------------------------------------------------
  5420. */
  5421. var Toast = /*#__PURE__*/function () {
  5422. function Toast(element, config) {
  5423. this._element = element;
  5424. this._config = this._getConfig(config);
  5425. this._timeout = null;
  5426. this._setListeners();
  5427. } // Getters
  5428. var _proto = Toast.prototype;
  5429. // Public
  5430. _proto.show = function show() {
  5431. var _this = this;
  5432. var showEvent = $.Event(EVENT_SHOW$4);
  5433. $(this._element).trigger(showEvent);
  5434. if (showEvent.isDefaultPrevented()) {
  5435. return;
  5436. }
  5437. if (this._config.animation) {
  5438. this._element.classList.add(CLASS_NAME_FADE$5);
  5439. }
  5440. var complete = function complete() {
  5441. _this._element.classList.remove(CLASS_NAME_SHOWING);
  5442. _this._element.classList.add(CLASS_NAME_SHOW$7);
  5443. $(_this._element).trigger(EVENT_SHOWN$4);
  5444. if (_this._config.autohide) {
  5445. _this._timeout = setTimeout(function () {
  5446. _this.hide();
  5447. }, _this._config.delay);
  5448. }
  5449. };
  5450. this._element.classList.remove(CLASS_NAME_HIDE);
  5451. Util.reflow(this._element);
  5452. this._element.classList.add(CLASS_NAME_SHOWING);
  5453. if (this._config.animation) {
  5454. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5455. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5456. } else {
  5457. complete();
  5458. }
  5459. };
  5460. _proto.hide = function hide() {
  5461. if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  5462. return;
  5463. }
  5464. var hideEvent = $.Event(EVENT_HIDE$4);
  5465. $(this._element).trigger(hideEvent);
  5466. if (hideEvent.isDefaultPrevented()) {
  5467. return;
  5468. }
  5469. this._close();
  5470. };
  5471. _proto.dispose = function dispose() {
  5472. clearTimeout(this._timeout);
  5473. this._timeout = null;
  5474. if (this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  5475. this._element.classList.remove(CLASS_NAME_SHOW$7);
  5476. }
  5477. $(this._element).off(EVENT_CLICK_DISMISS$1);
  5478. $.removeData(this._element, DATA_KEY$a);
  5479. this._element = null;
  5480. this._config = null;
  5481. } // Private
  5482. ;
  5483. _proto._getConfig = function _getConfig(config) {
  5484. config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$7), $(this._element).data()), typeof config === 'object' && config ? config : {});
  5485. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5486. return config;
  5487. };
  5488. _proto._setListeners = function _setListeners() {
  5489. var _this2 = this;
  5490. $(this._element).on(EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, function () {
  5491. return _this2.hide();
  5492. });
  5493. };
  5494. _proto._close = function _close() {
  5495. var _this3 = this;
  5496. var complete = function complete() {
  5497. _this3._element.classList.add(CLASS_NAME_HIDE);
  5498. $(_this3._element).trigger(EVENT_HIDDEN$4);
  5499. };
  5500. this._element.classList.remove(CLASS_NAME_SHOW$7);
  5501. if (this._config.animation) {
  5502. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5503. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5504. } else {
  5505. complete();
  5506. }
  5507. } // Static
  5508. ;
  5509. Toast._jQueryInterface = function _jQueryInterface(config) {
  5510. return this.each(function () {
  5511. var $element = $(this);
  5512. var data = $element.data(DATA_KEY$a);
  5513. var _config = typeof config === 'object' && config;
  5514. if (!data) {
  5515. data = new Toast(this, _config);
  5516. $element.data(DATA_KEY$a, data);
  5517. }
  5518. if (typeof config === 'string') {
  5519. if (typeof data[config] === 'undefined') {
  5520. throw new TypeError("No method named \"" + config + "\"");
  5521. }
  5522. data[config](this);
  5523. }
  5524. });
  5525. };
  5526. _createClass(Toast, null, [{
  5527. key: "VERSION",
  5528. get: function get() {
  5529. return VERSION$a;
  5530. }
  5531. }, {
  5532. key: "DefaultType",
  5533. get: function get() {
  5534. return DefaultType$7;
  5535. }
  5536. }, {
  5537. key: "Default",
  5538. get: function get() {
  5539. return Default$7;
  5540. }
  5541. }]);
  5542. return Toast;
  5543. }();
  5544. /**
  5545. * ------------------------------------------------------------------------
  5546. * jQuery
  5547. * ------------------------------------------------------------------------
  5548. */
  5549. $.fn[NAME$a] = Toast._jQueryInterface;
  5550. $.fn[NAME$a].Constructor = Toast;
  5551. $.fn[NAME$a].noConflict = function () {
  5552. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5553. return Toast._jQueryInterface;
  5554. };
  5555. exports.Alert = Alert;
  5556. exports.Button = Button;
  5557. exports.Carousel = Carousel;
  5558. exports.Collapse = Collapse;
  5559. exports.Dropdown = Dropdown;
  5560. exports.Modal = Modal;
  5561. exports.Popover = Popover;
  5562. exports.Scrollspy = ScrollSpy;
  5563. exports.Tab = Tab;
  5564. exports.Toast = Toast;
  5565. exports.Tooltip = Tooltip;
  5566. exports.Util = Util;
  5567. Object.defineProperty(exports, '__esModule', { value: true });
  5568. })));
  5569. //# sourceMappingURL=bootstrap.js.map
  5570. /***/ }),
  5571. /***/ "./node_modules/buffer/index.js":
  5572. /*!**************************************!*\
  5573. !*** ./node_modules/buffer/index.js ***!
  5574. \**************************************/
  5575. /*! no static exports found */
  5576. /***/ (function(module, exports, __webpack_require__) {
  5577. "use strict";
  5578. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5579. * The buffer module from node.js, for the browser.
  5580. *
  5581. * @author Feross Aboukhadijeh <http://feross.org>
  5582. * @license MIT
  5583. */
  5584. /* eslint-disable no-proto */
  5585. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5586. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5587. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5588. exports.Buffer = Buffer
  5589. exports.SlowBuffer = SlowBuffer
  5590. exports.INSPECT_MAX_BYTES = 50
  5591. /**
  5592. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5593. * === true Use Uint8Array implementation (fastest)
  5594. * === false Use Object implementation (most compatible, even IE6)
  5595. *
  5596. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5597. * Opera 11.6+, iOS 4.2+.
  5598. *
  5599. * Due to various browser bugs, sometimes the Object implementation will be used even
  5600. * when the browser supports typed arrays.
  5601. *
  5602. * Note:
  5603. *
  5604. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5605. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5606. *
  5607. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5608. *
  5609. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5610. * incorrect length in some situations.
  5611. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5612. * get the Object implementation, which is slower but behaves correctly.
  5613. */
  5614. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5615. ? global.TYPED_ARRAY_SUPPORT
  5616. : typedArraySupport()
  5617. /*
  5618. * Export kMaxLength after typed array support is determined.
  5619. */
  5620. exports.kMaxLength = kMaxLength()
  5621. function typedArraySupport () {
  5622. try {
  5623. var arr = new Uint8Array(1)
  5624. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5625. return arr.foo() === 42 && // typed array instances can be augmented
  5626. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5627. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5628. } catch (e) {
  5629. return false
  5630. }
  5631. }
  5632. function kMaxLength () {
  5633. return Buffer.TYPED_ARRAY_SUPPORT
  5634. ? 0x7fffffff
  5635. : 0x3fffffff
  5636. }
  5637. function createBuffer (that, length) {
  5638. if (kMaxLength() < length) {
  5639. throw new RangeError('Invalid typed array length')
  5640. }
  5641. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5642. // Return an augmented `Uint8Array` instance, for best performance
  5643. that = new Uint8Array(length)
  5644. that.__proto__ = Buffer.prototype
  5645. } else {
  5646. // Fallback: Return an object instance of the Buffer class
  5647. if (that === null) {
  5648. that = new Buffer(length)
  5649. }
  5650. that.length = length
  5651. }
  5652. return that
  5653. }
  5654. /**
  5655. * The Buffer constructor returns instances of `Uint8Array` that have their
  5656. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5657. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5658. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5659. * returns a single octet.
  5660. *
  5661. * The `Uint8Array` prototype remains unmodified.
  5662. */
  5663. function Buffer (arg, encodingOrOffset, length) {
  5664. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5665. return new Buffer(arg, encodingOrOffset, length)
  5666. }
  5667. // Common case.
  5668. if (typeof arg === 'number') {
  5669. if (typeof encodingOrOffset === 'string') {
  5670. throw new Error(
  5671. 'If encoding is specified then the first argument must be a string'
  5672. )
  5673. }
  5674. return allocUnsafe(this, arg)
  5675. }
  5676. return from(this, arg, encodingOrOffset, length)
  5677. }
  5678. Buffer.poolSize = 8192 // not used by this implementation
  5679. // TODO: Legacy, not needed anymore. Remove in next major version.
  5680. Buffer._augment = function (arr) {
  5681. arr.__proto__ = Buffer.prototype
  5682. return arr
  5683. }
  5684. function from (that, value, encodingOrOffset, length) {
  5685. if (typeof value === 'number') {
  5686. throw new TypeError('"value" argument must not be a number')
  5687. }
  5688. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5689. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5690. }
  5691. if (typeof value === 'string') {
  5692. return fromString(that, value, encodingOrOffset)
  5693. }
  5694. return fromObject(that, value)
  5695. }
  5696. /**
  5697. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5698. * if value is a number.
  5699. * Buffer.from(str[, encoding])
  5700. * Buffer.from(array)
  5701. * Buffer.from(buffer)
  5702. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5703. **/
  5704. Buffer.from = function (value, encodingOrOffset, length) {
  5705. return from(null, value, encodingOrOffset, length)
  5706. }
  5707. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5708. Buffer.prototype.__proto__ = Uint8Array.prototype
  5709. Buffer.__proto__ = Uint8Array
  5710. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5711. Buffer[Symbol.species] === Buffer) {
  5712. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5713. Object.defineProperty(Buffer, Symbol.species, {
  5714. value: null,
  5715. configurable: true
  5716. })
  5717. }
  5718. }
  5719. function assertSize (size) {
  5720. if (typeof size !== 'number') {
  5721. throw new TypeError('"size" argument must be a number')
  5722. } else if (size < 0) {
  5723. throw new RangeError('"size" argument must not be negative')
  5724. }
  5725. }
  5726. function alloc (that, size, fill, encoding) {
  5727. assertSize(size)
  5728. if (size <= 0) {
  5729. return createBuffer(that, size)
  5730. }
  5731. if (fill !== undefined) {
  5732. // Only pay attention to encoding if it's a string. This
  5733. // prevents accidentally sending in a number that would
  5734. // be interpretted as a start offset.
  5735. return typeof encoding === 'string'
  5736. ? createBuffer(that, size).fill(fill, encoding)
  5737. : createBuffer(that, size).fill(fill)
  5738. }
  5739. return createBuffer(that, size)
  5740. }
  5741. /**
  5742. * Creates a new filled Buffer instance.
  5743. * alloc(size[, fill[, encoding]])
  5744. **/
  5745. Buffer.alloc = function (size, fill, encoding) {
  5746. return alloc(null, size, fill, encoding)
  5747. }
  5748. function allocUnsafe (that, size) {
  5749. assertSize(size)
  5750. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5751. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5752. for (var i = 0; i < size; ++i) {
  5753. that[i] = 0
  5754. }
  5755. }
  5756. return that
  5757. }
  5758. /**
  5759. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5760. * */
  5761. Buffer.allocUnsafe = function (size) {
  5762. return allocUnsafe(null, size)
  5763. }
  5764. /**
  5765. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5766. */
  5767. Buffer.allocUnsafeSlow = function (size) {
  5768. return allocUnsafe(null, size)
  5769. }
  5770. function fromString (that, string, encoding) {
  5771. if (typeof encoding !== 'string' || encoding === '') {
  5772. encoding = 'utf8'
  5773. }
  5774. if (!Buffer.isEncoding(encoding)) {
  5775. throw new TypeError('"encoding" must be a valid string encoding')
  5776. }
  5777. var length = byteLength(string, encoding) | 0
  5778. that = createBuffer(that, length)
  5779. var actual = that.write(string, encoding)
  5780. if (actual !== length) {
  5781. // Writing a hex string, for example, that contains invalid characters will
  5782. // cause everything after the first invalid character to be ignored. (e.g.
  5783. // 'abxxcd' will be treated as 'ab')
  5784. that = that.slice(0, actual)
  5785. }
  5786. return that
  5787. }
  5788. function fromArrayLike (that, array) {
  5789. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5790. that = createBuffer(that, length)
  5791. for (var i = 0; i < length; i += 1) {
  5792. that[i] = array[i] & 255
  5793. }
  5794. return that
  5795. }
  5796. function fromArrayBuffer (that, array, byteOffset, length) {
  5797. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5798. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5799. throw new RangeError('\'offset\' is out of bounds')
  5800. }
  5801. if (array.byteLength < byteOffset + (length || 0)) {
  5802. throw new RangeError('\'length\' is out of bounds')
  5803. }
  5804. if (byteOffset === undefined && length === undefined) {
  5805. array = new Uint8Array(array)
  5806. } else if (length === undefined) {
  5807. array = new Uint8Array(array, byteOffset)
  5808. } else {
  5809. array = new Uint8Array(array, byteOffset, length)
  5810. }
  5811. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5812. // Return an augmented `Uint8Array` instance, for best performance
  5813. that = array
  5814. that.__proto__ = Buffer.prototype
  5815. } else {
  5816. // Fallback: Return an object instance of the Buffer class
  5817. that = fromArrayLike(that, array)
  5818. }
  5819. return that
  5820. }
  5821. function fromObject (that, obj) {
  5822. if (Buffer.isBuffer(obj)) {
  5823. var len = checked(obj.length) | 0
  5824. that = createBuffer(that, len)
  5825. if (that.length === 0) {
  5826. return that
  5827. }
  5828. obj.copy(that, 0, 0, len)
  5829. return that
  5830. }
  5831. if (obj) {
  5832. if ((typeof ArrayBuffer !== 'undefined' &&
  5833. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5834. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5835. return createBuffer(that, 0)
  5836. }
  5837. return fromArrayLike(that, obj)
  5838. }
  5839. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5840. return fromArrayLike(that, obj.data)
  5841. }
  5842. }
  5843. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5844. }
  5845. function checked (length) {
  5846. // Note: cannot use `length < kMaxLength()` here because that fails when
  5847. // length is NaN (which is otherwise coerced to zero.)
  5848. if (length >= kMaxLength()) {
  5849. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5850. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5851. }
  5852. return length | 0
  5853. }
  5854. function SlowBuffer (length) {
  5855. if (+length != length) { // eslint-disable-line eqeqeq
  5856. length = 0
  5857. }
  5858. return Buffer.alloc(+length)
  5859. }
  5860. Buffer.isBuffer = function isBuffer (b) {
  5861. return !!(b != null && b._isBuffer)
  5862. }
  5863. Buffer.compare = function compare (a, b) {
  5864. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5865. throw new TypeError('Arguments must be Buffers')
  5866. }
  5867. if (a === b) return 0
  5868. var x = a.length
  5869. var y = b.length
  5870. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5871. if (a[i] !== b[i]) {
  5872. x = a[i]
  5873. y = b[i]
  5874. break
  5875. }
  5876. }
  5877. if (x < y) return -1
  5878. if (y < x) return 1
  5879. return 0
  5880. }
  5881. Buffer.isEncoding = function isEncoding (encoding) {
  5882. switch (String(encoding).toLowerCase()) {
  5883. case 'hex':
  5884. case 'utf8':
  5885. case 'utf-8':
  5886. case 'ascii':
  5887. case 'latin1':
  5888. case 'binary':
  5889. case 'base64':
  5890. case 'ucs2':
  5891. case 'ucs-2':
  5892. case 'utf16le':
  5893. case 'utf-16le':
  5894. return true
  5895. default:
  5896. return false
  5897. }
  5898. }
  5899. Buffer.concat = function concat (list, length) {
  5900. if (!isArray(list)) {
  5901. throw new TypeError('"list" argument must be an Array of Buffers')
  5902. }
  5903. if (list.length === 0) {
  5904. return Buffer.alloc(0)
  5905. }
  5906. var i
  5907. if (length === undefined) {
  5908. length = 0
  5909. for (i = 0; i < list.length; ++i) {
  5910. length += list[i].length
  5911. }
  5912. }
  5913. var buffer = Buffer.allocUnsafe(length)
  5914. var pos = 0
  5915. for (i = 0; i < list.length; ++i) {
  5916. var buf = list[i]
  5917. if (!Buffer.isBuffer(buf)) {
  5918. throw new TypeError('"list" argument must be an Array of Buffers')
  5919. }
  5920. buf.copy(buffer, pos)
  5921. pos += buf.length
  5922. }
  5923. return buffer
  5924. }
  5925. function byteLength (string, encoding) {
  5926. if (Buffer.isBuffer(string)) {
  5927. return string.length
  5928. }
  5929. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5930. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5931. return string.byteLength
  5932. }
  5933. if (typeof string !== 'string') {
  5934. string = '' + string
  5935. }
  5936. var len = string.length
  5937. if (len === 0) return 0
  5938. // Use a for loop to avoid recursion
  5939. var loweredCase = false
  5940. for (;;) {
  5941. switch (encoding) {
  5942. case 'ascii':
  5943. case 'latin1':
  5944. case 'binary':
  5945. return len
  5946. case 'utf8':
  5947. case 'utf-8':
  5948. case undefined:
  5949. return utf8ToBytes(string).length
  5950. case 'ucs2':
  5951. case 'ucs-2':
  5952. case 'utf16le':
  5953. case 'utf-16le':
  5954. return len * 2
  5955. case 'hex':
  5956. return len >>> 1
  5957. case 'base64':
  5958. return base64ToBytes(string).length
  5959. default:
  5960. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5961. encoding = ('' + encoding).toLowerCase()
  5962. loweredCase = true
  5963. }
  5964. }
  5965. }
  5966. Buffer.byteLength = byteLength
  5967. function slowToString (encoding, start, end) {
  5968. var loweredCase = false
  5969. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5970. // property of a typed array.
  5971. // This behaves neither like String nor Uint8Array in that we set start/end
  5972. // to their upper/lower bounds if the value passed is out of range.
  5973. // undefined is handled specially as per ECMA-262 6th Edition,
  5974. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5975. if (start === undefined || start < 0) {
  5976. start = 0
  5977. }
  5978. // Return early if start > this.length. Done here to prevent potential uint32
  5979. // coercion fail below.
  5980. if (start > this.length) {
  5981. return ''
  5982. }
  5983. if (end === undefined || end > this.length) {
  5984. end = this.length
  5985. }
  5986. if (end <= 0) {
  5987. return ''
  5988. }
  5989. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5990. end >>>= 0
  5991. start >>>= 0
  5992. if (end <= start) {
  5993. return ''
  5994. }
  5995. if (!encoding) encoding = 'utf8'
  5996. while (true) {
  5997. switch (encoding) {
  5998. case 'hex':
  5999. return hexSlice(this, start, end)
  6000. case 'utf8':
  6001. case 'utf-8':
  6002. return utf8Slice(this, start, end)
  6003. case 'ascii':
  6004. return asciiSlice(this, start, end)
  6005. case 'latin1':
  6006. case 'binary':
  6007. return latin1Slice(this, start, end)
  6008. case 'base64':
  6009. return base64Slice(this, start, end)
  6010. case 'ucs2':
  6011. case 'ucs-2':
  6012. case 'utf16le':
  6013. case 'utf-16le':
  6014. return utf16leSlice(this, start, end)
  6015. default:
  6016. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6017. encoding = (encoding + '').toLowerCase()
  6018. loweredCase = true
  6019. }
  6020. }
  6021. }
  6022. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6023. // Buffer instances.
  6024. Buffer.prototype._isBuffer = true
  6025. function swap (b, n, m) {
  6026. var i = b[n]
  6027. b[n] = b[m]
  6028. b[m] = i
  6029. }
  6030. Buffer.prototype.swap16 = function swap16 () {
  6031. var len = this.length
  6032. if (len % 2 !== 0) {
  6033. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6034. }
  6035. for (var i = 0; i < len; i += 2) {
  6036. swap(this, i, i + 1)
  6037. }
  6038. return this
  6039. }
  6040. Buffer.prototype.swap32 = function swap32 () {
  6041. var len = this.length
  6042. if (len % 4 !== 0) {
  6043. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6044. }
  6045. for (var i = 0; i < len; i += 4) {
  6046. swap(this, i, i + 3)
  6047. swap(this, i + 1, i + 2)
  6048. }
  6049. return this
  6050. }
  6051. Buffer.prototype.swap64 = function swap64 () {
  6052. var len = this.length
  6053. if (len % 8 !== 0) {
  6054. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6055. }
  6056. for (var i = 0; i < len; i += 8) {
  6057. swap(this, i, i + 7)
  6058. swap(this, i + 1, i + 6)
  6059. swap(this, i + 2, i + 5)
  6060. swap(this, i + 3, i + 4)
  6061. }
  6062. return this
  6063. }
  6064. Buffer.prototype.toString = function toString () {
  6065. var length = this.length | 0
  6066. if (length === 0) return ''
  6067. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6068. return slowToString.apply(this, arguments)
  6069. }
  6070. Buffer.prototype.equals = function equals (b) {
  6071. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6072. if (this === b) return true
  6073. return Buffer.compare(this, b) === 0
  6074. }
  6075. Buffer.prototype.inspect = function inspect () {
  6076. var str = ''
  6077. var max = exports.INSPECT_MAX_BYTES
  6078. if (this.length > 0) {
  6079. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6080. if (this.length > max) str += ' ... '
  6081. }
  6082. return '<Buffer ' + str + '>'
  6083. }
  6084. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6085. if (!Buffer.isBuffer(target)) {
  6086. throw new TypeError('Argument must be a Buffer')
  6087. }
  6088. if (start === undefined) {
  6089. start = 0
  6090. }
  6091. if (end === undefined) {
  6092. end = target ? target.length : 0
  6093. }
  6094. if (thisStart === undefined) {
  6095. thisStart = 0
  6096. }
  6097. if (thisEnd === undefined) {
  6098. thisEnd = this.length
  6099. }
  6100. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6101. throw new RangeError('out of range index')
  6102. }
  6103. if (thisStart >= thisEnd && start >= end) {
  6104. return 0
  6105. }
  6106. if (thisStart >= thisEnd) {
  6107. return -1
  6108. }
  6109. if (start >= end) {
  6110. return 1
  6111. }
  6112. start >>>= 0
  6113. end >>>= 0
  6114. thisStart >>>= 0
  6115. thisEnd >>>= 0
  6116. if (this === target) return 0
  6117. var x = thisEnd - thisStart
  6118. var y = end - start
  6119. var len = Math.min(x, y)
  6120. var thisCopy = this.slice(thisStart, thisEnd)
  6121. var targetCopy = target.slice(start, end)
  6122. for (var i = 0; i < len; ++i) {
  6123. if (thisCopy[i] !== targetCopy[i]) {
  6124. x = thisCopy[i]
  6125. y = targetCopy[i]
  6126. break
  6127. }
  6128. }
  6129. if (x < y) return -1
  6130. if (y < x) return 1
  6131. return 0
  6132. }
  6133. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6134. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6135. //
  6136. // Arguments:
  6137. // - buffer - a Buffer to search
  6138. // - val - a string, Buffer, or number
  6139. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6140. // - encoding - an optional encoding, relevant is val is a string
  6141. // - dir - true for indexOf, false for lastIndexOf
  6142. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6143. // Empty buffer means no match
  6144. if (buffer.length === 0) return -1
  6145. // Normalize byteOffset
  6146. if (typeof byteOffset === 'string') {
  6147. encoding = byteOffset
  6148. byteOffset = 0
  6149. } else if (byteOffset > 0x7fffffff) {
  6150. byteOffset = 0x7fffffff
  6151. } else if (byteOffset < -0x80000000) {
  6152. byteOffset = -0x80000000
  6153. }
  6154. byteOffset = +byteOffset // Coerce to Number.
  6155. if (isNaN(byteOffset)) {
  6156. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6157. byteOffset = dir ? 0 : (buffer.length - 1)
  6158. }
  6159. // Normalize byteOffset: negative offsets start from the end of the buffer
  6160. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6161. if (byteOffset >= buffer.length) {
  6162. if (dir) return -1
  6163. else byteOffset = buffer.length - 1
  6164. } else if (byteOffset < 0) {
  6165. if (dir) byteOffset = 0
  6166. else return -1
  6167. }
  6168. // Normalize val
  6169. if (typeof val === 'string') {
  6170. val = Buffer.from(val, encoding)
  6171. }
  6172. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6173. if (Buffer.isBuffer(val)) {
  6174. // Special case: looking for empty string/buffer always fails
  6175. if (val.length === 0) {
  6176. return -1
  6177. }
  6178. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6179. } else if (typeof val === 'number') {
  6180. val = val & 0xFF // Search for a byte value [0-255]
  6181. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6182. typeof Uint8Array.prototype.indexOf === 'function') {
  6183. if (dir) {
  6184. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6185. } else {
  6186. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6187. }
  6188. }
  6189. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6190. }
  6191. throw new TypeError('val must be string, number or Buffer')
  6192. }
  6193. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6194. var indexSize = 1
  6195. var arrLength = arr.length
  6196. var valLength = val.length
  6197. if (encoding !== undefined) {
  6198. encoding = String(encoding).toLowerCase()
  6199. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6200. encoding === 'utf16le' || encoding === 'utf-16le') {
  6201. if (arr.length < 2 || val.length < 2) {
  6202. return -1
  6203. }
  6204. indexSize = 2
  6205. arrLength /= 2
  6206. valLength /= 2
  6207. byteOffset /= 2
  6208. }
  6209. }
  6210. function read (buf, i) {
  6211. if (indexSize === 1) {
  6212. return buf[i]
  6213. } else {
  6214. return buf.readUInt16BE(i * indexSize)
  6215. }
  6216. }
  6217. var i
  6218. if (dir) {
  6219. var foundIndex = -1
  6220. for (i = byteOffset; i < arrLength; i++) {
  6221. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6222. if (foundIndex === -1) foundIndex = i
  6223. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6224. } else {
  6225. if (foundIndex !== -1) i -= i - foundIndex
  6226. foundIndex = -1
  6227. }
  6228. }
  6229. } else {
  6230. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6231. for (i = byteOffset; i >= 0; i--) {
  6232. var found = true
  6233. for (var j = 0; j < valLength; j++) {
  6234. if (read(arr, i + j) !== read(val, j)) {
  6235. found = false
  6236. break
  6237. }
  6238. }
  6239. if (found) return i
  6240. }
  6241. }
  6242. return -1
  6243. }
  6244. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6245. return this.indexOf(val, byteOffset, encoding) !== -1
  6246. }
  6247. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6248. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6249. }
  6250. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6251. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6252. }
  6253. function hexWrite (buf, string, offset, length) {
  6254. offset = Number(offset) || 0
  6255. var remaining = buf.length - offset
  6256. if (!length) {
  6257. length = remaining
  6258. } else {
  6259. length = Number(length)
  6260. if (length > remaining) {
  6261. length = remaining
  6262. }
  6263. }
  6264. // must be an even number of digits
  6265. var strLen = string.length
  6266. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6267. if (length > strLen / 2) {
  6268. length = strLen / 2
  6269. }
  6270. for (var i = 0; i < length; ++i) {
  6271. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6272. if (isNaN(parsed)) return i
  6273. buf[offset + i] = parsed
  6274. }
  6275. return i
  6276. }
  6277. function utf8Write (buf, string, offset, length) {
  6278. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6279. }
  6280. function asciiWrite (buf, string, offset, length) {
  6281. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6282. }
  6283. function latin1Write (buf, string, offset, length) {
  6284. return asciiWrite(buf, string, offset, length)
  6285. }
  6286. function base64Write (buf, string, offset, length) {
  6287. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6288. }
  6289. function ucs2Write (buf, string, offset, length) {
  6290. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6291. }
  6292. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6293. // Buffer#write(string)
  6294. if (offset === undefined) {
  6295. encoding = 'utf8'
  6296. length = this.length
  6297. offset = 0
  6298. // Buffer#write(string, encoding)
  6299. } else if (length === undefined && typeof offset === 'string') {
  6300. encoding = offset
  6301. length = this.length
  6302. offset = 0
  6303. // Buffer#write(string, offset[, length][, encoding])
  6304. } else if (isFinite(offset)) {
  6305. offset = offset | 0
  6306. if (isFinite(length)) {
  6307. length = length | 0
  6308. if (encoding === undefined) encoding = 'utf8'
  6309. } else {
  6310. encoding = length
  6311. length = undefined
  6312. }
  6313. // legacy write(string, encoding, offset, length) - remove in v0.13
  6314. } else {
  6315. throw new Error(
  6316. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6317. )
  6318. }
  6319. var remaining = this.length - offset
  6320. if (length === undefined || length > remaining) length = remaining
  6321. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6322. throw new RangeError('Attempt to write outside buffer bounds')
  6323. }
  6324. if (!encoding) encoding = 'utf8'
  6325. var loweredCase = false
  6326. for (;;) {
  6327. switch (encoding) {
  6328. case 'hex':
  6329. return hexWrite(this, string, offset, length)
  6330. case 'utf8':
  6331. case 'utf-8':
  6332. return utf8Write(this, string, offset, length)
  6333. case 'ascii':
  6334. return asciiWrite(this, string, offset, length)
  6335. case 'latin1':
  6336. case 'binary':
  6337. return latin1Write(this, string, offset, length)
  6338. case 'base64':
  6339. // Warning: maxLength not taken into account in base64Write
  6340. return base64Write(this, string, offset, length)
  6341. case 'ucs2':
  6342. case 'ucs-2':
  6343. case 'utf16le':
  6344. case 'utf-16le':
  6345. return ucs2Write(this, string, offset, length)
  6346. default:
  6347. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6348. encoding = ('' + encoding).toLowerCase()
  6349. loweredCase = true
  6350. }
  6351. }
  6352. }
  6353. Buffer.prototype.toJSON = function toJSON () {
  6354. return {
  6355. type: 'Buffer',
  6356. data: Array.prototype.slice.call(this._arr || this, 0)
  6357. }
  6358. }
  6359. function base64Slice (buf, start, end) {
  6360. if (start === 0 && end === buf.length) {
  6361. return base64.fromByteArray(buf)
  6362. } else {
  6363. return base64.fromByteArray(buf.slice(start, end))
  6364. }
  6365. }
  6366. function utf8Slice (buf, start, end) {
  6367. end = Math.min(buf.length, end)
  6368. var res = []
  6369. var i = start
  6370. while (i < end) {
  6371. var firstByte = buf[i]
  6372. var codePoint = null
  6373. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6374. : (firstByte > 0xDF) ? 3
  6375. : (firstByte > 0xBF) ? 2
  6376. : 1
  6377. if (i + bytesPerSequence <= end) {
  6378. var secondByte, thirdByte, fourthByte, tempCodePoint
  6379. switch (bytesPerSequence) {
  6380. case 1:
  6381. if (firstByte < 0x80) {
  6382. codePoint = firstByte
  6383. }
  6384. break
  6385. case 2:
  6386. secondByte = buf[i + 1]
  6387. if ((secondByte & 0xC0) === 0x80) {
  6388. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6389. if (tempCodePoint > 0x7F) {
  6390. codePoint = tempCodePoint
  6391. }
  6392. }
  6393. break
  6394. case 3:
  6395. secondByte = buf[i + 1]
  6396. thirdByte = buf[i + 2]
  6397. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6398. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6399. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6400. codePoint = tempCodePoint
  6401. }
  6402. }
  6403. break
  6404. case 4:
  6405. secondByte = buf[i + 1]
  6406. thirdByte = buf[i + 2]
  6407. fourthByte = buf[i + 3]
  6408. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6409. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6410. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6411. codePoint = tempCodePoint
  6412. }
  6413. }
  6414. }
  6415. }
  6416. if (codePoint === null) {
  6417. // we did not generate a valid codePoint so insert a
  6418. // replacement char (U+FFFD) and advance only 1 byte
  6419. codePoint = 0xFFFD
  6420. bytesPerSequence = 1
  6421. } else if (codePoint > 0xFFFF) {
  6422. // encode to utf16 (surrogate pair dance)
  6423. codePoint -= 0x10000
  6424. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6425. codePoint = 0xDC00 | codePoint & 0x3FF
  6426. }
  6427. res.push(codePoint)
  6428. i += bytesPerSequence
  6429. }
  6430. return decodeCodePointsArray(res)
  6431. }
  6432. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6433. // the lowest limit is Chrome, with 0x10000 args.
  6434. // We go 1 magnitude less, for safety
  6435. var MAX_ARGUMENTS_LENGTH = 0x1000
  6436. function decodeCodePointsArray (codePoints) {
  6437. var len = codePoints.length
  6438. if (len <= MAX_ARGUMENTS_LENGTH) {
  6439. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6440. }
  6441. // Decode in chunks to avoid "call stack size exceeded".
  6442. var res = ''
  6443. var i = 0
  6444. while (i < len) {
  6445. res += String.fromCharCode.apply(
  6446. String,
  6447. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6448. )
  6449. }
  6450. return res
  6451. }
  6452. function asciiSlice (buf, start, end) {
  6453. var ret = ''
  6454. end = Math.min(buf.length, end)
  6455. for (var i = start; i < end; ++i) {
  6456. ret += String.fromCharCode(buf[i] & 0x7F)
  6457. }
  6458. return ret
  6459. }
  6460. function latin1Slice (buf, start, end) {
  6461. var ret = ''
  6462. end = Math.min(buf.length, end)
  6463. for (var i = start; i < end; ++i) {
  6464. ret += String.fromCharCode(buf[i])
  6465. }
  6466. return ret
  6467. }
  6468. function hexSlice (buf, start, end) {
  6469. var len = buf.length
  6470. if (!start || start < 0) start = 0
  6471. if (!end || end < 0 || end > len) end = len
  6472. var out = ''
  6473. for (var i = start; i < end; ++i) {
  6474. out += toHex(buf[i])
  6475. }
  6476. return out
  6477. }
  6478. function utf16leSlice (buf, start, end) {
  6479. var bytes = buf.slice(start, end)
  6480. var res = ''
  6481. for (var i = 0; i < bytes.length; i += 2) {
  6482. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6483. }
  6484. return res
  6485. }
  6486. Buffer.prototype.slice = function slice (start, end) {
  6487. var len = this.length
  6488. start = ~~start
  6489. end = end === undefined ? len : ~~end
  6490. if (start < 0) {
  6491. start += len
  6492. if (start < 0) start = 0
  6493. } else if (start > len) {
  6494. start = len
  6495. }
  6496. if (end < 0) {
  6497. end += len
  6498. if (end < 0) end = 0
  6499. } else if (end > len) {
  6500. end = len
  6501. }
  6502. if (end < start) end = start
  6503. var newBuf
  6504. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6505. newBuf = this.subarray(start, end)
  6506. newBuf.__proto__ = Buffer.prototype
  6507. } else {
  6508. var sliceLen = end - start
  6509. newBuf = new Buffer(sliceLen, undefined)
  6510. for (var i = 0; i < sliceLen; ++i) {
  6511. newBuf[i] = this[i + start]
  6512. }
  6513. }
  6514. return newBuf
  6515. }
  6516. /*
  6517. * Need to make sure that buffer isn't trying to write out of bounds.
  6518. */
  6519. function checkOffset (offset, ext, length) {
  6520. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6521. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6522. }
  6523. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6524. offset = offset | 0
  6525. byteLength = byteLength | 0
  6526. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6527. var val = this[offset]
  6528. var mul = 1
  6529. var i = 0
  6530. while (++i < byteLength && (mul *= 0x100)) {
  6531. val += this[offset + i] * mul
  6532. }
  6533. return val
  6534. }
  6535. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6536. offset = offset | 0
  6537. byteLength = byteLength | 0
  6538. if (!noAssert) {
  6539. checkOffset(offset, byteLength, this.length)
  6540. }
  6541. var val = this[offset + --byteLength]
  6542. var mul = 1
  6543. while (byteLength > 0 && (mul *= 0x100)) {
  6544. val += this[offset + --byteLength] * mul
  6545. }
  6546. return val
  6547. }
  6548. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6549. if (!noAssert) checkOffset(offset, 1, this.length)
  6550. return this[offset]
  6551. }
  6552. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6553. if (!noAssert) checkOffset(offset, 2, this.length)
  6554. return this[offset] | (this[offset + 1] << 8)
  6555. }
  6556. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6557. if (!noAssert) checkOffset(offset, 2, this.length)
  6558. return (this[offset] << 8) | this[offset + 1]
  6559. }
  6560. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6561. if (!noAssert) checkOffset(offset, 4, this.length)
  6562. return ((this[offset]) |
  6563. (this[offset + 1] << 8) |
  6564. (this[offset + 2] << 16)) +
  6565. (this[offset + 3] * 0x1000000)
  6566. }
  6567. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6568. if (!noAssert) checkOffset(offset, 4, this.length)
  6569. return (this[offset] * 0x1000000) +
  6570. ((this[offset + 1] << 16) |
  6571. (this[offset + 2] << 8) |
  6572. this[offset + 3])
  6573. }
  6574. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6575. offset = offset | 0
  6576. byteLength = byteLength | 0
  6577. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6578. var val = this[offset]
  6579. var mul = 1
  6580. var i = 0
  6581. while (++i < byteLength && (mul *= 0x100)) {
  6582. val += this[offset + i] * mul
  6583. }
  6584. mul *= 0x80
  6585. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6586. return val
  6587. }
  6588. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6589. offset = offset | 0
  6590. byteLength = byteLength | 0
  6591. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6592. var i = byteLength
  6593. var mul = 1
  6594. var val = this[offset + --i]
  6595. while (i > 0 && (mul *= 0x100)) {
  6596. val += this[offset + --i] * mul
  6597. }
  6598. mul *= 0x80
  6599. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6600. return val
  6601. }
  6602. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6603. if (!noAssert) checkOffset(offset, 1, this.length)
  6604. if (!(this[offset] & 0x80)) return (this[offset])
  6605. return ((0xff - this[offset] + 1) * -1)
  6606. }
  6607. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6608. if (!noAssert) checkOffset(offset, 2, this.length)
  6609. var val = this[offset] | (this[offset + 1] << 8)
  6610. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6611. }
  6612. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6613. if (!noAssert) checkOffset(offset, 2, this.length)
  6614. var val = this[offset + 1] | (this[offset] << 8)
  6615. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6616. }
  6617. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6618. if (!noAssert) checkOffset(offset, 4, this.length)
  6619. return (this[offset]) |
  6620. (this[offset + 1] << 8) |
  6621. (this[offset + 2] << 16) |
  6622. (this[offset + 3] << 24)
  6623. }
  6624. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6625. if (!noAssert) checkOffset(offset, 4, this.length)
  6626. return (this[offset] << 24) |
  6627. (this[offset + 1] << 16) |
  6628. (this[offset + 2] << 8) |
  6629. (this[offset + 3])
  6630. }
  6631. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6632. if (!noAssert) checkOffset(offset, 4, this.length)
  6633. return ieee754.read(this, offset, true, 23, 4)
  6634. }
  6635. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6636. if (!noAssert) checkOffset(offset, 4, this.length)
  6637. return ieee754.read(this, offset, false, 23, 4)
  6638. }
  6639. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6640. if (!noAssert) checkOffset(offset, 8, this.length)
  6641. return ieee754.read(this, offset, true, 52, 8)
  6642. }
  6643. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6644. if (!noAssert) checkOffset(offset, 8, this.length)
  6645. return ieee754.read(this, offset, false, 52, 8)
  6646. }
  6647. function checkInt (buf, value, offset, ext, max, min) {
  6648. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6649. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6650. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6651. }
  6652. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6653. value = +value
  6654. offset = offset | 0
  6655. byteLength = byteLength | 0
  6656. if (!noAssert) {
  6657. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6658. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6659. }
  6660. var mul = 1
  6661. var i = 0
  6662. this[offset] = value & 0xFF
  6663. while (++i < byteLength && (mul *= 0x100)) {
  6664. this[offset + i] = (value / mul) & 0xFF
  6665. }
  6666. return offset + byteLength
  6667. }
  6668. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6669. value = +value
  6670. offset = offset | 0
  6671. byteLength = byteLength | 0
  6672. if (!noAssert) {
  6673. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6674. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6675. }
  6676. var i = byteLength - 1
  6677. var mul = 1
  6678. this[offset + i] = value & 0xFF
  6679. while (--i >= 0 && (mul *= 0x100)) {
  6680. this[offset + i] = (value / mul) & 0xFF
  6681. }
  6682. return offset + byteLength
  6683. }
  6684. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6685. value = +value
  6686. offset = offset | 0
  6687. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6688. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6689. this[offset] = (value & 0xff)
  6690. return offset + 1
  6691. }
  6692. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6693. if (value < 0) value = 0xffff + value + 1
  6694. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6695. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6696. (littleEndian ? i : 1 - i) * 8
  6697. }
  6698. }
  6699. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6700. value = +value
  6701. offset = offset | 0
  6702. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6703. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6704. this[offset] = (value & 0xff)
  6705. this[offset + 1] = (value >>> 8)
  6706. } else {
  6707. objectWriteUInt16(this, value, offset, true)
  6708. }
  6709. return offset + 2
  6710. }
  6711. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6712. value = +value
  6713. offset = offset | 0
  6714. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6715. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6716. this[offset] = (value >>> 8)
  6717. this[offset + 1] = (value & 0xff)
  6718. } else {
  6719. objectWriteUInt16(this, value, offset, false)
  6720. }
  6721. return offset + 2
  6722. }
  6723. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6724. if (value < 0) value = 0xffffffff + value + 1
  6725. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6726. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6727. }
  6728. }
  6729. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6730. value = +value
  6731. offset = offset | 0
  6732. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6733. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6734. this[offset + 3] = (value >>> 24)
  6735. this[offset + 2] = (value >>> 16)
  6736. this[offset + 1] = (value >>> 8)
  6737. this[offset] = (value & 0xff)
  6738. } else {
  6739. objectWriteUInt32(this, value, offset, true)
  6740. }
  6741. return offset + 4
  6742. }
  6743. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6744. value = +value
  6745. offset = offset | 0
  6746. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6747. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6748. this[offset] = (value >>> 24)
  6749. this[offset + 1] = (value >>> 16)
  6750. this[offset + 2] = (value >>> 8)
  6751. this[offset + 3] = (value & 0xff)
  6752. } else {
  6753. objectWriteUInt32(this, value, offset, false)
  6754. }
  6755. return offset + 4
  6756. }
  6757. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6758. value = +value
  6759. offset = offset | 0
  6760. if (!noAssert) {
  6761. var limit = Math.pow(2, 8 * byteLength - 1)
  6762. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6763. }
  6764. var i = 0
  6765. var mul = 1
  6766. var sub = 0
  6767. this[offset] = value & 0xFF
  6768. while (++i < byteLength && (mul *= 0x100)) {
  6769. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6770. sub = 1
  6771. }
  6772. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6773. }
  6774. return offset + byteLength
  6775. }
  6776. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6777. value = +value
  6778. offset = offset | 0
  6779. if (!noAssert) {
  6780. var limit = Math.pow(2, 8 * byteLength - 1)
  6781. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6782. }
  6783. var i = byteLength - 1
  6784. var mul = 1
  6785. var sub = 0
  6786. this[offset + i] = value & 0xFF
  6787. while (--i >= 0 && (mul *= 0x100)) {
  6788. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6789. sub = 1
  6790. }
  6791. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6792. }
  6793. return offset + byteLength
  6794. }
  6795. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6796. value = +value
  6797. offset = offset | 0
  6798. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6799. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6800. if (value < 0) value = 0xff + value + 1
  6801. this[offset] = (value & 0xff)
  6802. return offset + 1
  6803. }
  6804. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6805. value = +value
  6806. offset = offset | 0
  6807. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6808. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6809. this[offset] = (value & 0xff)
  6810. this[offset + 1] = (value >>> 8)
  6811. } else {
  6812. objectWriteUInt16(this, value, offset, true)
  6813. }
  6814. return offset + 2
  6815. }
  6816. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6817. value = +value
  6818. offset = offset | 0
  6819. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6820. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6821. this[offset] = (value >>> 8)
  6822. this[offset + 1] = (value & 0xff)
  6823. } else {
  6824. objectWriteUInt16(this, value, offset, false)
  6825. }
  6826. return offset + 2
  6827. }
  6828. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6829. value = +value
  6830. offset = offset | 0
  6831. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6832. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6833. this[offset] = (value & 0xff)
  6834. this[offset + 1] = (value >>> 8)
  6835. this[offset + 2] = (value >>> 16)
  6836. this[offset + 3] = (value >>> 24)
  6837. } else {
  6838. objectWriteUInt32(this, value, offset, true)
  6839. }
  6840. return offset + 4
  6841. }
  6842. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6843. value = +value
  6844. offset = offset | 0
  6845. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6846. if (value < 0) value = 0xffffffff + value + 1
  6847. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6848. this[offset] = (value >>> 24)
  6849. this[offset + 1] = (value >>> 16)
  6850. this[offset + 2] = (value >>> 8)
  6851. this[offset + 3] = (value & 0xff)
  6852. } else {
  6853. objectWriteUInt32(this, value, offset, false)
  6854. }
  6855. return offset + 4
  6856. }
  6857. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6858. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6859. if (offset < 0) throw new RangeError('Index out of range')
  6860. }
  6861. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6862. if (!noAssert) {
  6863. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6864. }
  6865. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6866. return offset + 4
  6867. }
  6868. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6869. return writeFloat(this, value, offset, true, noAssert)
  6870. }
  6871. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6872. return writeFloat(this, value, offset, false, noAssert)
  6873. }
  6874. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6875. if (!noAssert) {
  6876. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6877. }
  6878. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6879. return offset + 8
  6880. }
  6881. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6882. return writeDouble(this, value, offset, true, noAssert)
  6883. }
  6884. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6885. return writeDouble(this, value, offset, false, noAssert)
  6886. }
  6887. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6888. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6889. if (!start) start = 0
  6890. if (!end && end !== 0) end = this.length
  6891. if (targetStart >= target.length) targetStart = target.length
  6892. if (!targetStart) targetStart = 0
  6893. if (end > 0 && end < start) end = start
  6894. // Copy 0 bytes; we're done
  6895. if (end === start) return 0
  6896. if (target.length === 0 || this.length === 0) return 0
  6897. // Fatal error conditions
  6898. if (targetStart < 0) {
  6899. throw new RangeError('targetStart out of bounds')
  6900. }
  6901. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6902. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6903. // Are we oob?
  6904. if (end > this.length) end = this.length
  6905. if (target.length - targetStart < end - start) {
  6906. end = target.length - targetStart + start
  6907. }
  6908. var len = end - start
  6909. var i
  6910. if (this === target && start < targetStart && targetStart < end) {
  6911. // descending copy from end
  6912. for (i = len - 1; i >= 0; --i) {
  6913. target[i + targetStart] = this[i + start]
  6914. }
  6915. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6916. // ascending copy from start
  6917. for (i = 0; i < len; ++i) {
  6918. target[i + targetStart] = this[i + start]
  6919. }
  6920. } else {
  6921. Uint8Array.prototype.set.call(
  6922. target,
  6923. this.subarray(start, start + len),
  6924. targetStart
  6925. )
  6926. }
  6927. return len
  6928. }
  6929. // Usage:
  6930. // buffer.fill(number[, offset[, end]])
  6931. // buffer.fill(buffer[, offset[, end]])
  6932. // buffer.fill(string[, offset[, end]][, encoding])
  6933. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6934. // Handle string cases:
  6935. if (typeof val === 'string') {
  6936. if (typeof start === 'string') {
  6937. encoding = start
  6938. start = 0
  6939. end = this.length
  6940. } else if (typeof end === 'string') {
  6941. encoding = end
  6942. end = this.length
  6943. }
  6944. if (val.length === 1) {
  6945. var code = val.charCodeAt(0)
  6946. if (code < 256) {
  6947. val = code
  6948. }
  6949. }
  6950. if (encoding !== undefined && typeof encoding !== 'string') {
  6951. throw new TypeError('encoding must be a string')
  6952. }
  6953. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6954. throw new TypeError('Unknown encoding: ' + encoding)
  6955. }
  6956. } else if (typeof val === 'number') {
  6957. val = val & 255
  6958. }
  6959. // Invalid ranges are not set to a default, so can range check early.
  6960. if (start < 0 || this.length < start || this.length < end) {
  6961. throw new RangeError('Out of range index')
  6962. }
  6963. if (end <= start) {
  6964. return this
  6965. }
  6966. start = start >>> 0
  6967. end = end === undefined ? this.length : end >>> 0
  6968. if (!val) val = 0
  6969. var i
  6970. if (typeof val === 'number') {
  6971. for (i = start; i < end; ++i) {
  6972. this[i] = val
  6973. }
  6974. } else {
  6975. var bytes = Buffer.isBuffer(val)
  6976. ? val
  6977. : utf8ToBytes(new Buffer(val, encoding).toString())
  6978. var len = bytes.length
  6979. for (i = 0; i < end - start; ++i) {
  6980. this[i + start] = bytes[i % len]
  6981. }
  6982. }
  6983. return this
  6984. }
  6985. // HELPER FUNCTIONS
  6986. // ================
  6987. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6988. function base64clean (str) {
  6989. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6990. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6991. // Node converts strings with length < 2 to ''
  6992. if (str.length < 2) return ''
  6993. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6994. while (str.length % 4 !== 0) {
  6995. str = str + '='
  6996. }
  6997. return str
  6998. }
  6999. function stringtrim (str) {
  7000. if (str.trim) return str.trim()
  7001. return str.replace(/^\s+|\s+$/g, '')
  7002. }
  7003. function toHex (n) {
  7004. if (n < 16) return '0' + n.toString(16)
  7005. return n.toString(16)
  7006. }
  7007. function utf8ToBytes (string, units) {
  7008. units = units || Infinity
  7009. var codePoint
  7010. var length = string.length
  7011. var leadSurrogate = null
  7012. var bytes = []
  7013. for (var i = 0; i < length; ++i) {
  7014. codePoint = string.charCodeAt(i)
  7015. // is surrogate component
  7016. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7017. // last char was a lead
  7018. if (!leadSurrogate) {
  7019. // no lead yet
  7020. if (codePoint > 0xDBFF) {
  7021. // unexpected trail
  7022. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7023. continue
  7024. } else if (i + 1 === length) {
  7025. // unpaired lead
  7026. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7027. continue
  7028. }
  7029. // valid lead
  7030. leadSurrogate = codePoint
  7031. continue
  7032. }
  7033. // 2 leads in a row
  7034. if (codePoint < 0xDC00) {
  7035. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7036. leadSurrogate = codePoint
  7037. continue
  7038. }
  7039. // valid surrogate pair
  7040. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7041. } else if (leadSurrogate) {
  7042. // valid bmp char, but last char was a lead
  7043. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7044. }
  7045. leadSurrogate = null
  7046. // encode utf8
  7047. if (codePoint < 0x80) {
  7048. if ((units -= 1) < 0) break
  7049. bytes.push(codePoint)
  7050. } else if (codePoint < 0x800) {
  7051. if ((units -= 2) < 0) break
  7052. bytes.push(
  7053. codePoint >> 0x6 | 0xC0,
  7054. codePoint & 0x3F | 0x80
  7055. )
  7056. } else if (codePoint < 0x10000) {
  7057. if ((units -= 3) < 0) break
  7058. bytes.push(
  7059. codePoint >> 0xC | 0xE0,
  7060. codePoint >> 0x6 & 0x3F | 0x80,
  7061. codePoint & 0x3F | 0x80
  7062. )
  7063. } else if (codePoint < 0x110000) {
  7064. if ((units -= 4) < 0) break
  7065. bytes.push(
  7066. codePoint >> 0x12 | 0xF0,
  7067. codePoint >> 0xC & 0x3F | 0x80,
  7068. codePoint >> 0x6 & 0x3F | 0x80,
  7069. codePoint & 0x3F | 0x80
  7070. )
  7071. } else {
  7072. throw new Error('Invalid code point')
  7073. }
  7074. }
  7075. return bytes
  7076. }
  7077. function asciiToBytes (str) {
  7078. var byteArray = []
  7079. for (var i = 0; i < str.length; ++i) {
  7080. // Node's code seems to be doing this and not & 0x7F..
  7081. byteArray.push(str.charCodeAt(i) & 0xFF)
  7082. }
  7083. return byteArray
  7084. }
  7085. function utf16leToBytes (str, units) {
  7086. var c, hi, lo
  7087. var byteArray = []
  7088. for (var i = 0; i < str.length; ++i) {
  7089. if ((units -= 2) < 0) break
  7090. c = str.charCodeAt(i)
  7091. hi = c >> 8
  7092. lo = c % 256
  7093. byteArray.push(lo)
  7094. byteArray.push(hi)
  7095. }
  7096. return byteArray
  7097. }
  7098. function base64ToBytes (str) {
  7099. return base64.toByteArray(base64clean(str))
  7100. }
  7101. function blitBuffer (src, dst, offset, length) {
  7102. for (var i = 0; i < length; ++i) {
  7103. if ((i + offset >= dst.length) || (i >= src.length)) break
  7104. dst[i + offset] = src[i]
  7105. }
  7106. return i
  7107. }
  7108. function isnan (val) {
  7109. return val !== val // eslint-disable-line no-self-compare
  7110. }
  7111. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7112. /***/ }),
  7113. /***/ "./node_modules/component-bind/index.js":
  7114. /*!**********************************************!*\
  7115. !*** ./node_modules/component-bind/index.js ***!
  7116. \**********************************************/
  7117. /*! no static exports found */
  7118. /***/ (function(module, exports) {
  7119. /**
  7120. * Slice reference.
  7121. */
  7122. var slice = [].slice;
  7123. /**
  7124. * Bind `obj` to `fn`.
  7125. *
  7126. * @param {Object} obj
  7127. * @param {Function|String} fn or string
  7128. * @return {Function}
  7129. * @api public
  7130. */
  7131. module.exports = function(obj, fn){
  7132. if ('string' == typeof fn) fn = obj[fn];
  7133. if ('function' != typeof fn) throw new Error('bind() requires a function');
  7134. var args = slice.call(arguments, 2);
  7135. return function(){
  7136. return fn.apply(obj, args.concat(slice.call(arguments)));
  7137. }
  7138. };
  7139. /***/ }),
  7140. /***/ "./node_modules/component-emitter/index.js":
  7141. /*!*************************************************!*\
  7142. !*** ./node_modules/component-emitter/index.js ***!
  7143. \*************************************************/
  7144. /*! no static exports found */
  7145. /***/ (function(module, exports, __webpack_require__) {
  7146. /**
  7147. * Expose `Emitter`.
  7148. */
  7149. if (true) {
  7150. module.exports = Emitter;
  7151. }
  7152. /**
  7153. * Initialize a new `Emitter`.
  7154. *
  7155. * @api public
  7156. */
  7157. function Emitter(obj) {
  7158. if (obj) return mixin(obj);
  7159. };
  7160. /**
  7161. * Mixin the emitter properties.
  7162. *
  7163. * @param {Object} obj
  7164. * @return {Object}
  7165. * @api private
  7166. */
  7167. function mixin(obj) {
  7168. for (var key in Emitter.prototype) {
  7169. obj[key] = Emitter.prototype[key];
  7170. }
  7171. return obj;
  7172. }
  7173. /**
  7174. * Listen on the given `event` with `fn`.
  7175. *
  7176. * @param {String} event
  7177. * @param {Function} fn
  7178. * @return {Emitter}
  7179. * @api public
  7180. */
  7181. Emitter.prototype.on =
  7182. Emitter.prototype.addEventListener = function(event, fn){
  7183. this._callbacks = this._callbacks || {};
  7184. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  7185. .push(fn);
  7186. return this;
  7187. };
  7188. /**
  7189. * Adds an `event` listener that will be invoked a single
  7190. * time then automatically removed.
  7191. *
  7192. * @param {String} event
  7193. * @param {Function} fn
  7194. * @return {Emitter}
  7195. * @api public
  7196. */
  7197. Emitter.prototype.once = function(event, fn){
  7198. function on() {
  7199. this.off(event, on);
  7200. fn.apply(this, arguments);
  7201. }
  7202. on.fn = fn;
  7203. this.on(event, on);
  7204. return this;
  7205. };
  7206. /**
  7207. * Remove the given callback for `event` or all
  7208. * registered callbacks.
  7209. *
  7210. * @param {String} event
  7211. * @param {Function} fn
  7212. * @return {Emitter}
  7213. * @api public
  7214. */
  7215. Emitter.prototype.off =
  7216. Emitter.prototype.removeListener =
  7217. Emitter.prototype.removeAllListeners =
  7218. Emitter.prototype.removeEventListener = function(event, fn){
  7219. this._callbacks = this._callbacks || {};
  7220. // all
  7221. if (0 == arguments.length) {
  7222. this._callbacks = {};
  7223. return this;
  7224. }
  7225. // specific event
  7226. var callbacks = this._callbacks['$' + event];
  7227. if (!callbacks) return this;
  7228. // remove all handlers
  7229. if (1 == arguments.length) {
  7230. delete this._callbacks['$' + event];
  7231. return this;
  7232. }
  7233. // remove specific handler
  7234. var cb;
  7235. for (var i = 0; i < callbacks.length; i++) {
  7236. cb = callbacks[i];
  7237. if (cb === fn || cb.fn === fn) {
  7238. callbacks.splice(i, 1);
  7239. break;
  7240. }
  7241. }
  7242. // Remove event specific arrays for event types that no
  7243. // one is subscribed for to avoid memory leak.
  7244. if (callbacks.length === 0) {
  7245. delete this._callbacks['$' + event];
  7246. }
  7247. return this;
  7248. };
  7249. /**
  7250. * Emit `event` with the given args.
  7251. *
  7252. * @param {String} event
  7253. * @param {Mixed} ...
  7254. * @return {Emitter}
  7255. */
  7256. Emitter.prototype.emit = function(event){
  7257. this._callbacks = this._callbacks || {};
  7258. var args = new Array(arguments.length - 1)
  7259. , callbacks = this._callbacks['$' + event];
  7260. for (var i = 1; i < arguments.length; i++) {
  7261. args[i - 1] = arguments[i];
  7262. }
  7263. if (callbacks) {
  7264. callbacks = callbacks.slice(0);
  7265. for (var i = 0, len = callbacks.length; i < len; ++i) {
  7266. callbacks[i].apply(this, args);
  7267. }
  7268. }
  7269. return this;
  7270. };
  7271. /**
  7272. * Return array of callbacks for `event`.
  7273. *
  7274. * @param {String} event
  7275. * @return {Array}
  7276. * @api public
  7277. */
  7278. Emitter.prototype.listeners = function(event){
  7279. this._callbacks = this._callbacks || {};
  7280. return this._callbacks['$' + event] || [];
  7281. };
  7282. /**
  7283. * Check if this emitter has `event` handlers.
  7284. *
  7285. * @param {String} event
  7286. * @return {Boolean}
  7287. * @api public
  7288. */
  7289. Emitter.prototype.hasListeners = function(event){
  7290. return !! this.listeners(event).length;
  7291. };
  7292. /***/ }),
  7293. /***/ "./node_modules/component-inherit/index.js":
  7294. /*!*************************************************!*\
  7295. !*** ./node_modules/component-inherit/index.js ***!
  7296. \*************************************************/
  7297. /*! no static exports found */
  7298. /***/ (function(module, exports) {
  7299. module.exports = function(a, b){
  7300. var fn = function(){};
  7301. fn.prototype = b.prototype;
  7302. a.prototype = new fn;
  7303. a.prototype.constructor = a;
  7304. };
  7305. /***/ }),
  7306. /***/ "./node_modules/debug/src/browser.js":
  7307. /*!*******************************************!*\
  7308. !*** ./node_modules/debug/src/browser.js ***!
  7309. \*******************************************/
  7310. /*! no static exports found */
  7311. /***/ (function(module, exports, __webpack_require__) {
  7312. /* WEBPACK VAR INJECTION */(function(process) {/**
  7313. * This is the web browser implementation of `debug()`.
  7314. *
  7315. * Expose `debug()` as the module.
  7316. */
  7317. exports = module.exports = __webpack_require__(/*! ./debug */ "./node_modules/debug/src/debug.js");
  7318. exports.log = log;
  7319. exports.formatArgs = formatArgs;
  7320. exports.save = save;
  7321. exports.load = load;
  7322. exports.useColors = useColors;
  7323. exports.storage = 'undefined' != typeof chrome
  7324. && 'undefined' != typeof chrome.storage
  7325. ? chrome.storage.local
  7326. : localstorage();
  7327. /**
  7328. * Colors.
  7329. */
  7330. exports.colors = [
  7331. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  7332. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  7333. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  7334. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  7335. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  7336. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  7337. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  7338. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  7339. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  7340. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  7341. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  7342. ];
  7343. /**
  7344. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  7345. * and the Firebug extension (any Firefox version) are known
  7346. * to support "%c" CSS customizations.
  7347. *
  7348. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  7349. */
  7350. function useColors() {
  7351. // NB: In an Electron preload script, document will be defined but not fully
  7352. // initialized. Since we know we're in Chrome, we'll just detect this case
  7353. // explicitly
  7354. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  7355. return true;
  7356. }
  7357. // Internet Explorer and Edge do not support colors.
  7358. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  7359. return false;
  7360. }
  7361. // is webkit? http://stackoverflow.com/a/16459606/376773
  7362. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  7363. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  7364. // is firebug? http://stackoverflow.com/a/398120/376773
  7365. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  7366. // is firefox >= v31?
  7367. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  7368. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  7369. // double check webkit in userAgent just in case we are in a worker
  7370. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  7371. }
  7372. /**
  7373. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  7374. */
  7375. exports.formatters.j = function(v) {
  7376. try {
  7377. return JSON.stringify(v);
  7378. } catch (err) {
  7379. return '[UnexpectedJSONParseError]: ' + err.message;
  7380. }
  7381. };
  7382. /**
  7383. * Colorize log arguments if enabled.
  7384. *
  7385. * @api public
  7386. */
  7387. function formatArgs(args) {
  7388. var useColors = this.useColors;
  7389. args[0] = (useColors ? '%c' : '')
  7390. + this.namespace
  7391. + (useColors ? ' %c' : ' ')
  7392. + args[0]
  7393. + (useColors ? '%c ' : ' ')
  7394. + '+' + exports.humanize(this.diff);
  7395. if (!useColors) return;
  7396. var c = 'color: ' + this.color;
  7397. args.splice(1, 0, c, 'color: inherit')
  7398. // the final "%c" is somewhat tricky, because there could be other
  7399. // arguments passed either before or after the %c, so we need to
  7400. // figure out the correct index to insert the CSS into
  7401. var index = 0;
  7402. var lastC = 0;
  7403. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  7404. if ('%%' === match) return;
  7405. index++;
  7406. if ('%c' === match) {
  7407. // we only are interested in the *last* %c
  7408. // (the user may have provided their own)
  7409. lastC = index;
  7410. }
  7411. });
  7412. args.splice(lastC, 0, c);
  7413. }
  7414. /**
  7415. * Invokes `console.log()` when available.
  7416. * No-op when `console.log` is not a "function".
  7417. *
  7418. * @api public
  7419. */
  7420. function log() {
  7421. // this hackery is required for IE8/9, where
  7422. // the `console.log` function doesn't have 'apply'
  7423. return 'object' === typeof console
  7424. && console.log
  7425. && Function.prototype.apply.call(console.log, console, arguments);
  7426. }
  7427. /**
  7428. * Save `namespaces`.
  7429. *
  7430. * @param {String} namespaces
  7431. * @api private
  7432. */
  7433. function save(namespaces) {
  7434. try {
  7435. if (null == namespaces) {
  7436. exports.storage.removeItem('debug');
  7437. } else {
  7438. exports.storage.debug = namespaces;
  7439. }
  7440. } catch(e) {}
  7441. }
  7442. /**
  7443. * Load `namespaces`.
  7444. *
  7445. * @return {String} returns the previously persisted debug modes
  7446. * @api private
  7447. */
  7448. function load() {
  7449. var r;
  7450. try {
  7451. r = exports.storage.debug;
  7452. } catch(e) {}
  7453. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  7454. if (!r && typeof process !== 'undefined' && 'env' in process) {
  7455. r = process.env.DEBUG;
  7456. }
  7457. return r;
  7458. }
  7459. /**
  7460. * Enable namespaces listed in `localStorage.debug` initially.
  7461. */
  7462. exports.enable(load());
  7463. /**
  7464. * Localstorage attempts to return the localstorage.
  7465. *
  7466. * This is necessary because safari throws
  7467. * when a user disables cookies/localstorage
  7468. * and you attempt to access it.
  7469. *
  7470. * @return {LocalStorage}
  7471. * @api private
  7472. */
  7473. function localstorage() {
  7474. try {
  7475. return window.localStorage;
  7476. } catch (e) {}
  7477. }
  7478. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  7479. /***/ }),
  7480. /***/ "./node_modules/debug/src/debug.js":
  7481. /*!*****************************************!*\
  7482. !*** ./node_modules/debug/src/debug.js ***!
  7483. \*****************************************/
  7484. /*! no static exports found */
  7485. /***/ (function(module, exports, __webpack_require__) {
  7486. /**
  7487. * This is the common logic for both the Node.js and web browser
  7488. * implementations of `debug()`.
  7489. *
  7490. * Expose `debug()` as the module.
  7491. */
  7492. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  7493. exports.coerce = coerce;
  7494. exports.disable = disable;
  7495. exports.enable = enable;
  7496. exports.enabled = enabled;
  7497. exports.humanize = __webpack_require__(/*! ms */ "./node_modules/ms/index.js");
  7498. /**
  7499. * Active `debug` instances.
  7500. */
  7501. exports.instances = [];
  7502. /**
  7503. * The currently active debug mode names, and names to skip.
  7504. */
  7505. exports.names = [];
  7506. exports.skips = [];
  7507. /**
  7508. * Map of special "%n" handling functions, for the debug "format" argument.
  7509. *
  7510. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  7511. */
  7512. exports.formatters = {};
  7513. /**
  7514. * Select a color.
  7515. * @param {String} namespace
  7516. * @return {Number}
  7517. * @api private
  7518. */
  7519. function selectColor(namespace) {
  7520. var hash = 0, i;
  7521. for (i in namespace) {
  7522. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  7523. hash |= 0; // Convert to 32bit integer
  7524. }
  7525. return exports.colors[Math.abs(hash) % exports.colors.length];
  7526. }
  7527. /**
  7528. * Create a debugger with the given `namespace`.
  7529. *
  7530. * @param {String} namespace
  7531. * @return {Function}
  7532. * @api public
  7533. */
  7534. function createDebug(namespace) {
  7535. var prevTime;
  7536. function debug() {
  7537. // disabled?
  7538. if (!debug.enabled) return;
  7539. var self = debug;
  7540. // set `diff` timestamp
  7541. var curr = +new Date();
  7542. var ms = curr - (prevTime || curr);
  7543. self.diff = ms;
  7544. self.prev = prevTime;
  7545. self.curr = curr;
  7546. prevTime = curr;
  7547. // turn the `arguments` into a proper Array
  7548. var args = new Array(arguments.length);
  7549. for (var i = 0; i < args.length; i++) {
  7550. args[i] = arguments[i];
  7551. }
  7552. args[0] = exports.coerce(args[0]);
  7553. if ('string' !== typeof args[0]) {
  7554. // anything else let's inspect with %O
  7555. args.unshift('%O');
  7556. }
  7557. // apply any `formatters` transformations
  7558. var index = 0;
  7559. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  7560. // if we encounter an escaped % then don't increase the array index
  7561. if (match === '%%') return match;
  7562. index++;
  7563. var formatter = exports.formatters[format];
  7564. if ('function' === typeof formatter) {
  7565. var val = args[index];
  7566. match = formatter.call(self, val);
  7567. // now we need to remove `args[index]` since it's inlined in the `format`
  7568. args.splice(index, 1);
  7569. index--;
  7570. }
  7571. return match;
  7572. });
  7573. // apply env-specific formatting (colors, etc.)
  7574. exports.formatArgs.call(self, args);
  7575. var logFn = debug.log || exports.log || console.log.bind(console);
  7576. logFn.apply(self, args);
  7577. }
  7578. debug.namespace = namespace;
  7579. debug.enabled = exports.enabled(namespace);
  7580. debug.useColors = exports.useColors();
  7581. debug.color = selectColor(namespace);
  7582. debug.destroy = destroy;
  7583. // env-specific initialization logic for debug instances
  7584. if ('function' === typeof exports.init) {
  7585. exports.init(debug);
  7586. }
  7587. exports.instances.push(debug);
  7588. return debug;
  7589. }
  7590. function destroy () {
  7591. var index = exports.instances.indexOf(this);
  7592. if (index !== -1) {
  7593. exports.instances.splice(index, 1);
  7594. return true;
  7595. } else {
  7596. return false;
  7597. }
  7598. }
  7599. /**
  7600. * Enables a debug mode by namespaces. This can include modes
  7601. * separated by a colon and wildcards.
  7602. *
  7603. * @param {String} namespaces
  7604. * @api public
  7605. */
  7606. function enable(namespaces) {
  7607. exports.save(namespaces);
  7608. exports.names = [];
  7609. exports.skips = [];
  7610. var i;
  7611. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  7612. var len = split.length;
  7613. for (i = 0; i < len; i++) {
  7614. if (!split[i]) continue; // ignore empty strings
  7615. namespaces = split[i].replace(/\*/g, '.*?');
  7616. if (namespaces[0] === '-') {
  7617. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  7618. } else {
  7619. exports.names.push(new RegExp('^' + namespaces + '$'));
  7620. }
  7621. }
  7622. for (i = 0; i < exports.instances.length; i++) {
  7623. var instance = exports.instances[i];
  7624. instance.enabled = exports.enabled(instance.namespace);
  7625. }
  7626. }
  7627. /**
  7628. * Disable debug output.
  7629. *
  7630. * @api public
  7631. */
  7632. function disable() {
  7633. exports.enable('');
  7634. }
  7635. /**
  7636. * Returns true if the given mode name is enabled, false otherwise.
  7637. *
  7638. * @param {String} name
  7639. * @return {Boolean}
  7640. * @api public
  7641. */
  7642. function enabled(name) {
  7643. if (name[name.length - 1] === '*') {
  7644. return true;
  7645. }
  7646. var i, len;
  7647. for (i = 0, len = exports.skips.length; i < len; i++) {
  7648. if (exports.skips[i].test(name)) {
  7649. return false;
  7650. }
  7651. }
  7652. for (i = 0, len = exports.names.length; i < len; i++) {
  7653. if (exports.names[i].test(name)) {
  7654. return true;
  7655. }
  7656. }
  7657. return false;
  7658. }
  7659. /**
  7660. * Coerce `val`.
  7661. *
  7662. * @param {Mixed} val
  7663. * @return {Mixed}
  7664. * @api private
  7665. */
  7666. function coerce(val) {
  7667. if (val instanceof Error) return val.stack || val.message;
  7668. return val;
  7669. }
  7670. /***/ }),
  7671. /***/ "./node_modules/engine.io-client/lib/globalThis.browser.js":
  7672. /*!*****************************************************************!*\
  7673. !*** ./node_modules/engine.io-client/lib/globalThis.browser.js ***!
  7674. \*****************************************************************/
  7675. /*! no static exports found */
  7676. /***/ (function(module, exports) {
  7677. module.exports = (function () {
  7678. if (typeof self !== 'undefined') {
  7679. return self;
  7680. } else if (typeof window !== 'undefined') {
  7681. return window;
  7682. } else {
  7683. return Function('return this')(); // eslint-disable-line no-new-func
  7684. }
  7685. })();
  7686. /***/ }),
  7687. /***/ "./node_modules/engine.io-client/lib/index.js":
  7688. /*!****************************************************!*\
  7689. !*** ./node_modules/engine.io-client/lib/index.js ***!
  7690. \****************************************************/
  7691. /*! no static exports found */
  7692. /***/ (function(module, exports, __webpack_require__) {
  7693. module.exports = __webpack_require__(/*! ./socket */ "./node_modules/engine.io-client/lib/socket.js");
  7694. /**
  7695. * Exports parser
  7696. *
  7697. * @api public
  7698. *
  7699. */
  7700. module.exports.parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  7701. /***/ }),
  7702. /***/ "./node_modules/engine.io-client/lib/socket.js":
  7703. /*!*****************************************************!*\
  7704. !*** ./node_modules/engine.io-client/lib/socket.js ***!
  7705. \*****************************************************/
  7706. /*! no static exports found */
  7707. /***/ (function(module, exports, __webpack_require__) {
  7708. /**
  7709. * Module dependencies.
  7710. */
  7711. var transports = __webpack_require__(/*! ./transports/index */ "./node_modules/engine.io-client/lib/transports/index.js");
  7712. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
  7713. var debug = __webpack_require__(/*! debug */ "./node_modules/engine.io-client/node_modules/debug/src/browser.js")('engine.io-client:socket');
  7714. var index = __webpack_require__(/*! indexof */ "./node_modules/indexof/index.js");
  7715. var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  7716. var parseuri = __webpack_require__(/*! parseuri */ "./node_modules/parseuri/index.js");
  7717. var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
  7718. /**
  7719. * Module exports.
  7720. */
  7721. module.exports = Socket;
  7722. /**
  7723. * Socket constructor.
  7724. *
  7725. * @param {String|Object} uri or options
  7726. * @param {Object} options
  7727. * @api public
  7728. */
  7729. function Socket (uri, opts) {
  7730. if (!(this instanceof Socket)) return new Socket(uri, opts);
  7731. opts = opts || {};
  7732. if (uri && 'object' === typeof uri) {
  7733. opts = uri;
  7734. uri = null;
  7735. }
  7736. if (uri) {
  7737. uri = parseuri(uri);
  7738. opts.hostname = uri.host;
  7739. opts.secure = uri.protocol === 'https' || uri.protocol === 'wss';
  7740. opts.port = uri.port;
  7741. if (uri.query) opts.query = uri.query;
  7742. } else if (opts.host) {
  7743. opts.hostname = parseuri(opts.host).host;
  7744. }
  7745. this.secure = null != opts.secure ? opts.secure
  7746. : (typeof location !== 'undefined' && 'https:' === location.protocol);
  7747. if (opts.hostname && !opts.port) {
  7748. // if no port is specified manually, use the protocol default
  7749. opts.port = this.secure ? '443' : '80';
  7750. }
  7751. this.agent = opts.agent || false;
  7752. this.hostname = opts.hostname ||
  7753. (typeof location !== 'undefined' ? location.hostname : 'localhost');
  7754. this.port = opts.port || (typeof location !== 'undefined' && location.port
  7755. ? location.port
  7756. : (this.secure ? 443 : 80));
  7757. this.query = opts.query || {};
  7758. if ('string' === typeof this.query) this.query = parseqs.decode(this.query);
  7759. this.upgrade = false !== opts.upgrade;
  7760. this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
  7761. this.forceJSONP = !!opts.forceJSONP;
  7762. this.jsonp = false !== opts.jsonp;
  7763. this.forceBase64 = !!opts.forceBase64;
  7764. this.enablesXDR = !!opts.enablesXDR;
  7765. this.withCredentials = false !== opts.withCredentials;
  7766. this.timestampParam = opts.timestampParam || 't';
  7767. this.timestampRequests = opts.timestampRequests;
  7768. this.transports = opts.transports || ['polling', 'websocket'];
  7769. this.transportOptions = opts.transportOptions || {};
  7770. this.readyState = '';
  7771. this.writeBuffer = [];
  7772. this.prevBufferLen = 0;
  7773. this.policyPort = opts.policyPort || 843;
  7774. this.rememberUpgrade = opts.rememberUpgrade || false;
  7775. this.binaryType = null;
  7776. this.onlyBinaryUpgrades = opts.onlyBinaryUpgrades;
  7777. this.perMessageDeflate = false !== opts.perMessageDeflate ? (opts.perMessageDeflate || {}) : false;
  7778. if (true === this.perMessageDeflate) this.perMessageDeflate = {};
  7779. if (this.perMessageDeflate && null == this.perMessageDeflate.threshold) {
  7780. this.perMessageDeflate.threshold = 1024;
  7781. }
  7782. // SSL options for Node.js client
  7783. this.pfx = opts.pfx || null;
  7784. this.key = opts.key || null;
  7785. this.passphrase = opts.passphrase || null;
  7786. this.cert = opts.cert || null;
  7787. this.ca = opts.ca || null;
  7788. this.ciphers = opts.ciphers || null;
  7789. this.rejectUnauthorized = opts.rejectUnauthorized === undefined ? true : opts.rejectUnauthorized;
  7790. this.forceNode = !!opts.forceNode;
  7791. // detect ReactNative environment
  7792. this.isReactNative = (typeof navigator !== 'undefined' && typeof navigator.product === 'string' && navigator.product.toLowerCase() === 'reactnative');
  7793. // other options for Node.js or ReactNative client
  7794. if (typeof self === 'undefined' || this.isReactNative) {
  7795. if (opts.extraHeaders && Object.keys(opts.extraHeaders).length > 0) {
  7796. this.extraHeaders = opts.extraHeaders;
  7797. }
  7798. if (opts.localAddress) {
  7799. this.localAddress = opts.localAddress;
  7800. }
  7801. }
  7802. // set on handshake
  7803. this.id = null;
  7804. this.upgrades = null;
  7805. this.pingInterval = null;
  7806. this.pingTimeout = null;
  7807. // set on heartbeat
  7808. this.pingIntervalTimer = null;
  7809. this.pingTimeoutTimer = null;
  7810. this.open();
  7811. }
  7812. Socket.priorWebsocketSuccess = false;
  7813. /**
  7814. * Mix in `Emitter`.
  7815. */
  7816. Emitter(Socket.prototype);
  7817. /**
  7818. * Protocol version.
  7819. *
  7820. * @api public
  7821. */
  7822. Socket.protocol = parser.protocol; // this is an int
  7823. /**
  7824. * Expose deps for legacy compatibility
  7825. * and standalone browser access.
  7826. */
  7827. Socket.Socket = Socket;
  7828. Socket.Transport = __webpack_require__(/*! ./transport */ "./node_modules/engine.io-client/lib/transport.js");
  7829. Socket.transports = __webpack_require__(/*! ./transports/index */ "./node_modules/engine.io-client/lib/transports/index.js");
  7830. Socket.parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  7831. /**
  7832. * Creates transport of the given type.
  7833. *
  7834. * @param {String} transport name
  7835. * @return {Transport}
  7836. * @api private
  7837. */
  7838. Socket.prototype.createTransport = function (name) {
  7839. debug('creating transport "%s"', name);
  7840. var query = clone(this.query);
  7841. // append engine.io protocol identifier
  7842. query.EIO = parser.protocol;
  7843. // transport name
  7844. query.transport = name;
  7845. // per-transport options
  7846. var options = this.transportOptions[name] || {};
  7847. // session id if we already have one
  7848. if (this.id) query.sid = this.id;
  7849. var transport = new transports[name]({
  7850. query: query,
  7851. socket: this,
  7852. agent: options.agent || this.agent,
  7853. hostname: options.hostname || this.hostname,
  7854. port: options.port || this.port,
  7855. secure: options.secure || this.secure,
  7856. path: options.path || this.path,
  7857. forceJSONP: options.forceJSONP || this.forceJSONP,
  7858. jsonp: options.jsonp || this.jsonp,
  7859. forceBase64: options.forceBase64 || this.forceBase64,
  7860. enablesXDR: options.enablesXDR || this.enablesXDR,
  7861. withCredentials: options.withCredentials || this.withCredentials,
  7862. timestampRequests: options.timestampRequests || this.timestampRequests,
  7863. timestampParam: options.timestampParam || this.timestampParam,
  7864. policyPort: options.policyPort || this.policyPort,
  7865. pfx: options.pfx || this.pfx,
  7866. key: options.key || this.key,
  7867. passphrase: options.passphrase || this.passphrase,
  7868. cert: options.cert || this.cert,
  7869. ca: options.ca || this.ca,
  7870. ciphers: options.ciphers || this.ciphers,
  7871. rejectUnauthorized: options.rejectUnauthorized || this.rejectUnauthorized,
  7872. perMessageDeflate: options.perMessageDeflate || this.perMessageDeflate,
  7873. extraHeaders: options.extraHeaders || this.extraHeaders,
  7874. forceNode: options.forceNode || this.forceNode,
  7875. localAddress: options.localAddress || this.localAddress,
  7876. requestTimeout: options.requestTimeout || this.requestTimeout,
  7877. protocols: options.protocols || void (0),
  7878. isReactNative: this.isReactNative
  7879. });
  7880. return transport;
  7881. };
  7882. function clone (obj) {
  7883. var o = {};
  7884. for (var i in obj) {
  7885. if (obj.hasOwnProperty(i)) {
  7886. o[i] = obj[i];
  7887. }
  7888. }
  7889. return o;
  7890. }
  7891. /**
  7892. * Initializes transport to use and starts probe.
  7893. *
  7894. * @api private
  7895. */
  7896. Socket.prototype.open = function () {
  7897. var transport;
  7898. if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') !== -1) {
  7899. transport = 'websocket';
  7900. } else if (0 === this.transports.length) {
  7901. // Emit error on next tick so it can be listened to
  7902. var self = this;
  7903. setTimeout(function () {
  7904. self.emit('error', 'No transports available');
  7905. }, 0);
  7906. return;
  7907. } else {
  7908. transport = this.transports[0];
  7909. }
  7910. this.readyState = 'opening';
  7911. // Retry with the next transport if the transport is disabled (jsonp: false)
  7912. try {
  7913. transport = this.createTransport(transport);
  7914. } catch (e) {
  7915. this.transports.shift();
  7916. this.open();
  7917. return;
  7918. }
  7919. transport.open();
  7920. this.setTransport(transport);
  7921. };
  7922. /**
  7923. * Sets the current transport. Disables the existing one (if any).
  7924. *
  7925. * @api private
  7926. */
  7927. Socket.prototype.setTransport = function (transport) {
  7928. debug('setting transport %s', transport.name);
  7929. var self = this;
  7930. if (this.transport) {
  7931. debug('clearing existing transport %s', this.transport.name);
  7932. this.transport.removeAllListeners();
  7933. }
  7934. // set up transport
  7935. this.transport = transport;
  7936. // set up transport listeners
  7937. transport
  7938. .on('drain', function () {
  7939. self.onDrain();
  7940. })
  7941. .on('packet', function (packet) {
  7942. self.onPacket(packet);
  7943. })
  7944. .on('error', function (e) {
  7945. self.onError(e);
  7946. })
  7947. .on('close', function () {
  7948. self.onClose('transport close');
  7949. });
  7950. };
  7951. /**
  7952. * Probes a transport.
  7953. *
  7954. * @param {String} transport name
  7955. * @api private
  7956. */
  7957. Socket.prototype.probe = function (name) {
  7958. debug('probing transport "%s"', name);
  7959. var transport = this.createTransport(name, { probe: 1 });
  7960. var failed = false;
  7961. var self = this;
  7962. Socket.priorWebsocketSuccess = false;
  7963. function onTransportOpen () {
  7964. if (self.onlyBinaryUpgrades) {
  7965. var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary;
  7966. failed = failed || upgradeLosesBinary;
  7967. }
  7968. if (failed) return;
  7969. debug('probe transport "%s" opened', name);
  7970. transport.send([{ type: 'ping', data: 'probe' }]);
  7971. transport.once('packet', function (msg) {
  7972. if (failed) return;
  7973. if ('pong' === msg.type && 'probe' === msg.data) {
  7974. debug('probe transport "%s" pong', name);
  7975. self.upgrading = true;
  7976. self.emit('upgrading', transport);
  7977. if (!transport) return;
  7978. Socket.priorWebsocketSuccess = 'websocket' === transport.name;
  7979. debug('pausing current transport "%s"', self.transport.name);
  7980. self.transport.pause(function () {
  7981. if (failed) return;
  7982. if ('closed' === self.readyState) return;
  7983. debug('changing transport and sending upgrade packet');
  7984. cleanup();
  7985. self.setTransport(transport);
  7986. transport.send([{ type: 'upgrade' }]);
  7987. self.emit('upgrade', transport);
  7988. transport = null;
  7989. self.upgrading = false;
  7990. self.flush();
  7991. });
  7992. } else {
  7993. debug('probe transport "%s" failed', name);
  7994. var err = new Error('probe error');
  7995. err.transport = transport.name;
  7996. self.emit('upgradeError', err);
  7997. }
  7998. });
  7999. }
  8000. function freezeTransport () {
  8001. if (failed) return;
  8002. // Any callback called by transport should be ignored since now
  8003. failed = true;
  8004. cleanup();
  8005. transport.close();
  8006. transport = null;
  8007. }
  8008. // Handle any error that happens while probing
  8009. function onerror (err) {
  8010. var error = new Error('probe error: ' + err);
  8011. error.transport = transport.name;
  8012. freezeTransport();
  8013. debug('probe transport "%s" failed because of error: %s', name, err);
  8014. self.emit('upgradeError', error);
  8015. }
  8016. function onTransportClose () {
  8017. onerror('transport closed');
  8018. }
  8019. // When the socket is closed while we're probing
  8020. function onclose () {
  8021. onerror('socket closed');
  8022. }
  8023. // When the socket is upgraded while we're probing
  8024. function onupgrade (to) {
  8025. if (transport && to.name !== transport.name) {
  8026. debug('"%s" works - aborting "%s"', to.name, transport.name);
  8027. freezeTransport();
  8028. }
  8029. }
  8030. // Remove all listeners on the transport and on self
  8031. function cleanup () {
  8032. transport.removeListener('open', onTransportOpen);
  8033. transport.removeListener('error', onerror);
  8034. transport.removeListener('close', onTransportClose);
  8035. self.removeListener('close', onclose);
  8036. self.removeListener('upgrading', onupgrade);
  8037. }
  8038. transport.once('open', onTransportOpen);
  8039. transport.once('error', onerror);
  8040. transport.once('close', onTransportClose);
  8041. this.once('close', onclose);
  8042. this.once('upgrading', onupgrade);
  8043. transport.open();
  8044. };
  8045. /**
  8046. * Called when connection is deemed open.
  8047. *
  8048. * @api public
  8049. */
  8050. Socket.prototype.onOpen = function () {
  8051. debug('socket open');
  8052. this.readyState = 'open';
  8053. Socket.priorWebsocketSuccess = 'websocket' === this.transport.name;
  8054. this.emit('open');
  8055. this.flush();
  8056. // we check for `readyState` in case an `open`
  8057. // listener already closed the socket
  8058. if ('open' === this.readyState && this.upgrade && this.transport.pause) {
  8059. debug('starting upgrade probes');
  8060. for (var i = 0, l = this.upgrades.length; i < l; i++) {
  8061. this.probe(this.upgrades[i]);
  8062. }
  8063. }
  8064. };
  8065. /**
  8066. * Handles a packet.
  8067. *
  8068. * @api private
  8069. */
  8070. Socket.prototype.onPacket = function (packet) {
  8071. if ('opening' === this.readyState || 'open' === this.readyState ||
  8072. 'closing' === this.readyState) {
  8073. debug('socket receive: type "%s", data "%s"', packet.type, packet.data);
  8074. this.emit('packet', packet);
  8075. // Socket is live - any packet counts
  8076. this.emit('heartbeat');
  8077. switch (packet.type) {
  8078. case 'open':
  8079. this.onHandshake(JSON.parse(packet.data));
  8080. break;
  8081. case 'pong':
  8082. this.setPing();
  8083. this.emit('pong');
  8084. break;
  8085. case 'error':
  8086. var err = new Error('server error');
  8087. err.code = packet.data;
  8088. this.onError(err);
  8089. break;
  8090. case 'message':
  8091. this.emit('data', packet.data);
  8092. this.emit('message', packet.data);
  8093. break;
  8094. }
  8095. } else {
  8096. debug('packet received with socket readyState "%s"', this.readyState);
  8097. }
  8098. };
  8099. /**
  8100. * Called upon handshake completion.
  8101. *
  8102. * @param {Object} handshake obj
  8103. * @api private
  8104. */
  8105. Socket.prototype.onHandshake = function (data) {
  8106. this.emit('handshake', data);
  8107. this.id = data.sid;
  8108. this.transport.query.sid = data.sid;
  8109. this.upgrades = this.filterUpgrades(data.upgrades);
  8110. this.pingInterval = data.pingInterval;
  8111. this.pingTimeout = data.pingTimeout;
  8112. this.onOpen();
  8113. // In case open handler closes socket
  8114. if ('closed' === this.readyState) return;
  8115. this.setPing();
  8116. // Prolong liveness of socket on heartbeat
  8117. this.removeListener('heartbeat', this.onHeartbeat);
  8118. this.on('heartbeat', this.onHeartbeat);
  8119. };
  8120. /**
  8121. * Resets ping timeout.
  8122. *
  8123. * @api private
  8124. */
  8125. Socket.prototype.onHeartbeat = function (timeout) {
  8126. clearTimeout(this.pingTimeoutTimer);
  8127. var self = this;
  8128. self.pingTimeoutTimer = setTimeout(function () {
  8129. if ('closed' === self.readyState) return;
  8130. self.onClose('ping timeout');
  8131. }, timeout || (self.pingInterval + self.pingTimeout));
  8132. };
  8133. /**
  8134. * Pings server every `this.pingInterval` and expects response
  8135. * within `this.pingTimeout` or closes connection.
  8136. *
  8137. * @api private
  8138. */
  8139. Socket.prototype.setPing = function () {
  8140. var self = this;
  8141. clearTimeout(self.pingIntervalTimer);
  8142. self.pingIntervalTimer = setTimeout(function () {
  8143. debug('writing ping packet - expecting pong within %sms', self.pingTimeout);
  8144. self.ping();
  8145. self.onHeartbeat(self.pingTimeout);
  8146. }, self.pingInterval);
  8147. };
  8148. /**
  8149. * Sends a ping packet.
  8150. *
  8151. * @api private
  8152. */
  8153. Socket.prototype.ping = function () {
  8154. var self = this;
  8155. this.sendPacket('ping', function () {
  8156. self.emit('ping');
  8157. });
  8158. };
  8159. /**
  8160. * Called on `drain` event
  8161. *
  8162. * @api private
  8163. */
  8164. Socket.prototype.onDrain = function () {
  8165. this.writeBuffer.splice(0, this.prevBufferLen);
  8166. // setting prevBufferLen = 0 is very important
  8167. // for example, when upgrading, upgrade packet is sent over,
  8168. // and a nonzero prevBufferLen could cause problems on `drain`
  8169. this.prevBufferLen = 0;
  8170. if (0 === this.writeBuffer.length) {
  8171. this.emit('drain');
  8172. } else {
  8173. this.flush();
  8174. }
  8175. };
  8176. /**
  8177. * Flush write buffers.
  8178. *
  8179. * @api private
  8180. */
  8181. Socket.prototype.flush = function () {
  8182. if ('closed' !== this.readyState && this.transport.writable &&
  8183. !this.upgrading && this.writeBuffer.length) {
  8184. debug('flushing %d packets in socket', this.writeBuffer.length);
  8185. this.transport.send(this.writeBuffer);
  8186. // keep track of current length of writeBuffer
  8187. // splice writeBuffer and callbackBuffer on `drain`
  8188. this.prevBufferLen = this.writeBuffer.length;
  8189. this.emit('flush');
  8190. }
  8191. };
  8192. /**
  8193. * Sends a message.
  8194. *
  8195. * @param {String} message.
  8196. * @param {Function} callback function.
  8197. * @param {Object} options.
  8198. * @return {Socket} for chaining.
  8199. * @api public
  8200. */
  8201. Socket.prototype.write =
  8202. Socket.prototype.send = function (msg, options, fn) {
  8203. this.sendPacket('message', msg, options, fn);
  8204. return this;
  8205. };
  8206. /**
  8207. * Sends a packet.
  8208. *
  8209. * @param {String} packet type.
  8210. * @param {String} data.
  8211. * @param {Object} options.
  8212. * @param {Function} callback function.
  8213. * @api private
  8214. */
  8215. Socket.prototype.sendPacket = function (type, data, options, fn) {
  8216. if ('function' === typeof data) {
  8217. fn = data;
  8218. data = undefined;
  8219. }
  8220. if ('function' === typeof options) {
  8221. fn = options;
  8222. options = null;
  8223. }
  8224. if ('closing' === this.readyState || 'closed' === this.readyState) {
  8225. return;
  8226. }
  8227. options = options || {};
  8228. options.compress = false !== options.compress;
  8229. var packet = {
  8230. type: type,
  8231. data: data,
  8232. options: options
  8233. };
  8234. this.emit('packetCreate', packet);
  8235. this.writeBuffer.push(packet);
  8236. if (fn) this.once('flush', fn);
  8237. this.flush();
  8238. };
  8239. /**
  8240. * Closes the connection.
  8241. *
  8242. * @api private
  8243. */
  8244. Socket.prototype.close = function () {
  8245. if ('opening' === this.readyState || 'open' === this.readyState) {
  8246. this.readyState = 'closing';
  8247. var self = this;
  8248. if (this.writeBuffer.length) {
  8249. this.once('drain', function () {
  8250. if (this.upgrading) {
  8251. waitForUpgrade();
  8252. } else {
  8253. close();
  8254. }
  8255. });
  8256. } else if (this.upgrading) {
  8257. waitForUpgrade();
  8258. } else {
  8259. close();
  8260. }
  8261. }
  8262. function close () {
  8263. self.onClose('forced close');
  8264. debug('socket closing - telling transport to close');
  8265. self.transport.close();
  8266. }
  8267. function cleanupAndClose () {
  8268. self.removeListener('upgrade', cleanupAndClose);
  8269. self.removeListener('upgradeError', cleanupAndClose);
  8270. close();
  8271. }
  8272. function waitForUpgrade () {
  8273. // wait for upgrade to finish since we can't send packets while pausing a transport
  8274. self.once('upgrade', cleanupAndClose);
  8275. self.once('upgradeError', cleanupAndClose);
  8276. }
  8277. return this;
  8278. };
  8279. /**
  8280. * Called upon transport error
  8281. *
  8282. * @api private
  8283. */
  8284. Socket.prototype.onError = function (err) {
  8285. debug('socket error %j', err);
  8286. Socket.priorWebsocketSuccess = false;
  8287. this.emit('error', err);
  8288. this.onClose('transport error', err);
  8289. };
  8290. /**
  8291. * Called upon transport close.
  8292. *
  8293. * @api private
  8294. */
  8295. Socket.prototype.onClose = function (reason, desc) {
  8296. if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState) {
  8297. debug('socket close with reason: "%s"', reason);
  8298. var self = this;
  8299. // clear timers
  8300. clearTimeout(this.pingIntervalTimer);
  8301. clearTimeout(this.pingTimeoutTimer);
  8302. // stop event from firing again for transport
  8303. this.transport.removeAllListeners('close');
  8304. // ensure transport won't stay open
  8305. this.transport.close();
  8306. // ignore further transport communication
  8307. this.transport.removeAllListeners();
  8308. // set ready state
  8309. this.readyState = 'closed';
  8310. // clear session id
  8311. this.id = null;
  8312. // emit close event
  8313. this.emit('close', reason, desc);
  8314. // clean buffers after, so users can still
  8315. // grab the buffers on `close` event
  8316. self.writeBuffer = [];
  8317. self.prevBufferLen = 0;
  8318. }
  8319. };
  8320. /**
  8321. * Filters upgrades, returning only those matching client transports.
  8322. *
  8323. * @param {Array} server upgrades
  8324. * @api private
  8325. *
  8326. */
  8327. Socket.prototype.filterUpgrades = function (upgrades) {
  8328. var filteredUpgrades = [];
  8329. for (var i = 0, j = upgrades.length; i < j; i++) {
  8330. if (~index(this.transports, upgrades[i])) filteredUpgrades.push(upgrades[i]);
  8331. }
  8332. return filteredUpgrades;
  8333. };
  8334. /***/ }),
  8335. /***/ "./node_modules/engine.io-client/lib/transport.js":
  8336. /*!********************************************************!*\
  8337. !*** ./node_modules/engine.io-client/lib/transport.js ***!
  8338. \********************************************************/
  8339. /*! no static exports found */
  8340. /***/ (function(module, exports, __webpack_require__) {
  8341. /**
  8342. * Module dependencies.
  8343. */
  8344. var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  8345. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
  8346. /**
  8347. * Module exports.
  8348. */
  8349. module.exports = Transport;
  8350. /**
  8351. * Transport abstract constructor.
  8352. *
  8353. * @param {Object} options.
  8354. * @api private
  8355. */
  8356. function Transport (opts) {
  8357. this.path = opts.path;
  8358. this.hostname = opts.hostname;
  8359. this.port = opts.port;
  8360. this.secure = opts.secure;
  8361. this.query = opts.query;
  8362. this.timestampParam = opts.timestampParam;
  8363. this.timestampRequests = opts.timestampRequests;
  8364. this.readyState = '';
  8365. this.agent = opts.agent || false;
  8366. this.socket = opts.socket;
  8367. this.enablesXDR = opts.enablesXDR;
  8368. this.withCredentials = opts.withCredentials;
  8369. // SSL options for Node.js client
  8370. this.pfx = opts.pfx;
  8371. this.key = opts.key;
  8372. this.passphrase = opts.passphrase;
  8373. this.cert = opts.cert;
  8374. this.ca = opts.ca;
  8375. this.ciphers = opts.ciphers;
  8376. this.rejectUnauthorized = opts.rejectUnauthorized;
  8377. this.forceNode = opts.forceNode;
  8378. // results of ReactNative environment detection
  8379. this.isReactNative = opts.isReactNative;
  8380. // other options for Node.js client
  8381. this.extraHeaders = opts.extraHeaders;
  8382. this.localAddress = opts.localAddress;
  8383. }
  8384. /**
  8385. * Mix in `Emitter`.
  8386. */
  8387. Emitter(Transport.prototype);
  8388. /**
  8389. * Emits an error.
  8390. *
  8391. * @param {String} str
  8392. * @return {Transport} for chaining
  8393. * @api public
  8394. */
  8395. Transport.prototype.onError = function (msg, desc) {
  8396. var err = new Error(msg);
  8397. err.type = 'TransportError';
  8398. err.description = desc;
  8399. this.emit('error', err);
  8400. return this;
  8401. };
  8402. /**
  8403. * Opens the transport.
  8404. *
  8405. * @api public
  8406. */
  8407. Transport.prototype.open = function () {
  8408. if ('closed' === this.readyState || '' === this.readyState) {
  8409. this.readyState = 'opening';
  8410. this.doOpen();
  8411. }
  8412. return this;
  8413. };
  8414. /**
  8415. * Closes the transport.
  8416. *
  8417. * @api private
  8418. */
  8419. Transport.prototype.close = function () {
  8420. if ('opening' === this.readyState || 'open' === this.readyState) {
  8421. this.doClose();
  8422. this.onClose();
  8423. }
  8424. return this;
  8425. };
  8426. /**
  8427. * Sends multiple packets.
  8428. *
  8429. * @param {Array} packets
  8430. * @api private
  8431. */
  8432. Transport.prototype.send = function (packets) {
  8433. if ('open' === this.readyState) {
  8434. this.write(packets);
  8435. } else {
  8436. throw new Error('Transport not open');
  8437. }
  8438. };
  8439. /**
  8440. * Called upon open
  8441. *
  8442. * @api private
  8443. */
  8444. Transport.prototype.onOpen = function () {
  8445. this.readyState = 'open';
  8446. this.writable = true;
  8447. this.emit('open');
  8448. };
  8449. /**
  8450. * Called with data.
  8451. *
  8452. * @param {String} data
  8453. * @api private
  8454. */
  8455. Transport.prototype.onData = function (data) {
  8456. var packet = parser.decodePacket(data, this.socket.binaryType);
  8457. this.onPacket(packet);
  8458. };
  8459. /**
  8460. * Called with a decoded packet.
  8461. */
  8462. Transport.prototype.onPacket = function (packet) {
  8463. this.emit('packet', packet);
  8464. };
  8465. /**
  8466. * Called upon close.
  8467. *
  8468. * @api private
  8469. */
  8470. Transport.prototype.onClose = function () {
  8471. this.readyState = 'closed';
  8472. this.emit('close');
  8473. };
  8474. /***/ }),
  8475. /***/ "./node_modules/engine.io-client/lib/transports/index.js":
  8476. /*!***************************************************************!*\
  8477. !*** ./node_modules/engine.io-client/lib/transports/index.js ***!
  8478. \***************************************************************/
  8479. /*! no static exports found */
  8480. /***/ (function(module, exports, __webpack_require__) {
  8481. /**
  8482. * Module dependencies
  8483. */
  8484. var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
  8485. var XHR = __webpack_require__(/*! ./polling-xhr */ "./node_modules/engine.io-client/lib/transports/polling-xhr.js");
  8486. var JSONP = __webpack_require__(/*! ./polling-jsonp */ "./node_modules/engine.io-client/lib/transports/polling-jsonp.js");
  8487. var websocket = __webpack_require__(/*! ./websocket */ "./node_modules/engine.io-client/lib/transports/websocket.js");
  8488. /**
  8489. * Export transports.
  8490. */
  8491. exports.polling = polling;
  8492. exports.websocket = websocket;
  8493. /**
  8494. * Polling transport polymorphic constructor.
  8495. * Decides on xhr vs jsonp based on feature detection.
  8496. *
  8497. * @api private
  8498. */
  8499. function polling (opts) {
  8500. var xhr;
  8501. var xd = false;
  8502. var xs = false;
  8503. var jsonp = false !== opts.jsonp;
  8504. if (typeof location !== 'undefined') {
  8505. var isSSL = 'https:' === location.protocol;
  8506. var port = location.port;
  8507. // some user agents have empty `location.port`
  8508. if (!port) {
  8509. port = isSSL ? 443 : 80;
  8510. }
  8511. xd = opts.hostname !== location.hostname || port !== opts.port;
  8512. xs = opts.secure !== isSSL;
  8513. }
  8514. opts.xdomain = xd;
  8515. opts.xscheme = xs;
  8516. xhr = new XMLHttpRequest(opts);
  8517. if ('open' in xhr && !opts.forceJSONP) {
  8518. return new XHR(opts);
  8519. } else {
  8520. if (!jsonp) throw new Error('JSONP disabled');
  8521. return new JSONP(opts);
  8522. }
  8523. }
  8524. /***/ }),
  8525. /***/ "./node_modules/engine.io-client/lib/transports/polling-jsonp.js":
  8526. /*!***********************************************************************!*\
  8527. !*** ./node_modules/engine.io-client/lib/transports/polling-jsonp.js ***!
  8528. \***********************************************************************/
  8529. /*! no static exports found */
  8530. /***/ (function(module, exports, __webpack_require__) {
  8531. /**
  8532. * Module requirements.
  8533. */
  8534. var Polling = __webpack_require__(/*! ./polling */ "./node_modules/engine.io-client/lib/transports/polling.js");
  8535. var inherit = __webpack_require__(/*! component-inherit */ "./node_modules/component-inherit/index.js");
  8536. var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
  8537. /**
  8538. * Module exports.
  8539. */
  8540. module.exports = JSONPPolling;
  8541. /**
  8542. * Cached regular expressions.
  8543. */
  8544. var rNewline = /\n/g;
  8545. var rEscapedNewline = /\\n/g;
  8546. /**
  8547. * Global JSONP callbacks.
  8548. */
  8549. var callbacks;
  8550. /**
  8551. * Noop.
  8552. */
  8553. function empty () { }
  8554. /**
  8555. * JSONP Polling constructor.
  8556. *
  8557. * @param {Object} opts.
  8558. * @api public
  8559. */
  8560. function JSONPPolling (opts) {
  8561. Polling.call(this, opts);
  8562. this.query = this.query || {};
  8563. // define global callbacks array if not present
  8564. // we do this here (lazily) to avoid unneeded global pollution
  8565. if (!callbacks) {
  8566. // we need to consider multiple engines in the same page
  8567. callbacks = globalThis.___eio = (globalThis.___eio || []);
  8568. }
  8569. // callback identifier
  8570. this.index = callbacks.length;
  8571. // add callback to jsonp global
  8572. var self = this;
  8573. callbacks.push(function (msg) {
  8574. self.onData(msg);
  8575. });
  8576. // append to query string
  8577. this.query.j = this.index;
  8578. // prevent spurious errors from being emitted when the window is unloaded
  8579. if (typeof addEventListener === 'function') {
  8580. addEventListener('beforeunload', function () {
  8581. if (self.script) self.script.onerror = empty;
  8582. }, false);
  8583. }
  8584. }
  8585. /**
  8586. * Inherits from Polling.
  8587. */
  8588. inherit(JSONPPolling, Polling);
  8589. /*
  8590. * JSONP only supports binary as base64 encoded strings
  8591. */
  8592. JSONPPolling.prototype.supportsBinary = false;
  8593. /**
  8594. * Closes the socket.
  8595. *
  8596. * @api private
  8597. */
  8598. JSONPPolling.prototype.doClose = function () {
  8599. if (this.script) {
  8600. this.script.parentNode.removeChild(this.script);
  8601. this.script = null;
  8602. }
  8603. if (this.form) {
  8604. this.form.parentNode.removeChild(this.form);
  8605. this.form = null;
  8606. this.iframe = null;
  8607. }
  8608. Polling.prototype.doClose.call(this);
  8609. };
  8610. /**
  8611. * Starts a poll cycle.
  8612. *
  8613. * @api private
  8614. */
  8615. JSONPPolling.prototype.doPoll = function () {
  8616. var self = this;
  8617. var script = document.createElement('script');
  8618. if (this.script) {
  8619. this.script.parentNode.removeChild(this.script);
  8620. this.script = null;
  8621. }
  8622. script.async = true;
  8623. script.src = this.uri();
  8624. script.onerror = function (e) {
  8625. self.onError('jsonp poll error', e);
  8626. };
  8627. var insertAt = document.getElementsByTagName('script')[0];
  8628. if (insertAt) {
  8629. insertAt.parentNode.insertBefore(script, insertAt);
  8630. } else {
  8631. (document.head || document.body).appendChild(script);
  8632. }
  8633. this.script = script;
  8634. var isUAgecko = 'undefined' !== typeof navigator && /gecko/i.test(navigator.userAgent);
  8635. if (isUAgecko) {
  8636. setTimeout(function () {
  8637. var iframe = document.createElement('iframe');
  8638. document.body.appendChild(iframe);
  8639. document.body.removeChild(iframe);
  8640. }, 100);
  8641. }
  8642. };
  8643. /**
  8644. * Writes with a hidden iframe.
  8645. *
  8646. * @param {String} data to send
  8647. * @param {Function} called upon flush.
  8648. * @api private
  8649. */
  8650. JSONPPolling.prototype.doWrite = function (data, fn) {
  8651. var self = this;
  8652. if (!this.form) {
  8653. var form = document.createElement('form');
  8654. var area = document.createElement('textarea');
  8655. var id = this.iframeId = 'eio_iframe_' + this.index;
  8656. var iframe;
  8657. form.className = 'socketio';
  8658. form.style.position = 'absolute';
  8659. form.style.top = '-1000px';
  8660. form.style.left = '-1000px';
  8661. form.target = id;
  8662. form.method = 'POST';
  8663. form.setAttribute('accept-charset', 'utf-8');
  8664. area.name = 'd';
  8665. form.appendChild(area);
  8666. document.body.appendChild(form);
  8667. this.form = form;
  8668. this.area = area;
  8669. }
  8670. this.form.action = this.uri();
  8671. function complete () {
  8672. initIframe();
  8673. fn();
  8674. }
  8675. function initIframe () {
  8676. if (self.iframe) {
  8677. try {
  8678. self.form.removeChild(self.iframe);
  8679. } catch (e) {
  8680. self.onError('jsonp polling iframe removal error', e);
  8681. }
  8682. }
  8683. try {
  8684. // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
  8685. var html = '<iframe src="javascript:0" name="' + self.iframeId + '">';
  8686. iframe = document.createElement(html);
  8687. } catch (e) {
  8688. iframe = document.createElement('iframe');
  8689. iframe.name = self.iframeId;
  8690. iframe.src = 'javascript:0';
  8691. }
  8692. iframe.id = self.iframeId;
  8693. self.form.appendChild(iframe);
  8694. self.iframe = iframe;
  8695. }
  8696. initIframe();
  8697. // escape \n to prevent it from being converted into \r\n by some UAs
  8698. // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side
  8699. data = data.replace(rEscapedNewline, '\\\n');
  8700. this.area.value = data.replace(rNewline, '\\n');
  8701. try {
  8702. this.form.submit();
  8703. } catch (e) {}
  8704. if (this.iframe.attachEvent) {
  8705. this.iframe.onreadystatechange = function () {
  8706. if (self.iframe.readyState === 'complete') {
  8707. complete();
  8708. }
  8709. };
  8710. } else {
  8711. this.iframe.onload = complete;
  8712. }
  8713. };
  8714. /***/ }),
  8715. /***/ "./node_modules/engine.io-client/lib/transports/polling-xhr.js":
  8716. /*!*********************************************************************!*\
  8717. !*** ./node_modules/engine.io-client/lib/transports/polling-xhr.js ***!
  8718. \*********************************************************************/
  8719. /*! no static exports found */
  8720. /***/ (function(module, exports, __webpack_require__) {
  8721. /* global attachEvent */
  8722. /**
  8723. * Module requirements.
  8724. */
  8725. var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
  8726. var Polling = __webpack_require__(/*! ./polling */ "./node_modules/engine.io-client/lib/transports/polling.js");
  8727. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/component-emitter/index.js");
  8728. var inherit = __webpack_require__(/*! component-inherit */ "./node_modules/component-inherit/index.js");
  8729. var debug = __webpack_require__(/*! debug */ "./node_modules/engine.io-client/node_modules/debug/src/browser.js")('engine.io-client:polling-xhr');
  8730. var globalThis = __webpack_require__(/*! ../globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
  8731. /**
  8732. * Module exports.
  8733. */
  8734. module.exports = XHR;
  8735. module.exports.Request = Request;
  8736. /**
  8737. * Empty function
  8738. */
  8739. function empty () {}
  8740. /**
  8741. * XHR Polling constructor.
  8742. *
  8743. * @param {Object} opts
  8744. * @api public
  8745. */
  8746. function XHR (opts) {
  8747. Polling.call(this, opts);
  8748. this.requestTimeout = opts.requestTimeout;
  8749. this.extraHeaders = opts.extraHeaders;
  8750. if (typeof location !== 'undefined') {
  8751. var isSSL = 'https:' === location.protocol;
  8752. var port = location.port;
  8753. // some user agents have empty `location.port`
  8754. if (!port) {
  8755. port = isSSL ? 443 : 80;
  8756. }
  8757. this.xd = (typeof location !== 'undefined' && opts.hostname !== location.hostname) ||
  8758. port !== opts.port;
  8759. this.xs = opts.secure !== isSSL;
  8760. }
  8761. }
  8762. /**
  8763. * Inherits from Polling.
  8764. */
  8765. inherit(XHR, Polling);
  8766. /**
  8767. * XHR supports binary
  8768. */
  8769. XHR.prototype.supportsBinary = true;
  8770. /**
  8771. * Creates a request.
  8772. *
  8773. * @param {String} method
  8774. * @api private
  8775. */
  8776. XHR.prototype.request = function (opts) {
  8777. opts = opts || {};
  8778. opts.uri = this.uri();
  8779. opts.xd = this.xd;
  8780. opts.xs = this.xs;
  8781. opts.agent = this.agent || false;
  8782. opts.supportsBinary = this.supportsBinary;
  8783. opts.enablesXDR = this.enablesXDR;
  8784. opts.withCredentials = this.withCredentials;
  8785. // SSL options for Node.js client
  8786. opts.pfx = this.pfx;
  8787. opts.key = this.key;
  8788. opts.passphrase = this.passphrase;
  8789. opts.cert = this.cert;
  8790. opts.ca = this.ca;
  8791. opts.ciphers = this.ciphers;
  8792. opts.rejectUnauthorized = this.rejectUnauthorized;
  8793. opts.requestTimeout = this.requestTimeout;
  8794. // other options for Node.js client
  8795. opts.extraHeaders = this.extraHeaders;
  8796. return new Request(opts);
  8797. };
  8798. /**
  8799. * Sends data.
  8800. *
  8801. * @param {String} data to send.
  8802. * @param {Function} called upon flush.
  8803. * @api private
  8804. */
  8805. XHR.prototype.doWrite = function (data, fn) {
  8806. var isBinary = typeof data !== 'string' && data !== undefined;
  8807. var req = this.request({ method: 'POST', data: data, isBinary: isBinary });
  8808. var self = this;
  8809. req.on('success', fn);
  8810. req.on('error', function (err) {
  8811. self.onError('xhr post error', err);
  8812. });
  8813. this.sendXhr = req;
  8814. };
  8815. /**
  8816. * Starts a poll cycle.
  8817. *
  8818. * @api private
  8819. */
  8820. XHR.prototype.doPoll = function () {
  8821. debug('xhr poll');
  8822. var req = this.request();
  8823. var self = this;
  8824. req.on('data', function (data) {
  8825. self.onData(data);
  8826. });
  8827. req.on('error', function (err) {
  8828. self.onError('xhr poll error', err);
  8829. });
  8830. this.pollXhr = req;
  8831. };
  8832. /**
  8833. * Request constructor
  8834. *
  8835. * @param {Object} options
  8836. * @api public
  8837. */
  8838. function Request (opts) {
  8839. this.method = opts.method || 'GET';
  8840. this.uri = opts.uri;
  8841. this.xd = !!opts.xd;
  8842. this.xs = !!opts.xs;
  8843. this.async = false !== opts.async;
  8844. this.data = undefined !== opts.data ? opts.data : null;
  8845. this.agent = opts.agent;
  8846. this.isBinary = opts.isBinary;
  8847. this.supportsBinary = opts.supportsBinary;
  8848. this.enablesXDR = opts.enablesXDR;
  8849. this.withCredentials = opts.withCredentials;
  8850. this.requestTimeout = opts.requestTimeout;
  8851. // SSL options for Node.js client
  8852. this.pfx = opts.pfx;
  8853. this.key = opts.key;
  8854. this.passphrase = opts.passphrase;
  8855. this.cert = opts.cert;
  8856. this.ca = opts.ca;
  8857. this.ciphers = opts.ciphers;
  8858. this.rejectUnauthorized = opts.rejectUnauthorized;
  8859. // other options for Node.js client
  8860. this.extraHeaders = opts.extraHeaders;
  8861. this.create();
  8862. }
  8863. /**
  8864. * Mix in `Emitter`.
  8865. */
  8866. Emitter(Request.prototype);
  8867. /**
  8868. * Creates the XHR object and sends the request.
  8869. *
  8870. * @api private
  8871. */
  8872. Request.prototype.create = function () {
  8873. var opts = { agent: this.agent, xdomain: this.xd, xscheme: this.xs, enablesXDR: this.enablesXDR };
  8874. // SSL options for Node.js client
  8875. opts.pfx = this.pfx;
  8876. opts.key = this.key;
  8877. opts.passphrase = this.passphrase;
  8878. opts.cert = this.cert;
  8879. opts.ca = this.ca;
  8880. opts.ciphers = this.ciphers;
  8881. opts.rejectUnauthorized = this.rejectUnauthorized;
  8882. var xhr = this.xhr = new XMLHttpRequest(opts);
  8883. var self = this;
  8884. try {
  8885. debug('xhr open %s: %s', this.method, this.uri);
  8886. xhr.open(this.method, this.uri, this.async);
  8887. try {
  8888. if (this.extraHeaders) {
  8889. xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
  8890. for (var i in this.extraHeaders) {
  8891. if (this.extraHeaders.hasOwnProperty(i)) {
  8892. xhr.setRequestHeader(i, this.extraHeaders[i]);
  8893. }
  8894. }
  8895. }
  8896. } catch (e) {}
  8897. if ('POST' === this.method) {
  8898. try {
  8899. if (this.isBinary) {
  8900. xhr.setRequestHeader('Content-type', 'application/octet-stream');
  8901. } else {
  8902. xhr.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
  8903. }
  8904. } catch (e) {}
  8905. }
  8906. try {
  8907. xhr.setRequestHeader('Accept', '*/*');
  8908. } catch (e) {}
  8909. // ie6 check
  8910. if ('withCredentials' in xhr) {
  8911. xhr.withCredentials = this.withCredentials;
  8912. }
  8913. if (this.requestTimeout) {
  8914. xhr.timeout = this.requestTimeout;
  8915. }
  8916. if (this.hasXDR()) {
  8917. xhr.onload = function () {
  8918. self.onLoad();
  8919. };
  8920. xhr.onerror = function () {
  8921. self.onError(xhr.responseText);
  8922. };
  8923. } else {
  8924. xhr.onreadystatechange = function () {
  8925. if (xhr.readyState === 2) {
  8926. try {
  8927. var contentType = xhr.getResponseHeader('Content-Type');
  8928. if (self.supportsBinary && contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
  8929. xhr.responseType = 'arraybuffer';
  8930. }
  8931. } catch (e) {}
  8932. }
  8933. if (4 !== xhr.readyState) return;
  8934. if (200 === xhr.status || 1223 === xhr.status) {
  8935. self.onLoad();
  8936. } else {
  8937. // make sure the `error` event handler that's user-set
  8938. // does not throw in the same tick and gets caught here
  8939. setTimeout(function () {
  8940. self.onError(typeof xhr.status === 'number' ? xhr.status : 0);
  8941. }, 0);
  8942. }
  8943. };
  8944. }
  8945. debug('xhr data %s', this.data);
  8946. xhr.send(this.data);
  8947. } catch (e) {
  8948. // Need to defer since .create() is called directly fhrom the constructor
  8949. // and thus the 'error' event can only be only bound *after* this exception
  8950. // occurs. Therefore, also, we cannot throw here at all.
  8951. setTimeout(function () {
  8952. self.onError(e);
  8953. }, 0);
  8954. return;
  8955. }
  8956. if (typeof document !== 'undefined') {
  8957. this.index = Request.requestsCount++;
  8958. Request.requests[this.index] = this;
  8959. }
  8960. };
  8961. /**
  8962. * Called upon successful response.
  8963. *
  8964. * @api private
  8965. */
  8966. Request.prototype.onSuccess = function () {
  8967. this.emit('success');
  8968. this.cleanup();
  8969. };
  8970. /**
  8971. * Called if we have data.
  8972. *
  8973. * @api private
  8974. */
  8975. Request.prototype.onData = function (data) {
  8976. this.emit('data', data);
  8977. this.onSuccess();
  8978. };
  8979. /**
  8980. * Called upon error.
  8981. *
  8982. * @api private
  8983. */
  8984. Request.prototype.onError = function (err) {
  8985. this.emit('error', err);
  8986. this.cleanup(true);
  8987. };
  8988. /**
  8989. * Cleans up house.
  8990. *
  8991. * @api private
  8992. */
  8993. Request.prototype.cleanup = function (fromError) {
  8994. if ('undefined' === typeof this.xhr || null === this.xhr) {
  8995. return;
  8996. }
  8997. // xmlhttprequest
  8998. if (this.hasXDR()) {
  8999. this.xhr.onload = this.xhr.onerror = empty;
  9000. } else {
  9001. this.xhr.onreadystatechange = empty;
  9002. }
  9003. if (fromError) {
  9004. try {
  9005. this.xhr.abort();
  9006. } catch (e) {}
  9007. }
  9008. if (typeof document !== 'undefined') {
  9009. delete Request.requests[this.index];
  9010. }
  9011. this.xhr = null;
  9012. };
  9013. /**
  9014. * Called upon load.
  9015. *
  9016. * @api private
  9017. */
  9018. Request.prototype.onLoad = function () {
  9019. var data;
  9020. try {
  9021. var contentType;
  9022. try {
  9023. contentType = this.xhr.getResponseHeader('Content-Type');
  9024. } catch (e) {}
  9025. if (contentType === 'application/octet-stream' || contentType === 'application/octet-stream; charset=UTF-8') {
  9026. data = this.xhr.response || this.xhr.responseText;
  9027. } else {
  9028. data = this.xhr.responseText;
  9029. }
  9030. } catch (e) {
  9031. this.onError(e);
  9032. }
  9033. if (null != data) {
  9034. this.onData(data);
  9035. }
  9036. };
  9037. /**
  9038. * Check if it has XDomainRequest.
  9039. *
  9040. * @api private
  9041. */
  9042. Request.prototype.hasXDR = function () {
  9043. return typeof XDomainRequest !== 'undefined' && !this.xs && this.enablesXDR;
  9044. };
  9045. /**
  9046. * Aborts the request.
  9047. *
  9048. * @api public
  9049. */
  9050. Request.prototype.abort = function () {
  9051. this.cleanup();
  9052. };
  9053. /**
  9054. * Aborts pending requests when unloading the window. This is needed to prevent
  9055. * memory leaks (e.g. when using IE) and to ensure that no spurious error is
  9056. * emitted.
  9057. */
  9058. Request.requestsCount = 0;
  9059. Request.requests = {};
  9060. if (typeof document !== 'undefined') {
  9061. if (typeof attachEvent === 'function') {
  9062. attachEvent('onunload', unloadHandler);
  9063. } else if (typeof addEventListener === 'function') {
  9064. var terminationEvent = 'onpagehide' in globalThis ? 'pagehide' : 'unload';
  9065. addEventListener(terminationEvent, unloadHandler, false);
  9066. }
  9067. }
  9068. function unloadHandler () {
  9069. for (var i in Request.requests) {
  9070. if (Request.requests.hasOwnProperty(i)) {
  9071. Request.requests[i].abort();
  9072. }
  9073. }
  9074. }
  9075. /***/ }),
  9076. /***/ "./node_modules/engine.io-client/lib/transports/polling.js":
  9077. /*!*****************************************************************!*\
  9078. !*** ./node_modules/engine.io-client/lib/transports/polling.js ***!
  9079. \*****************************************************************/
  9080. /*! no static exports found */
  9081. /***/ (function(module, exports, __webpack_require__) {
  9082. /**
  9083. * Module dependencies.
  9084. */
  9085. var Transport = __webpack_require__(/*! ../transport */ "./node_modules/engine.io-client/lib/transport.js");
  9086. var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
  9087. var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  9088. var inherit = __webpack_require__(/*! component-inherit */ "./node_modules/component-inherit/index.js");
  9089. var yeast = __webpack_require__(/*! yeast */ "./node_modules/yeast/index.js");
  9090. var debug = __webpack_require__(/*! debug */ "./node_modules/engine.io-client/node_modules/debug/src/browser.js")('engine.io-client:polling');
  9091. /**
  9092. * Module exports.
  9093. */
  9094. module.exports = Polling;
  9095. /**
  9096. * Is XHR2 supported?
  9097. */
  9098. var hasXHR2 = (function () {
  9099. var XMLHttpRequest = __webpack_require__(/*! xmlhttprequest-ssl */ "./node_modules/engine.io-client/lib/xmlhttprequest.js");
  9100. var xhr = new XMLHttpRequest({ xdomain: false });
  9101. return null != xhr.responseType;
  9102. })();
  9103. /**
  9104. * Polling interface.
  9105. *
  9106. * @param {Object} opts
  9107. * @api private
  9108. */
  9109. function Polling (opts) {
  9110. var forceBase64 = (opts && opts.forceBase64);
  9111. if (!hasXHR2 || forceBase64) {
  9112. this.supportsBinary = false;
  9113. }
  9114. Transport.call(this, opts);
  9115. }
  9116. /**
  9117. * Inherits from Transport.
  9118. */
  9119. inherit(Polling, Transport);
  9120. /**
  9121. * Transport name.
  9122. */
  9123. Polling.prototype.name = 'polling';
  9124. /**
  9125. * Opens the socket (triggers polling). We write a PING message to determine
  9126. * when the transport is open.
  9127. *
  9128. * @api private
  9129. */
  9130. Polling.prototype.doOpen = function () {
  9131. this.poll();
  9132. };
  9133. /**
  9134. * Pauses polling.
  9135. *
  9136. * @param {Function} callback upon buffers are flushed and transport is paused
  9137. * @api private
  9138. */
  9139. Polling.prototype.pause = function (onPause) {
  9140. var self = this;
  9141. this.readyState = 'pausing';
  9142. function pause () {
  9143. debug('paused');
  9144. self.readyState = 'paused';
  9145. onPause();
  9146. }
  9147. if (this.polling || !this.writable) {
  9148. var total = 0;
  9149. if (this.polling) {
  9150. debug('we are currently polling - waiting to pause');
  9151. total++;
  9152. this.once('pollComplete', function () {
  9153. debug('pre-pause polling complete');
  9154. --total || pause();
  9155. });
  9156. }
  9157. if (!this.writable) {
  9158. debug('we are currently writing - waiting to pause');
  9159. total++;
  9160. this.once('drain', function () {
  9161. debug('pre-pause writing complete');
  9162. --total || pause();
  9163. });
  9164. }
  9165. } else {
  9166. pause();
  9167. }
  9168. };
  9169. /**
  9170. * Starts polling cycle.
  9171. *
  9172. * @api public
  9173. */
  9174. Polling.prototype.poll = function () {
  9175. debug('polling');
  9176. this.polling = true;
  9177. this.doPoll();
  9178. this.emit('poll');
  9179. };
  9180. /**
  9181. * Overloads onData to detect payloads.
  9182. *
  9183. * @api private
  9184. */
  9185. Polling.prototype.onData = function (data) {
  9186. var self = this;
  9187. debug('polling got data %s', data);
  9188. var callback = function (packet, index, total) {
  9189. // if its the first message we consider the transport open
  9190. if ('opening' === self.readyState) {
  9191. self.onOpen();
  9192. }
  9193. // if its a close packet, we close the ongoing requests
  9194. if ('close' === packet.type) {
  9195. self.onClose();
  9196. return false;
  9197. }
  9198. // otherwise bypass onData and handle the message
  9199. self.onPacket(packet);
  9200. };
  9201. // decode payload
  9202. parser.decodePayload(data, this.socket.binaryType, callback);
  9203. // if an event did not trigger closing
  9204. if ('closed' !== this.readyState) {
  9205. // if we got data we're not polling
  9206. this.polling = false;
  9207. this.emit('pollComplete');
  9208. if ('open' === this.readyState) {
  9209. this.poll();
  9210. } else {
  9211. debug('ignoring poll - transport state "%s"', this.readyState);
  9212. }
  9213. }
  9214. };
  9215. /**
  9216. * For polling, send a close packet.
  9217. *
  9218. * @api private
  9219. */
  9220. Polling.prototype.doClose = function () {
  9221. var self = this;
  9222. function close () {
  9223. debug('writing close packet');
  9224. self.write([{ type: 'close' }]);
  9225. }
  9226. if ('open' === this.readyState) {
  9227. debug('transport open - closing');
  9228. close();
  9229. } else {
  9230. // in case we're trying to close while
  9231. // handshaking is in progress (GH-164)
  9232. debug('transport not open - deferring close');
  9233. this.once('open', close);
  9234. }
  9235. };
  9236. /**
  9237. * Writes a packets payload.
  9238. *
  9239. * @param {Array} data packets
  9240. * @param {Function} drain callback
  9241. * @api private
  9242. */
  9243. Polling.prototype.write = function (packets) {
  9244. var self = this;
  9245. this.writable = false;
  9246. var callbackfn = function () {
  9247. self.writable = true;
  9248. self.emit('drain');
  9249. };
  9250. parser.encodePayload(packets, this.supportsBinary, function (data) {
  9251. self.doWrite(data, callbackfn);
  9252. });
  9253. };
  9254. /**
  9255. * Generates uri for connection.
  9256. *
  9257. * @api private
  9258. */
  9259. Polling.prototype.uri = function () {
  9260. var query = this.query || {};
  9261. var schema = this.secure ? 'https' : 'http';
  9262. var port = '';
  9263. // cache busting is forced
  9264. if (false !== this.timestampRequests) {
  9265. query[this.timestampParam] = yeast();
  9266. }
  9267. if (!this.supportsBinary && !query.sid) {
  9268. query.b64 = 1;
  9269. }
  9270. query = parseqs.encode(query);
  9271. // avoid port if default for schema
  9272. if (this.port && (('https' === schema && Number(this.port) !== 443) ||
  9273. ('http' === schema && Number(this.port) !== 80))) {
  9274. port = ':' + this.port;
  9275. }
  9276. // prepend ? to query
  9277. if (query.length) {
  9278. query = '?' + query;
  9279. }
  9280. var ipv6 = this.hostname.indexOf(':') !== -1;
  9281. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  9282. };
  9283. /***/ }),
  9284. /***/ "./node_modules/engine.io-client/lib/transports/websocket.js":
  9285. /*!*******************************************************************!*\
  9286. !*** ./node_modules/engine.io-client/lib/transports/websocket.js ***!
  9287. \*******************************************************************/
  9288. /*! no static exports found */
  9289. /***/ (function(module, exports, __webpack_require__) {
  9290. /* WEBPACK VAR INJECTION */(function(Buffer) {/**
  9291. * Module dependencies.
  9292. */
  9293. var Transport = __webpack_require__(/*! ../transport */ "./node_modules/engine.io-client/lib/transport.js");
  9294. var parser = __webpack_require__(/*! engine.io-parser */ "./node_modules/engine.io-parser/lib/browser.js");
  9295. var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
  9296. var inherit = __webpack_require__(/*! component-inherit */ "./node_modules/component-inherit/index.js");
  9297. var yeast = __webpack_require__(/*! yeast */ "./node_modules/yeast/index.js");
  9298. var debug = __webpack_require__(/*! debug */ "./node_modules/engine.io-client/node_modules/debug/src/browser.js")('engine.io-client:websocket');
  9299. var BrowserWebSocket, NodeWebSocket;
  9300. if (typeof WebSocket !== 'undefined') {
  9301. BrowserWebSocket = WebSocket;
  9302. } else if (typeof self !== 'undefined') {
  9303. BrowserWebSocket = self.WebSocket || self.MozWebSocket;
  9304. }
  9305. if (typeof window === 'undefined') {
  9306. try {
  9307. NodeWebSocket = __webpack_require__(/*! ws */ 1);
  9308. } catch (e) { }
  9309. }
  9310. /**
  9311. * Get either the `WebSocket` or `MozWebSocket` globals
  9312. * in the browser or try to resolve WebSocket-compatible
  9313. * interface exposed by `ws` for Node-like environment.
  9314. */
  9315. var WebSocketImpl = BrowserWebSocket || NodeWebSocket;
  9316. /**
  9317. * Module exports.
  9318. */
  9319. module.exports = WS;
  9320. /**
  9321. * WebSocket transport constructor.
  9322. *
  9323. * @api {Object} connection options
  9324. * @api public
  9325. */
  9326. function WS (opts) {
  9327. var forceBase64 = (opts && opts.forceBase64);
  9328. if (forceBase64) {
  9329. this.supportsBinary = false;
  9330. }
  9331. this.perMessageDeflate = opts.perMessageDeflate;
  9332. this.usingBrowserWebSocket = BrowserWebSocket && !opts.forceNode;
  9333. this.protocols = opts.protocols;
  9334. if (!this.usingBrowserWebSocket) {
  9335. WebSocketImpl = NodeWebSocket;
  9336. }
  9337. Transport.call(this, opts);
  9338. }
  9339. /**
  9340. * Inherits from Transport.
  9341. */
  9342. inherit(WS, Transport);
  9343. /**
  9344. * Transport name.
  9345. *
  9346. * @api public
  9347. */
  9348. WS.prototype.name = 'websocket';
  9349. /*
  9350. * WebSockets support binary
  9351. */
  9352. WS.prototype.supportsBinary = true;
  9353. /**
  9354. * Opens socket.
  9355. *
  9356. * @api private
  9357. */
  9358. WS.prototype.doOpen = function () {
  9359. if (!this.check()) {
  9360. // let probe timeout
  9361. return;
  9362. }
  9363. var uri = this.uri();
  9364. var protocols = this.protocols;
  9365. var opts = {
  9366. agent: this.agent,
  9367. perMessageDeflate: this.perMessageDeflate
  9368. };
  9369. // SSL options for Node.js client
  9370. opts.pfx = this.pfx;
  9371. opts.key = this.key;
  9372. opts.passphrase = this.passphrase;
  9373. opts.cert = this.cert;
  9374. opts.ca = this.ca;
  9375. opts.ciphers = this.ciphers;
  9376. opts.rejectUnauthorized = this.rejectUnauthorized;
  9377. if (this.extraHeaders) {
  9378. opts.headers = this.extraHeaders;
  9379. }
  9380. if (this.localAddress) {
  9381. opts.localAddress = this.localAddress;
  9382. }
  9383. try {
  9384. this.ws =
  9385. this.usingBrowserWebSocket && !this.isReactNative
  9386. ? protocols
  9387. ? new WebSocketImpl(uri, protocols)
  9388. : new WebSocketImpl(uri)
  9389. : new WebSocketImpl(uri, protocols, opts);
  9390. } catch (err) {
  9391. return this.emit('error', err);
  9392. }
  9393. if (this.ws.binaryType === undefined) {
  9394. this.supportsBinary = false;
  9395. }
  9396. if (this.ws.supports && this.ws.supports.binary) {
  9397. this.supportsBinary = true;
  9398. this.ws.binaryType = 'nodebuffer';
  9399. } else {
  9400. this.ws.binaryType = 'arraybuffer';
  9401. }
  9402. this.addEventListeners();
  9403. };
  9404. /**
  9405. * Adds event listeners to the socket
  9406. *
  9407. * @api private
  9408. */
  9409. WS.prototype.addEventListeners = function () {
  9410. var self = this;
  9411. this.ws.onopen = function () {
  9412. self.onOpen();
  9413. };
  9414. this.ws.onclose = function () {
  9415. self.onClose();
  9416. };
  9417. this.ws.onmessage = function (ev) {
  9418. self.onData(ev.data);
  9419. };
  9420. this.ws.onerror = function (e) {
  9421. self.onError('websocket error', e);
  9422. };
  9423. };
  9424. /**
  9425. * Writes data to socket.
  9426. *
  9427. * @param {Array} array of packets.
  9428. * @api private
  9429. */
  9430. WS.prototype.write = function (packets) {
  9431. var self = this;
  9432. this.writable = false;
  9433. // encodePacket efficient as it uses WS framing
  9434. // no need for encodePayload
  9435. var total = packets.length;
  9436. for (var i = 0, l = total; i < l; i++) {
  9437. (function (packet) {
  9438. parser.encodePacket(packet, self.supportsBinary, function (data) {
  9439. if (!self.usingBrowserWebSocket) {
  9440. // always create a new object (GH-437)
  9441. var opts = {};
  9442. if (packet.options) {
  9443. opts.compress = packet.options.compress;
  9444. }
  9445. if (self.perMessageDeflate) {
  9446. var len = 'string' === typeof data ? Buffer.byteLength(data) : data.length;
  9447. if (len < self.perMessageDeflate.threshold) {
  9448. opts.compress = false;
  9449. }
  9450. }
  9451. }
  9452. // Sometimes the websocket has already been closed but the browser didn't
  9453. // have a chance of informing us about it yet, in that case send will
  9454. // throw an error
  9455. try {
  9456. if (self.usingBrowserWebSocket) {
  9457. // TypeError is thrown when passing the second argument on Safari
  9458. self.ws.send(data);
  9459. } else {
  9460. self.ws.send(data, opts);
  9461. }
  9462. } catch (e) {
  9463. debug('websocket closed before onclose event');
  9464. }
  9465. --total || done();
  9466. });
  9467. })(packets[i]);
  9468. }
  9469. function done () {
  9470. self.emit('flush');
  9471. // fake drain
  9472. // defer to next tick to allow Socket to clear writeBuffer
  9473. setTimeout(function () {
  9474. self.writable = true;
  9475. self.emit('drain');
  9476. }, 0);
  9477. }
  9478. };
  9479. /**
  9480. * Called upon close
  9481. *
  9482. * @api private
  9483. */
  9484. WS.prototype.onClose = function () {
  9485. Transport.prototype.onClose.call(this);
  9486. };
  9487. /**
  9488. * Closes socket.
  9489. *
  9490. * @api private
  9491. */
  9492. WS.prototype.doClose = function () {
  9493. if (typeof this.ws !== 'undefined') {
  9494. this.ws.close();
  9495. }
  9496. };
  9497. /**
  9498. * Generates uri for connection.
  9499. *
  9500. * @api private
  9501. */
  9502. WS.prototype.uri = function () {
  9503. var query = this.query || {};
  9504. var schema = this.secure ? 'wss' : 'ws';
  9505. var port = '';
  9506. // avoid port if default for schema
  9507. if (this.port && (('wss' === schema && Number(this.port) !== 443) ||
  9508. ('ws' === schema && Number(this.port) !== 80))) {
  9509. port = ':' + this.port;
  9510. }
  9511. // append timestamp to URI
  9512. if (this.timestampRequests) {
  9513. query[this.timestampParam] = yeast();
  9514. }
  9515. // communicate binary support capabilities
  9516. if (!this.supportsBinary) {
  9517. query.b64 = 1;
  9518. }
  9519. query = parseqs.encode(query);
  9520. // prepend ? to query
  9521. if (query.length) {
  9522. query = '?' + query;
  9523. }
  9524. var ipv6 = this.hostname.indexOf(':') !== -1;
  9525. return schema + '://' + (ipv6 ? '[' + this.hostname + ']' : this.hostname) + port + this.path + query;
  9526. };
  9527. /**
  9528. * Feature detection for WebSocket.
  9529. *
  9530. * @return {Boolean} whether this transport is available.
  9531. * @api public
  9532. */
  9533. WS.prototype.check = function () {
  9534. return !!WebSocketImpl && !('__initialize' in WebSocketImpl && this.name === WS.prototype.name);
  9535. };
  9536. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  9537. /***/ }),
  9538. /***/ "./node_modules/engine.io-client/lib/xmlhttprequest.js":
  9539. /*!*************************************************************!*\
  9540. !*** ./node_modules/engine.io-client/lib/xmlhttprequest.js ***!
  9541. \*************************************************************/
  9542. /*! no static exports found */
  9543. /***/ (function(module, exports, __webpack_require__) {
  9544. // browser shim for xmlhttprequest module
  9545. var hasCORS = __webpack_require__(/*! has-cors */ "./node_modules/has-cors/index.js");
  9546. var globalThis = __webpack_require__(/*! ./globalThis */ "./node_modules/engine.io-client/lib/globalThis.browser.js");
  9547. module.exports = function (opts) {
  9548. var xdomain = opts.xdomain;
  9549. // scheme must be same when usign XDomainRequest
  9550. // http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
  9551. var xscheme = opts.xscheme;
  9552. // XDomainRequest has a flow of not sending cookie, therefore it should be disabled as a default.
  9553. // https://github.com/Automattic/engine.io-client/pull/217
  9554. var enablesXDR = opts.enablesXDR;
  9555. // XMLHttpRequest can be disabled on IE
  9556. try {
  9557. if ('undefined' !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
  9558. return new XMLHttpRequest();
  9559. }
  9560. } catch (e) { }
  9561. // Use XDomainRequest for IE8 if enablesXDR is true
  9562. // because loading bar keeps flashing when using jsonp-polling
  9563. // https://github.com/yujiosaka/socke.io-ie8-loading-example
  9564. try {
  9565. if ('undefined' !== typeof XDomainRequest && !xscheme && enablesXDR) {
  9566. return new XDomainRequest();
  9567. }
  9568. } catch (e) { }
  9569. if (!xdomain) {
  9570. try {
  9571. return new globalThis[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP');
  9572. } catch (e) { }
  9573. }
  9574. };
  9575. /***/ }),
  9576. /***/ "./node_modules/engine.io-client/node_modules/debug/src/browser.js":
  9577. /*!*************************************************************************!*\
  9578. !*** ./node_modules/engine.io-client/node_modules/debug/src/browser.js ***!
  9579. \*************************************************************************/
  9580. /*! no static exports found */
  9581. /***/ (function(module, exports, __webpack_require__) {
  9582. /* WEBPACK VAR INJECTION */(function(process) {/* eslint-env browser */
  9583. /**
  9584. * This is the web browser implementation of `debug()`.
  9585. */
  9586. exports.log = log;
  9587. exports.formatArgs = formatArgs;
  9588. exports.save = save;
  9589. exports.load = load;
  9590. exports.useColors = useColors;
  9591. exports.storage = localstorage();
  9592. /**
  9593. * Colors.
  9594. */
  9595. exports.colors = [
  9596. '#0000CC',
  9597. '#0000FF',
  9598. '#0033CC',
  9599. '#0033FF',
  9600. '#0066CC',
  9601. '#0066FF',
  9602. '#0099CC',
  9603. '#0099FF',
  9604. '#00CC00',
  9605. '#00CC33',
  9606. '#00CC66',
  9607. '#00CC99',
  9608. '#00CCCC',
  9609. '#00CCFF',
  9610. '#3300CC',
  9611. '#3300FF',
  9612. '#3333CC',
  9613. '#3333FF',
  9614. '#3366CC',
  9615. '#3366FF',
  9616. '#3399CC',
  9617. '#3399FF',
  9618. '#33CC00',
  9619. '#33CC33',
  9620. '#33CC66',
  9621. '#33CC99',
  9622. '#33CCCC',
  9623. '#33CCFF',
  9624. '#6600CC',
  9625. '#6600FF',
  9626. '#6633CC',
  9627. '#6633FF',
  9628. '#66CC00',
  9629. '#66CC33',
  9630. '#9900CC',
  9631. '#9900FF',
  9632. '#9933CC',
  9633. '#9933FF',
  9634. '#99CC00',
  9635. '#99CC33',
  9636. '#CC0000',
  9637. '#CC0033',
  9638. '#CC0066',
  9639. '#CC0099',
  9640. '#CC00CC',
  9641. '#CC00FF',
  9642. '#CC3300',
  9643. '#CC3333',
  9644. '#CC3366',
  9645. '#CC3399',
  9646. '#CC33CC',
  9647. '#CC33FF',
  9648. '#CC6600',
  9649. '#CC6633',
  9650. '#CC9900',
  9651. '#CC9933',
  9652. '#CCCC00',
  9653. '#CCCC33',
  9654. '#FF0000',
  9655. '#FF0033',
  9656. '#FF0066',
  9657. '#FF0099',
  9658. '#FF00CC',
  9659. '#FF00FF',
  9660. '#FF3300',
  9661. '#FF3333',
  9662. '#FF3366',
  9663. '#FF3399',
  9664. '#FF33CC',
  9665. '#FF33FF',
  9666. '#FF6600',
  9667. '#FF6633',
  9668. '#FF9900',
  9669. '#FF9933',
  9670. '#FFCC00',
  9671. '#FFCC33'
  9672. ];
  9673. /**
  9674. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  9675. * and the Firebug extension (any Firefox version) are known
  9676. * to support "%c" CSS customizations.
  9677. *
  9678. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  9679. */
  9680. // eslint-disable-next-line complexity
  9681. function useColors() {
  9682. // NB: In an Electron preload script, document will be defined but not fully
  9683. // initialized. Since we know we're in Chrome, we'll just detect this case
  9684. // explicitly
  9685. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  9686. return true;
  9687. }
  9688. // Internet Explorer and Edge do not support colors.
  9689. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  9690. return false;
  9691. }
  9692. // Is webkit? http://stackoverflow.com/a/16459606/376773
  9693. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  9694. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  9695. // Is firebug? http://stackoverflow.com/a/398120/376773
  9696. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  9697. // Is firefox >= v31?
  9698. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  9699. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  9700. // Double check webkit in userAgent just in case we are in a worker
  9701. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  9702. }
  9703. /**
  9704. * Colorize log arguments if enabled.
  9705. *
  9706. * @api public
  9707. */
  9708. function formatArgs(args) {
  9709. args[0] = (this.useColors ? '%c' : '') +
  9710. this.namespace +
  9711. (this.useColors ? ' %c' : ' ') +
  9712. args[0] +
  9713. (this.useColors ? '%c ' : ' ') +
  9714. '+' + module.exports.humanize(this.diff);
  9715. if (!this.useColors) {
  9716. return;
  9717. }
  9718. const c = 'color: ' + this.color;
  9719. args.splice(1, 0, c, 'color: inherit');
  9720. // The final "%c" is somewhat tricky, because there could be other
  9721. // arguments passed either before or after the %c, so we need to
  9722. // figure out the correct index to insert the CSS into
  9723. let index = 0;
  9724. let lastC = 0;
  9725. args[0].replace(/%[a-zA-Z%]/g, match => {
  9726. if (match === '%%') {
  9727. return;
  9728. }
  9729. index++;
  9730. if (match === '%c') {
  9731. // We only are interested in the *last* %c
  9732. // (the user may have provided their own)
  9733. lastC = index;
  9734. }
  9735. });
  9736. args.splice(lastC, 0, c);
  9737. }
  9738. /**
  9739. * Invokes `console.log()` when available.
  9740. * No-op when `console.log` is not a "function".
  9741. *
  9742. * @api public
  9743. */
  9744. function log(...args) {
  9745. // This hackery is required for IE8/9, where
  9746. // the `console.log` function doesn't have 'apply'
  9747. return typeof console === 'object' &&
  9748. console.log &&
  9749. console.log(...args);
  9750. }
  9751. /**
  9752. * Save `namespaces`.
  9753. *
  9754. * @param {String} namespaces
  9755. * @api private
  9756. */
  9757. function save(namespaces) {
  9758. try {
  9759. if (namespaces) {
  9760. exports.storage.setItem('debug', namespaces);
  9761. } else {
  9762. exports.storage.removeItem('debug');
  9763. }
  9764. } catch (error) {
  9765. // Swallow
  9766. // XXX (@Qix-) should we be logging these?
  9767. }
  9768. }
  9769. /**
  9770. * Load `namespaces`.
  9771. *
  9772. * @return {String} returns the previously persisted debug modes
  9773. * @api private
  9774. */
  9775. function load() {
  9776. let r;
  9777. try {
  9778. r = exports.storage.getItem('debug');
  9779. } catch (error) {
  9780. // Swallow
  9781. // XXX (@Qix-) should we be logging these?
  9782. }
  9783. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  9784. if (!r && typeof process !== 'undefined' && 'env' in process) {
  9785. r = process.env.DEBUG;
  9786. }
  9787. return r;
  9788. }
  9789. /**
  9790. * Localstorage attempts to return the localstorage.
  9791. *
  9792. * This is necessary because safari throws
  9793. * when a user disables cookies/localstorage
  9794. * and you attempt to access it.
  9795. *
  9796. * @return {LocalStorage}
  9797. * @api private
  9798. */
  9799. function localstorage() {
  9800. try {
  9801. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  9802. // The Browser also has localStorage in the global context.
  9803. return localStorage;
  9804. } catch (error) {
  9805. // Swallow
  9806. // XXX (@Qix-) should we be logging these?
  9807. }
  9808. }
  9809. module.exports = __webpack_require__(/*! ./common */ "./node_modules/engine.io-client/node_modules/debug/src/common.js")(exports);
  9810. const {formatters} = module.exports;
  9811. /**
  9812. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  9813. */
  9814. formatters.j = function (v) {
  9815. try {
  9816. return JSON.stringify(v);
  9817. } catch (error) {
  9818. return '[UnexpectedJSONParseError]: ' + error.message;
  9819. }
  9820. };
  9821. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../process/browser.js */ "./node_modules/process/browser.js")))
  9822. /***/ }),
  9823. /***/ "./node_modules/engine.io-client/node_modules/debug/src/common.js":
  9824. /*!************************************************************************!*\
  9825. !*** ./node_modules/engine.io-client/node_modules/debug/src/common.js ***!
  9826. \************************************************************************/
  9827. /*! no static exports found */
  9828. /***/ (function(module, exports, __webpack_require__) {
  9829. /**
  9830. * This is the common logic for both the Node.js and web browser
  9831. * implementations of `debug()`.
  9832. */
  9833. function setup(env) {
  9834. createDebug.debug = createDebug;
  9835. createDebug.default = createDebug;
  9836. createDebug.coerce = coerce;
  9837. createDebug.disable = disable;
  9838. createDebug.enable = enable;
  9839. createDebug.enabled = enabled;
  9840. createDebug.humanize = __webpack_require__(/*! ms */ "./node_modules/engine.io-client/node_modules/ms/index.js");
  9841. Object.keys(env).forEach(key => {
  9842. createDebug[key] = env[key];
  9843. });
  9844. /**
  9845. * Active `debug` instances.
  9846. */
  9847. createDebug.instances = [];
  9848. /**
  9849. * The currently active debug mode names, and names to skip.
  9850. */
  9851. createDebug.names = [];
  9852. createDebug.skips = [];
  9853. /**
  9854. * Map of special "%n" handling functions, for the debug "format" argument.
  9855. *
  9856. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  9857. */
  9858. createDebug.formatters = {};
  9859. /**
  9860. * Selects a color for a debug namespace
  9861. * @param {String} namespace The namespace string for the for the debug instance to be colored
  9862. * @return {Number|String} An ANSI color code for the given namespace
  9863. * @api private
  9864. */
  9865. function selectColor(namespace) {
  9866. let hash = 0;
  9867. for (let i = 0; i < namespace.length; i++) {
  9868. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  9869. hash |= 0; // Convert to 32bit integer
  9870. }
  9871. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  9872. }
  9873. createDebug.selectColor = selectColor;
  9874. /**
  9875. * Create a debugger with the given `namespace`.
  9876. *
  9877. * @param {String} namespace
  9878. * @return {Function}
  9879. * @api public
  9880. */
  9881. function createDebug(namespace) {
  9882. let prevTime;
  9883. function debug(...args) {
  9884. // Disabled?
  9885. if (!debug.enabled) {
  9886. return;
  9887. }
  9888. const self = debug;
  9889. // Set `diff` timestamp
  9890. const curr = Number(new Date());
  9891. const ms = curr - (prevTime || curr);
  9892. self.diff = ms;
  9893. self.prev = prevTime;
  9894. self.curr = curr;
  9895. prevTime = curr;
  9896. args[0] = createDebug.coerce(args[0]);
  9897. if (typeof args[0] !== 'string') {
  9898. // Anything else let's inspect with %O
  9899. args.unshift('%O');
  9900. }
  9901. // Apply any `formatters` transformations
  9902. let index = 0;
  9903. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  9904. // If we encounter an escaped % then don't increase the array index
  9905. if (match === '%%') {
  9906. return match;
  9907. }
  9908. index++;
  9909. const formatter = createDebug.formatters[format];
  9910. if (typeof formatter === 'function') {
  9911. const val = args[index];
  9912. match = formatter.call(self, val);
  9913. // Now we need to remove `args[index]` since it's inlined in the `format`
  9914. args.splice(index, 1);
  9915. index--;
  9916. }
  9917. return match;
  9918. });
  9919. // Apply env-specific formatting (colors, etc.)
  9920. createDebug.formatArgs.call(self, args);
  9921. const logFn = self.log || createDebug.log;
  9922. logFn.apply(self, args);
  9923. }
  9924. debug.namespace = namespace;
  9925. debug.enabled = createDebug.enabled(namespace);
  9926. debug.useColors = createDebug.useColors();
  9927. debug.color = selectColor(namespace);
  9928. debug.destroy = destroy;
  9929. debug.extend = extend;
  9930. // Debug.formatArgs = formatArgs;
  9931. // debug.rawLog = rawLog;
  9932. // env-specific initialization logic for debug instances
  9933. if (typeof createDebug.init === 'function') {
  9934. createDebug.init(debug);
  9935. }
  9936. createDebug.instances.push(debug);
  9937. return debug;
  9938. }
  9939. function destroy() {
  9940. const index = createDebug.instances.indexOf(this);
  9941. if (index !== -1) {
  9942. createDebug.instances.splice(index, 1);
  9943. return true;
  9944. }
  9945. return false;
  9946. }
  9947. function extend(namespace, delimiter) {
  9948. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  9949. newDebug.log = this.log;
  9950. return newDebug;
  9951. }
  9952. /**
  9953. * Enables a debug mode by namespaces. This can include modes
  9954. * separated by a colon and wildcards.
  9955. *
  9956. * @param {String} namespaces
  9957. * @api public
  9958. */
  9959. function enable(namespaces) {
  9960. createDebug.save(namespaces);
  9961. createDebug.names = [];
  9962. createDebug.skips = [];
  9963. let i;
  9964. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  9965. const len = split.length;
  9966. for (i = 0; i < len; i++) {
  9967. if (!split[i]) {
  9968. // ignore empty strings
  9969. continue;
  9970. }
  9971. namespaces = split[i].replace(/\*/g, '.*?');
  9972. if (namespaces[0] === '-') {
  9973. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  9974. } else {
  9975. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  9976. }
  9977. }
  9978. for (i = 0; i < createDebug.instances.length; i++) {
  9979. const instance = createDebug.instances[i];
  9980. instance.enabled = createDebug.enabled(instance.namespace);
  9981. }
  9982. }
  9983. /**
  9984. * Disable debug output.
  9985. *
  9986. * @return {String} namespaces
  9987. * @api public
  9988. */
  9989. function disable() {
  9990. const namespaces = [
  9991. ...createDebug.names.map(toNamespace),
  9992. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  9993. ].join(',');
  9994. createDebug.enable('');
  9995. return namespaces;
  9996. }
  9997. /**
  9998. * Returns true if the given mode name is enabled, false otherwise.
  9999. *
  10000. * @param {String} name
  10001. * @return {Boolean}
  10002. * @api public
  10003. */
  10004. function enabled(name) {
  10005. if (name[name.length - 1] === '*') {
  10006. return true;
  10007. }
  10008. let i;
  10009. let len;
  10010. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  10011. if (createDebug.skips[i].test(name)) {
  10012. return false;
  10013. }
  10014. }
  10015. for (i = 0, len = createDebug.names.length; i < len; i++) {
  10016. if (createDebug.names[i].test(name)) {
  10017. return true;
  10018. }
  10019. }
  10020. return false;
  10021. }
  10022. /**
  10023. * Convert regexp to namespace
  10024. *
  10025. * @param {RegExp} regxep
  10026. * @return {String} namespace
  10027. * @api private
  10028. */
  10029. function toNamespace(regexp) {
  10030. return regexp.toString()
  10031. .substring(2, regexp.toString().length - 2)
  10032. .replace(/\.\*\?$/, '*');
  10033. }
  10034. /**
  10035. * Coerce `val`.
  10036. *
  10037. * @param {Mixed} val
  10038. * @return {Mixed}
  10039. * @api private
  10040. */
  10041. function coerce(val) {
  10042. if (val instanceof Error) {
  10043. return val.stack || val.message;
  10044. }
  10045. return val;
  10046. }
  10047. createDebug.enable(createDebug.load());
  10048. return createDebug;
  10049. }
  10050. module.exports = setup;
  10051. /***/ }),
  10052. /***/ "./node_modules/engine.io-client/node_modules/ms/index.js":
  10053. /*!****************************************************************!*\
  10054. !*** ./node_modules/engine.io-client/node_modules/ms/index.js ***!
  10055. \****************************************************************/
  10056. /*! no static exports found */
  10057. /***/ (function(module, exports) {
  10058. /**
  10059. * Helpers.
  10060. */
  10061. var s = 1000;
  10062. var m = s * 60;
  10063. var h = m * 60;
  10064. var d = h * 24;
  10065. var w = d * 7;
  10066. var y = d * 365.25;
  10067. /**
  10068. * Parse or format the given `val`.
  10069. *
  10070. * Options:
  10071. *
  10072. * - `long` verbose formatting [false]
  10073. *
  10074. * @param {String|Number} val
  10075. * @param {Object} [options]
  10076. * @throws {Error} throw an error if val is not a non-empty string or a number
  10077. * @return {String|Number}
  10078. * @api public
  10079. */
  10080. module.exports = function(val, options) {
  10081. options = options || {};
  10082. var type = typeof val;
  10083. if (type === 'string' && val.length > 0) {
  10084. return parse(val);
  10085. } else if (type === 'number' && isFinite(val)) {
  10086. return options.long ? fmtLong(val) : fmtShort(val);
  10087. }
  10088. throw new Error(
  10089. 'val is not a non-empty string or a valid number. val=' +
  10090. JSON.stringify(val)
  10091. );
  10092. };
  10093. /**
  10094. * Parse the given `str` and return milliseconds.
  10095. *
  10096. * @param {String} str
  10097. * @return {Number}
  10098. * @api private
  10099. */
  10100. function parse(str) {
  10101. str = String(str);
  10102. if (str.length > 100) {
  10103. return;
  10104. }
  10105. var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  10106. str
  10107. );
  10108. if (!match) {
  10109. return;
  10110. }
  10111. var n = parseFloat(match[1]);
  10112. var type = (match[2] || 'ms').toLowerCase();
  10113. switch (type) {
  10114. case 'years':
  10115. case 'year':
  10116. case 'yrs':
  10117. case 'yr':
  10118. case 'y':
  10119. return n * y;
  10120. case 'weeks':
  10121. case 'week':
  10122. case 'w':
  10123. return n * w;
  10124. case 'days':
  10125. case 'day':
  10126. case 'd':
  10127. return n * d;
  10128. case 'hours':
  10129. case 'hour':
  10130. case 'hrs':
  10131. case 'hr':
  10132. case 'h':
  10133. return n * h;
  10134. case 'minutes':
  10135. case 'minute':
  10136. case 'mins':
  10137. case 'min':
  10138. case 'm':
  10139. return n * m;
  10140. case 'seconds':
  10141. case 'second':
  10142. case 'secs':
  10143. case 'sec':
  10144. case 's':
  10145. return n * s;
  10146. case 'milliseconds':
  10147. case 'millisecond':
  10148. case 'msecs':
  10149. case 'msec':
  10150. case 'ms':
  10151. return n;
  10152. default:
  10153. return undefined;
  10154. }
  10155. }
  10156. /**
  10157. * Short format for `ms`.
  10158. *
  10159. * @param {Number} ms
  10160. * @return {String}
  10161. * @api private
  10162. */
  10163. function fmtShort(ms) {
  10164. var msAbs = Math.abs(ms);
  10165. if (msAbs >= d) {
  10166. return Math.round(ms / d) + 'd';
  10167. }
  10168. if (msAbs >= h) {
  10169. return Math.round(ms / h) + 'h';
  10170. }
  10171. if (msAbs >= m) {
  10172. return Math.round(ms / m) + 'm';
  10173. }
  10174. if (msAbs >= s) {
  10175. return Math.round(ms / s) + 's';
  10176. }
  10177. return ms + 'ms';
  10178. }
  10179. /**
  10180. * Long format for `ms`.
  10181. *
  10182. * @param {Number} ms
  10183. * @return {String}
  10184. * @api private
  10185. */
  10186. function fmtLong(ms) {
  10187. var msAbs = Math.abs(ms);
  10188. if (msAbs >= d) {
  10189. return plural(ms, msAbs, d, 'day');
  10190. }
  10191. if (msAbs >= h) {
  10192. return plural(ms, msAbs, h, 'hour');
  10193. }
  10194. if (msAbs >= m) {
  10195. return plural(ms, msAbs, m, 'minute');
  10196. }
  10197. if (msAbs >= s) {
  10198. return plural(ms, msAbs, s, 'second');
  10199. }
  10200. return ms + ' ms';
  10201. }
  10202. /**
  10203. * Pluralization helper.
  10204. */
  10205. function plural(ms, msAbs, n, name) {
  10206. var isPlural = msAbs >= n * 1.5;
  10207. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  10208. }
  10209. /***/ }),
  10210. /***/ "./node_modules/engine.io-parser/lib/browser.js":
  10211. /*!******************************************************!*\
  10212. !*** ./node_modules/engine.io-parser/lib/browser.js ***!
  10213. \******************************************************/
  10214. /*! no static exports found */
  10215. /***/ (function(module, exports, __webpack_require__) {
  10216. /**
  10217. * Module dependencies.
  10218. */
  10219. var keys = __webpack_require__(/*! ./keys */ "./node_modules/engine.io-parser/lib/keys.js");
  10220. var hasBinary = __webpack_require__(/*! has-binary2 */ "./node_modules/has-binary2/index.js");
  10221. var sliceBuffer = __webpack_require__(/*! arraybuffer.slice */ "./node_modules/arraybuffer.slice/index.js");
  10222. var after = __webpack_require__(/*! after */ "./node_modules/after/index.js");
  10223. var utf8 = __webpack_require__(/*! ./utf8 */ "./node_modules/engine.io-parser/lib/utf8.js");
  10224. var base64encoder;
  10225. if (typeof ArrayBuffer !== 'undefined') {
  10226. base64encoder = __webpack_require__(/*! base64-arraybuffer */ "./node_modules/base64-arraybuffer/lib/base64-arraybuffer.js");
  10227. }
  10228. /**
  10229. * Check if we are running an android browser. That requires us to use
  10230. * ArrayBuffer with polling transports...
  10231. *
  10232. * http://ghinda.net/jpeg-blob-ajax-android/
  10233. */
  10234. var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
  10235. /**
  10236. * Check if we are running in PhantomJS.
  10237. * Uploading a Blob with PhantomJS does not work correctly, as reported here:
  10238. * https://github.com/ariya/phantomjs/issues/11395
  10239. * @type boolean
  10240. */
  10241. var isPhantomJS = typeof navigator !== 'undefined' && /PhantomJS/i.test(navigator.userAgent);
  10242. /**
  10243. * When true, avoids using Blobs to encode payloads.
  10244. * @type boolean
  10245. */
  10246. var dontSendBlobs = isAndroid || isPhantomJS;
  10247. /**
  10248. * Current protocol version.
  10249. */
  10250. exports.protocol = 3;
  10251. /**
  10252. * Packet types.
  10253. */
  10254. var packets = exports.packets = {
  10255. open: 0 // non-ws
  10256. , close: 1 // non-ws
  10257. , ping: 2
  10258. , pong: 3
  10259. , message: 4
  10260. , upgrade: 5
  10261. , noop: 6
  10262. };
  10263. var packetslist = keys(packets);
  10264. /**
  10265. * Premade error packet.
  10266. */
  10267. var err = { type: 'error', data: 'parser error' };
  10268. /**
  10269. * Create a blob api even for blob builder when vendor prefixes exist
  10270. */
  10271. var Blob = __webpack_require__(/*! blob */ "./node_modules/blob/index.js");
  10272. /**
  10273. * Encodes a packet.
  10274. *
  10275. * <packet type id> [ <data> ]
  10276. *
  10277. * Example:
  10278. *
  10279. * 5hello world
  10280. * 3
  10281. * 4
  10282. *
  10283. * Binary is encoded in an identical principle
  10284. *
  10285. * @api private
  10286. */
  10287. exports.encodePacket = function (packet, supportsBinary, utf8encode, callback) {
  10288. if (typeof supportsBinary === 'function') {
  10289. callback = supportsBinary;
  10290. supportsBinary = false;
  10291. }
  10292. if (typeof utf8encode === 'function') {
  10293. callback = utf8encode;
  10294. utf8encode = null;
  10295. }
  10296. var data = (packet.data === undefined)
  10297. ? undefined
  10298. : packet.data.buffer || packet.data;
  10299. if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
  10300. return encodeArrayBuffer(packet, supportsBinary, callback);
  10301. } else if (typeof Blob !== 'undefined' && data instanceof Blob) {
  10302. return encodeBlob(packet, supportsBinary, callback);
  10303. }
  10304. // might be an object with { base64: true, data: dataAsBase64String }
  10305. if (data && data.base64) {
  10306. return encodeBase64Object(packet, callback);
  10307. }
  10308. // Sending data as a utf-8 string
  10309. var encoded = packets[packet.type];
  10310. // data fragment is optional
  10311. if (undefined !== packet.data) {
  10312. encoded += utf8encode ? utf8.encode(String(packet.data), { strict: false }) : String(packet.data);
  10313. }
  10314. return callback('' + encoded);
  10315. };
  10316. function encodeBase64Object(packet, callback) {
  10317. // packet data is an object { base64: true, data: dataAsBase64String }
  10318. var message = 'b' + exports.packets[packet.type] + packet.data.data;
  10319. return callback(message);
  10320. }
  10321. /**
  10322. * Encode packet helpers for binary types
  10323. */
  10324. function encodeArrayBuffer(packet, supportsBinary, callback) {
  10325. if (!supportsBinary) {
  10326. return exports.encodeBase64Packet(packet, callback);
  10327. }
  10328. var data = packet.data;
  10329. var contentArray = new Uint8Array(data);
  10330. var resultBuffer = new Uint8Array(1 + data.byteLength);
  10331. resultBuffer[0] = packets[packet.type];
  10332. for (var i = 0; i < contentArray.length; i++) {
  10333. resultBuffer[i+1] = contentArray[i];
  10334. }
  10335. return callback(resultBuffer.buffer);
  10336. }
  10337. function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) {
  10338. if (!supportsBinary) {
  10339. return exports.encodeBase64Packet(packet, callback);
  10340. }
  10341. var fr = new FileReader();
  10342. fr.onload = function() {
  10343. exports.encodePacket({ type: packet.type, data: fr.result }, supportsBinary, true, callback);
  10344. };
  10345. return fr.readAsArrayBuffer(packet.data);
  10346. }
  10347. function encodeBlob(packet, supportsBinary, callback) {
  10348. if (!supportsBinary) {
  10349. return exports.encodeBase64Packet(packet, callback);
  10350. }
  10351. if (dontSendBlobs) {
  10352. return encodeBlobAsArrayBuffer(packet, supportsBinary, callback);
  10353. }
  10354. var length = new Uint8Array(1);
  10355. length[0] = packets[packet.type];
  10356. var blob = new Blob([length.buffer, packet.data]);
  10357. return callback(blob);
  10358. }
  10359. /**
  10360. * Encodes a packet with binary data in a base64 string
  10361. *
  10362. * @param {Object} packet, has `type` and `data`
  10363. * @return {String} base64 encoded message
  10364. */
  10365. exports.encodeBase64Packet = function(packet, callback) {
  10366. var message = 'b' + exports.packets[packet.type];
  10367. if (typeof Blob !== 'undefined' && packet.data instanceof Blob) {
  10368. var fr = new FileReader();
  10369. fr.onload = function() {
  10370. var b64 = fr.result.split(',')[1];
  10371. callback(message + b64);
  10372. };
  10373. return fr.readAsDataURL(packet.data);
  10374. }
  10375. var b64data;
  10376. try {
  10377. b64data = String.fromCharCode.apply(null, new Uint8Array(packet.data));
  10378. } catch (e) {
  10379. // iPhone Safari doesn't let you apply with typed arrays
  10380. var typed = new Uint8Array(packet.data);
  10381. var basic = new Array(typed.length);
  10382. for (var i = 0; i < typed.length; i++) {
  10383. basic[i] = typed[i];
  10384. }
  10385. b64data = String.fromCharCode.apply(null, basic);
  10386. }
  10387. message += btoa(b64data);
  10388. return callback(message);
  10389. };
  10390. /**
  10391. * Decodes a packet. Changes format to Blob if requested.
  10392. *
  10393. * @return {Object} with `type` and `data` (if any)
  10394. * @api private
  10395. */
  10396. exports.decodePacket = function (data, binaryType, utf8decode) {
  10397. if (data === undefined) {
  10398. return err;
  10399. }
  10400. // String data
  10401. if (typeof data === 'string') {
  10402. if (data.charAt(0) === 'b') {
  10403. return exports.decodeBase64Packet(data.substr(1), binaryType);
  10404. }
  10405. if (utf8decode) {
  10406. data = tryDecode(data);
  10407. if (data === false) {
  10408. return err;
  10409. }
  10410. }
  10411. var type = data.charAt(0);
  10412. if (Number(type) != type || !packetslist[type]) {
  10413. return err;
  10414. }
  10415. if (data.length > 1) {
  10416. return { type: packetslist[type], data: data.substring(1) };
  10417. } else {
  10418. return { type: packetslist[type] };
  10419. }
  10420. }
  10421. var asArray = new Uint8Array(data);
  10422. var type = asArray[0];
  10423. var rest = sliceBuffer(data, 1);
  10424. if (Blob && binaryType === 'blob') {
  10425. rest = new Blob([rest]);
  10426. }
  10427. return { type: packetslist[type], data: rest };
  10428. };
  10429. function tryDecode(data) {
  10430. try {
  10431. data = utf8.decode(data, { strict: false });
  10432. } catch (e) {
  10433. return false;
  10434. }
  10435. return data;
  10436. }
  10437. /**
  10438. * Decodes a packet encoded in a base64 string
  10439. *
  10440. * @param {String} base64 encoded message
  10441. * @return {Object} with `type` and `data` (if any)
  10442. */
  10443. exports.decodeBase64Packet = function(msg, binaryType) {
  10444. var type = packetslist[msg.charAt(0)];
  10445. if (!base64encoder) {
  10446. return { type: type, data: { base64: true, data: msg.substr(1) } };
  10447. }
  10448. var data = base64encoder.decode(msg.substr(1));
  10449. if (binaryType === 'blob' && Blob) {
  10450. data = new Blob([data]);
  10451. }
  10452. return { type: type, data: data };
  10453. };
  10454. /**
  10455. * Encodes multiple messages (payload).
  10456. *
  10457. * <length>:data
  10458. *
  10459. * Example:
  10460. *
  10461. * 11:hello world2:hi
  10462. *
  10463. * If any contents are binary, they will be encoded as base64 strings. Base64
  10464. * encoded strings are marked with a b before the length specifier
  10465. *
  10466. * @param {Array} packets
  10467. * @api private
  10468. */
  10469. exports.encodePayload = function (packets, supportsBinary, callback) {
  10470. if (typeof supportsBinary === 'function') {
  10471. callback = supportsBinary;
  10472. supportsBinary = null;
  10473. }
  10474. var isBinary = hasBinary(packets);
  10475. if (supportsBinary && isBinary) {
  10476. if (Blob && !dontSendBlobs) {
  10477. return exports.encodePayloadAsBlob(packets, callback);
  10478. }
  10479. return exports.encodePayloadAsArrayBuffer(packets, callback);
  10480. }
  10481. if (!packets.length) {
  10482. return callback('0:');
  10483. }
  10484. function setLengthHeader(message) {
  10485. return message.length + ':' + message;
  10486. }
  10487. function encodeOne(packet, doneCallback) {
  10488. exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
  10489. doneCallback(null, setLengthHeader(message));
  10490. });
  10491. }
  10492. map(packets, encodeOne, function(err, results) {
  10493. return callback(results.join(''));
  10494. });
  10495. };
  10496. /**
  10497. * Async array map using after
  10498. */
  10499. function map(ary, each, done) {
  10500. var result = new Array(ary.length);
  10501. var next = after(ary.length, done);
  10502. var eachWithIndex = function(i, el, cb) {
  10503. each(el, function(error, msg) {
  10504. result[i] = msg;
  10505. cb(error, result);
  10506. });
  10507. };
  10508. for (var i = 0; i < ary.length; i++) {
  10509. eachWithIndex(i, ary[i], next);
  10510. }
  10511. }
  10512. /*
  10513. * Decodes data when a payload is maybe expected. Possible binary contents are
  10514. * decoded from their base64 representation
  10515. *
  10516. * @param {String} data, callback method
  10517. * @api public
  10518. */
  10519. exports.decodePayload = function (data, binaryType, callback) {
  10520. if (typeof data !== 'string') {
  10521. return exports.decodePayloadAsBinary(data, binaryType, callback);
  10522. }
  10523. if (typeof binaryType === 'function') {
  10524. callback = binaryType;
  10525. binaryType = null;
  10526. }
  10527. var packet;
  10528. if (data === '') {
  10529. // parser error - ignoring payload
  10530. return callback(err, 0, 1);
  10531. }
  10532. var length = '', n, msg;
  10533. for (var i = 0, l = data.length; i < l; i++) {
  10534. var chr = data.charAt(i);
  10535. if (chr !== ':') {
  10536. length += chr;
  10537. continue;
  10538. }
  10539. if (length === '' || (length != (n = Number(length)))) {
  10540. // parser error - ignoring payload
  10541. return callback(err, 0, 1);
  10542. }
  10543. msg = data.substr(i + 1, n);
  10544. if (length != msg.length) {
  10545. // parser error - ignoring payload
  10546. return callback(err, 0, 1);
  10547. }
  10548. if (msg.length) {
  10549. packet = exports.decodePacket(msg, binaryType, false);
  10550. if (err.type === packet.type && err.data === packet.data) {
  10551. // parser error in individual packet - ignoring payload
  10552. return callback(err, 0, 1);
  10553. }
  10554. var ret = callback(packet, i + n, l);
  10555. if (false === ret) return;
  10556. }
  10557. // advance cursor
  10558. i += n;
  10559. length = '';
  10560. }
  10561. if (length !== '') {
  10562. // parser error - ignoring payload
  10563. return callback(err, 0, 1);
  10564. }
  10565. };
  10566. /**
  10567. * Encodes multiple messages (payload) as binary.
  10568. *
  10569. * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
  10570. * 255><data>
  10571. *
  10572. * Example:
  10573. * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
  10574. *
  10575. * @param {Array} packets
  10576. * @return {ArrayBuffer} encoded payload
  10577. * @api private
  10578. */
  10579. exports.encodePayloadAsArrayBuffer = function(packets, callback) {
  10580. if (!packets.length) {
  10581. return callback(new ArrayBuffer(0));
  10582. }
  10583. function encodeOne(packet, doneCallback) {
  10584. exports.encodePacket(packet, true, true, function(data) {
  10585. return doneCallback(null, data);
  10586. });
  10587. }
  10588. map(packets, encodeOne, function(err, encodedPackets) {
  10589. var totalLength = encodedPackets.reduce(function(acc, p) {
  10590. var len;
  10591. if (typeof p === 'string'){
  10592. len = p.length;
  10593. } else {
  10594. len = p.byteLength;
  10595. }
  10596. return acc + len.toString().length + len + 2; // string/binary identifier + separator = 2
  10597. }, 0);
  10598. var resultArray = new Uint8Array(totalLength);
  10599. var bufferIndex = 0;
  10600. encodedPackets.forEach(function(p) {
  10601. var isString = typeof p === 'string';
  10602. var ab = p;
  10603. if (isString) {
  10604. var view = new Uint8Array(p.length);
  10605. for (var i = 0; i < p.length; i++) {
  10606. view[i] = p.charCodeAt(i);
  10607. }
  10608. ab = view.buffer;
  10609. }
  10610. if (isString) { // not true binary
  10611. resultArray[bufferIndex++] = 0;
  10612. } else { // true binary
  10613. resultArray[bufferIndex++] = 1;
  10614. }
  10615. var lenStr = ab.byteLength.toString();
  10616. for (var i = 0; i < lenStr.length; i++) {
  10617. resultArray[bufferIndex++] = parseInt(lenStr[i]);
  10618. }
  10619. resultArray[bufferIndex++] = 255;
  10620. var view = new Uint8Array(ab);
  10621. for (var i = 0; i < view.length; i++) {
  10622. resultArray[bufferIndex++] = view[i];
  10623. }
  10624. });
  10625. return callback(resultArray.buffer);
  10626. });
  10627. };
  10628. /**
  10629. * Encode as Blob
  10630. */
  10631. exports.encodePayloadAsBlob = function(packets, callback) {
  10632. function encodeOne(packet, doneCallback) {
  10633. exports.encodePacket(packet, true, true, function(encoded) {
  10634. var binaryIdentifier = new Uint8Array(1);
  10635. binaryIdentifier[0] = 1;
  10636. if (typeof encoded === 'string') {
  10637. var view = new Uint8Array(encoded.length);
  10638. for (var i = 0; i < encoded.length; i++) {
  10639. view[i] = encoded.charCodeAt(i);
  10640. }
  10641. encoded = view.buffer;
  10642. binaryIdentifier[0] = 0;
  10643. }
  10644. var len = (encoded instanceof ArrayBuffer)
  10645. ? encoded.byteLength
  10646. : encoded.size;
  10647. var lenStr = len.toString();
  10648. var lengthAry = new Uint8Array(lenStr.length + 1);
  10649. for (var i = 0; i < lenStr.length; i++) {
  10650. lengthAry[i] = parseInt(lenStr[i]);
  10651. }
  10652. lengthAry[lenStr.length] = 255;
  10653. if (Blob) {
  10654. var blob = new Blob([binaryIdentifier.buffer, lengthAry.buffer, encoded]);
  10655. doneCallback(null, blob);
  10656. }
  10657. });
  10658. }
  10659. map(packets, encodeOne, function(err, results) {
  10660. return callback(new Blob(results));
  10661. });
  10662. };
  10663. /*
  10664. * Decodes data when a payload is maybe expected. Strings are decoded by
  10665. * interpreting each byte as a key code for entries marked to start with 0. See
  10666. * description of encodePayloadAsBinary
  10667. *
  10668. * @param {ArrayBuffer} data, callback method
  10669. * @api public
  10670. */
  10671. exports.decodePayloadAsBinary = function (data, binaryType, callback) {
  10672. if (typeof binaryType === 'function') {
  10673. callback = binaryType;
  10674. binaryType = null;
  10675. }
  10676. var bufferTail = data;
  10677. var buffers = [];
  10678. while (bufferTail.byteLength > 0) {
  10679. var tailArray = new Uint8Array(bufferTail);
  10680. var isString = tailArray[0] === 0;
  10681. var msgLength = '';
  10682. for (var i = 1; ; i++) {
  10683. if (tailArray[i] === 255) break;
  10684. // 310 = char length of Number.MAX_VALUE
  10685. if (msgLength.length > 310) {
  10686. return callback(err, 0, 1);
  10687. }
  10688. msgLength += tailArray[i];
  10689. }
  10690. bufferTail = sliceBuffer(bufferTail, 2 + msgLength.length);
  10691. msgLength = parseInt(msgLength);
  10692. var msg = sliceBuffer(bufferTail, 0, msgLength);
  10693. if (isString) {
  10694. try {
  10695. msg = String.fromCharCode.apply(null, new Uint8Array(msg));
  10696. } catch (e) {
  10697. // iPhone Safari doesn't let you apply to typed arrays
  10698. var typed = new Uint8Array(msg);
  10699. msg = '';
  10700. for (var i = 0; i < typed.length; i++) {
  10701. msg += String.fromCharCode(typed[i]);
  10702. }
  10703. }
  10704. }
  10705. buffers.push(msg);
  10706. bufferTail = sliceBuffer(bufferTail, msgLength);
  10707. }
  10708. var total = buffers.length;
  10709. buffers.forEach(function(buffer, i) {
  10710. callback(exports.decodePacket(buffer, binaryType, true), i, total);
  10711. });
  10712. };
  10713. /***/ }),
  10714. /***/ "./node_modules/engine.io-parser/lib/keys.js":
  10715. /*!***************************************************!*\
  10716. !*** ./node_modules/engine.io-parser/lib/keys.js ***!
  10717. \***************************************************/
  10718. /*! no static exports found */
  10719. /***/ (function(module, exports) {
  10720. /**
  10721. * Gets the keys for an object.
  10722. *
  10723. * @return {Array} keys
  10724. * @api private
  10725. */
  10726. module.exports = Object.keys || function keys (obj){
  10727. var arr = [];
  10728. var has = Object.prototype.hasOwnProperty;
  10729. for (var i in obj) {
  10730. if (has.call(obj, i)) {
  10731. arr.push(i);
  10732. }
  10733. }
  10734. return arr;
  10735. };
  10736. /***/ }),
  10737. /***/ "./node_modules/engine.io-parser/lib/utf8.js":
  10738. /*!***************************************************!*\
  10739. !*** ./node_modules/engine.io-parser/lib/utf8.js ***!
  10740. \***************************************************/
  10741. /*! no static exports found */
  10742. /***/ (function(module, exports) {
  10743. /*! https://mths.be/utf8js v2.1.2 by @mathias */
  10744. var stringFromCharCode = String.fromCharCode;
  10745. // Taken from https://mths.be/punycode
  10746. function ucs2decode(string) {
  10747. var output = [];
  10748. var counter = 0;
  10749. var length = string.length;
  10750. var value;
  10751. var extra;
  10752. while (counter < length) {
  10753. value = string.charCodeAt(counter++);
  10754. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  10755. // high surrogate, and there is a next character
  10756. extra = string.charCodeAt(counter++);
  10757. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  10758. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  10759. } else {
  10760. // unmatched surrogate; only append this code unit, in case the next
  10761. // code unit is the high surrogate of a surrogate pair
  10762. output.push(value);
  10763. counter--;
  10764. }
  10765. } else {
  10766. output.push(value);
  10767. }
  10768. }
  10769. return output;
  10770. }
  10771. // Taken from https://mths.be/punycode
  10772. function ucs2encode(array) {
  10773. var length = array.length;
  10774. var index = -1;
  10775. var value;
  10776. var output = '';
  10777. while (++index < length) {
  10778. value = array[index];
  10779. if (value > 0xFFFF) {
  10780. value -= 0x10000;
  10781. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  10782. value = 0xDC00 | value & 0x3FF;
  10783. }
  10784. output += stringFromCharCode(value);
  10785. }
  10786. return output;
  10787. }
  10788. function checkScalarValue(codePoint, strict) {
  10789. if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
  10790. if (strict) {
  10791. throw Error(
  10792. 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
  10793. ' is not a scalar value'
  10794. );
  10795. }
  10796. return false;
  10797. }
  10798. return true;
  10799. }
  10800. /*--------------------------------------------------------------------------*/
  10801. function createByte(codePoint, shift) {
  10802. return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
  10803. }
  10804. function encodeCodePoint(codePoint, strict) {
  10805. if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
  10806. return stringFromCharCode(codePoint);
  10807. }
  10808. var symbol = '';
  10809. if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
  10810. symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
  10811. }
  10812. else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
  10813. if (!checkScalarValue(codePoint, strict)) {
  10814. codePoint = 0xFFFD;
  10815. }
  10816. symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
  10817. symbol += createByte(codePoint, 6);
  10818. }
  10819. else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
  10820. symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
  10821. symbol += createByte(codePoint, 12);
  10822. symbol += createByte(codePoint, 6);
  10823. }
  10824. symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
  10825. return symbol;
  10826. }
  10827. function utf8encode(string, opts) {
  10828. opts = opts || {};
  10829. var strict = false !== opts.strict;
  10830. var codePoints = ucs2decode(string);
  10831. var length = codePoints.length;
  10832. var index = -1;
  10833. var codePoint;
  10834. var byteString = '';
  10835. while (++index < length) {
  10836. codePoint = codePoints[index];
  10837. byteString += encodeCodePoint(codePoint, strict);
  10838. }
  10839. return byteString;
  10840. }
  10841. /*--------------------------------------------------------------------------*/
  10842. function readContinuationByte() {
  10843. if (byteIndex >= byteCount) {
  10844. throw Error('Invalid byte index');
  10845. }
  10846. var continuationByte = byteArray[byteIndex] & 0xFF;
  10847. byteIndex++;
  10848. if ((continuationByte & 0xC0) == 0x80) {
  10849. return continuationByte & 0x3F;
  10850. }
  10851. // If we end up here, it’s not a continuation byte
  10852. throw Error('Invalid continuation byte');
  10853. }
  10854. function decodeSymbol(strict) {
  10855. var byte1;
  10856. var byte2;
  10857. var byte3;
  10858. var byte4;
  10859. var codePoint;
  10860. if (byteIndex > byteCount) {
  10861. throw Error('Invalid byte index');
  10862. }
  10863. if (byteIndex == byteCount) {
  10864. return false;
  10865. }
  10866. // Read first byte
  10867. byte1 = byteArray[byteIndex] & 0xFF;
  10868. byteIndex++;
  10869. // 1-byte sequence (no continuation bytes)
  10870. if ((byte1 & 0x80) == 0) {
  10871. return byte1;
  10872. }
  10873. // 2-byte sequence
  10874. if ((byte1 & 0xE0) == 0xC0) {
  10875. byte2 = readContinuationByte();
  10876. codePoint = ((byte1 & 0x1F) << 6) | byte2;
  10877. if (codePoint >= 0x80) {
  10878. return codePoint;
  10879. } else {
  10880. throw Error('Invalid continuation byte');
  10881. }
  10882. }
  10883. // 3-byte sequence (may include unpaired surrogates)
  10884. if ((byte1 & 0xF0) == 0xE0) {
  10885. byte2 = readContinuationByte();
  10886. byte3 = readContinuationByte();
  10887. codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
  10888. if (codePoint >= 0x0800) {
  10889. return checkScalarValue(codePoint, strict) ? codePoint : 0xFFFD;
  10890. } else {
  10891. throw Error('Invalid continuation byte');
  10892. }
  10893. }
  10894. // 4-byte sequence
  10895. if ((byte1 & 0xF8) == 0xF0) {
  10896. byte2 = readContinuationByte();
  10897. byte3 = readContinuationByte();
  10898. byte4 = readContinuationByte();
  10899. codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
  10900. (byte3 << 0x06) | byte4;
  10901. if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
  10902. return codePoint;
  10903. }
  10904. }
  10905. throw Error('Invalid UTF-8 detected');
  10906. }
  10907. var byteArray;
  10908. var byteCount;
  10909. var byteIndex;
  10910. function utf8decode(byteString, opts) {
  10911. opts = opts || {};
  10912. var strict = false !== opts.strict;
  10913. byteArray = ucs2decode(byteString);
  10914. byteCount = byteArray.length;
  10915. byteIndex = 0;
  10916. var codePoints = [];
  10917. var tmp;
  10918. while ((tmp = decodeSymbol(strict)) !== false) {
  10919. codePoints.push(tmp);
  10920. }
  10921. return ucs2encode(codePoints);
  10922. }
  10923. module.exports = {
  10924. version: '2.1.2',
  10925. encode: utf8encode,
  10926. decode: utf8decode
  10927. };
  10928. /***/ }),
  10929. /***/ "./node_modules/has-binary2/index.js":
  10930. /*!*******************************************!*\
  10931. !*** ./node_modules/has-binary2/index.js ***!
  10932. \*******************************************/
  10933. /*! no static exports found */
  10934. /***/ (function(module, exports, __webpack_require__) {
  10935. /* WEBPACK VAR INJECTION */(function(Buffer) {/* global Blob File */
  10936. /*
  10937. * Module requirements.
  10938. */
  10939. var isArray = __webpack_require__(/*! isarray */ "./node_modules/has-binary2/node_modules/isarray/index.js");
  10940. var toString = Object.prototype.toString;
  10941. var withNativeBlob = typeof Blob === 'function' ||
  10942. typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]';
  10943. var withNativeFile = typeof File === 'function' ||
  10944. typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]';
  10945. /**
  10946. * Module exports.
  10947. */
  10948. module.exports = hasBinary;
  10949. /**
  10950. * Checks for binary data.
  10951. *
  10952. * Supports Buffer, ArrayBuffer, Blob and File.
  10953. *
  10954. * @param {Object} anything
  10955. * @api public
  10956. */
  10957. function hasBinary (obj) {
  10958. if (!obj || typeof obj !== 'object') {
  10959. return false;
  10960. }
  10961. if (isArray(obj)) {
  10962. for (var i = 0, l = obj.length; i < l; i++) {
  10963. if (hasBinary(obj[i])) {
  10964. return true;
  10965. }
  10966. }
  10967. return false;
  10968. }
  10969. if ((typeof Buffer === 'function' && Buffer.isBuffer && Buffer.isBuffer(obj)) ||
  10970. (typeof ArrayBuffer === 'function' && obj instanceof ArrayBuffer) ||
  10971. (withNativeBlob && obj instanceof Blob) ||
  10972. (withNativeFile && obj instanceof File)
  10973. ) {
  10974. return true;
  10975. }
  10976. // see: https://github.com/Automattic/has-binary/pull/4
  10977. if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
  10978. return hasBinary(obj.toJSON(), true);
  10979. }
  10980. for (var key in obj) {
  10981. if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
  10982. return true;
  10983. }
  10984. }
  10985. return false;
  10986. }
  10987. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  10988. /***/ }),
  10989. /***/ "./node_modules/has-binary2/node_modules/isarray/index.js":
  10990. /*!****************************************************************!*\
  10991. !*** ./node_modules/has-binary2/node_modules/isarray/index.js ***!
  10992. \****************************************************************/
  10993. /*! no static exports found */
  10994. /***/ (function(module, exports) {
  10995. var toString = {}.toString;
  10996. module.exports = Array.isArray || function (arr) {
  10997. return toString.call(arr) == '[object Array]';
  10998. };
  10999. /***/ }),
  11000. /***/ "./node_modules/has-cors/index.js":
  11001. /*!****************************************!*\
  11002. !*** ./node_modules/has-cors/index.js ***!
  11003. \****************************************/
  11004. /*! no static exports found */
  11005. /***/ (function(module, exports) {
  11006. /**
  11007. * Module exports.
  11008. *
  11009. * Logic borrowed from Modernizr:
  11010. *
  11011. * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js
  11012. */
  11013. try {
  11014. module.exports = typeof XMLHttpRequest !== 'undefined' &&
  11015. 'withCredentials' in new XMLHttpRequest();
  11016. } catch (err) {
  11017. // if XMLHttp support is disabled in IE then it will throw
  11018. // when trying to create
  11019. module.exports = false;
  11020. }
  11021. /***/ }),
  11022. /***/ "./node_modules/ieee754/index.js":
  11023. /*!***************************************!*\
  11024. !*** ./node_modules/ieee754/index.js ***!
  11025. \***************************************/
  11026. /*! no static exports found */
  11027. /***/ (function(module, exports) {
  11028. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  11029. var e, m
  11030. var eLen = (nBytes * 8) - mLen - 1
  11031. var eMax = (1 << eLen) - 1
  11032. var eBias = eMax >> 1
  11033. var nBits = -7
  11034. var i = isLE ? (nBytes - 1) : 0
  11035. var d = isLE ? -1 : 1
  11036. var s = buffer[offset + i]
  11037. i += d
  11038. e = s & ((1 << (-nBits)) - 1)
  11039. s >>= (-nBits)
  11040. nBits += eLen
  11041. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  11042. m = e & ((1 << (-nBits)) - 1)
  11043. e >>= (-nBits)
  11044. nBits += mLen
  11045. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  11046. if (e === 0) {
  11047. e = 1 - eBias
  11048. } else if (e === eMax) {
  11049. return m ? NaN : ((s ? -1 : 1) * Infinity)
  11050. } else {
  11051. m = m + Math.pow(2, mLen)
  11052. e = e - eBias
  11053. }
  11054. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  11055. }
  11056. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  11057. var e, m, c
  11058. var eLen = (nBytes * 8) - mLen - 1
  11059. var eMax = (1 << eLen) - 1
  11060. var eBias = eMax >> 1
  11061. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  11062. var i = isLE ? 0 : (nBytes - 1)
  11063. var d = isLE ? 1 : -1
  11064. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  11065. value = Math.abs(value)
  11066. if (isNaN(value) || value === Infinity) {
  11067. m = isNaN(value) ? 1 : 0
  11068. e = eMax
  11069. } else {
  11070. e = Math.floor(Math.log(value) / Math.LN2)
  11071. if (value * (c = Math.pow(2, -e)) < 1) {
  11072. e--
  11073. c *= 2
  11074. }
  11075. if (e + eBias >= 1) {
  11076. value += rt / c
  11077. } else {
  11078. value += rt * Math.pow(2, 1 - eBias)
  11079. }
  11080. if (value * c >= 2) {
  11081. e++
  11082. c /= 2
  11083. }
  11084. if (e + eBias >= eMax) {
  11085. m = 0
  11086. e = eMax
  11087. } else if (e + eBias >= 1) {
  11088. m = ((value * c) - 1) * Math.pow(2, mLen)
  11089. e = e + eBias
  11090. } else {
  11091. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  11092. e = 0
  11093. }
  11094. }
  11095. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  11096. e = (e << mLen) | m
  11097. eLen += mLen
  11098. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  11099. buffer[offset + i - d] |= s * 128
  11100. }
  11101. /***/ }),
  11102. /***/ "./node_modules/indexof/index.js":
  11103. /*!***************************************!*\
  11104. !*** ./node_modules/indexof/index.js ***!
  11105. \***************************************/
  11106. /*! no static exports found */
  11107. /***/ (function(module, exports) {
  11108. var indexOf = [].indexOf;
  11109. module.exports = function(arr, obj){
  11110. if (indexOf) return arr.indexOf(obj);
  11111. for (var i = 0; i < arr.length; ++i) {
  11112. if (arr[i] === obj) return i;
  11113. }
  11114. return -1;
  11115. };
  11116. /***/ }),
  11117. /***/ "./node_modules/isarray/index.js":
  11118. /*!***************************************!*\
  11119. !*** ./node_modules/isarray/index.js ***!
  11120. \***************************************/
  11121. /*! no static exports found */
  11122. /***/ (function(module, exports) {
  11123. var toString = {}.toString;
  11124. module.exports = Array.isArray || function (arr) {
  11125. return toString.call(arr) == '[object Array]';
  11126. };
  11127. /***/ }),
  11128. /***/ "./node_modules/jquery/dist/jquery.js":
  11129. /*!********************************************!*\
  11130. !*** ./node_modules/jquery/dist/jquery.js ***!
  11131. \********************************************/
  11132. /*! no static exports found */
  11133. /***/ (function(module, exports, __webpack_require__) {
  11134. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  11135. * jQuery JavaScript Library v3.5.1
  11136. * https://jquery.com/
  11137. *
  11138. * Includes Sizzle.js
  11139. * https://sizzlejs.com/
  11140. *
  11141. * Copyright JS Foundation and other contributors
  11142. * Released under the MIT license
  11143. * https://jquery.org/license
  11144. *
  11145. * Date: 2020-05-04T22:49Z
  11146. */
  11147. ( function( global, factory ) {
  11148. "use strict";
  11149. if ( true && typeof module.exports === "object" ) {
  11150. // For CommonJS and CommonJS-like environments where a proper `window`
  11151. // is present, execute the factory and get jQuery.
  11152. // For environments that do not have a `window` with a `document`
  11153. // (such as Node.js), expose a factory as module.exports.
  11154. // This accentuates the need for the creation of a real `window`.
  11155. // e.g. var jQuery = require("jquery")(window);
  11156. // See ticket #14549 for more info.
  11157. module.exports = global.document ?
  11158. factory( global, true ) :
  11159. function( w ) {
  11160. if ( !w.document ) {
  11161. throw new Error( "jQuery requires a window with a document" );
  11162. }
  11163. return factory( w );
  11164. };
  11165. } else {
  11166. factory( global );
  11167. }
  11168. // Pass this if window is not defined yet
  11169. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  11170. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  11171. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  11172. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  11173. // enough that all such attempts are guarded in a try block.
  11174. "use strict";
  11175. var arr = [];
  11176. var getProto = Object.getPrototypeOf;
  11177. var slice = arr.slice;
  11178. var flat = arr.flat ? function( array ) {
  11179. return arr.flat.call( array );
  11180. } : function( array ) {
  11181. return arr.concat.apply( [], array );
  11182. };
  11183. var push = arr.push;
  11184. var indexOf = arr.indexOf;
  11185. var class2type = {};
  11186. var toString = class2type.toString;
  11187. var hasOwn = class2type.hasOwnProperty;
  11188. var fnToString = hasOwn.toString;
  11189. var ObjectFunctionString = fnToString.call( Object );
  11190. var support = {};
  11191. var isFunction = function isFunction( obj ) {
  11192. // Support: Chrome <=57, Firefox <=52
  11193. // In some browsers, typeof returns "function" for HTML <object> elements
  11194. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  11195. // We don't want to classify *any* DOM node as a function.
  11196. return typeof obj === "function" && typeof obj.nodeType !== "number";
  11197. };
  11198. var isWindow = function isWindow( obj ) {
  11199. return obj != null && obj === obj.window;
  11200. };
  11201. var document = window.document;
  11202. var preservedScriptAttributes = {
  11203. type: true,
  11204. src: true,
  11205. nonce: true,
  11206. noModule: true
  11207. };
  11208. function DOMEval( code, node, doc ) {
  11209. doc = doc || document;
  11210. var i, val,
  11211. script = doc.createElement( "script" );
  11212. script.text = code;
  11213. if ( node ) {
  11214. for ( i in preservedScriptAttributes ) {
  11215. // Support: Firefox 64+, Edge 18+
  11216. // Some browsers don't support the "nonce" property on scripts.
  11217. // On the other hand, just using `getAttribute` is not enough as
  11218. // the `nonce` attribute is reset to an empty string whenever it
  11219. // becomes browsing-context connected.
  11220. // See https://github.com/whatwg/html/issues/2369
  11221. // See https://html.spec.whatwg.org/#nonce-attributes
  11222. // The `node.getAttribute` check was added for the sake of
  11223. // `jQuery.globalEval` so that it can fake a nonce-containing node
  11224. // via an object.
  11225. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  11226. if ( val ) {
  11227. script.setAttribute( i, val );
  11228. }
  11229. }
  11230. }
  11231. doc.head.appendChild( script ).parentNode.removeChild( script );
  11232. }
  11233. function toType( obj ) {
  11234. if ( obj == null ) {
  11235. return obj + "";
  11236. }
  11237. // Support: Android <=2.3 only (functionish RegExp)
  11238. return typeof obj === "object" || typeof obj === "function" ?
  11239. class2type[ toString.call( obj ) ] || "object" :
  11240. typeof obj;
  11241. }
  11242. /* global Symbol */
  11243. // Defining this global in .eslintrc.json would create a danger of using the global
  11244. // unguarded in another place, it seems safer to define global only for this module
  11245. var
  11246. version = "3.5.1",
  11247. // Define a local copy of jQuery
  11248. jQuery = function( selector, context ) {
  11249. // The jQuery object is actually just the init constructor 'enhanced'
  11250. // Need init if jQuery is called (just allow error to be thrown if not included)
  11251. return new jQuery.fn.init( selector, context );
  11252. };
  11253. jQuery.fn = jQuery.prototype = {
  11254. // The current version of jQuery being used
  11255. jquery: version,
  11256. constructor: jQuery,
  11257. // The default length of a jQuery object is 0
  11258. length: 0,
  11259. toArray: function() {
  11260. return slice.call( this );
  11261. },
  11262. // Get the Nth element in the matched element set OR
  11263. // Get the whole matched element set as a clean array
  11264. get: function( num ) {
  11265. // Return all the elements in a clean array
  11266. if ( num == null ) {
  11267. return slice.call( this );
  11268. }
  11269. // Return just the one element from the set
  11270. return num < 0 ? this[ num + this.length ] : this[ num ];
  11271. },
  11272. // Take an array of elements and push it onto the stack
  11273. // (returning the new matched element set)
  11274. pushStack: function( elems ) {
  11275. // Build a new jQuery matched element set
  11276. var ret = jQuery.merge( this.constructor(), elems );
  11277. // Add the old object onto the stack (as a reference)
  11278. ret.prevObject = this;
  11279. // Return the newly-formed element set
  11280. return ret;
  11281. },
  11282. // Execute a callback for every element in the matched set.
  11283. each: function( callback ) {
  11284. return jQuery.each( this, callback );
  11285. },
  11286. map: function( callback ) {
  11287. return this.pushStack( jQuery.map( this, function( elem, i ) {
  11288. return callback.call( elem, i, elem );
  11289. } ) );
  11290. },
  11291. slice: function() {
  11292. return this.pushStack( slice.apply( this, arguments ) );
  11293. },
  11294. first: function() {
  11295. return this.eq( 0 );
  11296. },
  11297. last: function() {
  11298. return this.eq( -1 );
  11299. },
  11300. even: function() {
  11301. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  11302. return ( i + 1 ) % 2;
  11303. } ) );
  11304. },
  11305. odd: function() {
  11306. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  11307. return i % 2;
  11308. } ) );
  11309. },
  11310. eq: function( i ) {
  11311. var len = this.length,
  11312. j = +i + ( i < 0 ? len : 0 );
  11313. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  11314. },
  11315. end: function() {
  11316. return this.prevObject || this.constructor();
  11317. },
  11318. // For internal use only.
  11319. // Behaves like an Array's method, not like a jQuery method.
  11320. push: push,
  11321. sort: arr.sort,
  11322. splice: arr.splice
  11323. };
  11324. jQuery.extend = jQuery.fn.extend = function() {
  11325. var options, name, src, copy, copyIsArray, clone,
  11326. target = arguments[ 0 ] || {},
  11327. i = 1,
  11328. length = arguments.length,
  11329. deep = false;
  11330. // Handle a deep copy situation
  11331. if ( typeof target === "boolean" ) {
  11332. deep = target;
  11333. // Skip the boolean and the target
  11334. target = arguments[ i ] || {};
  11335. i++;
  11336. }
  11337. // Handle case when target is a string or something (possible in deep copy)
  11338. if ( typeof target !== "object" && !isFunction( target ) ) {
  11339. target = {};
  11340. }
  11341. // Extend jQuery itself if only one argument is passed
  11342. if ( i === length ) {
  11343. target = this;
  11344. i--;
  11345. }
  11346. for ( ; i < length; i++ ) {
  11347. // Only deal with non-null/undefined values
  11348. if ( ( options = arguments[ i ] ) != null ) {
  11349. // Extend the base object
  11350. for ( name in options ) {
  11351. copy = options[ name ];
  11352. // Prevent Object.prototype pollution
  11353. // Prevent never-ending loop
  11354. if ( name === "__proto__" || target === copy ) {
  11355. continue;
  11356. }
  11357. // Recurse if we're merging plain objects or arrays
  11358. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  11359. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  11360. src = target[ name ];
  11361. // Ensure proper type for the source value
  11362. if ( copyIsArray && !Array.isArray( src ) ) {
  11363. clone = [];
  11364. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  11365. clone = {};
  11366. } else {
  11367. clone = src;
  11368. }
  11369. copyIsArray = false;
  11370. // Never move original objects, clone them
  11371. target[ name ] = jQuery.extend( deep, clone, copy );
  11372. // Don't bring in undefined values
  11373. } else if ( copy !== undefined ) {
  11374. target[ name ] = copy;
  11375. }
  11376. }
  11377. }
  11378. }
  11379. // Return the modified object
  11380. return target;
  11381. };
  11382. jQuery.extend( {
  11383. // Unique for each copy of jQuery on the page
  11384. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  11385. // Assume jQuery is ready without the ready module
  11386. isReady: true,
  11387. error: function( msg ) {
  11388. throw new Error( msg );
  11389. },
  11390. noop: function() {},
  11391. isPlainObject: function( obj ) {
  11392. var proto, Ctor;
  11393. // Detect obvious negatives
  11394. // Use toString instead of jQuery.type to catch host objects
  11395. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  11396. return false;
  11397. }
  11398. proto = getProto( obj );
  11399. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  11400. if ( !proto ) {
  11401. return true;
  11402. }
  11403. // Objects with prototype are plain iff they were constructed by a global Object function
  11404. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  11405. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  11406. },
  11407. isEmptyObject: function( obj ) {
  11408. var name;
  11409. for ( name in obj ) {
  11410. return false;
  11411. }
  11412. return true;
  11413. },
  11414. // Evaluates a script in a provided context; falls back to the global one
  11415. // if not specified.
  11416. globalEval: function( code, options, doc ) {
  11417. DOMEval( code, { nonce: options && options.nonce }, doc );
  11418. },
  11419. each: function( obj, callback ) {
  11420. var length, i = 0;
  11421. if ( isArrayLike( obj ) ) {
  11422. length = obj.length;
  11423. for ( ; i < length; i++ ) {
  11424. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  11425. break;
  11426. }
  11427. }
  11428. } else {
  11429. for ( i in obj ) {
  11430. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  11431. break;
  11432. }
  11433. }
  11434. }
  11435. return obj;
  11436. },
  11437. // results is for internal usage only
  11438. makeArray: function( arr, results ) {
  11439. var ret = results || [];
  11440. if ( arr != null ) {
  11441. if ( isArrayLike( Object( arr ) ) ) {
  11442. jQuery.merge( ret,
  11443. typeof arr === "string" ?
  11444. [ arr ] : arr
  11445. );
  11446. } else {
  11447. push.call( ret, arr );
  11448. }
  11449. }
  11450. return ret;
  11451. },
  11452. inArray: function( elem, arr, i ) {
  11453. return arr == null ? -1 : indexOf.call( arr, elem, i );
  11454. },
  11455. // Support: Android <=4.0 only, PhantomJS 1 only
  11456. // push.apply(_, arraylike) throws on ancient WebKit
  11457. merge: function( first, second ) {
  11458. var len = +second.length,
  11459. j = 0,
  11460. i = first.length;
  11461. for ( ; j < len; j++ ) {
  11462. first[ i++ ] = second[ j ];
  11463. }
  11464. first.length = i;
  11465. return first;
  11466. },
  11467. grep: function( elems, callback, invert ) {
  11468. var callbackInverse,
  11469. matches = [],
  11470. i = 0,
  11471. length = elems.length,
  11472. callbackExpect = !invert;
  11473. // Go through the array, only saving the items
  11474. // that pass the validator function
  11475. for ( ; i < length; i++ ) {
  11476. callbackInverse = !callback( elems[ i ], i );
  11477. if ( callbackInverse !== callbackExpect ) {
  11478. matches.push( elems[ i ] );
  11479. }
  11480. }
  11481. return matches;
  11482. },
  11483. // arg is for internal usage only
  11484. map: function( elems, callback, arg ) {
  11485. var length, value,
  11486. i = 0,
  11487. ret = [];
  11488. // Go through the array, translating each of the items to their new values
  11489. if ( isArrayLike( elems ) ) {
  11490. length = elems.length;
  11491. for ( ; i < length; i++ ) {
  11492. value = callback( elems[ i ], i, arg );
  11493. if ( value != null ) {
  11494. ret.push( value );
  11495. }
  11496. }
  11497. // Go through every key on the object,
  11498. } else {
  11499. for ( i in elems ) {
  11500. value = callback( elems[ i ], i, arg );
  11501. if ( value != null ) {
  11502. ret.push( value );
  11503. }
  11504. }
  11505. }
  11506. // Flatten any nested arrays
  11507. return flat( ret );
  11508. },
  11509. // A global GUID counter for objects
  11510. guid: 1,
  11511. // jQuery.support is not used in Core but other projects attach their
  11512. // properties to it so it needs to exist.
  11513. support: support
  11514. } );
  11515. if ( typeof Symbol === "function" ) {
  11516. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  11517. }
  11518. // Populate the class2type map
  11519. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  11520. function( _i, name ) {
  11521. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  11522. } );
  11523. function isArrayLike( obj ) {
  11524. // Support: real iOS 8.2 only (not reproducible in simulator)
  11525. // `in` check used to prevent JIT error (gh-2145)
  11526. // hasOwn isn't used here due to false negatives
  11527. // regarding Nodelist length in IE
  11528. var length = !!obj && "length" in obj && obj.length,
  11529. type = toType( obj );
  11530. if ( isFunction( obj ) || isWindow( obj ) ) {
  11531. return false;
  11532. }
  11533. return type === "array" || length === 0 ||
  11534. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  11535. }
  11536. var Sizzle =
  11537. /*!
  11538. * Sizzle CSS Selector Engine v2.3.5
  11539. * https://sizzlejs.com/
  11540. *
  11541. * Copyright JS Foundation and other contributors
  11542. * Released under the MIT license
  11543. * https://js.foundation/
  11544. *
  11545. * Date: 2020-03-14
  11546. */
  11547. ( function( window ) {
  11548. var i,
  11549. support,
  11550. Expr,
  11551. getText,
  11552. isXML,
  11553. tokenize,
  11554. compile,
  11555. select,
  11556. outermostContext,
  11557. sortInput,
  11558. hasDuplicate,
  11559. // Local document vars
  11560. setDocument,
  11561. document,
  11562. docElem,
  11563. documentIsHTML,
  11564. rbuggyQSA,
  11565. rbuggyMatches,
  11566. matches,
  11567. contains,
  11568. // Instance-specific data
  11569. expando = "sizzle" + 1 * new Date(),
  11570. preferredDoc = window.document,
  11571. dirruns = 0,
  11572. done = 0,
  11573. classCache = createCache(),
  11574. tokenCache = createCache(),
  11575. compilerCache = createCache(),
  11576. nonnativeSelectorCache = createCache(),
  11577. sortOrder = function( a, b ) {
  11578. if ( a === b ) {
  11579. hasDuplicate = true;
  11580. }
  11581. return 0;
  11582. },
  11583. // Instance methods
  11584. hasOwn = ( {} ).hasOwnProperty,
  11585. arr = [],
  11586. pop = arr.pop,
  11587. pushNative = arr.push,
  11588. push = arr.push,
  11589. slice = arr.slice,
  11590. // Use a stripped-down indexOf as it's faster than native
  11591. // https://jsperf.com/thor-indexof-vs-for/5
  11592. indexOf = function( list, elem ) {
  11593. var i = 0,
  11594. len = list.length;
  11595. for ( ; i < len; i++ ) {
  11596. if ( list[ i ] === elem ) {
  11597. return i;
  11598. }
  11599. }
  11600. return -1;
  11601. },
  11602. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
  11603. "ismap|loop|multiple|open|readonly|required|scoped",
  11604. // Regular expressions
  11605. // http://www.w3.org/TR/css3-selectors/#whitespace
  11606. whitespace = "[\\x20\\t\\r\\n\\f]",
  11607. // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
  11608. identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
  11609. "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
  11610. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  11611. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  11612. // Operator (capture 2)
  11613. "*([*^$|!~]?=)" + whitespace +
  11614. // "Attribute values must be CSS identifiers [capture 5]
  11615. // or strings [capture 3 or capture 4]"
  11616. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
  11617. whitespace + "*\\]",
  11618. pseudos = ":(" + identifier + ")(?:\\((" +
  11619. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  11620. // 1. quoted (capture 3; capture 4 or capture 5)
  11621. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  11622. // 2. simple (capture 6)
  11623. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  11624. // 3. anything else (capture 2)
  11625. ".*" +
  11626. ")\\)|)",
  11627. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  11628. rwhitespace = new RegExp( whitespace + "+", "g" ),
  11629. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
  11630. whitespace + "+$", "g" ),
  11631. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  11632. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
  11633. "*" ),
  11634. rdescend = new RegExp( whitespace + "|>" ),
  11635. rpseudo = new RegExp( pseudos ),
  11636. ridentifier = new RegExp( "^" + identifier + "$" ),
  11637. matchExpr = {
  11638. "ID": new RegExp( "^#(" + identifier + ")" ),
  11639. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  11640. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  11641. "ATTR": new RegExp( "^" + attributes ),
  11642. "PSEUDO": new RegExp( "^" + pseudos ),
  11643. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
  11644. whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
  11645. whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  11646. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  11647. // For use in libraries implementing .is()
  11648. // We use this for POS matching in `select`
  11649. "needsContext": new RegExp( "^" + whitespace +
  11650. "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  11651. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  11652. },
  11653. rhtml = /HTML$/i,
  11654. rinputs = /^(?:input|select|textarea|button)$/i,
  11655. rheader = /^h\d$/i,
  11656. rnative = /^[^{]+\{\s*\[native \w/,
  11657. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  11658. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  11659. rsibling = /[+~]/,
  11660. // CSS escapes
  11661. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  11662. runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
  11663. funescape = function( escape, nonHex ) {
  11664. var high = "0x" + escape.slice( 1 ) - 0x10000;
  11665. return nonHex ?
  11666. // Strip the backslash prefix from a non-hex escape sequence
  11667. nonHex :
  11668. // Replace a hexadecimal escape sequence with the encoded Unicode code point
  11669. // Support: IE <=11+
  11670. // For values outside the Basic Multilingual Plane (BMP), manually construct a
  11671. // surrogate pair
  11672. high < 0 ?
  11673. String.fromCharCode( high + 0x10000 ) :
  11674. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  11675. },
  11676. // CSS string/identifier serialization
  11677. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  11678. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  11679. fcssescape = function( ch, asCodePoint ) {
  11680. if ( asCodePoint ) {
  11681. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  11682. if ( ch === "\0" ) {
  11683. return "\uFFFD";
  11684. }
  11685. // Control characters and (dependent upon position) numbers get escaped as code points
  11686. return ch.slice( 0, -1 ) + "\\" +
  11687. ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  11688. }
  11689. // Other potentially-special ASCII characters get backslash-escaped
  11690. return "\\" + ch;
  11691. },
  11692. // Used for iframes
  11693. // See setDocument()
  11694. // Removing the function wrapper causes a "Permission Denied"
  11695. // error in IE
  11696. unloadHandler = function() {
  11697. setDocument();
  11698. },
  11699. inDisabledFieldset = addCombinator(
  11700. function( elem ) {
  11701. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  11702. },
  11703. { dir: "parentNode", next: "legend" }
  11704. );
  11705. // Optimize for push.apply( _, NodeList )
  11706. try {
  11707. push.apply(
  11708. ( arr = slice.call( preferredDoc.childNodes ) ),
  11709. preferredDoc.childNodes
  11710. );
  11711. // Support: Android<4.0
  11712. // Detect silently failing push.apply
  11713. // eslint-disable-next-line no-unused-expressions
  11714. arr[ preferredDoc.childNodes.length ].nodeType;
  11715. } catch ( e ) {
  11716. push = { apply: arr.length ?
  11717. // Leverage slice if possible
  11718. function( target, els ) {
  11719. pushNative.apply( target, slice.call( els ) );
  11720. } :
  11721. // Support: IE<9
  11722. // Otherwise append directly
  11723. function( target, els ) {
  11724. var j = target.length,
  11725. i = 0;
  11726. // Can't trust NodeList.length
  11727. while ( ( target[ j++ ] = els[ i++ ] ) ) {}
  11728. target.length = j - 1;
  11729. }
  11730. };
  11731. }
  11732. function Sizzle( selector, context, results, seed ) {
  11733. var m, i, elem, nid, match, groups, newSelector,
  11734. newContext = context && context.ownerDocument,
  11735. // nodeType defaults to 9, since context defaults to document
  11736. nodeType = context ? context.nodeType : 9;
  11737. results = results || [];
  11738. // Return early from calls with invalid selector or context
  11739. if ( typeof selector !== "string" || !selector ||
  11740. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  11741. return results;
  11742. }
  11743. // Try to shortcut find operations (as opposed to filters) in HTML documents
  11744. if ( !seed ) {
  11745. setDocument( context );
  11746. context = context || document;
  11747. if ( documentIsHTML ) {
  11748. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  11749. // (excepting DocumentFragment context, where the methods don't exist)
  11750. if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
  11751. // ID selector
  11752. if ( ( m = match[ 1 ] ) ) {
  11753. // Document context
  11754. if ( nodeType === 9 ) {
  11755. if ( ( elem = context.getElementById( m ) ) ) {
  11756. // Support: IE, Opera, Webkit
  11757. // TODO: identify versions
  11758. // getElementById can match elements by name instead of ID
  11759. if ( elem.id === m ) {
  11760. results.push( elem );
  11761. return results;
  11762. }
  11763. } else {
  11764. return results;
  11765. }
  11766. // Element context
  11767. } else {
  11768. // Support: IE, Opera, Webkit
  11769. // TODO: identify versions
  11770. // getElementById can match elements by name instead of ID
  11771. if ( newContext && ( elem = newContext.getElementById( m ) ) &&
  11772. contains( context, elem ) &&
  11773. elem.id === m ) {
  11774. results.push( elem );
  11775. return results;
  11776. }
  11777. }
  11778. // Type selector
  11779. } else if ( match[ 2 ] ) {
  11780. push.apply( results, context.getElementsByTagName( selector ) );
  11781. return results;
  11782. // Class selector
  11783. } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
  11784. context.getElementsByClassName ) {
  11785. push.apply( results, context.getElementsByClassName( m ) );
  11786. return results;
  11787. }
  11788. }
  11789. // Take advantage of querySelectorAll
  11790. if ( support.qsa &&
  11791. !nonnativeSelectorCache[ selector + " " ] &&
  11792. ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
  11793. // Support: IE 8 only
  11794. // Exclude object elements
  11795. ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
  11796. newSelector = selector;
  11797. newContext = context;
  11798. // qSA considers elements outside a scoping root when evaluating child or
  11799. // descendant combinators, which is not what we want.
  11800. // In such cases, we work around the behavior by prefixing every selector in the
  11801. // list with an ID selector referencing the scope context.
  11802. // The technique has to be used as well when a leading combinator is used
  11803. // as such selectors are not recognized by querySelectorAll.
  11804. // Thanks to Andrew Dupont for this technique.
  11805. if ( nodeType === 1 &&
  11806. ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
  11807. // Expand context for sibling selectors
  11808. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  11809. context;
  11810. // We can use :scope instead of the ID hack if the browser
  11811. // supports it & if we're not changing the context.
  11812. if ( newContext !== context || !support.scope ) {
  11813. // Capture the context ID, setting it first if necessary
  11814. if ( ( nid = context.getAttribute( "id" ) ) ) {
  11815. nid = nid.replace( rcssescape, fcssescape );
  11816. } else {
  11817. context.setAttribute( "id", ( nid = expando ) );
  11818. }
  11819. }
  11820. // Prefix every selector in the list
  11821. groups = tokenize( selector );
  11822. i = groups.length;
  11823. while ( i-- ) {
  11824. groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
  11825. toSelector( groups[ i ] );
  11826. }
  11827. newSelector = groups.join( "," );
  11828. }
  11829. try {
  11830. push.apply( results,
  11831. newContext.querySelectorAll( newSelector )
  11832. );
  11833. return results;
  11834. } catch ( qsaError ) {
  11835. nonnativeSelectorCache( selector, true );
  11836. } finally {
  11837. if ( nid === expando ) {
  11838. context.removeAttribute( "id" );
  11839. }
  11840. }
  11841. }
  11842. }
  11843. }
  11844. // All others
  11845. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  11846. }
  11847. /**
  11848. * Create key-value caches of limited size
  11849. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  11850. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  11851. * deleting the oldest entry
  11852. */
  11853. function createCache() {
  11854. var keys = [];
  11855. function cache( key, value ) {
  11856. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  11857. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  11858. // Only keep the most recent entries
  11859. delete cache[ keys.shift() ];
  11860. }
  11861. return ( cache[ key + " " ] = value );
  11862. }
  11863. return cache;
  11864. }
  11865. /**
  11866. * Mark a function for special use by Sizzle
  11867. * @param {Function} fn The function to mark
  11868. */
  11869. function markFunction( fn ) {
  11870. fn[ expando ] = true;
  11871. return fn;
  11872. }
  11873. /**
  11874. * Support testing using an element
  11875. * @param {Function} fn Passed the created element and returns a boolean result
  11876. */
  11877. function assert( fn ) {
  11878. var el = document.createElement( "fieldset" );
  11879. try {
  11880. return !!fn( el );
  11881. } catch ( e ) {
  11882. return false;
  11883. } finally {
  11884. // Remove from its parent by default
  11885. if ( el.parentNode ) {
  11886. el.parentNode.removeChild( el );
  11887. }
  11888. // release memory in IE
  11889. el = null;
  11890. }
  11891. }
  11892. /**
  11893. * Adds the same handler for all of the specified attrs
  11894. * @param {String} attrs Pipe-separated list of attributes
  11895. * @param {Function} handler The method that will be applied
  11896. */
  11897. function addHandle( attrs, handler ) {
  11898. var arr = attrs.split( "|" ),
  11899. i = arr.length;
  11900. while ( i-- ) {
  11901. Expr.attrHandle[ arr[ i ] ] = handler;
  11902. }
  11903. }
  11904. /**
  11905. * Checks document order of two siblings
  11906. * @param {Element} a
  11907. * @param {Element} b
  11908. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  11909. */
  11910. function siblingCheck( a, b ) {
  11911. var cur = b && a,
  11912. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  11913. a.sourceIndex - b.sourceIndex;
  11914. // Use IE sourceIndex if available on both nodes
  11915. if ( diff ) {
  11916. return diff;
  11917. }
  11918. // Check if b follows a
  11919. if ( cur ) {
  11920. while ( ( cur = cur.nextSibling ) ) {
  11921. if ( cur === b ) {
  11922. return -1;
  11923. }
  11924. }
  11925. }
  11926. return a ? 1 : -1;
  11927. }
  11928. /**
  11929. * Returns a function to use in pseudos for input types
  11930. * @param {String} type
  11931. */
  11932. function createInputPseudo( type ) {
  11933. return function( elem ) {
  11934. var name = elem.nodeName.toLowerCase();
  11935. return name === "input" && elem.type === type;
  11936. };
  11937. }
  11938. /**
  11939. * Returns a function to use in pseudos for buttons
  11940. * @param {String} type
  11941. */
  11942. function createButtonPseudo( type ) {
  11943. return function( elem ) {
  11944. var name = elem.nodeName.toLowerCase();
  11945. return ( name === "input" || name === "button" ) && elem.type === type;
  11946. };
  11947. }
  11948. /**
  11949. * Returns a function to use in pseudos for :enabled/:disabled
  11950. * @param {Boolean} disabled true for :disabled; false for :enabled
  11951. */
  11952. function createDisabledPseudo( disabled ) {
  11953. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  11954. return function( elem ) {
  11955. // Only certain elements can match :enabled or :disabled
  11956. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  11957. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  11958. if ( "form" in elem ) {
  11959. // Check for inherited disabledness on relevant non-disabled elements:
  11960. // * listed form-associated elements in a disabled fieldset
  11961. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  11962. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  11963. // * option elements in a disabled optgroup
  11964. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  11965. // All such elements have a "form" property.
  11966. if ( elem.parentNode && elem.disabled === false ) {
  11967. // Option elements defer to a parent optgroup if present
  11968. if ( "label" in elem ) {
  11969. if ( "label" in elem.parentNode ) {
  11970. return elem.parentNode.disabled === disabled;
  11971. } else {
  11972. return elem.disabled === disabled;
  11973. }
  11974. }
  11975. // Support: IE 6 - 11
  11976. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  11977. return elem.isDisabled === disabled ||
  11978. // Where there is no isDisabled, check manually
  11979. /* jshint -W018 */
  11980. elem.isDisabled !== !disabled &&
  11981. inDisabledFieldset( elem ) === disabled;
  11982. }
  11983. return elem.disabled === disabled;
  11984. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  11985. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  11986. // even exist on them, let alone have a boolean value.
  11987. } else if ( "label" in elem ) {
  11988. return elem.disabled === disabled;
  11989. }
  11990. // Remaining elements are neither :enabled nor :disabled
  11991. return false;
  11992. };
  11993. }
  11994. /**
  11995. * Returns a function to use in pseudos for positionals
  11996. * @param {Function} fn
  11997. */
  11998. function createPositionalPseudo( fn ) {
  11999. return markFunction( function( argument ) {
  12000. argument = +argument;
  12001. return markFunction( function( seed, matches ) {
  12002. var j,
  12003. matchIndexes = fn( [], seed.length, argument ),
  12004. i = matchIndexes.length;
  12005. // Match elements found at the specified indexes
  12006. while ( i-- ) {
  12007. if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
  12008. seed[ j ] = !( matches[ j ] = seed[ j ] );
  12009. }
  12010. }
  12011. } );
  12012. } );
  12013. }
  12014. /**
  12015. * Checks a node for validity as a Sizzle context
  12016. * @param {Element|Object=} context
  12017. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  12018. */
  12019. function testContext( context ) {
  12020. return context && typeof context.getElementsByTagName !== "undefined" && context;
  12021. }
  12022. // Expose support vars for convenience
  12023. support = Sizzle.support = {};
  12024. /**
  12025. * Detects XML nodes
  12026. * @param {Element|Object} elem An element or a document
  12027. * @returns {Boolean} True iff elem is a non-HTML XML node
  12028. */
  12029. isXML = Sizzle.isXML = function( elem ) {
  12030. var namespace = elem.namespaceURI,
  12031. docElem = ( elem.ownerDocument || elem ).documentElement;
  12032. // Support: IE <=8
  12033. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  12034. // https://bugs.jquery.com/ticket/4833
  12035. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  12036. };
  12037. /**
  12038. * Sets document-related variables once based on the current document
  12039. * @param {Element|Object} [doc] An element or document object to use to set the document
  12040. * @returns {Object} Returns the current document
  12041. */
  12042. setDocument = Sizzle.setDocument = function( node ) {
  12043. var hasCompare, subWindow,
  12044. doc = node ? node.ownerDocument || node : preferredDoc;
  12045. // Return early if doc is invalid or already selected
  12046. // Support: IE 11+, Edge 17 - 18+
  12047. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12048. // two documents; shallow comparisons work.
  12049. // eslint-disable-next-line eqeqeq
  12050. if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
  12051. return document;
  12052. }
  12053. // Update global variables
  12054. document = doc;
  12055. docElem = document.documentElement;
  12056. documentIsHTML = !isXML( document );
  12057. // Support: IE 9 - 11+, Edge 12 - 18+
  12058. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  12059. // Support: IE 11+, Edge 17 - 18+
  12060. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12061. // two documents; shallow comparisons work.
  12062. // eslint-disable-next-line eqeqeq
  12063. if ( preferredDoc != document &&
  12064. ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
  12065. // Support: IE 11, Edge
  12066. if ( subWindow.addEventListener ) {
  12067. subWindow.addEventListener( "unload", unloadHandler, false );
  12068. // Support: IE 9 - 10 only
  12069. } else if ( subWindow.attachEvent ) {
  12070. subWindow.attachEvent( "onunload", unloadHandler );
  12071. }
  12072. }
  12073. // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
  12074. // Safari 4 - 5 only, Opera <=11.6 - 12.x only
  12075. // IE/Edge & older browsers don't support the :scope pseudo-class.
  12076. // Support: Safari 6.0 only
  12077. // Safari 6.0 supports :scope but it's an alias of :root there.
  12078. support.scope = assert( function( el ) {
  12079. docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
  12080. return typeof el.querySelectorAll !== "undefined" &&
  12081. !el.querySelectorAll( ":scope fieldset div" ).length;
  12082. } );
  12083. /* Attributes
  12084. ---------------------------------------------------------------------- */
  12085. // Support: IE<8
  12086. // Verify that getAttribute really returns attributes and not properties
  12087. // (excepting IE8 booleans)
  12088. support.attributes = assert( function( el ) {
  12089. el.className = "i";
  12090. return !el.getAttribute( "className" );
  12091. } );
  12092. /* getElement(s)By*
  12093. ---------------------------------------------------------------------- */
  12094. // Check if getElementsByTagName("*") returns only elements
  12095. support.getElementsByTagName = assert( function( el ) {
  12096. el.appendChild( document.createComment( "" ) );
  12097. return !el.getElementsByTagName( "*" ).length;
  12098. } );
  12099. // Support: IE<9
  12100. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  12101. // Support: IE<10
  12102. // Check if getElementById returns elements by name
  12103. // The broken getElementById methods don't pick up programmatically-set names,
  12104. // so use a roundabout getElementsByName test
  12105. support.getById = assert( function( el ) {
  12106. docElem.appendChild( el ).id = expando;
  12107. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  12108. } );
  12109. // ID filter and find
  12110. if ( support.getById ) {
  12111. Expr.filter[ "ID" ] = function( id ) {
  12112. var attrId = id.replace( runescape, funescape );
  12113. return function( elem ) {
  12114. return elem.getAttribute( "id" ) === attrId;
  12115. };
  12116. };
  12117. Expr.find[ "ID" ] = function( id, context ) {
  12118. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  12119. var elem = context.getElementById( id );
  12120. return elem ? [ elem ] : [];
  12121. }
  12122. };
  12123. } else {
  12124. Expr.filter[ "ID" ] = function( id ) {
  12125. var attrId = id.replace( runescape, funescape );
  12126. return function( elem ) {
  12127. var node = typeof elem.getAttributeNode !== "undefined" &&
  12128. elem.getAttributeNode( "id" );
  12129. return node && node.value === attrId;
  12130. };
  12131. };
  12132. // Support: IE 6 - 7 only
  12133. // getElementById is not reliable as a find shortcut
  12134. Expr.find[ "ID" ] = function( id, context ) {
  12135. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  12136. var node, i, elems,
  12137. elem = context.getElementById( id );
  12138. if ( elem ) {
  12139. // Verify the id attribute
  12140. node = elem.getAttributeNode( "id" );
  12141. if ( node && node.value === id ) {
  12142. return [ elem ];
  12143. }
  12144. // Fall back on getElementsByName
  12145. elems = context.getElementsByName( id );
  12146. i = 0;
  12147. while ( ( elem = elems[ i++ ] ) ) {
  12148. node = elem.getAttributeNode( "id" );
  12149. if ( node && node.value === id ) {
  12150. return [ elem ];
  12151. }
  12152. }
  12153. }
  12154. return [];
  12155. }
  12156. };
  12157. }
  12158. // Tag
  12159. Expr.find[ "TAG" ] = support.getElementsByTagName ?
  12160. function( tag, context ) {
  12161. if ( typeof context.getElementsByTagName !== "undefined" ) {
  12162. return context.getElementsByTagName( tag );
  12163. // DocumentFragment nodes don't have gEBTN
  12164. } else if ( support.qsa ) {
  12165. return context.querySelectorAll( tag );
  12166. }
  12167. } :
  12168. function( tag, context ) {
  12169. var elem,
  12170. tmp = [],
  12171. i = 0,
  12172. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  12173. results = context.getElementsByTagName( tag );
  12174. // Filter out possible comments
  12175. if ( tag === "*" ) {
  12176. while ( ( elem = results[ i++ ] ) ) {
  12177. if ( elem.nodeType === 1 ) {
  12178. tmp.push( elem );
  12179. }
  12180. }
  12181. return tmp;
  12182. }
  12183. return results;
  12184. };
  12185. // Class
  12186. Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
  12187. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  12188. return context.getElementsByClassName( className );
  12189. }
  12190. };
  12191. /* QSA/matchesSelector
  12192. ---------------------------------------------------------------------- */
  12193. // QSA and matchesSelector support
  12194. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  12195. rbuggyMatches = [];
  12196. // qSa(:focus) reports false when true (Chrome 21)
  12197. // We allow this because of a bug in IE8/9 that throws an error
  12198. // whenever `document.activeElement` is accessed on an iframe
  12199. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  12200. // See https://bugs.jquery.com/ticket/13378
  12201. rbuggyQSA = [];
  12202. if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
  12203. // Build QSA regex
  12204. // Regex strategy adopted from Diego Perini
  12205. assert( function( el ) {
  12206. var input;
  12207. // Select is set to empty string on purpose
  12208. // This is to test IE's treatment of not explicitly
  12209. // setting a boolean content attribute,
  12210. // since its presence should be enough
  12211. // https://bugs.jquery.com/ticket/12359
  12212. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  12213. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  12214. "<option selected=''></option></select>";
  12215. // Support: IE8, Opera 11-12.16
  12216. // Nothing should be selected when empty strings follow ^= or $= or *=
  12217. // The test attribute must be unknown in Opera but "safe" for WinRT
  12218. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  12219. if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
  12220. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  12221. }
  12222. // Support: IE8
  12223. // Boolean attributes and "value" are not treated correctly
  12224. if ( !el.querySelectorAll( "[selected]" ).length ) {
  12225. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  12226. }
  12227. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  12228. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  12229. rbuggyQSA.push( "~=" );
  12230. }
  12231. // Support: IE 11+, Edge 15 - 18+
  12232. // IE 11/Edge don't find elements on a `[name='']` query in some cases.
  12233. // Adding a temporary attribute to the document before the selection works
  12234. // around the issue.
  12235. // Interestingly, IE 10 & older don't seem to have the issue.
  12236. input = document.createElement( "input" );
  12237. input.setAttribute( "name", "" );
  12238. el.appendChild( input );
  12239. if ( !el.querySelectorAll( "[name='']" ).length ) {
  12240. rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
  12241. whitespace + "*(?:''|\"\")" );
  12242. }
  12243. // Webkit/Opera - :checked should return selected option elements
  12244. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  12245. // IE8 throws error here and will not see later tests
  12246. if ( !el.querySelectorAll( ":checked" ).length ) {
  12247. rbuggyQSA.push( ":checked" );
  12248. }
  12249. // Support: Safari 8+, iOS 8+
  12250. // https://bugs.webkit.org/show_bug.cgi?id=136851
  12251. // In-page `selector#id sibling-combinator selector` fails
  12252. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  12253. rbuggyQSA.push( ".#.+[+~]" );
  12254. }
  12255. // Support: Firefox <=3.6 - 5 only
  12256. // Old Firefox doesn't throw on a badly-escaped identifier.
  12257. el.querySelectorAll( "\\\f" );
  12258. rbuggyQSA.push( "[\\r\\n\\f]" );
  12259. } );
  12260. assert( function( el ) {
  12261. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  12262. "<select disabled='disabled'><option/></select>";
  12263. // Support: Windows 8 Native Apps
  12264. // The type and name attributes are restricted during .innerHTML assignment
  12265. var input = document.createElement( "input" );
  12266. input.setAttribute( "type", "hidden" );
  12267. el.appendChild( input ).setAttribute( "name", "D" );
  12268. // Support: IE8
  12269. // Enforce case-sensitivity of name attribute
  12270. if ( el.querySelectorAll( "[name=d]" ).length ) {
  12271. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  12272. }
  12273. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  12274. // IE8 throws error here and will not see later tests
  12275. if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
  12276. rbuggyQSA.push( ":enabled", ":disabled" );
  12277. }
  12278. // Support: IE9-11+
  12279. // IE's :disabled selector does not pick up the children of disabled fieldsets
  12280. docElem.appendChild( el ).disabled = true;
  12281. if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
  12282. rbuggyQSA.push( ":enabled", ":disabled" );
  12283. }
  12284. // Support: Opera 10 - 11 only
  12285. // Opera 10-11 does not throw on post-comma invalid pseudos
  12286. el.querySelectorAll( "*,:x" );
  12287. rbuggyQSA.push( ",.*:" );
  12288. } );
  12289. }
  12290. if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
  12291. docElem.webkitMatchesSelector ||
  12292. docElem.mozMatchesSelector ||
  12293. docElem.oMatchesSelector ||
  12294. docElem.msMatchesSelector ) ) ) ) {
  12295. assert( function( el ) {
  12296. // Check to see if it's possible to do matchesSelector
  12297. // on a disconnected node (IE 9)
  12298. support.disconnectedMatch = matches.call( el, "*" );
  12299. // This should fail with an exception
  12300. // Gecko does not error, returns false instead
  12301. matches.call( el, "[s!='']:x" );
  12302. rbuggyMatches.push( "!=", pseudos );
  12303. } );
  12304. }
  12305. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
  12306. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
  12307. /* Contains
  12308. ---------------------------------------------------------------------- */
  12309. hasCompare = rnative.test( docElem.compareDocumentPosition );
  12310. // Element contains another
  12311. // Purposefully self-exclusive
  12312. // As in, an element does not contain itself
  12313. contains = hasCompare || rnative.test( docElem.contains ) ?
  12314. function( a, b ) {
  12315. var adown = a.nodeType === 9 ? a.documentElement : a,
  12316. bup = b && b.parentNode;
  12317. return a === bup || !!( bup && bup.nodeType === 1 && (
  12318. adown.contains ?
  12319. adown.contains( bup ) :
  12320. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  12321. ) );
  12322. } :
  12323. function( a, b ) {
  12324. if ( b ) {
  12325. while ( ( b = b.parentNode ) ) {
  12326. if ( b === a ) {
  12327. return true;
  12328. }
  12329. }
  12330. }
  12331. return false;
  12332. };
  12333. /* Sorting
  12334. ---------------------------------------------------------------------- */
  12335. // Document order sorting
  12336. sortOrder = hasCompare ?
  12337. function( a, b ) {
  12338. // Flag for duplicate removal
  12339. if ( a === b ) {
  12340. hasDuplicate = true;
  12341. return 0;
  12342. }
  12343. // Sort on method existence if only one input has compareDocumentPosition
  12344. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  12345. if ( compare ) {
  12346. return compare;
  12347. }
  12348. // Calculate position if both inputs belong to the same document
  12349. // Support: IE 11+, Edge 17 - 18+
  12350. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12351. // two documents; shallow comparisons work.
  12352. // eslint-disable-next-line eqeqeq
  12353. compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
  12354. a.compareDocumentPosition( b ) :
  12355. // Otherwise we know they are disconnected
  12356. 1;
  12357. // Disconnected nodes
  12358. if ( compare & 1 ||
  12359. ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
  12360. // Choose the first element that is related to our preferred document
  12361. // Support: IE 11+, Edge 17 - 18+
  12362. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12363. // two documents; shallow comparisons work.
  12364. // eslint-disable-next-line eqeqeq
  12365. if ( a == document || a.ownerDocument == preferredDoc &&
  12366. contains( preferredDoc, a ) ) {
  12367. return -1;
  12368. }
  12369. // Support: IE 11+, Edge 17 - 18+
  12370. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12371. // two documents; shallow comparisons work.
  12372. // eslint-disable-next-line eqeqeq
  12373. if ( b == document || b.ownerDocument == preferredDoc &&
  12374. contains( preferredDoc, b ) ) {
  12375. return 1;
  12376. }
  12377. // Maintain original order
  12378. return sortInput ?
  12379. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  12380. 0;
  12381. }
  12382. return compare & 4 ? -1 : 1;
  12383. } :
  12384. function( a, b ) {
  12385. // Exit early if the nodes are identical
  12386. if ( a === b ) {
  12387. hasDuplicate = true;
  12388. return 0;
  12389. }
  12390. var cur,
  12391. i = 0,
  12392. aup = a.parentNode,
  12393. bup = b.parentNode,
  12394. ap = [ a ],
  12395. bp = [ b ];
  12396. // Parentless nodes are either documents or disconnected
  12397. if ( !aup || !bup ) {
  12398. // Support: IE 11+, Edge 17 - 18+
  12399. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12400. // two documents; shallow comparisons work.
  12401. /* eslint-disable eqeqeq */
  12402. return a == document ? -1 :
  12403. b == document ? 1 :
  12404. /* eslint-enable eqeqeq */
  12405. aup ? -1 :
  12406. bup ? 1 :
  12407. sortInput ?
  12408. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  12409. 0;
  12410. // If the nodes are siblings, we can do a quick check
  12411. } else if ( aup === bup ) {
  12412. return siblingCheck( a, b );
  12413. }
  12414. // Otherwise we need full lists of their ancestors for comparison
  12415. cur = a;
  12416. while ( ( cur = cur.parentNode ) ) {
  12417. ap.unshift( cur );
  12418. }
  12419. cur = b;
  12420. while ( ( cur = cur.parentNode ) ) {
  12421. bp.unshift( cur );
  12422. }
  12423. // Walk down the tree looking for a discrepancy
  12424. while ( ap[ i ] === bp[ i ] ) {
  12425. i++;
  12426. }
  12427. return i ?
  12428. // Do a sibling check if the nodes have a common ancestor
  12429. siblingCheck( ap[ i ], bp[ i ] ) :
  12430. // Otherwise nodes in our document sort first
  12431. // Support: IE 11+, Edge 17 - 18+
  12432. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12433. // two documents; shallow comparisons work.
  12434. /* eslint-disable eqeqeq */
  12435. ap[ i ] == preferredDoc ? -1 :
  12436. bp[ i ] == preferredDoc ? 1 :
  12437. /* eslint-enable eqeqeq */
  12438. 0;
  12439. };
  12440. return document;
  12441. };
  12442. Sizzle.matches = function( expr, elements ) {
  12443. return Sizzle( expr, null, null, elements );
  12444. };
  12445. Sizzle.matchesSelector = function( elem, expr ) {
  12446. setDocument( elem );
  12447. if ( support.matchesSelector && documentIsHTML &&
  12448. !nonnativeSelectorCache[ expr + " " ] &&
  12449. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  12450. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  12451. try {
  12452. var ret = matches.call( elem, expr );
  12453. // IE 9's matchesSelector returns false on disconnected nodes
  12454. if ( ret || support.disconnectedMatch ||
  12455. // As well, disconnected nodes are said to be in a document
  12456. // fragment in IE 9
  12457. elem.document && elem.document.nodeType !== 11 ) {
  12458. return ret;
  12459. }
  12460. } catch ( e ) {
  12461. nonnativeSelectorCache( expr, true );
  12462. }
  12463. }
  12464. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  12465. };
  12466. Sizzle.contains = function( context, elem ) {
  12467. // Set document vars if needed
  12468. // Support: IE 11+, Edge 17 - 18+
  12469. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12470. // two documents; shallow comparisons work.
  12471. // eslint-disable-next-line eqeqeq
  12472. if ( ( context.ownerDocument || context ) != document ) {
  12473. setDocument( context );
  12474. }
  12475. return contains( context, elem );
  12476. };
  12477. Sizzle.attr = function( elem, name ) {
  12478. // Set document vars if needed
  12479. // Support: IE 11+, Edge 17 - 18+
  12480. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  12481. // two documents; shallow comparisons work.
  12482. // eslint-disable-next-line eqeqeq
  12483. if ( ( elem.ownerDocument || elem ) != document ) {
  12484. setDocument( elem );
  12485. }
  12486. var fn = Expr.attrHandle[ name.toLowerCase() ],
  12487. // Don't get fooled by Object.prototype properties (jQuery #13807)
  12488. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  12489. fn( elem, name, !documentIsHTML ) :
  12490. undefined;
  12491. return val !== undefined ?
  12492. val :
  12493. support.attributes || !documentIsHTML ?
  12494. elem.getAttribute( name ) :
  12495. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  12496. val.value :
  12497. null;
  12498. };
  12499. Sizzle.escape = function( sel ) {
  12500. return ( sel + "" ).replace( rcssescape, fcssescape );
  12501. };
  12502. Sizzle.error = function( msg ) {
  12503. throw new Error( "Syntax error, unrecognized expression: " + msg );
  12504. };
  12505. /**
  12506. * Document sorting and removing duplicates
  12507. * @param {ArrayLike} results
  12508. */
  12509. Sizzle.uniqueSort = function( results ) {
  12510. var elem,
  12511. duplicates = [],
  12512. j = 0,
  12513. i = 0;
  12514. // Unless we *know* we can detect duplicates, assume their presence
  12515. hasDuplicate = !support.detectDuplicates;
  12516. sortInput = !support.sortStable && results.slice( 0 );
  12517. results.sort( sortOrder );
  12518. if ( hasDuplicate ) {
  12519. while ( ( elem = results[ i++ ] ) ) {
  12520. if ( elem === results[ i ] ) {
  12521. j = duplicates.push( i );
  12522. }
  12523. }
  12524. while ( j-- ) {
  12525. results.splice( duplicates[ j ], 1 );
  12526. }
  12527. }
  12528. // Clear input after sorting to release objects
  12529. // See https://github.com/jquery/sizzle/pull/225
  12530. sortInput = null;
  12531. return results;
  12532. };
  12533. /**
  12534. * Utility function for retrieving the text value of an array of DOM nodes
  12535. * @param {Array|Element} elem
  12536. */
  12537. getText = Sizzle.getText = function( elem ) {
  12538. var node,
  12539. ret = "",
  12540. i = 0,
  12541. nodeType = elem.nodeType;
  12542. if ( !nodeType ) {
  12543. // If no nodeType, this is expected to be an array
  12544. while ( ( node = elem[ i++ ] ) ) {
  12545. // Do not traverse comment nodes
  12546. ret += getText( node );
  12547. }
  12548. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  12549. // Use textContent for elements
  12550. // innerText usage removed for consistency of new lines (jQuery #11153)
  12551. if ( typeof elem.textContent === "string" ) {
  12552. return elem.textContent;
  12553. } else {
  12554. // Traverse its children
  12555. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  12556. ret += getText( elem );
  12557. }
  12558. }
  12559. } else if ( nodeType === 3 || nodeType === 4 ) {
  12560. return elem.nodeValue;
  12561. }
  12562. // Do not include comment or processing instruction nodes
  12563. return ret;
  12564. };
  12565. Expr = Sizzle.selectors = {
  12566. // Can be adjusted by the user
  12567. cacheLength: 50,
  12568. createPseudo: markFunction,
  12569. match: matchExpr,
  12570. attrHandle: {},
  12571. find: {},
  12572. relative: {
  12573. ">": { dir: "parentNode", first: true },
  12574. " ": { dir: "parentNode" },
  12575. "+": { dir: "previousSibling", first: true },
  12576. "~": { dir: "previousSibling" }
  12577. },
  12578. preFilter: {
  12579. "ATTR": function( match ) {
  12580. match[ 1 ] = match[ 1 ].replace( runescape, funescape );
  12581. // Move the given value to match[3] whether quoted or unquoted
  12582. match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
  12583. match[ 5 ] || "" ).replace( runescape, funescape );
  12584. if ( match[ 2 ] === "~=" ) {
  12585. match[ 3 ] = " " + match[ 3 ] + " ";
  12586. }
  12587. return match.slice( 0, 4 );
  12588. },
  12589. "CHILD": function( match ) {
  12590. /* matches from matchExpr["CHILD"]
  12591. 1 type (only|nth|...)
  12592. 2 what (child|of-type)
  12593. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  12594. 4 xn-component of xn+y argument ([+-]?\d*n|)
  12595. 5 sign of xn-component
  12596. 6 x of xn-component
  12597. 7 sign of y-component
  12598. 8 y of y-component
  12599. */
  12600. match[ 1 ] = match[ 1 ].toLowerCase();
  12601. if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
  12602. // nth-* requires argument
  12603. if ( !match[ 3 ] ) {
  12604. Sizzle.error( match[ 0 ] );
  12605. }
  12606. // numeric x and y parameters for Expr.filter.CHILD
  12607. // remember that false/true cast respectively to 0/1
  12608. match[ 4 ] = +( match[ 4 ] ?
  12609. match[ 5 ] + ( match[ 6 ] || 1 ) :
  12610. 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
  12611. match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
  12612. // other types prohibit arguments
  12613. } else if ( match[ 3 ] ) {
  12614. Sizzle.error( match[ 0 ] );
  12615. }
  12616. return match;
  12617. },
  12618. "PSEUDO": function( match ) {
  12619. var excess,
  12620. unquoted = !match[ 6 ] && match[ 2 ];
  12621. if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
  12622. return null;
  12623. }
  12624. // Accept quoted arguments as-is
  12625. if ( match[ 3 ] ) {
  12626. match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
  12627. // Strip excess characters from unquoted arguments
  12628. } else if ( unquoted && rpseudo.test( unquoted ) &&
  12629. // Get excess from tokenize (recursively)
  12630. ( excess = tokenize( unquoted, true ) ) &&
  12631. // advance to the next closing parenthesis
  12632. ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
  12633. // excess is a negative index
  12634. match[ 0 ] = match[ 0 ].slice( 0, excess );
  12635. match[ 2 ] = unquoted.slice( 0, excess );
  12636. }
  12637. // Return only captures needed by the pseudo filter method (type and argument)
  12638. return match.slice( 0, 3 );
  12639. }
  12640. },
  12641. filter: {
  12642. "TAG": function( nodeNameSelector ) {
  12643. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  12644. return nodeNameSelector === "*" ?
  12645. function() {
  12646. return true;
  12647. } :
  12648. function( elem ) {
  12649. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  12650. };
  12651. },
  12652. "CLASS": function( className ) {
  12653. var pattern = classCache[ className + " " ];
  12654. return pattern ||
  12655. ( pattern = new RegExp( "(^|" + whitespace +
  12656. ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
  12657. className, function( elem ) {
  12658. return pattern.test(
  12659. typeof elem.className === "string" && elem.className ||
  12660. typeof elem.getAttribute !== "undefined" &&
  12661. elem.getAttribute( "class" ) ||
  12662. ""
  12663. );
  12664. } );
  12665. },
  12666. "ATTR": function( name, operator, check ) {
  12667. return function( elem ) {
  12668. var result = Sizzle.attr( elem, name );
  12669. if ( result == null ) {
  12670. return operator === "!=";
  12671. }
  12672. if ( !operator ) {
  12673. return true;
  12674. }
  12675. result += "";
  12676. /* eslint-disable max-len */
  12677. return operator === "=" ? result === check :
  12678. operator === "!=" ? result !== check :
  12679. operator === "^=" ? check && result.indexOf( check ) === 0 :
  12680. operator === "*=" ? check && result.indexOf( check ) > -1 :
  12681. operator === "$=" ? check && result.slice( -check.length ) === check :
  12682. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  12683. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  12684. false;
  12685. /* eslint-enable max-len */
  12686. };
  12687. },
  12688. "CHILD": function( type, what, _argument, first, last ) {
  12689. var simple = type.slice( 0, 3 ) !== "nth",
  12690. forward = type.slice( -4 ) !== "last",
  12691. ofType = what === "of-type";
  12692. return first === 1 && last === 0 ?
  12693. // Shortcut for :nth-*(n)
  12694. function( elem ) {
  12695. return !!elem.parentNode;
  12696. } :
  12697. function( elem, _context, xml ) {
  12698. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  12699. dir = simple !== forward ? "nextSibling" : "previousSibling",
  12700. parent = elem.parentNode,
  12701. name = ofType && elem.nodeName.toLowerCase(),
  12702. useCache = !xml && !ofType,
  12703. diff = false;
  12704. if ( parent ) {
  12705. // :(first|last|only)-(child|of-type)
  12706. if ( simple ) {
  12707. while ( dir ) {
  12708. node = elem;
  12709. while ( ( node = node[ dir ] ) ) {
  12710. if ( ofType ?
  12711. node.nodeName.toLowerCase() === name :
  12712. node.nodeType === 1 ) {
  12713. return false;
  12714. }
  12715. }
  12716. // Reverse direction for :only-* (if we haven't yet done so)
  12717. start = dir = type === "only" && !start && "nextSibling";
  12718. }
  12719. return true;
  12720. }
  12721. start = [ forward ? parent.firstChild : parent.lastChild ];
  12722. // non-xml :nth-child(...) stores cache data on `parent`
  12723. if ( forward && useCache ) {
  12724. // Seek `elem` from a previously-cached index
  12725. // ...in a gzip-friendly way
  12726. node = parent;
  12727. outerCache = node[ expando ] || ( node[ expando ] = {} );
  12728. // Support: IE <9 only
  12729. // Defend against cloned attroperties (jQuery gh-1709)
  12730. uniqueCache = outerCache[ node.uniqueID ] ||
  12731. ( outerCache[ node.uniqueID ] = {} );
  12732. cache = uniqueCache[ type ] || [];
  12733. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  12734. diff = nodeIndex && cache[ 2 ];
  12735. node = nodeIndex && parent.childNodes[ nodeIndex ];
  12736. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  12737. // Fallback to seeking `elem` from the start
  12738. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  12739. // When found, cache indexes on `parent` and break
  12740. if ( node.nodeType === 1 && ++diff && node === elem ) {
  12741. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  12742. break;
  12743. }
  12744. }
  12745. } else {
  12746. // Use previously-cached element index if available
  12747. if ( useCache ) {
  12748. // ...in a gzip-friendly way
  12749. node = elem;
  12750. outerCache = node[ expando ] || ( node[ expando ] = {} );
  12751. // Support: IE <9 only
  12752. // Defend against cloned attroperties (jQuery gh-1709)
  12753. uniqueCache = outerCache[ node.uniqueID ] ||
  12754. ( outerCache[ node.uniqueID ] = {} );
  12755. cache = uniqueCache[ type ] || [];
  12756. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  12757. diff = nodeIndex;
  12758. }
  12759. // xml :nth-child(...)
  12760. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  12761. if ( diff === false ) {
  12762. // Use the same loop as above to seek `elem` from the start
  12763. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  12764. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  12765. if ( ( ofType ?
  12766. node.nodeName.toLowerCase() === name :
  12767. node.nodeType === 1 ) &&
  12768. ++diff ) {
  12769. // Cache the index of each encountered element
  12770. if ( useCache ) {
  12771. outerCache = node[ expando ] ||
  12772. ( node[ expando ] = {} );
  12773. // Support: IE <9 only
  12774. // Defend against cloned attroperties (jQuery gh-1709)
  12775. uniqueCache = outerCache[ node.uniqueID ] ||
  12776. ( outerCache[ node.uniqueID ] = {} );
  12777. uniqueCache[ type ] = [ dirruns, diff ];
  12778. }
  12779. if ( node === elem ) {
  12780. break;
  12781. }
  12782. }
  12783. }
  12784. }
  12785. }
  12786. // Incorporate the offset, then check against cycle size
  12787. diff -= last;
  12788. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  12789. }
  12790. };
  12791. },
  12792. "PSEUDO": function( pseudo, argument ) {
  12793. // pseudo-class names are case-insensitive
  12794. // http://www.w3.org/TR/selectors/#pseudo-classes
  12795. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  12796. // Remember that setFilters inherits from pseudos
  12797. var args,
  12798. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  12799. Sizzle.error( "unsupported pseudo: " + pseudo );
  12800. // The user may use createPseudo to indicate that
  12801. // arguments are needed to create the filter function
  12802. // just as Sizzle does
  12803. if ( fn[ expando ] ) {
  12804. return fn( argument );
  12805. }
  12806. // But maintain support for old signatures
  12807. if ( fn.length > 1 ) {
  12808. args = [ pseudo, pseudo, "", argument ];
  12809. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  12810. markFunction( function( seed, matches ) {
  12811. var idx,
  12812. matched = fn( seed, argument ),
  12813. i = matched.length;
  12814. while ( i-- ) {
  12815. idx = indexOf( seed, matched[ i ] );
  12816. seed[ idx ] = !( matches[ idx ] = matched[ i ] );
  12817. }
  12818. } ) :
  12819. function( elem ) {
  12820. return fn( elem, 0, args );
  12821. };
  12822. }
  12823. return fn;
  12824. }
  12825. },
  12826. pseudos: {
  12827. // Potentially complex pseudos
  12828. "not": markFunction( function( selector ) {
  12829. // Trim the selector passed to compile
  12830. // to avoid treating leading and trailing
  12831. // spaces as combinators
  12832. var input = [],
  12833. results = [],
  12834. matcher = compile( selector.replace( rtrim, "$1" ) );
  12835. return matcher[ expando ] ?
  12836. markFunction( function( seed, matches, _context, xml ) {
  12837. var elem,
  12838. unmatched = matcher( seed, null, xml, [] ),
  12839. i = seed.length;
  12840. // Match elements unmatched by `matcher`
  12841. while ( i-- ) {
  12842. if ( ( elem = unmatched[ i ] ) ) {
  12843. seed[ i ] = !( matches[ i ] = elem );
  12844. }
  12845. }
  12846. } ) :
  12847. function( elem, _context, xml ) {
  12848. input[ 0 ] = elem;
  12849. matcher( input, null, xml, results );
  12850. // Don't keep the element (issue #299)
  12851. input[ 0 ] = null;
  12852. return !results.pop();
  12853. };
  12854. } ),
  12855. "has": markFunction( function( selector ) {
  12856. return function( elem ) {
  12857. return Sizzle( selector, elem ).length > 0;
  12858. };
  12859. } ),
  12860. "contains": markFunction( function( text ) {
  12861. text = text.replace( runescape, funescape );
  12862. return function( elem ) {
  12863. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  12864. };
  12865. } ),
  12866. // "Whether an element is represented by a :lang() selector
  12867. // is based solely on the element's language value
  12868. // being equal to the identifier C,
  12869. // or beginning with the identifier C immediately followed by "-".
  12870. // The matching of C against the element's language value is performed case-insensitively.
  12871. // The identifier C does not have to be a valid language name."
  12872. // http://www.w3.org/TR/selectors/#lang-pseudo
  12873. "lang": markFunction( function( lang ) {
  12874. // lang value must be a valid identifier
  12875. if ( !ridentifier.test( lang || "" ) ) {
  12876. Sizzle.error( "unsupported lang: " + lang );
  12877. }
  12878. lang = lang.replace( runescape, funescape ).toLowerCase();
  12879. return function( elem ) {
  12880. var elemLang;
  12881. do {
  12882. if ( ( elemLang = documentIsHTML ?
  12883. elem.lang :
  12884. elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
  12885. elemLang = elemLang.toLowerCase();
  12886. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  12887. }
  12888. } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
  12889. return false;
  12890. };
  12891. } ),
  12892. // Miscellaneous
  12893. "target": function( elem ) {
  12894. var hash = window.location && window.location.hash;
  12895. return hash && hash.slice( 1 ) === elem.id;
  12896. },
  12897. "root": function( elem ) {
  12898. return elem === docElem;
  12899. },
  12900. "focus": function( elem ) {
  12901. return elem === document.activeElement &&
  12902. ( !document.hasFocus || document.hasFocus() ) &&
  12903. !!( elem.type || elem.href || ~elem.tabIndex );
  12904. },
  12905. // Boolean properties
  12906. "enabled": createDisabledPseudo( false ),
  12907. "disabled": createDisabledPseudo( true ),
  12908. "checked": function( elem ) {
  12909. // In CSS3, :checked should return both checked and selected elements
  12910. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  12911. var nodeName = elem.nodeName.toLowerCase();
  12912. return ( nodeName === "input" && !!elem.checked ) ||
  12913. ( nodeName === "option" && !!elem.selected );
  12914. },
  12915. "selected": function( elem ) {
  12916. // Accessing this property makes selected-by-default
  12917. // options in Safari work properly
  12918. if ( elem.parentNode ) {
  12919. // eslint-disable-next-line no-unused-expressions
  12920. elem.parentNode.selectedIndex;
  12921. }
  12922. return elem.selected === true;
  12923. },
  12924. // Contents
  12925. "empty": function( elem ) {
  12926. // http://www.w3.org/TR/selectors/#empty-pseudo
  12927. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  12928. // but not by others (comment: 8; processing instruction: 7; etc.)
  12929. // nodeType < 6 works because attributes (2) do not appear as children
  12930. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  12931. if ( elem.nodeType < 6 ) {
  12932. return false;
  12933. }
  12934. }
  12935. return true;
  12936. },
  12937. "parent": function( elem ) {
  12938. return !Expr.pseudos[ "empty" ]( elem );
  12939. },
  12940. // Element/input types
  12941. "header": function( elem ) {
  12942. return rheader.test( elem.nodeName );
  12943. },
  12944. "input": function( elem ) {
  12945. return rinputs.test( elem.nodeName );
  12946. },
  12947. "button": function( elem ) {
  12948. var name = elem.nodeName.toLowerCase();
  12949. return name === "input" && elem.type === "button" || name === "button";
  12950. },
  12951. "text": function( elem ) {
  12952. var attr;
  12953. return elem.nodeName.toLowerCase() === "input" &&
  12954. elem.type === "text" &&
  12955. // Support: IE<8
  12956. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  12957. ( ( attr = elem.getAttribute( "type" ) ) == null ||
  12958. attr.toLowerCase() === "text" );
  12959. },
  12960. // Position-in-collection
  12961. "first": createPositionalPseudo( function() {
  12962. return [ 0 ];
  12963. } ),
  12964. "last": createPositionalPseudo( function( _matchIndexes, length ) {
  12965. return [ length - 1 ];
  12966. } ),
  12967. "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
  12968. return [ argument < 0 ? argument + length : argument ];
  12969. } ),
  12970. "even": createPositionalPseudo( function( matchIndexes, length ) {
  12971. var i = 0;
  12972. for ( ; i < length; i += 2 ) {
  12973. matchIndexes.push( i );
  12974. }
  12975. return matchIndexes;
  12976. } ),
  12977. "odd": createPositionalPseudo( function( matchIndexes, length ) {
  12978. var i = 1;
  12979. for ( ; i < length; i += 2 ) {
  12980. matchIndexes.push( i );
  12981. }
  12982. return matchIndexes;
  12983. } ),
  12984. "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  12985. var i = argument < 0 ?
  12986. argument + length :
  12987. argument > length ?
  12988. length :
  12989. argument;
  12990. for ( ; --i >= 0; ) {
  12991. matchIndexes.push( i );
  12992. }
  12993. return matchIndexes;
  12994. } ),
  12995. "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  12996. var i = argument < 0 ? argument + length : argument;
  12997. for ( ; ++i < length; ) {
  12998. matchIndexes.push( i );
  12999. }
  13000. return matchIndexes;
  13001. } )
  13002. }
  13003. };
  13004. Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
  13005. // Add button/input type pseudos
  13006. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  13007. Expr.pseudos[ i ] = createInputPseudo( i );
  13008. }
  13009. for ( i in { submit: true, reset: true } ) {
  13010. Expr.pseudos[ i ] = createButtonPseudo( i );
  13011. }
  13012. // Easy API for creating new setFilters
  13013. function setFilters() {}
  13014. setFilters.prototype = Expr.filters = Expr.pseudos;
  13015. Expr.setFilters = new setFilters();
  13016. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  13017. var matched, match, tokens, type,
  13018. soFar, groups, preFilters,
  13019. cached = tokenCache[ selector + " " ];
  13020. if ( cached ) {
  13021. return parseOnly ? 0 : cached.slice( 0 );
  13022. }
  13023. soFar = selector;
  13024. groups = [];
  13025. preFilters = Expr.preFilter;
  13026. while ( soFar ) {
  13027. // Comma and first run
  13028. if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
  13029. if ( match ) {
  13030. // Don't consume trailing commas as valid
  13031. soFar = soFar.slice( match[ 0 ].length ) || soFar;
  13032. }
  13033. groups.push( ( tokens = [] ) );
  13034. }
  13035. matched = false;
  13036. // Combinators
  13037. if ( ( match = rcombinators.exec( soFar ) ) ) {
  13038. matched = match.shift();
  13039. tokens.push( {
  13040. value: matched,
  13041. // Cast descendant combinators to space
  13042. type: match[ 0 ].replace( rtrim, " " )
  13043. } );
  13044. soFar = soFar.slice( matched.length );
  13045. }
  13046. // Filters
  13047. for ( type in Expr.filter ) {
  13048. if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
  13049. ( match = preFilters[ type ]( match ) ) ) ) {
  13050. matched = match.shift();
  13051. tokens.push( {
  13052. value: matched,
  13053. type: type,
  13054. matches: match
  13055. } );
  13056. soFar = soFar.slice( matched.length );
  13057. }
  13058. }
  13059. if ( !matched ) {
  13060. break;
  13061. }
  13062. }
  13063. // Return the length of the invalid excess
  13064. // if we're just parsing
  13065. // Otherwise, throw an error or return tokens
  13066. return parseOnly ?
  13067. soFar.length :
  13068. soFar ?
  13069. Sizzle.error( selector ) :
  13070. // Cache the tokens
  13071. tokenCache( selector, groups ).slice( 0 );
  13072. };
  13073. function toSelector( tokens ) {
  13074. var i = 0,
  13075. len = tokens.length,
  13076. selector = "";
  13077. for ( ; i < len; i++ ) {
  13078. selector += tokens[ i ].value;
  13079. }
  13080. return selector;
  13081. }
  13082. function addCombinator( matcher, combinator, base ) {
  13083. var dir = combinator.dir,
  13084. skip = combinator.next,
  13085. key = skip || dir,
  13086. checkNonElements = base && key === "parentNode",
  13087. doneName = done++;
  13088. return combinator.first ?
  13089. // Check against closest ancestor/preceding element
  13090. function( elem, context, xml ) {
  13091. while ( ( elem = elem[ dir ] ) ) {
  13092. if ( elem.nodeType === 1 || checkNonElements ) {
  13093. return matcher( elem, context, xml );
  13094. }
  13095. }
  13096. return false;
  13097. } :
  13098. // Check against all ancestor/preceding elements
  13099. function( elem, context, xml ) {
  13100. var oldCache, uniqueCache, outerCache,
  13101. newCache = [ dirruns, doneName ];
  13102. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  13103. if ( xml ) {
  13104. while ( ( elem = elem[ dir ] ) ) {
  13105. if ( elem.nodeType === 1 || checkNonElements ) {
  13106. if ( matcher( elem, context, xml ) ) {
  13107. return true;
  13108. }
  13109. }
  13110. }
  13111. } else {
  13112. while ( ( elem = elem[ dir ] ) ) {
  13113. if ( elem.nodeType === 1 || checkNonElements ) {
  13114. outerCache = elem[ expando ] || ( elem[ expando ] = {} );
  13115. // Support: IE <9 only
  13116. // Defend against cloned attroperties (jQuery gh-1709)
  13117. uniqueCache = outerCache[ elem.uniqueID ] ||
  13118. ( outerCache[ elem.uniqueID ] = {} );
  13119. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  13120. elem = elem[ dir ] || elem;
  13121. } else if ( ( oldCache = uniqueCache[ key ] ) &&
  13122. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  13123. // Assign to newCache so results back-propagate to previous elements
  13124. return ( newCache[ 2 ] = oldCache[ 2 ] );
  13125. } else {
  13126. // Reuse newcache so results back-propagate to previous elements
  13127. uniqueCache[ key ] = newCache;
  13128. // A match means we're done; a fail means we have to keep checking
  13129. if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
  13130. return true;
  13131. }
  13132. }
  13133. }
  13134. }
  13135. }
  13136. return false;
  13137. };
  13138. }
  13139. function elementMatcher( matchers ) {
  13140. return matchers.length > 1 ?
  13141. function( elem, context, xml ) {
  13142. var i = matchers.length;
  13143. while ( i-- ) {
  13144. if ( !matchers[ i ]( elem, context, xml ) ) {
  13145. return false;
  13146. }
  13147. }
  13148. return true;
  13149. } :
  13150. matchers[ 0 ];
  13151. }
  13152. function multipleContexts( selector, contexts, results ) {
  13153. var i = 0,
  13154. len = contexts.length;
  13155. for ( ; i < len; i++ ) {
  13156. Sizzle( selector, contexts[ i ], results );
  13157. }
  13158. return results;
  13159. }
  13160. function condense( unmatched, map, filter, context, xml ) {
  13161. var elem,
  13162. newUnmatched = [],
  13163. i = 0,
  13164. len = unmatched.length,
  13165. mapped = map != null;
  13166. for ( ; i < len; i++ ) {
  13167. if ( ( elem = unmatched[ i ] ) ) {
  13168. if ( !filter || filter( elem, context, xml ) ) {
  13169. newUnmatched.push( elem );
  13170. if ( mapped ) {
  13171. map.push( i );
  13172. }
  13173. }
  13174. }
  13175. }
  13176. return newUnmatched;
  13177. }
  13178. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  13179. if ( postFilter && !postFilter[ expando ] ) {
  13180. postFilter = setMatcher( postFilter );
  13181. }
  13182. if ( postFinder && !postFinder[ expando ] ) {
  13183. postFinder = setMatcher( postFinder, postSelector );
  13184. }
  13185. return markFunction( function( seed, results, context, xml ) {
  13186. var temp, i, elem,
  13187. preMap = [],
  13188. postMap = [],
  13189. preexisting = results.length,
  13190. // Get initial elements from seed or context
  13191. elems = seed || multipleContexts(
  13192. selector || "*",
  13193. context.nodeType ? [ context ] : context,
  13194. []
  13195. ),
  13196. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  13197. matcherIn = preFilter && ( seed || !selector ) ?
  13198. condense( elems, preMap, preFilter, context, xml ) :
  13199. elems,
  13200. matcherOut = matcher ?
  13201. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  13202. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  13203. // ...intermediate processing is necessary
  13204. [] :
  13205. // ...otherwise use results directly
  13206. results :
  13207. matcherIn;
  13208. // Find primary matches
  13209. if ( matcher ) {
  13210. matcher( matcherIn, matcherOut, context, xml );
  13211. }
  13212. // Apply postFilter
  13213. if ( postFilter ) {
  13214. temp = condense( matcherOut, postMap );
  13215. postFilter( temp, [], context, xml );
  13216. // Un-match failing elements by moving them back to matcherIn
  13217. i = temp.length;
  13218. while ( i-- ) {
  13219. if ( ( elem = temp[ i ] ) ) {
  13220. matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
  13221. }
  13222. }
  13223. }
  13224. if ( seed ) {
  13225. if ( postFinder || preFilter ) {
  13226. if ( postFinder ) {
  13227. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  13228. temp = [];
  13229. i = matcherOut.length;
  13230. while ( i-- ) {
  13231. if ( ( elem = matcherOut[ i ] ) ) {
  13232. // Restore matcherIn since elem is not yet a final match
  13233. temp.push( ( matcherIn[ i ] = elem ) );
  13234. }
  13235. }
  13236. postFinder( null, ( matcherOut = [] ), temp, xml );
  13237. }
  13238. // Move matched elements from seed to results to keep them synchronized
  13239. i = matcherOut.length;
  13240. while ( i-- ) {
  13241. if ( ( elem = matcherOut[ i ] ) &&
  13242. ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
  13243. seed[ temp ] = !( results[ temp ] = elem );
  13244. }
  13245. }
  13246. }
  13247. // Add elements to results, through postFinder if defined
  13248. } else {
  13249. matcherOut = condense(
  13250. matcherOut === results ?
  13251. matcherOut.splice( preexisting, matcherOut.length ) :
  13252. matcherOut
  13253. );
  13254. if ( postFinder ) {
  13255. postFinder( null, results, matcherOut, xml );
  13256. } else {
  13257. push.apply( results, matcherOut );
  13258. }
  13259. }
  13260. } );
  13261. }
  13262. function matcherFromTokens( tokens ) {
  13263. var checkContext, matcher, j,
  13264. len = tokens.length,
  13265. leadingRelative = Expr.relative[ tokens[ 0 ].type ],
  13266. implicitRelative = leadingRelative || Expr.relative[ " " ],
  13267. i = leadingRelative ? 1 : 0,
  13268. // The foundational matcher ensures that elements are reachable from top-level context(s)
  13269. matchContext = addCombinator( function( elem ) {
  13270. return elem === checkContext;
  13271. }, implicitRelative, true ),
  13272. matchAnyContext = addCombinator( function( elem ) {
  13273. return indexOf( checkContext, elem ) > -1;
  13274. }, implicitRelative, true ),
  13275. matchers = [ function( elem, context, xml ) {
  13276. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  13277. ( checkContext = context ).nodeType ?
  13278. matchContext( elem, context, xml ) :
  13279. matchAnyContext( elem, context, xml ) );
  13280. // Avoid hanging onto element (issue #299)
  13281. checkContext = null;
  13282. return ret;
  13283. } ];
  13284. for ( ; i < len; i++ ) {
  13285. if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
  13286. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  13287. } else {
  13288. matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
  13289. // Return special upon seeing a positional matcher
  13290. if ( matcher[ expando ] ) {
  13291. // Find the next relative operator (if any) for proper handling
  13292. j = ++i;
  13293. for ( ; j < len; j++ ) {
  13294. if ( Expr.relative[ tokens[ j ].type ] ) {
  13295. break;
  13296. }
  13297. }
  13298. return setMatcher(
  13299. i > 1 && elementMatcher( matchers ),
  13300. i > 1 && toSelector(
  13301. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  13302. tokens
  13303. .slice( 0, i - 1 )
  13304. .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
  13305. ).replace( rtrim, "$1" ),
  13306. matcher,
  13307. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  13308. j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
  13309. j < len && toSelector( tokens )
  13310. );
  13311. }
  13312. matchers.push( matcher );
  13313. }
  13314. }
  13315. return elementMatcher( matchers );
  13316. }
  13317. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  13318. var bySet = setMatchers.length > 0,
  13319. byElement = elementMatchers.length > 0,
  13320. superMatcher = function( seed, context, xml, results, outermost ) {
  13321. var elem, j, matcher,
  13322. matchedCount = 0,
  13323. i = "0",
  13324. unmatched = seed && [],
  13325. setMatched = [],
  13326. contextBackup = outermostContext,
  13327. // We must always have either seed elements or outermost context
  13328. elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
  13329. // Use integer dirruns iff this is the outermost matcher
  13330. dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
  13331. len = elems.length;
  13332. if ( outermost ) {
  13333. // Support: IE 11+, Edge 17 - 18+
  13334. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  13335. // two documents; shallow comparisons work.
  13336. // eslint-disable-next-line eqeqeq
  13337. outermostContext = context == document || context || outermost;
  13338. }
  13339. // Add elements passing elementMatchers directly to results
  13340. // Support: IE<9, Safari
  13341. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  13342. for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
  13343. if ( byElement && elem ) {
  13344. j = 0;
  13345. // Support: IE 11+, Edge 17 - 18+
  13346. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  13347. // two documents; shallow comparisons work.
  13348. // eslint-disable-next-line eqeqeq
  13349. if ( !context && elem.ownerDocument != document ) {
  13350. setDocument( elem );
  13351. xml = !documentIsHTML;
  13352. }
  13353. while ( ( matcher = elementMatchers[ j++ ] ) ) {
  13354. if ( matcher( elem, context || document, xml ) ) {
  13355. results.push( elem );
  13356. break;
  13357. }
  13358. }
  13359. if ( outermost ) {
  13360. dirruns = dirrunsUnique;
  13361. }
  13362. }
  13363. // Track unmatched elements for set filters
  13364. if ( bySet ) {
  13365. // They will have gone through all possible matchers
  13366. if ( ( elem = !matcher && elem ) ) {
  13367. matchedCount--;
  13368. }
  13369. // Lengthen the array for every element, matched or not
  13370. if ( seed ) {
  13371. unmatched.push( elem );
  13372. }
  13373. }
  13374. }
  13375. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  13376. // makes the latter nonnegative.
  13377. matchedCount += i;
  13378. // Apply set filters to unmatched elements
  13379. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  13380. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  13381. // no element matchers and no seed.
  13382. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  13383. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  13384. // numerically zero.
  13385. if ( bySet && i !== matchedCount ) {
  13386. j = 0;
  13387. while ( ( matcher = setMatchers[ j++ ] ) ) {
  13388. matcher( unmatched, setMatched, context, xml );
  13389. }
  13390. if ( seed ) {
  13391. // Reintegrate element matches to eliminate the need for sorting
  13392. if ( matchedCount > 0 ) {
  13393. while ( i-- ) {
  13394. if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
  13395. setMatched[ i ] = pop.call( results );
  13396. }
  13397. }
  13398. }
  13399. // Discard index placeholder values to get only actual matches
  13400. setMatched = condense( setMatched );
  13401. }
  13402. // Add matches to results
  13403. push.apply( results, setMatched );
  13404. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  13405. if ( outermost && !seed && setMatched.length > 0 &&
  13406. ( matchedCount + setMatchers.length ) > 1 ) {
  13407. Sizzle.uniqueSort( results );
  13408. }
  13409. }
  13410. // Override manipulation of globals by nested matchers
  13411. if ( outermost ) {
  13412. dirruns = dirrunsUnique;
  13413. outermostContext = contextBackup;
  13414. }
  13415. return unmatched;
  13416. };
  13417. return bySet ?
  13418. markFunction( superMatcher ) :
  13419. superMatcher;
  13420. }
  13421. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  13422. var i,
  13423. setMatchers = [],
  13424. elementMatchers = [],
  13425. cached = compilerCache[ selector + " " ];
  13426. if ( !cached ) {
  13427. // Generate a function of recursive functions that can be used to check each element
  13428. if ( !match ) {
  13429. match = tokenize( selector );
  13430. }
  13431. i = match.length;
  13432. while ( i-- ) {
  13433. cached = matcherFromTokens( match[ i ] );
  13434. if ( cached[ expando ] ) {
  13435. setMatchers.push( cached );
  13436. } else {
  13437. elementMatchers.push( cached );
  13438. }
  13439. }
  13440. // Cache the compiled function
  13441. cached = compilerCache(
  13442. selector,
  13443. matcherFromGroupMatchers( elementMatchers, setMatchers )
  13444. );
  13445. // Save selector and tokenization
  13446. cached.selector = selector;
  13447. }
  13448. return cached;
  13449. };
  13450. /**
  13451. * A low-level selection function that works with Sizzle's compiled
  13452. * selector functions
  13453. * @param {String|Function} selector A selector or a pre-compiled
  13454. * selector function built with Sizzle.compile
  13455. * @param {Element} context
  13456. * @param {Array} [results]
  13457. * @param {Array} [seed] A set of elements to match against
  13458. */
  13459. select = Sizzle.select = function( selector, context, results, seed ) {
  13460. var i, tokens, token, type, find,
  13461. compiled = typeof selector === "function" && selector,
  13462. match = !seed && tokenize( ( selector = compiled.selector || selector ) );
  13463. results = results || [];
  13464. // Try to minimize operations if there is only one selector in the list and no seed
  13465. // (the latter of which guarantees us context)
  13466. if ( match.length === 1 ) {
  13467. // Reduce context if the leading compound selector is an ID
  13468. tokens = match[ 0 ] = match[ 0 ].slice( 0 );
  13469. if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
  13470. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
  13471. context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
  13472. .replace( runescape, funescape ), context ) || [] )[ 0 ];
  13473. if ( !context ) {
  13474. return results;
  13475. // Precompiled matchers will still verify ancestry, so step up a level
  13476. } else if ( compiled ) {
  13477. context = context.parentNode;
  13478. }
  13479. selector = selector.slice( tokens.shift().value.length );
  13480. }
  13481. // Fetch a seed set for right-to-left matching
  13482. i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
  13483. while ( i-- ) {
  13484. token = tokens[ i ];
  13485. // Abort if we hit a combinator
  13486. if ( Expr.relative[ ( type = token.type ) ] ) {
  13487. break;
  13488. }
  13489. if ( ( find = Expr.find[ type ] ) ) {
  13490. // Search, expanding context for leading sibling combinators
  13491. if ( ( seed = find(
  13492. token.matches[ 0 ].replace( runescape, funescape ),
  13493. rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
  13494. context
  13495. ) ) ) {
  13496. // If seed is empty or no tokens remain, we can return early
  13497. tokens.splice( i, 1 );
  13498. selector = seed.length && toSelector( tokens );
  13499. if ( !selector ) {
  13500. push.apply( results, seed );
  13501. return results;
  13502. }
  13503. break;
  13504. }
  13505. }
  13506. }
  13507. }
  13508. // Compile and execute a filtering function if one is not provided
  13509. // Provide `match` to avoid retokenization if we modified the selector above
  13510. ( compiled || compile( selector, match ) )(
  13511. seed,
  13512. context,
  13513. !documentIsHTML,
  13514. results,
  13515. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  13516. );
  13517. return results;
  13518. };
  13519. // One-time assignments
  13520. // Sort stability
  13521. support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
  13522. // Support: Chrome 14-35+
  13523. // Always assume duplicates if they aren't passed to the comparison function
  13524. support.detectDuplicates = !!hasDuplicate;
  13525. // Initialize against the default document
  13526. setDocument();
  13527. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  13528. // Detached nodes confoundingly follow *each other*
  13529. support.sortDetached = assert( function( el ) {
  13530. // Should return 1, but returns 4 (following)
  13531. return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
  13532. } );
  13533. // Support: IE<8
  13534. // Prevent attribute/property "interpolation"
  13535. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  13536. if ( !assert( function( el ) {
  13537. el.innerHTML = "<a href='#'></a>";
  13538. return el.firstChild.getAttribute( "href" ) === "#";
  13539. } ) ) {
  13540. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  13541. if ( !isXML ) {
  13542. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  13543. }
  13544. } );
  13545. }
  13546. // Support: IE<9
  13547. // Use defaultValue in place of getAttribute("value")
  13548. if ( !support.attributes || !assert( function( el ) {
  13549. el.innerHTML = "<input/>";
  13550. el.firstChild.setAttribute( "value", "" );
  13551. return el.firstChild.getAttribute( "value" ) === "";
  13552. } ) ) {
  13553. addHandle( "value", function( elem, _name, isXML ) {
  13554. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  13555. return elem.defaultValue;
  13556. }
  13557. } );
  13558. }
  13559. // Support: IE<9
  13560. // Use getAttributeNode to fetch booleans when getAttribute lies
  13561. if ( !assert( function( el ) {
  13562. return el.getAttribute( "disabled" ) == null;
  13563. } ) ) {
  13564. addHandle( booleans, function( elem, name, isXML ) {
  13565. var val;
  13566. if ( !isXML ) {
  13567. return elem[ name ] === true ? name.toLowerCase() :
  13568. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  13569. val.value :
  13570. null;
  13571. }
  13572. } );
  13573. }
  13574. return Sizzle;
  13575. } )( window );
  13576. jQuery.find = Sizzle;
  13577. jQuery.expr = Sizzle.selectors;
  13578. // Deprecated
  13579. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  13580. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  13581. jQuery.text = Sizzle.getText;
  13582. jQuery.isXMLDoc = Sizzle.isXML;
  13583. jQuery.contains = Sizzle.contains;
  13584. jQuery.escapeSelector = Sizzle.escape;
  13585. var dir = function( elem, dir, until ) {
  13586. var matched = [],
  13587. truncate = until !== undefined;
  13588. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  13589. if ( elem.nodeType === 1 ) {
  13590. if ( truncate && jQuery( elem ).is( until ) ) {
  13591. break;
  13592. }
  13593. matched.push( elem );
  13594. }
  13595. }
  13596. return matched;
  13597. };
  13598. var siblings = function( n, elem ) {
  13599. var matched = [];
  13600. for ( ; n; n = n.nextSibling ) {
  13601. if ( n.nodeType === 1 && n !== elem ) {
  13602. matched.push( n );
  13603. }
  13604. }
  13605. return matched;
  13606. };
  13607. var rneedsContext = jQuery.expr.match.needsContext;
  13608. function nodeName( elem, name ) {
  13609. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  13610. };
  13611. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  13612. // Implement the identical functionality for filter and not
  13613. function winnow( elements, qualifier, not ) {
  13614. if ( isFunction( qualifier ) ) {
  13615. return jQuery.grep( elements, function( elem, i ) {
  13616. return !!qualifier.call( elem, i, elem ) !== not;
  13617. } );
  13618. }
  13619. // Single element
  13620. if ( qualifier.nodeType ) {
  13621. return jQuery.grep( elements, function( elem ) {
  13622. return ( elem === qualifier ) !== not;
  13623. } );
  13624. }
  13625. // Arraylike of elements (jQuery, arguments, Array)
  13626. if ( typeof qualifier !== "string" ) {
  13627. return jQuery.grep( elements, function( elem ) {
  13628. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  13629. } );
  13630. }
  13631. // Filtered directly for both simple and complex selectors
  13632. return jQuery.filter( qualifier, elements, not );
  13633. }
  13634. jQuery.filter = function( expr, elems, not ) {
  13635. var elem = elems[ 0 ];
  13636. if ( not ) {
  13637. expr = ":not(" + expr + ")";
  13638. }
  13639. if ( elems.length === 1 && elem.nodeType === 1 ) {
  13640. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  13641. }
  13642. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  13643. return elem.nodeType === 1;
  13644. } ) );
  13645. };
  13646. jQuery.fn.extend( {
  13647. find: function( selector ) {
  13648. var i, ret,
  13649. len = this.length,
  13650. self = this;
  13651. if ( typeof selector !== "string" ) {
  13652. return this.pushStack( jQuery( selector ).filter( function() {
  13653. for ( i = 0; i < len; i++ ) {
  13654. if ( jQuery.contains( self[ i ], this ) ) {
  13655. return true;
  13656. }
  13657. }
  13658. } ) );
  13659. }
  13660. ret = this.pushStack( [] );
  13661. for ( i = 0; i < len; i++ ) {
  13662. jQuery.find( selector, self[ i ], ret );
  13663. }
  13664. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  13665. },
  13666. filter: function( selector ) {
  13667. return this.pushStack( winnow( this, selector || [], false ) );
  13668. },
  13669. not: function( selector ) {
  13670. return this.pushStack( winnow( this, selector || [], true ) );
  13671. },
  13672. is: function( selector ) {
  13673. return !!winnow(
  13674. this,
  13675. // If this is a positional/relative selector, check membership in the returned set
  13676. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  13677. typeof selector === "string" && rneedsContext.test( selector ) ?
  13678. jQuery( selector ) :
  13679. selector || [],
  13680. false
  13681. ).length;
  13682. }
  13683. } );
  13684. // Initialize a jQuery object
  13685. // A central reference to the root jQuery(document)
  13686. var rootjQuery,
  13687. // A simple way to check for HTML strings
  13688. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  13689. // Strict HTML recognition (#11290: must start with <)
  13690. // Shortcut simple #id case for speed
  13691. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  13692. init = jQuery.fn.init = function( selector, context, root ) {
  13693. var match, elem;
  13694. // HANDLE: $(""), $(null), $(undefined), $(false)
  13695. if ( !selector ) {
  13696. return this;
  13697. }
  13698. // Method init() accepts an alternate rootjQuery
  13699. // so migrate can support jQuery.sub (gh-2101)
  13700. root = root || rootjQuery;
  13701. // Handle HTML strings
  13702. if ( typeof selector === "string" ) {
  13703. if ( selector[ 0 ] === "<" &&
  13704. selector[ selector.length - 1 ] === ">" &&
  13705. selector.length >= 3 ) {
  13706. // Assume that strings that start and end with <> are HTML and skip the regex check
  13707. match = [ null, selector, null ];
  13708. } else {
  13709. match = rquickExpr.exec( selector );
  13710. }
  13711. // Match html or make sure no context is specified for #id
  13712. if ( match && ( match[ 1 ] || !context ) ) {
  13713. // HANDLE: $(html) -> $(array)
  13714. if ( match[ 1 ] ) {
  13715. context = context instanceof jQuery ? context[ 0 ] : context;
  13716. // Option to run scripts is true for back-compat
  13717. // Intentionally let the error be thrown if parseHTML is not present
  13718. jQuery.merge( this, jQuery.parseHTML(
  13719. match[ 1 ],
  13720. context && context.nodeType ? context.ownerDocument || context : document,
  13721. true
  13722. ) );
  13723. // HANDLE: $(html, props)
  13724. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  13725. for ( match in context ) {
  13726. // Properties of context are called as methods if possible
  13727. if ( isFunction( this[ match ] ) ) {
  13728. this[ match ]( context[ match ] );
  13729. // ...and otherwise set as attributes
  13730. } else {
  13731. this.attr( match, context[ match ] );
  13732. }
  13733. }
  13734. }
  13735. return this;
  13736. // HANDLE: $(#id)
  13737. } else {
  13738. elem = document.getElementById( match[ 2 ] );
  13739. if ( elem ) {
  13740. // Inject the element directly into the jQuery object
  13741. this[ 0 ] = elem;
  13742. this.length = 1;
  13743. }
  13744. return this;
  13745. }
  13746. // HANDLE: $(expr, $(...))
  13747. } else if ( !context || context.jquery ) {
  13748. return ( context || root ).find( selector );
  13749. // HANDLE: $(expr, context)
  13750. // (which is just equivalent to: $(context).find(expr)
  13751. } else {
  13752. return this.constructor( context ).find( selector );
  13753. }
  13754. // HANDLE: $(DOMElement)
  13755. } else if ( selector.nodeType ) {
  13756. this[ 0 ] = selector;
  13757. this.length = 1;
  13758. return this;
  13759. // HANDLE: $(function)
  13760. // Shortcut for document ready
  13761. } else if ( isFunction( selector ) ) {
  13762. return root.ready !== undefined ?
  13763. root.ready( selector ) :
  13764. // Execute immediately if ready is not present
  13765. selector( jQuery );
  13766. }
  13767. return jQuery.makeArray( selector, this );
  13768. };
  13769. // Give the init function the jQuery prototype for later instantiation
  13770. init.prototype = jQuery.fn;
  13771. // Initialize central reference
  13772. rootjQuery = jQuery( document );
  13773. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  13774. // Methods guaranteed to produce a unique set when starting from a unique set
  13775. guaranteedUnique = {
  13776. children: true,
  13777. contents: true,
  13778. next: true,
  13779. prev: true
  13780. };
  13781. jQuery.fn.extend( {
  13782. has: function( target ) {
  13783. var targets = jQuery( target, this ),
  13784. l = targets.length;
  13785. return this.filter( function() {
  13786. var i = 0;
  13787. for ( ; i < l; i++ ) {
  13788. if ( jQuery.contains( this, targets[ i ] ) ) {
  13789. return true;
  13790. }
  13791. }
  13792. } );
  13793. },
  13794. closest: function( selectors, context ) {
  13795. var cur,
  13796. i = 0,
  13797. l = this.length,
  13798. matched = [],
  13799. targets = typeof selectors !== "string" && jQuery( selectors );
  13800. // Positional selectors never match, since there's no _selection_ context
  13801. if ( !rneedsContext.test( selectors ) ) {
  13802. for ( ; i < l; i++ ) {
  13803. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  13804. // Always skip document fragments
  13805. if ( cur.nodeType < 11 && ( targets ?
  13806. targets.index( cur ) > -1 :
  13807. // Don't pass non-elements to Sizzle
  13808. cur.nodeType === 1 &&
  13809. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  13810. matched.push( cur );
  13811. break;
  13812. }
  13813. }
  13814. }
  13815. }
  13816. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  13817. },
  13818. // Determine the position of an element within the set
  13819. index: function( elem ) {
  13820. // No argument, return index in parent
  13821. if ( !elem ) {
  13822. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  13823. }
  13824. // Index in selector
  13825. if ( typeof elem === "string" ) {
  13826. return indexOf.call( jQuery( elem ), this[ 0 ] );
  13827. }
  13828. // Locate the position of the desired element
  13829. return indexOf.call( this,
  13830. // If it receives a jQuery object, the first element is used
  13831. elem.jquery ? elem[ 0 ] : elem
  13832. );
  13833. },
  13834. add: function( selector, context ) {
  13835. return this.pushStack(
  13836. jQuery.uniqueSort(
  13837. jQuery.merge( this.get(), jQuery( selector, context ) )
  13838. )
  13839. );
  13840. },
  13841. addBack: function( selector ) {
  13842. return this.add( selector == null ?
  13843. this.prevObject : this.prevObject.filter( selector )
  13844. );
  13845. }
  13846. } );
  13847. function sibling( cur, dir ) {
  13848. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  13849. return cur;
  13850. }
  13851. jQuery.each( {
  13852. parent: function( elem ) {
  13853. var parent = elem.parentNode;
  13854. return parent && parent.nodeType !== 11 ? parent : null;
  13855. },
  13856. parents: function( elem ) {
  13857. return dir( elem, "parentNode" );
  13858. },
  13859. parentsUntil: function( elem, _i, until ) {
  13860. return dir( elem, "parentNode", until );
  13861. },
  13862. next: function( elem ) {
  13863. return sibling( elem, "nextSibling" );
  13864. },
  13865. prev: function( elem ) {
  13866. return sibling( elem, "previousSibling" );
  13867. },
  13868. nextAll: function( elem ) {
  13869. return dir( elem, "nextSibling" );
  13870. },
  13871. prevAll: function( elem ) {
  13872. return dir( elem, "previousSibling" );
  13873. },
  13874. nextUntil: function( elem, _i, until ) {
  13875. return dir( elem, "nextSibling", until );
  13876. },
  13877. prevUntil: function( elem, _i, until ) {
  13878. return dir( elem, "previousSibling", until );
  13879. },
  13880. siblings: function( elem ) {
  13881. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  13882. },
  13883. children: function( elem ) {
  13884. return siblings( elem.firstChild );
  13885. },
  13886. contents: function( elem ) {
  13887. if ( elem.contentDocument != null &&
  13888. // Support: IE 11+
  13889. // <object> elements with no `data` attribute has an object
  13890. // `contentDocument` with a `null` prototype.
  13891. getProto( elem.contentDocument ) ) {
  13892. return elem.contentDocument;
  13893. }
  13894. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  13895. // Treat the template element as a regular one in browsers that
  13896. // don't support it.
  13897. if ( nodeName( elem, "template" ) ) {
  13898. elem = elem.content || elem;
  13899. }
  13900. return jQuery.merge( [], elem.childNodes );
  13901. }
  13902. }, function( name, fn ) {
  13903. jQuery.fn[ name ] = function( until, selector ) {
  13904. var matched = jQuery.map( this, fn, until );
  13905. if ( name.slice( -5 ) !== "Until" ) {
  13906. selector = until;
  13907. }
  13908. if ( selector && typeof selector === "string" ) {
  13909. matched = jQuery.filter( selector, matched );
  13910. }
  13911. if ( this.length > 1 ) {
  13912. // Remove duplicates
  13913. if ( !guaranteedUnique[ name ] ) {
  13914. jQuery.uniqueSort( matched );
  13915. }
  13916. // Reverse order for parents* and prev-derivatives
  13917. if ( rparentsprev.test( name ) ) {
  13918. matched.reverse();
  13919. }
  13920. }
  13921. return this.pushStack( matched );
  13922. };
  13923. } );
  13924. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  13925. // Convert String-formatted options into Object-formatted ones
  13926. function createOptions( options ) {
  13927. var object = {};
  13928. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  13929. object[ flag ] = true;
  13930. } );
  13931. return object;
  13932. }
  13933. /*
  13934. * Create a callback list using the following parameters:
  13935. *
  13936. * options: an optional list of space-separated options that will change how
  13937. * the callback list behaves or a more traditional option object
  13938. *
  13939. * By default a callback list will act like an event callback list and can be
  13940. * "fired" multiple times.
  13941. *
  13942. * Possible options:
  13943. *
  13944. * once: will ensure the callback list can only be fired once (like a Deferred)
  13945. *
  13946. * memory: will keep track of previous values and will call any callback added
  13947. * after the list has been fired right away with the latest "memorized"
  13948. * values (like a Deferred)
  13949. *
  13950. * unique: will ensure a callback can only be added once (no duplicate in the list)
  13951. *
  13952. * stopOnFalse: interrupt callings when a callback returns false
  13953. *
  13954. */
  13955. jQuery.Callbacks = function( options ) {
  13956. // Convert options from String-formatted to Object-formatted if needed
  13957. // (we check in cache first)
  13958. options = typeof options === "string" ?
  13959. createOptions( options ) :
  13960. jQuery.extend( {}, options );
  13961. var // Flag to know if list is currently firing
  13962. firing,
  13963. // Last fire value for non-forgettable lists
  13964. memory,
  13965. // Flag to know if list was already fired
  13966. fired,
  13967. // Flag to prevent firing
  13968. locked,
  13969. // Actual callback list
  13970. list = [],
  13971. // Queue of execution data for repeatable lists
  13972. queue = [],
  13973. // Index of currently firing callback (modified by add/remove as needed)
  13974. firingIndex = -1,
  13975. // Fire callbacks
  13976. fire = function() {
  13977. // Enforce single-firing
  13978. locked = locked || options.once;
  13979. // Execute callbacks for all pending executions,
  13980. // respecting firingIndex overrides and runtime changes
  13981. fired = firing = true;
  13982. for ( ; queue.length; firingIndex = -1 ) {
  13983. memory = queue.shift();
  13984. while ( ++firingIndex < list.length ) {
  13985. // Run callback and check for early termination
  13986. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  13987. options.stopOnFalse ) {
  13988. // Jump to end and forget the data so .add doesn't re-fire
  13989. firingIndex = list.length;
  13990. memory = false;
  13991. }
  13992. }
  13993. }
  13994. // Forget the data if we're done with it
  13995. if ( !options.memory ) {
  13996. memory = false;
  13997. }
  13998. firing = false;
  13999. // Clean up if we're done firing for good
  14000. if ( locked ) {
  14001. // Keep an empty list if we have data for future add calls
  14002. if ( memory ) {
  14003. list = [];
  14004. // Otherwise, this object is spent
  14005. } else {
  14006. list = "";
  14007. }
  14008. }
  14009. },
  14010. // Actual Callbacks object
  14011. self = {
  14012. // Add a callback or a collection of callbacks to the list
  14013. add: function() {
  14014. if ( list ) {
  14015. // If we have memory from a past run, we should fire after adding
  14016. if ( memory && !firing ) {
  14017. firingIndex = list.length - 1;
  14018. queue.push( memory );
  14019. }
  14020. ( function add( args ) {
  14021. jQuery.each( args, function( _, arg ) {
  14022. if ( isFunction( arg ) ) {
  14023. if ( !options.unique || !self.has( arg ) ) {
  14024. list.push( arg );
  14025. }
  14026. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  14027. // Inspect recursively
  14028. add( arg );
  14029. }
  14030. } );
  14031. } )( arguments );
  14032. if ( memory && !firing ) {
  14033. fire();
  14034. }
  14035. }
  14036. return this;
  14037. },
  14038. // Remove a callback from the list
  14039. remove: function() {
  14040. jQuery.each( arguments, function( _, arg ) {
  14041. var index;
  14042. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  14043. list.splice( index, 1 );
  14044. // Handle firing indexes
  14045. if ( index <= firingIndex ) {
  14046. firingIndex--;
  14047. }
  14048. }
  14049. } );
  14050. return this;
  14051. },
  14052. // Check if a given callback is in the list.
  14053. // If no argument is given, return whether or not list has callbacks attached.
  14054. has: function( fn ) {
  14055. return fn ?
  14056. jQuery.inArray( fn, list ) > -1 :
  14057. list.length > 0;
  14058. },
  14059. // Remove all callbacks from the list
  14060. empty: function() {
  14061. if ( list ) {
  14062. list = [];
  14063. }
  14064. return this;
  14065. },
  14066. // Disable .fire and .add
  14067. // Abort any current/pending executions
  14068. // Clear all callbacks and values
  14069. disable: function() {
  14070. locked = queue = [];
  14071. list = memory = "";
  14072. return this;
  14073. },
  14074. disabled: function() {
  14075. return !list;
  14076. },
  14077. // Disable .fire
  14078. // Also disable .add unless we have memory (since it would have no effect)
  14079. // Abort any pending executions
  14080. lock: function() {
  14081. locked = queue = [];
  14082. if ( !memory && !firing ) {
  14083. list = memory = "";
  14084. }
  14085. return this;
  14086. },
  14087. locked: function() {
  14088. return !!locked;
  14089. },
  14090. // Call all callbacks with the given context and arguments
  14091. fireWith: function( context, args ) {
  14092. if ( !locked ) {
  14093. args = args || [];
  14094. args = [ context, args.slice ? args.slice() : args ];
  14095. queue.push( args );
  14096. if ( !firing ) {
  14097. fire();
  14098. }
  14099. }
  14100. return this;
  14101. },
  14102. // Call all the callbacks with the given arguments
  14103. fire: function() {
  14104. self.fireWith( this, arguments );
  14105. return this;
  14106. },
  14107. // To know if the callbacks have already been called at least once
  14108. fired: function() {
  14109. return !!fired;
  14110. }
  14111. };
  14112. return self;
  14113. };
  14114. function Identity( v ) {
  14115. return v;
  14116. }
  14117. function Thrower( ex ) {
  14118. throw ex;
  14119. }
  14120. function adoptValue( value, resolve, reject, noValue ) {
  14121. var method;
  14122. try {
  14123. // Check for promise aspect first to privilege synchronous behavior
  14124. if ( value && isFunction( ( method = value.promise ) ) ) {
  14125. method.call( value ).done( resolve ).fail( reject );
  14126. // Other thenables
  14127. } else if ( value && isFunction( ( method = value.then ) ) ) {
  14128. method.call( value, resolve, reject );
  14129. // Other non-thenables
  14130. } else {
  14131. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  14132. // * false: [ value ].slice( 0 ) => resolve( value )
  14133. // * true: [ value ].slice( 1 ) => resolve()
  14134. resolve.apply( undefined, [ value ].slice( noValue ) );
  14135. }
  14136. // For Promises/A+, convert exceptions into rejections
  14137. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  14138. // Deferred#then to conditionally suppress rejection.
  14139. } catch ( value ) {
  14140. // Support: Android 4.0 only
  14141. // Strict mode functions invoked without .call/.apply get global-object context
  14142. reject.apply( undefined, [ value ] );
  14143. }
  14144. }
  14145. jQuery.extend( {
  14146. Deferred: function( func ) {
  14147. var tuples = [
  14148. // action, add listener, callbacks,
  14149. // ... .then handlers, argument index, [final state]
  14150. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  14151. jQuery.Callbacks( "memory" ), 2 ],
  14152. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  14153. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  14154. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  14155. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  14156. ],
  14157. state = "pending",
  14158. promise = {
  14159. state: function() {
  14160. return state;
  14161. },
  14162. always: function() {
  14163. deferred.done( arguments ).fail( arguments );
  14164. return this;
  14165. },
  14166. "catch": function( fn ) {
  14167. return promise.then( null, fn );
  14168. },
  14169. // Keep pipe for back-compat
  14170. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  14171. var fns = arguments;
  14172. return jQuery.Deferred( function( newDefer ) {
  14173. jQuery.each( tuples, function( _i, tuple ) {
  14174. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  14175. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  14176. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  14177. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  14178. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  14179. deferred[ tuple[ 1 ] ]( function() {
  14180. var returned = fn && fn.apply( this, arguments );
  14181. if ( returned && isFunction( returned.promise ) ) {
  14182. returned.promise()
  14183. .progress( newDefer.notify )
  14184. .done( newDefer.resolve )
  14185. .fail( newDefer.reject );
  14186. } else {
  14187. newDefer[ tuple[ 0 ] + "With" ](
  14188. this,
  14189. fn ? [ returned ] : arguments
  14190. );
  14191. }
  14192. } );
  14193. } );
  14194. fns = null;
  14195. } ).promise();
  14196. },
  14197. then: function( onFulfilled, onRejected, onProgress ) {
  14198. var maxDepth = 0;
  14199. function resolve( depth, deferred, handler, special ) {
  14200. return function() {
  14201. var that = this,
  14202. args = arguments,
  14203. mightThrow = function() {
  14204. var returned, then;
  14205. // Support: Promises/A+ section 2.3.3.3.3
  14206. // https://promisesaplus.com/#point-59
  14207. // Ignore double-resolution attempts
  14208. if ( depth < maxDepth ) {
  14209. return;
  14210. }
  14211. returned = handler.apply( that, args );
  14212. // Support: Promises/A+ section 2.3.1
  14213. // https://promisesaplus.com/#point-48
  14214. if ( returned === deferred.promise() ) {
  14215. throw new TypeError( "Thenable self-resolution" );
  14216. }
  14217. // Support: Promises/A+ sections 2.3.3.1, 3.5
  14218. // https://promisesaplus.com/#point-54
  14219. // https://promisesaplus.com/#point-75
  14220. // Retrieve `then` only once
  14221. then = returned &&
  14222. // Support: Promises/A+ section 2.3.4
  14223. // https://promisesaplus.com/#point-64
  14224. // Only check objects and functions for thenability
  14225. ( typeof returned === "object" ||
  14226. typeof returned === "function" ) &&
  14227. returned.then;
  14228. // Handle a returned thenable
  14229. if ( isFunction( then ) ) {
  14230. // Special processors (notify) just wait for resolution
  14231. if ( special ) {
  14232. then.call(
  14233. returned,
  14234. resolve( maxDepth, deferred, Identity, special ),
  14235. resolve( maxDepth, deferred, Thrower, special )
  14236. );
  14237. // Normal processors (resolve) also hook into progress
  14238. } else {
  14239. // ...and disregard older resolution values
  14240. maxDepth++;
  14241. then.call(
  14242. returned,
  14243. resolve( maxDepth, deferred, Identity, special ),
  14244. resolve( maxDepth, deferred, Thrower, special ),
  14245. resolve( maxDepth, deferred, Identity,
  14246. deferred.notifyWith )
  14247. );
  14248. }
  14249. // Handle all other returned values
  14250. } else {
  14251. // Only substitute handlers pass on context
  14252. // and multiple values (non-spec behavior)
  14253. if ( handler !== Identity ) {
  14254. that = undefined;
  14255. args = [ returned ];
  14256. }
  14257. // Process the value(s)
  14258. // Default process is resolve
  14259. ( special || deferred.resolveWith )( that, args );
  14260. }
  14261. },
  14262. // Only normal processors (resolve) catch and reject exceptions
  14263. process = special ?
  14264. mightThrow :
  14265. function() {
  14266. try {
  14267. mightThrow();
  14268. } catch ( e ) {
  14269. if ( jQuery.Deferred.exceptionHook ) {
  14270. jQuery.Deferred.exceptionHook( e,
  14271. process.stackTrace );
  14272. }
  14273. // Support: Promises/A+ section 2.3.3.3.4.1
  14274. // https://promisesaplus.com/#point-61
  14275. // Ignore post-resolution exceptions
  14276. if ( depth + 1 >= maxDepth ) {
  14277. // Only substitute handlers pass on context
  14278. // and multiple values (non-spec behavior)
  14279. if ( handler !== Thrower ) {
  14280. that = undefined;
  14281. args = [ e ];
  14282. }
  14283. deferred.rejectWith( that, args );
  14284. }
  14285. }
  14286. };
  14287. // Support: Promises/A+ section 2.3.3.3.1
  14288. // https://promisesaplus.com/#point-57
  14289. // Re-resolve promises immediately to dodge false rejection from
  14290. // subsequent errors
  14291. if ( depth ) {
  14292. process();
  14293. } else {
  14294. // Call an optional hook to record the stack, in case of exception
  14295. // since it's otherwise lost when execution goes async
  14296. if ( jQuery.Deferred.getStackHook ) {
  14297. process.stackTrace = jQuery.Deferred.getStackHook();
  14298. }
  14299. window.setTimeout( process );
  14300. }
  14301. };
  14302. }
  14303. return jQuery.Deferred( function( newDefer ) {
  14304. // progress_handlers.add( ... )
  14305. tuples[ 0 ][ 3 ].add(
  14306. resolve(
  14307. 0,
  14308. newDefer,
  14309. isFunction( onProgress ) ?
  14310. onProgress :
  14311. Identity,
  14312. newDefer.notifyWith
  14313. )
  14314. );
  14315. // fulfilled_handlers.add( ... )
  14316. tuples[ 1 ][ 3 ].add(
  14317. resolve(
  14318. 0,
  14319. newDefer,
  14320. isFunction( onFulfilled ) ?
  14321. onFulfilled :
  14322. Identity
  14323. )
  14324. );
  14325. // rejected_handlers.add( ... )
  14326. tuples[ 2 ][ 3 ].add(
  14327. resolve(
  14328. 0,
  14329. newDefer,
  14330. isFunction( onRejected ) ?
  14331. onRejected :
  14332. Thrower
  14333. )
  14334. );
  14335. } ).promise();
  14336. },
  14337. // Get a promise for this deferred
  14338. // If obj is provided, the promise aspect is added to the object
  14339. promise: function( obj ) {
  14340. return obj != null ? jQuery.extend( obj, promise ) : promise;
  14341. }
  14342. },
  14343. deferred = {};
  14344. // Add list-specific methods
  14345. jQuery.each( tuples, function( i, tuple ) {
  14346. var list = tuple[ 2 ],
  14347. stateString = tuple[ 5 ];
  14348. // promise.progress = list.add
  14349. // promise.done = list.add
  14350. // promise.fail = list.add
  14351. promise[ tuple[ 1 ] ] = list.add;
  14352. // Handle state
  14353. if ( stateString ) {
  14354. list.add(
  14355. function() {
  14356. // state = "resolved" (i.e., fulfilled)
  14357. // state = "rejected"
  14358. state = stateString;
  14359. },
  14360. // rejected_callbacks.disable
  14361. // fulfilled_callbacks.disable
  14362. tuples[ 3 - i ][ 2 ].disable,
  14363. // rejected_handlers.disable
  14364. // fulfilled_handlers.disable
  14365. tuples[ 3 - i ][ 3 ].disable,
  14366. // progress_callbacks.lock
  14367. tuples[ 0 ][ 2 ].lock,
  14368. // progress_handlers.lock
  14369. tuples[ 0 ][ 3 ].lock
  14370. );
  14371. }
  14372. // progress_handlers.fire
  14373. // fulfilled_handlers.fire
  14374. // rejected_handlers.fire
  14375. list.add( tuple[ 3 ].fire );
  14376. // deferred.notify = function() { deferred.notifyWith(...) }
  14377. // deferred.resolve = function() { deferred.resolveWith(...) }
  14378. // deferred.reject = function() { deferred.rejectWith(...) }
  14379. deferred[ tuple[ 0 ] ] = function() {
  14380. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  14381. return this;
  14382. };
  14383. // deferred.notifyWith = list.fireWith
  14384. // deferred.resolveWith = list.fireWith
  14385. // deferred.rejectWith = list.fireWith
  14386. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  14387. } );
  14388. // Make the deferred a promise
  14389. promise.promise( deferred );
  14390. // Call given func if any
  14391. if ( func ) {
  14392. func.call( deferred, deferred );
  14393. }
  14394. // All done!
  14395. return deferred;
  14396. },
  14397. // Deferred helper
  14398. when: function( singleValue ) {
  14399. var
  14400. // count of uncompleted subordinates
  14401. remaining = arguments.length,
  14402. // count of unprocessed arguments
  14403. i = remaining,
  14404. // subordinate fulfillment data
  14405. resolveContexts = Array( i ),
  14406. resolveValues = slice.call( arguments ),
  14407. // the master Deferred
  14408. master = jQuery.Deferred(),
  14409. // subordinate callback factory
  14410. updateFunc = function( i ) {
  14411. return function( value ) {
  14412. resolveContexts[ i ] = this;
  14413. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  14414. if ( !( --remaining ) ) {
  14415. master.resolveWith( resolveContexts, resolveValues );
  14416. }
  14417. };
  14418. };
  14419. // Single- and empty arguments are adopted like Promise.resolve
  14420. if ( remaining <= 1 ) {
  14421. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  14422. !remaining );
  14423. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  14424. if ( master.state() === "pending" ||
  14425. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  14426. return master.then();
  14427. }
  14428. }
  14429. // Multiple arguments are aggregated like Promise.all array elements
  14430. while ( i-- ) {
  14431. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  14432. }
  14433. return master.promise();
  14434. }
  14435. } );
  14436. // These usually indicate a programmer mistake during development,
  14437. // warn about them ASAP rather than swallowing them by default.
  14438. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  14439. jQuery.Deferred.exceptionHook = function( error, stack ) {
  14440. // Support: IE 8 - 9 only
  14441. // Console exists when dev tools are open, which can happen at any time
  14442. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  14443. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  14444. }
  14445. };
  14446. jQuery.readyException = function( error ) {
  14447. window.setTimeout( function() {
  14448. throw error;
  14449. } );
  14450. };
  14451. // The deferred used on DOM ready
  14452. var readyList = jQuery.Deferred();
  14453. jQuery.fn.ready = function( fn ) {
  14454. readyList
  14455. .then( fn )
  14456. // Wrap jQuery.readyException in a function so that the lookup
  14457. // happens at the time of error handling instead of callback
  14458. // registration.
  14459. .catch( function( error ) {
  14460. jQuery.readyException( error );
  14461. } );
  14462. return this;
  14463. };
  14464. jQuery.extend( {
  14465. // Is the DOM ready to be used? Set to true once it occurs.
  14466. isReady: false,
  14467. // A counter to track how many items to wait for before
  14468. // the ready event fires. See #6781
  14469. readyWait: 1,
  14470. // Handle when the DOM is ready
  14471. ready: function( wait ) {
  14472. // Abort if there are pending holds or we're already ready
  14473. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  14474. return;
  14475. }
  14476. // Remember that the DOM is ready
  14477. jQuery.isReady = true;
  14478. // If a normal DOM Ready event fired, decrement, and wait if need be
  14479. if ( wait !== true && --jQuery.readyWait > 0 ) {
  14480. return;
  14481. }
  14482. // If there are functions bound, to execute
  14483. readyList.resolveWith( document, [ jQuery ] );
  14484. }
  14485. } );
  14486. jQuery.ready.then = readyList.then;
  14487. // The ready event handler and self cleanup method
  14488. function completed() {
  14489. document.removeEventListener( "DOMContentLoaded", completed );
  14490. window.removeEventListener( "load", completed );
  14491. jQuery.ready();
  14492. }
  14493. // Catch cases where $(document).ready() is called
  14494. // after the browser event has already occurred.
  14495. // Support: IE <=9 - 10 only
  14496. // Older IE sometimes signals "interactive" too soon
  14497. if ( document.readyState === "complete" ||
  14498. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  14499. // Handle it asynchronously to allow scripts the opportunity to delay ready
  14500. window.setTimeout( jQuery.ready );
  14501. } else {
  14502. // Use the handy event callback
  14503. document.addEventListener( "DOMContentLoaded", completed );
  14504. // A fallback to window.onload, that will always work
  14505. window.addEventListener( "load", completed );
  14506. }
  14507. // Multifunctional method to get and set values of a collection
  14508. // The value/s can optionally be executed if it's a function
  14509. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  14510. var i = 0,
  14511. len = elems.length,
  14512. bulk = key == null;
  14513. // Sets many values
  14514. if ( toType( key ) === "object" ) {
  14515. chainable = true;
  14516. for ( i in key ) {
  14517. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  14518. }
  14519. // Sets one value
  14520. } else if ( value !== undefined ) {
  14521. chainable = true;
  14522. if ( !isFunction( value ) ) {
  14523. raw = true;
  14524. }
  14525. if ( bulk ) {
  14526. // Bulk operations run against the entire set
  14527. if ( raw ) {
  14528. fn.call( elems, value );
  14529. fn = null;
  14530. // ...except when executing function values
  14531. } else {
  14532. bulk = fn;
  14533. fn = function( elem, _key, value ) {
  14534. return bulk.call( jQuery( elem ), value );
  14535. };
  14536. }
  14537. }
  14538. if ( fn ) {
  14539. for ( ; i < len; i++ ) {
  14540. fn(
  14541. elems[ i ], key, raw ?
  14542. value :
  14543. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  14544. );
  14545. }
  14546. }
  14547. }
  14548. if ( chainable ) {
  14549. return elems;
  14550. }
  14551. // Gets
  14552. if ( bulk ) {
  14553. return fn.call( elems );
  14554. }
  14555. return len ? fn( elems[ 0 ], key ) : emptyGet;
  14556. };
  14557. // Matches dashed string for camelizing
  14558. var rmsPrefix = /^-ms-/,
  14559. rdashAlpha = /-([a-z])/g;
  14560. // Used by camelCase as callback to replace()
  14561. function fcamelCase( _all, letter ) {
  14562. return letter.toUpperCase();
  14563. }
  14564. // Convert dashed to camelCase; used by the css and data modules
  14565. // Support: IE <=9 - 11, Edge 12 - 15
  14566. // Microsoft forgot to hump their vendor prefix (#9572)
  14567. function camelCase( string ) {
  14568. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  14569. }
  14570. var acceptData = function( owner ) {
  14571. // Accepts only:
  14572. // - Node
  14573. // - Node.ELEMENT_NODE
  14574. // - Node.DOCUMENT_NODE
  14575. // - Object
  14576. // - Any
  14577. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  14578. };
  14579. function Data() {
  14580. this.expando = jQuery.expando + Data.uid++;
  14581. }
  14582. Data.uid = 1;
  14583. Data.prototype = {
  14584. cache: function( owner ) {
  14585. // Check if the owner object already has a cache
  14586. var value = owner[ this.expando ];
  14587. // If not, create one
  14588. if ( !value ) {
  14589. value = {};
  14590. // We can accept data for non-element nodes in modern browsers,
  14591. // but we should not, see #8335.
  14592. // Always return an empty object.
  14593. if ( acceptData( owner ) ) {
  14594. // If it is a node unlikely to be stringify-ed or looped over
  14595. // use plain assignment
  14596. if ( owner.nodeType ) {
  14597. owner[ this.expando ] = value;
  14598. // Otherwise secure it in a non-enumerable property
  14599. // configurable must be true to allow the property to be
  14600. // deleted when data is removed
  14601. } else {
  14602. Object.defineProperty( owner, this.expando, {
  14603. value: value,
  14604. configurable: true
  14605. } );
  14606. }
  14607. }
  14608. }
  14609. return value;
  14610. },
  14611. set: function( owner, data, value ) {
  14612. var prop,
  14613. cache = this.cache( owner );
  14614. // Handle: [ owner, key, value ] args
  14615. // Always use camelCase key (gh-2257)
  14616. if ( typeof data === "string" ) {
  14617. cache[ camelCase( data ) ] = value;
  14618. // Handle: [ owner, { properties } ] args
  14619. } else {
  14620. // Copy the properties one-by-one to the cache object
  14621. for ( prop in data ) {
  14622. cache[ camelCase( prop ) ] = data[ prop ];
  14623. }
  14624. }
  14625. return cache;
  14626. },
  14627. get: function( owner, key ) {
  14628. return key === undefined ?
  14629. this.cache( owner ) :
  14630. // Always use camelCase key (gh-2257)
  14631. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  14632. },
  14633. access: function( owner, key, value ) {
  14634. // In cases where either:
  14635. //
  14636. // 1. No key was specified
  14637. // 2. A string key was specified, but no value provided
  14638. //
  14639. // Take the "read" path and allow the get method to determine
  14640. // which value to return, respectively either:
  14641. //
  14642. // 1. The entire cache object
  14643. // 2. The data stored at the key
  14644. //
  14645. if ( key === undefined ||
  14646. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  14647. return this.get( owner, key );
  14648. }
  14649. // When the key is not a string, or both a key and value
  14650. // are specified, set or extend (existing objects) with either:
  14651. //
  14652. // 1. An object of properties
  14653. // 2. A key and value
  14654. //
  14655. this.set( owner, key, value );
  14656. // Since the "set" path can have two possible entry points
  14657. // return the expected data based on which path was taken[*]
  14658. return value !== undefined ? value : key;
  14659. },
  14660. remove: function( owner, key ) {
  14661. var i,
  14662. cache = owner[ this.expando ];
  14663. if ( cache === undefined ) {
  14664. return;
  14665. }
  14666. if ( key !== undefined ) {
  14667. // Support array or space separated string of keys
  14668. if ( Array.isArray( key ) ) {
  14669. // If key is an array of keys...
  14670. // We always set camelCase keys, so remove that.
  14671. key = key.map( camelCase );
  14672. } else {
  14673. key = camelCase( key );
  14674. // If a key with the spaces exists, use it.
  14675. // Otherwise, create an array by matching non-whitespace
  14676. key = key in cache ?
  14677. [ key ] :
  14678. ( key.match( rnothtmlwhite ) || [] );
  14679. }
  14680. i = key.length;
  14681. while ( i-- ) {
  14682. delete cache[ key[ i ] ];
  14683. }
  14684. }
  14685. // Remove the expando if there's no more data
  14686. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  14687. // Support: Chrome <=35 - 45
  14688. // Webkit & Blink performance suffers when deleting properties
  14689. // from DOM nodes, so set to undefined instead
  14690. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  14691. if ( owner.nodeType ) {
  14692. owner[ this.expando ] = undefined;
  14693. } else {
  14694. delete owner[ this.expando ];
  14695. }
  14696. }
  14697. },
  14698. hasData: function( owner ) {
  14699. var cache = owner[ this.expando ];
  14700. return cache !== undefined && !jQuery.isEmptyObject( cache );
  14701. }
  14702. };
  14703. var dataPriv = new Data();
  14704. var dataUser = new Data();
  14705. // Implementation Summary
  14706. //
  14707. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  14708. // 2. Improve the module's maintainability by reducing the storage
  14709. // paths to a single mechanism.
  14710. // 3. Use the same single mechanism to support "private" and "user" data.
  14711. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  14712. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  14713. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  14714. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  14715. rmultiDash = /[A-Z]/g;
  14716. function getData( data ) {
  14717. if ( data === "true" ) {
  14718. return true;
  14719. }
  14720. if ( data === "false" ) {
  14721. return false;
  14722. }
  14723. if ( data === "null" ) {
  14724. return null;
  14725. }
  14726. // Only convert to a number if it doesn't change the string
  14727. if ( data === +data + "" ) {
  14728. return +data;
  14729. }
  14730. if ( rbrace.test( data ) ) {
  14731. return JSON.parse( data );
  14732. }
  14733. return data;
  14734. }
  14735. function dataAttr( elem, key, data ) {
  14736. var name;
  14737. // If nothing was found internally, try to fetch any
  14738. // data from the HTML5 data-* attribute
  14739. if ( data === undefined && elem.nodeType === 1 ) {
  14740. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  14741. data = elem.getAttribute( name );
  14742. if ( typeof data === "string" ) {
  14743. try {
  14744. data = getData( data );
  14745. } catch ( e ) {}
  14746. // Make sure we set the data so it isn't changed later
  14747. dataUser.set( elem, key, data );
  14748. } else {
  14749. data = undefined;
  14750. }
  14751. }
  14752. return data;
  14753. }
  14754. jQuery.extend( {
  14755. hasData: function( elem ) {
  14756. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  14757. },
  14758. data: function( elem, name, data ) {
  14759. return dataUser.access( elem, name, data );
  14760. },
  14761. removeData: function( elem, name ) {
  14762. dataUser.remove( elem, name );
  14763. },
  14764. // TODO: Now that all calls to _data and _removeData have been replaced
  14765. // with direct calls to dataPriv methods, these can be deprecated.
  14766. _data: function( elem, name, data ) {
  14767. return dataPriv.access( elem, name, data );
  14768. },
  14769. _removeData: function( elem, name ) {
  14770. dataPriv.remove( elem, name );
  14771. }
  14772. } );
  14773. jQuery.fn.extend( {
  14774. data: function( key, value ) {
  14775. var i, name, data,
  14776. elem = this[ 0 ],
  14777. attrs = elem && elem.attributes;
  14778. // Gets all values
  14779. if ( key === undefined ) {
  14780. if ( this.length ) {
  14781. data = dataUser.get( elem );
  14782. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  14783. i = attrs.length;
  14784. while ( i-- ) {
  14785. // Support: IE 11 only
  14786. // The attrs elements can be null (#14894)
  14787. if ( attrs[ i ] ) {
  14788. name = attrs[ i ].name;
  14789. if ( name.indexOf( "data-" ) === 0 ) {
  14790. name = camelCase( name.slice( 5 ) );
  14791. dataAttr( elem, name, data[ name ] );
  14792. }
  14793. }
  14794. }
  14795. dataPriv.set( elem, "hasDataAttrs", true );
  14796. }
  14797. }
  14798. return data;
  14799. }
  14800. // Sets multiple values
  14801. if ( typeof key === "object" ) {
  14802. return this.each( function() {
  14803. dataUser.set( this, key );
  14804. } );
  14805. }
  14806. return access( this, function( value ) {
  14807. var data;
  14808. // The calling jQuery object (element matches) is not empty
  14809. // (and therefore has an element appears at this[ 0 ]) and the
  14810. // `value` parameter was not undefined. An empty jQuery object
  14811. // will result in `undefined` for elem = this[ 0 ] which will
  14812. // throw an exception if an attempt to read a data cache is made.
  14813. if ( elem && value === undefined ) {
  14814. // Attempt to get data from the cache
  14815. // The key will always be camelCased in Data
  14816. data = dataUser.get( elem, key );
  14817. if ( data !== undefined ) {
  14818. return data;
  14819. }
  14820. // Attempt to "discover" the data in
  14821. // HTML5 custom data-* attrs
  14822. data = dataAttr( elem, key );
  14823. if ( data !== undefined ) {
  14824. return data;
  14825. }
  14826. // We tried really hard, but the data doesn't exist.
  14827. return;
  14828. }
  14829. // Set the data...
  14830. this.each( function() {
  14831. // We always store the camelCased key
  14832. dataUser.set( this, key, value );
  14833. } );
  14834. }, null, value, arguments.length > 1, null, true );
  14835. },
  14836. removeData: function( key ) {
  14837. return this.each( function() {
  14838. dataUser.remove( this, key );
  14839. } );
  14840. }
  14841. } );
  14842. jQuery.extend( {
  14843. queue: function( elem, type, data ) {
  14844. var queue;
  14845. if ( elem ) {
  14846. type = ( type || "fx" ) + "queue";
  14847. queue = dataPriv.get( elem, type );
  14848. // Speed up dequeue by getting out quickly if this is just a lookup
  14849. if ( data ) {
  14850. if ( !queue || Array.isArray( data ) ) {
  14851. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  14852. } else {
  14853. queue.push( data );
  14854. }
  14855. }
  14856. return queue || [];
  14857. }
  14858. },
  14859. dequeue: function( elem, type ) {
  14860. type = type || "fx";
  14861. var queue = jQuery.queue( elem, type ),
  14862. startLength = queue.length,
  14863. fn = queue.shift(),
  14864. hooks = jQuery._queueHooks( elem, type ),
  14865. next = function() {
  14866. jQuery.dequeue( elem, type );
  14867. };
  14868. // If the fx queue is dequeued, always remove the progress sentinel
  14869. if ( fn === "inprogress" ) {
  14870. fn = queue.shift();
  14871. startLength--;
  14872. }
  14873. if ( fn ) {
  14874. // Add a progress sentinel to prevent the fx queue from being
  14875. // automatically dequeued
  14876. if ( type === "fx" ) {
  14877. queue.unshift( "inprogress" );
  14878. }
  14879. // Clear up the last queue stop function
  14880. delete hooks.stop;
  14881. fn.call( elem, next, hooks );
  14882. }
  14883. if ( !startLength && hooks ) {
  14884. hooks.empty.fire();
  14885. }
  14886. },
  14887. // Not public - generate a queueHooks object, or return the current one
  14888. _queueHooks: function( elem, type ) {
  14889. var key = type + "queueHooks";
  14890. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  14891. empty: jQuery.Callbacks( "once memory" ).add( function() {
  14892. dataPriv.remove( elem, [ type + "queue", key ] );
  14893. } )
  14894. } );
  14895. }
  14896. } );
  14897. jQuery.fn.extend( {
  14898. queue: function( type, data ) {
  14899. var setter = 2;
  14900. if ( typeof type !== "string" ) {
  14901. data = type;
  14902. type = "fx";
  14903. setter--;
  14904. }
  14905. if ( arguments.length < setter ) {
  14906. return jQuery.queue( this[ 0 ], type );
  14907. }
  14908. return data === undefined ?
  14909. this :
  14910. this.each( function() {
  14911. var queue = jQuery.queue( this, type, data );
  14912. // Ensure a hooks for this queue
  14913. jQuery._queueHooks( this, type );
  14914. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  14915. jQuery.dequeue( this, type );
  14916. }
  14917. } );
  14918. },
  14919. dequeue: function( type ) {
  14920. return this.each( function() {
  14921. jQuery.dequeue( this, type );
  14922. } );
  14923. },
  14924. clearQueue: function( type ) {
  14925. return this.queue( type || "fx", [] );
  14926. },
  14927. // Get a promise resolved when queues of a certain type
  14928. // are emptied (fx is the type by default)
  14929. promise: function( type, obj ) {
  14930. var tmp,
  14931. count = 1,
  14932. defer = jQuery.Deferred(),
  14933. elements = this,
  14934. i = this.length,
  14935. resolve = function() {
  14936. if ( !( --count ) ) {
  14937. defer.resolveWith( elements, [ elements ] );
  14938. }
  14939. };
  14940. if ( typeof type !== "string" ) {
  14941. obj = type;
  14942. type = undefined;
  14943. }
  14944. type = type || "fx";
  14945. while ( i-- ) {
  14946. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  14947. if ( tmp && tmp.empty ) {
  14948. count++;
  14949. tmp.empty.add( resolve );
  14950. }
  14951. }
  14952. resolve();
  14953. return defer.promise( obj );
  14954. }
  14955. } );
  14956. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  14957. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  14958. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  14959. var documentElement = document.documentElement;
  14960. var isAttached = function( elem ) {
  14961. return jQuery.contains( elem.ownerDocument, elem );
  14962. },
  14963. composed = { composed: true };
  14964. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  14965. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  14966. // Support: iOS 10.0-10.2 only
  14967. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  14968. // leading to errors. We need to check for `getRootNode`.
  14969. if ( documentElement.getRootNode ) {
  14970. isAttached = function( elem ) {
  14971. return jQuery.contains( elem.ownerDocument, elem ) ||
  14972. elem.getRootNode( composed ) === elem.ownerDocument;
  14973. };
  14974. }
  14975. var isHiddenWithinTree = function( elem, el ) {
  14976. // isHiddenWithinTree might be called from jQuery#filter function;
  14977. // in that case, element will be second argument
  14978. elem = el || elem;
  14979. // Inline style trumps all
  14980. return elem.style.display === "none" ||
  14981. elem.style.display === "" &&
  14982. // Otherwise, check computed style
  14983. // Support: Firefox <=43 - 45
  14984. // Disconnected elements can have computed display: none, so first confirm that elem is
  14985. // in the document.
  14986. isAttached( elem ) &&
  14987. jQuery.css( elem, "display" ) === "none";
  14988. };
  14989. function adjustCSS( elem, prop, valueParts, tween ) {
  14990. var adjusted, scale,
  14991. maxIterations = 20,
  14992. currentValue = tween ?
  14993. function() {
  14994. return tween.cur();
  14995. } :
  14996. function() {
  14997. return jQuery.css( elem, prop, "" );
  14998. },
  14999. initial = currentValue(),
  15000. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  15001. // Starting value computation is required for potential unit mismatches
  15002. initialInUnit = elem.nodeType &&
  15003. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  15004. rcssNum.exec( jQuery.css( elem, prop ) );
  15005. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  15006. // Support: Firefox <=54
  15007. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  15008. initial = initial / 2;
  15009. // Trust units reported by jQuery.css
  15010. unit = unit || initialInUnit[ 3 ];
  15011. // Iteratively approximate from a nonzero starting point
  15012. initialInUnit = +initial || 1;
  15013. while ( maxIterations-- ) {
  15014. // Evaluate and update our best guess (doubling guesses that zero out).
  15015. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  15016. jQuery.style( elem, prop, initialInUnit + unit );
  15017. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  15018. maxIterations = 0;
  15019. }
  15020. initialInUnit = initialInUnit / scale;
  15021. }
  15022. initialInUnit = initialInUnit * 2;
  15023. jQuery.style( elem, prop, initialInUnit + unit );
  15024. // Make sure we update the tween properties later on
  15025. valueParts = valueParts || [];
  15026. }
  15027. if ( valueParts ) {
  15028. initialInUnit = +initialInUnit || +initial || 0;
  15029. // Apply relative offset (+=/-=) if specified
  15030. adjusted = valueParts[ 1 ] ?
  15031. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  15032. +valueParts[ 2 ];
  15033. if ( tween ) {
  15034. tween.unit = unit;
  15035. tween.start = initialInUnit;
  15036. tween.end = adjusted;
  15037. }
  15038. }
  15039. return adjusted;
  15040. }
  15041. var defaultDisplayMap = {};
  15042. function getDefaultDisplay( elem ) {
  15043. var temp,
  15044. doc = elem.ownerDocument,
  15045. nodeName = elem.nodeName,
  15046. display = defaultDisplayMap[ nodeName ];
  15047. if ( display ) {
  15048. return display;
  15049. }
  15050. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  15051. display = jQuery.css( temp, "display" );
  15052. temp.parentNode.removeChild( temp );
  15053. if ( display === "none" ) {
  15054. display = "block";
  15055. }
  15056. defaultDisplayMap[ nodeName ] = display;
  15057. return display;
  15058. }
  15059. function showHide( elements, show ) {
  15060. var display, elem,
  15061. values = [],
  15062. index = 0,
  15063. length = elements.length;
  15064. // Determine new display value for elements that need to change
  15065. for ( ; index < length; index++ ) {
  15066. elem = elements[ index ];
  15067. if ( !elem.style ) {
  15068. continue;
  15069. }
  15070. display = elem.style.display;
  15071. if ( show ) {
  15072. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  15073. // check is required in this first loop unless we have a nonempty display value (either
  15074. // inline or about-to-be-restored)
  15075. if ( display === "none" ) {
  15076. values[ index ] = dataPriv.get( elem, "display" ) || null;
  15077. if ( !values[ index ] ) {
  15078. elem.style.display = "";
  15079. }
  15080. }
  15081. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  15082. values[ index ] = getDefaultDisplay( elem );
  15083. }
  15084. } else {
  15085. if ( display !== "none" ) {
  15086. values[ index ] = "none";
  15087. // Remember what we're overwriting
  15088. dataPriv.set( elem, "display", display );
  15089. }
  15090. }
  15091. }
  15092. // Set the display of the elements in a second loop to avoid constant reflow
  15093. for ( index = 0; index < length; index++ ) {
  15094. if ( values[ index ] != null ) {
  15095. elements[ index ].style.display = values[ index ];
  15096. }
  15097. }
  15098. return elements;
  15099. }
  15100. jQuery.fn.extend( {
  15101. show: function() {
  15102. return showHide( this, true );
  15103. },
  15104. hide: function() {
  15105. return showHide( this );
  15106. },
  15107. toggle: function( state ) {
  15108. if ( typeof state === "boolean" ) {
  15109. return state ? this.show() : this.hide();
  15110. }
  15111. return this.each( function() {
  15112. if ( isHiddenWithinTree( this ) ) {
  15113. jQuery( this ).show();
  15114. } else {
  15115. jQuery( this ).hide();
  15116. }
  15117. } );
  15118. }
  15119. } );
  15120. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  15121. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  15122. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  15123. ( function() {
  15124. var fragment = document.createDocumentFragment(),
  15125. div = fragment.appendChild( document.createElement( "div" ) ),
  15126. input = document.createElement( "input" );
  15127. // Support: Android 4.0 - 4.3 only
  15128. // Check state lost if the name is set (#11217)
  15129. // Support: Windows Web Apps (WWA)
  15130. // `name` and `type` must use .setAttribute for WWA (#14901)
  15131. input.setAttribute( "type", "radio" );
  15132. input.setAttribute( "checked", "checked" );
  15133. input.setAttribute( "name", "t" );
  15134. div.appendChild( input );
  15135. // Support: Android <=4.1 only
  15136. // Older WebKit doesn't clone checked state correctly in fragments
  15137. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  15138. // Support: IE <=11 only
  15139. // Make sure textarea (and checkbox) defaultValue is properly cloned
  15140. div.innerHTML = "<textarea>x</textarea>";
  15141. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  15142. // Support: IE <=9 only
  15143. // IE <=9 replaces <option> tags with their contents when inserted outside of
  15144. // the select element.
  15145. div.innerHTML = "<option></option>";
  15146. support.option = !!div.lastChild;
  15147. } )();
  15148. // We have to close these tags to support XHTML (#13200)
  15149. var wrapMap = {
  15150. // XHTML parsers do not magically insert elements in the
  15151. // same way that tag soup parsers do. So we cannot shorten
  15152. // this by omitting <tbody> or other required elements.
  15153. thead: [ 1, "<table>", "</table>" ],
  15154. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  15155. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  15156. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  15157. _default: [ 0, "", "" ]
  15158. };
  15159. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  15160. wrapMap.th = wrapMap.td;
  15161. // Support: IE <=9 only
  15162. if ( !support.option ) {
  15163. wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
  15164. }
  15165. function getAll( context, tag ) {
  15166. // Support: IE <=9 - 11 only
  15167. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  15168. var ret;
  15169. if ( typeof context.getElementsByTagName !== "undefined" ) {
  15170. ret = context.getElementsByTagName( tag || "*" );
  15171. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  15172. ret = context.querySelectorAll( tag || "*" );
  15173. } else {
  15174. ret = [];
  15175. }
  15176. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  15177. return jQuery.merge( [ context ], ret );
  15178. }
  15179. return ret;
  15180. }
  15181. // Mark scripts as having already been evaluated
  15182. function setGlobalEval( elems, refElements ) {
  15183. var i = 0,
  15184. l = elems.length;
  15185. for ( ; i < l; i++ ) {
  15186. dataPriv.set(
  15187. elems[ i ],
  15188. "globalEval",
  15189. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  15190. );
  15191. }
  15192. }
  15193. var rhtml = /<|&#?\w+;/;
  15194. function buildFragment( elems, context, scripts, selection, ignored ) {
  15195. var elem, tmp, tag, wrap, attached, j,
  15196. fragment = context.createDocumentFragment(),
  15197. nodes = [],
  15198. i = 0,
  15199. l = elems.length;
  15200. for ( ; i < l; i++ ) {
  15201. elem = elems[ i ];
  15202. if ( elem || elem === 0 ) {
  15203. // Add nodes directly
  15204. if ( toType( elem ) === "object" ) {
  15205. // Support: Android <=4.0 only, PhantomJS 1 only
  15206. // push.apply(_, arraylike) throws on ancient WebKit
  15207. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  15208. // Convert non-html into a text node
  15209. } else if ( !rhtml.test( elem ) ) {
  15210. nodes.push( context.createTextNode( elem ) );
  15211. // Convert html into DOM nodes
  15212. } else {
  15213. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  15214. // Deserialize a standard representation
  15215. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  15216. wrap = wrapMap[ tag ] || wrapMap._default;
  15217. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  15218. // Descend through wrappers to the right content
  15219. j = wrap[ 0 ];
  15220. while ( j-- ) {
  15221. tmp = tmp.lastChild;
  15222. }
  15223. // Support: Android <=4.0 only, PhantomJS 1 only
  15224. // push.apply(_, arraylike) throws on ancient WebKit
  15225. jQuery.merge( nodes, tmp.childNodes );
  15226. // Remember the top-level container
  15227. tmp = fragment.firstChild;
  15228. // Ensure the created nodes are orphaned (#12392)
  15229. tmp.textContent = "";
  15230. }
  15231. }
  15232. }
  15233. // Remove wrapper from fragment
  15234. fragment.textContent = "";
  15235. i = 0;
  15236. while ( ( elem = nodes[ i++ ] ) ) {
  15237. // Skip elements already in the context collection (trac-4087)
  15238. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  15239. if ( ignored ) {
  15240. ignored.push( elem );
  15241. }
  15242. continue;
  15243. }
  15244. attached = isAttached( elem );
  15245. // Append to fragment
  15246. tmp = getAll( fragment.appendChild( elem ), "script" );
  15247. // Preserve script evaluation history
  15248. if ( attached ) {
  15249. setGlobalEval( tmp );
  15250. }
  15251. // Capture executables
  15252. if ( scripts ) {
  15253. j = 0;
  15254. while ( ( elem = tmp[ j++ ] ) ) {
  15255. if ( rscriptType.test( elem.type || "" ) ) {
  15256. scripts.push( elem );
  15257. }
  15258. }
  15259. }
  15260. }
  15261. return fragment;
  15262. }
  15263. var
  15264. rkeyEvent = /^key/,
  15265. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  15266. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  15267. function returnTrue() {
  15268. return true;
  15269. }
  15270. function returnFalse() {
  15271. return false;
  15272. }
  15273. // Support: IE <=9 - 11+
  15274. // focus() and blur() are asynchronous, except when they are no-op.
  15275. // So expect focus to be synchronous when the element is already active,
  15276. // and blur to be synchronous when the element is not already active.
  15277. // (focus and blur are always synchronous in other supported browsers,
  15278. // this just defines when we can count on it).
  15279. function expectSync( elem, type ) {
  15280. return ( elem === safeActiveElement() ) === ( type === "focus" );
  15281. }
  15282. // Support: IE <=9 only
  15283. // Accessing document.activeElement can throw unexpectedly
  15284. // https://bugs.jquery.com/ticket/13393
  15285. function safeActiveElement() {
  15286. try {
  15287. return document.activeElement;
  15288. } catch ( err ) { }
  15289. }
  15290. function on( elem, types, selector, data, fn, one ) {
  15291. var origFn, type;
  15292. // Types can be a map of types/handlers
  15293. if ( typeof types === "object" ) {
  15294. // ( types-Object, selector, data )
  15295. if ( typeof selector !== "string" ) {
  15296. // ( types-Object, data )
  15297. data = data || selector;
  15298. selector = undefined;
  15299. }
  15300. for ( type in types ) {
  15301. on( elem, type, selector, data, types[ type ], one );
  15302. }
  15303. return elem;
  15304. }
  15305. if ( data == null && fn == null ) {
  15306. // ( types, fn )
  15307. fn = selector;
  15308. data = selector = undefined;
  15309. } else if ( fn == null ) {
  15310. if ( typeof selector === "string" ) {
  15311. // ( types, selector, fn )
  15312. fn = data;
  15313. data = undefined;
  15314. } else {
  15315. // ( types, data, fn )
  15316. fn = data;
  15317. data = selector;
  15318. selector = undefined;
  15319. }
  15320. }
  15321. if ( fn === false ) {
  15322. fn = returnFalse;
  15323. } else if ( !fn ) {
  15324. return elem;
  15325. }
  15326. if ( one === 1 ) {
  15327. origFn = fn;
  15328. fn = function( event ) {
  15329. // Can use an empty set, since event contains the info
  15330. jQuery().off( event );
  15331. return origFn.apply( this, arguments );
  15332. };
  15333. // Use same guid so caller can remove using origFn
  15334. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  15335. }
  15336. return elem.each( function() {
  15337. jQuery.event.add( this, types, fn, data, selector );
  15338. } );
  15339. }
  15340. /*
  15341. * Helper functions for managing events -- not part of the public interface.
  15342. * Props to Dean Edwards' addEvent library for many of the ideas.
  15343. */
  15344. jQuery.event = {
  15345. global: {},
  15346. add: function( elem, types, handler, data, selector ) {
  15347. var handleObjIn, eventHandle, tmp,
  15348. events, t, handleObj,
  15349. special, handlers, type, namespaces, origType,
  15350. elemData = dataPriv.get( elem );
  15351. // Only attach events to objects that accept data
  15352. if ( !acceptData( elem ) ) {
  15353. return;
  15354. }
  15355. // Caller can pass in an object of custom data in lieu of the handler
  15356. if ( handler.handler ) {
  15357. handleObjIn = handler;
  15358. handler = handleObjIn.handler;
  15359. selector = handleObjIn.selector;
  15360. }
  15361. // Ensure that invalid selectors throw exceptions at attach time
  15362. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  15363. if ( selector ) {
  15364. jQuery.find.matchesSelector( documentElement, selector );
  15365. }
  15366. // Make sure that the handler has a unique ID, used to find/remove it later
  15367. if ( !handler.guid ) {
  15368. handler.guid = jQuery.guid++;
  15369. }
  15370. // Init the element's event structure and main handler, if this is the first
  15371. if ( !( events = elemData.events ) ) {
  15372. events = elemData.events = Object.create( null );
  15373. }
  15374. if ( !( eventHandle = elemData.handle ) ) {
  15375. eventHandle = elemData.handle = function( e ) {
  15376. // Discard the second event of a jQuery.event.trigger() and
  15377. // when an event is called after a page has unloaded
  15378. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  15379. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  15380. };
  15381. }
  15382. // Handle multiple events separated by a space
  15383. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  15384. t = types.length;
  15385. while ( t-- ) {
  15386. tmp = rtypenamespace.exec( types[ t ] ) || [];
  15387. type = origType = tmp[ 1 ];
  15388. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  15389. // There *must* be a type, no attaching namespace-only handlers
  15390. if ( !type ) {
  15391. continue;
  15392. }
  15393. // If event changes its type, use the special event handlers for the changed type
  15394. special = jQuery.event.special[ type ] || {};
  15395. // If selector defined, determine special event api type, otherwise given type
  15396. type = ( selector ? special.delegateType : special.bindType ) || type;
  15397. // Update special based on newly reset type
  15398. special = jQuery.event.special[ type ] || {};
  15399. // handleObj is passed to all event handlers
  15400. handleObj = jQuery.extend( {
  15401. type: type,
  15402. origType: origType,
  15403. data: data,
  15404. handler: handler,
  15405. guid: handler.guid,
  15406. selector: selector,
  15407. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  15408. namespace: namespaces.join( "." )
  15409. }, handleObjIn );
  15410. // Init the event handler queue if we're the first
  15411. if ( !( handlers = events[ type ] ) ) {
  15412. handlers = events[ type ] = [];
  15413. handlers.delegateCount = 0;
  15414. // Only use addEventListener if the special events handler returns false
  15415. if ( !special.setup ||
  15416. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  15417. if ( elem.addEventListener ) {
  15418. elem.addEventListener( type, eventHandle );
  15419. }
  15420. }
  15421. }
  15422. if ( special.add ) {
  15423. special.add.call( elem, handleObj );
  15424. if ( !handleObj.handler.guid ) {
  15425. handleObj.handler.guid = handler.guid;
  15426. }
  15427. }
  15428. // Add to the element's handler list, delegates in front
  15429. if ( selector ) {
  15430. handlers.splice( handlers.delegateCount++, 0, handleObj );
  15431. } else {
  15432. handlers.push( handleObj );
  15433. }
  15434. // Keep track of which events have ever been used, for event optimization
  15435. jQuery.event.global[ type ] = true;
  15436. }
  15437. },
  15438. // Detach an event or set of events from an element
  15439. remove: function( elem, types, handler, selector, mappedTypes ) {
  15440. var j, origCount, tmp,
  15441. events, t, handleObj,
  15442. special, handlers, type, namespaces, origType,
  15443. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  15444. if ( !elemData || !( events = elemData.events ) ) {
  15445. return;
  15446. }
  15447. // Once for each type.namespace in types; type may be omitted
  15448. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  15449. t = types.length;
  15450. while ( t-- ) {
  15451. tmp = rtypenamespace.exec( types[ t ] ) || [];
  15452. type = origType = tmp[ 1 ];
  15453. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  15454. // Unbind all events (on this namespace, if provided) for the element
  15455. if ( !type ) {
  15456. for ( type in events ) {
  15457. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  15458. }
  15459. continue;
  15460. }
  15461. special = jQuery.event.special[ type ] || {};
  15462. type = ( selector ? special.delegateType : special.bindType ) || type;
  15463. handlers = events[ type ] || [];
  15464. tmp = tmp[ 2 ] &&
  15465. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  15466. // Remove matching events
  15467. origCount = j = handlers.length;
  15468. while ( j-- ) {
  15469. handleObj = handlers[ j ];
  15470. if ( ( mappedTypes || origType === handleObj.origType ) &&
  15471. ( !handler || handler.guid === handleObj.guid ) &&
  15472. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  15473. ( !selector || selector === handleObj.selector ||
  15474. selector === "**" && handleObj.selector ) ) {
  15475. handlers.splice( j, 1 );
  15476. if ( handleObj.selector ) {
  15477. handlers.delegateCount--;
  15478. }
  15479. if ( special.remove ) {
  15480. special.remove.call( elem, handleObj );
  15481. }
  15482. }
  15483. }
  15484. // Remove generic event handler if we removed something and no more handlers exist
  15485. // (avoids potential for endless recursion during removal of special event handlers)
  15486. if ( origCount && !handlers.length ) {
  15487. if ( !special.teardown ||
  15488. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  15489. jQuery.removeEvent( elem, type, elemData.handle );
  15490. }
  15491. delete events[ type ];
  15492. }
  15493. }
  15494. // Remove data and the expando if it's no longer used
  15495. if ( jQuery.isEmptyObject( events ) ) {
  15496. dataPriv.remove( elem, "handle events" );
  15497. }
  15498. },
  15499. dispatch: function( nativeEvent ) {
  15500. var i, j, ret, matched, handleObj, handlerQueue,
  15501. args = new Array( arguments.length ),
  15502. // Make a writable jQuery.Event from the native event object
  15503. event = jQuery.event.fix( nativeEvent ),
  15504. handlers = (
  15505. dataPriv.get( this, "events" ) || Object.create( null )
  15506. )[ event.type ] || [],
  15507. special = jQuery.event.special[ event.type ] || {};
  15508. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  15509. args[ 0 ] = event;
  15510. for ( i = 1; i < arguments.length; i++ ) {
  15511. args[ i ] = arguments[ i ];
  15512. }
  15513. event.delegateTarget = this;
  15514. // Call the preDispatch hook for the mapped type, and let it bail if desired
  15515. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  15516. return;
  15517. }
  15518. // Determine handlers
  15519. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  15520. // Run delegates first; they may want to stop propagation beneath us
  15521. i = 0;
  15522. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  15523. event.currentTarget = matched.elem;
  15524. j = 0;
  15525. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  15526. !event.isImmediatePropagationStopped() ) {
  15527. // If the event is namespaced, then each handler is only invoked if it is
  15528. // specially universal or its namespaces are a superset of the event's.
  15529. if ( !event.rnamespace || handleObj.namespace === false ||
  15530. event.rnamespace.test( handleObj.namespace ) ) {
  15531. event.handleObj = handleObj;
  15532. event.data = handleObj.data;
  15533. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  15534. handleObj.handler ).apply( matched.elem, args );
  15535. if ( ret !== undefined ) {
  15536. if ( ( event.result = ret ) === false ) {
  15537. event.preventDefault();
  15538. event.stopPropagation();
  15539. }
  15540. }
  15541. }
  15542. }
  15543. }
  15544. // Call the postDispatch hook for the mapped type
  15545. if ( special.postDispatch ) {
  15546. special.postDispatch.call( this, event );
  15547. }
  15548. return event.result;
  15549. },
  15550. handlers: function( event, handlers ) {
  15551. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  15552. handlerQueue = [],
  15553. delegateCount = handlers.delegateCount,
  15554. cur = event.target;
  15555. // Find delegate handlers
  15556. if ( delegateCount &&
  15557. // Support: IE <=9
  15558. // Black-hole SVG <use> instance trees (trac-13180)
  15559. cur.nodeType &&
  15560. // Support: Firefox <=42
  15561. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  15562. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  15563. // Support: IE 11 only
  15564. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  15565. !( event.type === "click" && event.button >= 1 ) ) {
  15566. for ( ; cur !== this; cur = cur.parentNode || this ) {
  15567. // Don't check non-elements (#13208)
  15568. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  15569. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  15570. matchedHandlers = [];
  15571. matchedSelectors = {};
  15572. for ( i = 0; i < delegateCount; i++ ) {
  15573. handleObj = handlers[ i ];
  15574. // Don't conflict with Object.prototype properties (#13203)
  15575. sel = handleObj.selector + " ";
  15576. if ( matchedSelectors[ sel ] === undefined ) {
  15577. matchedSelectors[ sel ] = handleObj.needsContext ?
  15578. jQuery( sel, this ).index( cur ) > -1 :
  15579. jQuery.find( sel, this, null, [ cur ] ).length;
  15580. }
  15581. if ( matchedSelectors[ sel ] ) {
  15582. matchedHandlers.push( handleObj );
  15583. }
  15584. }
  15585. if ( matchedHandlers.length ) {
  15586. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  15587. }
  15588. }
  15589. }
  15590. }
  15591. // Add the remaining (directly-bound) handlers
  15592. cur = this;
  15593. if ( delegateCount < handlers.length ) {
  15594. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  15595. }
  15596. return handlerQueue;
  15597. },
  15598. addProp: function( name, hook ) {
  15599. Object.defineProperty( jQuery.Event.prototype, name, {
  15600. enumerable: true,
  15601. configurable: true,
  15602. get: isFunction( hook ) ?
  15603. function() {
  15604. if ( this.originalEvent ) {
  15605. return hook( this.originalEvent );
  15606. }
  15607. } :
  15608. function() {
  15609. if ( this.originalEvent ) {
  15610. return this.originalEvent[ name ];
  15611. }
  15612. },
  15613. set: function( value ) {
  15614. Object.defineProperty( this, name, {
  15615. enumerable: true,
  15616. configurable: true,
  15617. writable: true,
  15618. value: value
  15619. } );
  15620. }
  15621. } );
  15622. },
  15623. fix: function( originalEvent ) {
  15624. return originalEvent[ jQuery.expando ] ?
  15625. originalEvent :
  15626. new jQuery.Event( originalEvent );
  15627. },
  15628. special: {
  15629. load: {
  15630. // Prevent triggered image.load events from bubbling to window.load
  15631. noBubble: true
  15632. },
  15633. click: {
  15634. // Utilize native event to ensure correct state for checkable inputs
  15635. setup: function( data ) {
  15636. // For mutual compressibility with _default, replace `this` access with a local var.
  15637. // `|| data` is dead code meant only to preserve the variable through minification.
  15638. var el = this || data;
  15639. // Claim the first handler
  15640. if ( rcheckableType.test( el.type ) &&
  15641. el.click && nodeName( el, "input" ) ) {
  15642. // dataPriv.set( el, "click", ... )
  15643. leverageNative( el, "click", returnTrue );
  15644. }
  15645. // Return false to allow normal processing in the caller
  15646. return false;
  15647. },
  15648. trigger: function( data ) {
  15649. // For mutual compressibility with _default, replace `this` access with a local var.
  15650. // `|| data` is dead code meant only to preserve the variable through minification.
  15651. var el = this || data;
  15652. // Force setup before triggering a click
  15653. if ( rcheckableType.test( el.type ) &&
  15654. el.click && nodeName( el, "input" ) ) {
  15655. leverageNative( el, "click" );
  15656. }
  15657. // Return non-false to allow normal event-path propagation
  15658. return true;
  15659. },
  15660. // For cross-browser consistency, suppress native .click() on links
  15661. // Also prevent it if we're currently inside a leveraged native-event stack
  15662. _default: function( event ) {
  15663. var target = event.target;
  15664. return rcheckableType.test( target.type ) &&
  15665. target.click && nodeName( target, "input" ) &&
  15666. dataPriv.get( target, "click" ) ||
  15667. nodeName( target, "a" );
  15668. }
  15669. },
  15670. beforeunload: {
  15671. postDispatch: function( event ) {
  15672. // Support: Firefox 20+
  15673. // Firefox doesn't alert if the returnValue field is not set.
  15674. if ( event.result !== undefined && event.originalEvent ) {
  15675. event.originalEvent.returnValue = event.result;
  15676. }
  15677. }
  15678. }
  15679. }
  15680. };
  15681. // Ensure the presence of an event listener that handles manually-triggered
  15682. // synthetic events by interrupting progress until reinvoked in response to
  15683. // *native* events that it fires directly, ensuring that state changes have
  15684. // already occurred before other listeners are invoked.
  15685. function leverageNative( el, type, expectSync ) {
  15686. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  15687. if ( !expectSync ) {
  15688. if ( dataPriv.get( el, type ) === undefined ) {
  15689. jQuery.event.add( el, type, returnTrue );
  15690. }
  15691. return;
  15692. }
  15693. // Register the controller as a special universal handler for all event namespaces
  15694. dataPriv.set( el, type, false );
  15695. jQuery.event.add( el, type, {
  15696. namespace: false,
  15697. handler: function( event ) {
  15698. var notAsync, result,
  15699. saved = dataPriv.get( this, type );
  15700. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  15701. // Interrupt processing of the outer synthetic .trigger()ed event
  15702. // Saved data should be false in such cases, but might be a leftover capture object
  15703. // from an async native handler (gh-4350)
  15704. if ( !saved.length ) {
  15705. // Store arguments for use when handling the inner native event
  15706. // There will always be at least one argument (an event object), so this array
  15707. // will not be confused with a leftover capture object.
  15708. saved = slice.call( arguments );
  15709. dataPriv.set( this, type, saved );
  15710. // Trigger the native event and capture its result
  15711. // Support: IE <=9 - 11+
  15712. // focus() and blur() are asynchronous
  15713. notAsync = expectSync( this, type );
  15714. this[ type ]();
  15715. result = dataPriv.get( this, type );
  15716. if ( saved !== result || notAsync ) {
  15717. dataPriv.set( this, type, false );
  15718. } else {
  15719. result = {};
  15720. }
  15721. if ( saved !== result ) {
  15722. // Cancel the outer synthetic event
  15723. event.stopImmediatePropagation();
  15724. event.preventDefault();
  15725. return result.value;
  15726. }
  15727. // If this is an inner synthetic event for an event with a bubbling surrogate
  15728. // (focus or blur), assume that the surrogate already propagated from triggering the
  15729. // native event and prevent that from happening again here.
  15730. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  15731. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  15732. // less bad than duplication.
  15733. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  15734. event.stopPropagation();
  15735. }
  15736. // If this is a native event triggered above, everything is now in order
  15737. // Fire an inner synthetic event with the original arguments
  15738. } else if ( saved.length ) {
  15739. // ...and capture the result
  15740. dataPriv.set( this, type, {
  15741. value: jQuery.event.trigger(
  15742. // Support: IE <=9 - 11+
  15743. // Extend with the prototype to reset the above stopImmediatePropagation()
  15744. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  15745. saved.slice( 1 ),
  15746. this
  15747. )
  15748. } );
  15749. // Abort handling of the native event
  15750. event.stopImmediatePropagation();
  15751. }
  15752. }
  15753. } );
  15754. }
  15755. jQuery.removeEvent = function( elem, type, handle ) {
  15756. // This "if" is needed for plain objects
  15757. if ( elem.removeEventListener ) {
  15758. elem.removeEventListener( type, handle );
  15759. }
  15760. };
  15761. jQuery.Event = function( src, props ) {
  15762. // Allow instantiation without the 'new' keyword
  15763. if ( !( this instanceof jQuery.Event ) ) {
  15764. return new jQuery.Event( src, props );
  15765. }
  15766. // Event object
  15767. if ( src && src.type ) {
  15768. this.originalEvent = src;
  15769. this.type = src.type;
  15770. // Events bubbling up the document may have been marked as prevented
  15771. // by a handler lower down the tree; reflect the correct value.
  15772. this.isDefaultPrevented = src.defaultPrevented ||
  15773. src.defaultPrevented === undefined &&
  15774. // Support: Android <=2.3 only
  15775. src.returnValue === false ?
  15776. returnTrue :
  15777. returnFalse;
  15778. // Create target properties
  15779. // Support: Safari <=6 - 7 only
  15780. // Target should not be a text node (#504, #13143)
  15781. this.target = ( src.target && src.target.nodeType === 3 ) ?
  15782. src.target.parentNode :
  15783. src.target;
  15784. this.currentTarget = src.currentTarget;
  15785. this.relatedTarget = src.relatedTarget;
  15786. // Event type
  15787. } else {
  15788. this.type = src;
  15789. }
  15790. // Put explicitly provided properties onto the event object
  15791. if ( props ) {
  15792. jQuery.extend( this, props );
  15793. }
  15794. // Create a timestamp if incoming event doesn't have one
  15795. this.timeStamp = src && src.timeStamp || Date.now();
  15796. // Mark it as fixed
  15797. this[ jQuery.expando ] = true;
  15798. };
  15799. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  15800. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  15801. jQuery.Event.prototype = {
  15802. constructor: jQuery.Event,
  15803. isDefaultPrevented: returnFalse,
  15804. isPropagationStopped: returnFalse,
  15805. isImmediatePropagationStopped: returnFalse,
  15806. isSimulated: false,
  15807. preventDefault: function() {
  15808. var e = this.originalEvent;
  15809. this.isDefaultPrevented = returnTrue;
  15810. if ( e && !this.isSimulated ) {
  15811. e.preventDefault();
  15812. }
  15813. },
  15814. stopPropagation: function() {
  15815. var e = this.originalEvent;
  15816. this.isPropagationStopped = returnTrue;
  15817. if ( e && !this.isSimulated ) {
  15818. e.stopPropagation();
  15819. }
  15820. },
  15821. stopImmediatePropagation: function() {
  15822. var e = this.originalEvent;
  15823. this.isImmediatePropagationStopped = returnTrue;
  15824. if ( e && !this.isSimulated ) {
  15825. e.stopImmediatePropagation();
  15826. }
  15827. this.stopPropagation();
  15828. }
  15829. };
  15830. // Includes all common event props including KeyEvent and MouseEvent specific props
  15831. jQuery.each( {
  15832. altKey: true,
  15833. bubbles: true,
  15834. cancelable: true,
  15835. changedTouches: true,
  15836. ctrlKey: true,
  15837. detail: true,
  15838. eventPhase: true,
  15839. metaKey: true,
  15840. pageX: true,
  15841. pageY: true,
  15842. shiftKey: true,
  15843. view: true,
  15844. "char": true,
  15845. code: true,
  15846. charCode: true,
  15847. key: true,
  15848. keyCode: true,
  15849. button: true,
  15850. buttons: true,
  15851. clientX: true,
  15852. clientY: true,
  15853. offsetX: true,
  15854. offsetY: true,
  15855. pointerId: true,
  15856. pointerType: true,
  15857. screenX: true,
  15858. screenY: true,
  15859. targetTouches: true,
  15860. toElement: true,
  15861. touches: true,
  15862. which: function( event ) {
  15863. var button = event.button;
  15864. // Add which for key events
  15865. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  15866. return event.charCode != null ? event.charCode : event.keyCode;
  15867. }
  15868. // Add which for click: 1 === left; 2 === middle; 3 === right
  15869. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  15870. if ( button & 1 ) {
  15871. return 1;
  15872. }
  15873. if ( button & 2 ) {
  15874. return 3;
  15875. }
  15876. if ( button & 4 ) {
  15877. return 2;
  15878. }
  15879. return 0;
  15880. }
  15881. return event.which;
  15882. }
  15883. }, jQuery.event.addProp );
  15884. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  15885. jQuery.event.special[ type ] = {
  15886. // Utilize native event if possible so blur/focus sequence is correct
  15887. setup: function() {
  15888. // Claim the first handler
  15889. // dataPriv.set( this, "focus", ... )
  15890. // dataPriv.set( this, "blur", ... )
  15891. leverageNative( this, type, expectSync );
  15892. // Return false to allow normal processing in the caller
  15893. return false;
  15894. },
  15895. trigger: function() {
  15896. // Force setup before trigger
  15897. leverageNative( this, type );
  15898. // Return non-false to allow normal event-path propagation
  15899. return true;
  15900. },
  15901. delegateType: delegateType
  15902. };
  15903. } );
  15904. // Create mouseenter/leave events using mouseover/out and event-time checks
  15905. // so that event delegation works in jQuery.
  15906. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  15907. //
  15908. // Support: Safari 7 only
  15909. // Safari sends mouseenter too often; see:
  15910. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  15911. // for the description of the bug (it existed in older Chrome versions as well).
  15912. jQuery.each( {
  15913. mouseenter: "mouseover",
  15914. mouseleave: "mouseout",
  15915. pointerenter: "pointerover",
  15916. pointerleave: "pointerout"
  15917. }, function( orig, fix ) {
  15918. jQuery.event.special[ orig ] = {
  15919. delegateType: fix,
  15920. bindType: fix,
  15921. handle: function( event ) {
  15922. var ret,
  15923. target = this,
  15924. related = event.relatedTarget,
  15925. handleObj = event.handleObj;
  15926. // For mouseenter/leave call the handler if related is outside the target.
  15927. // NB: No relatedTarget if the mouse left/entered the browser window
  15928. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  15929. event.type = handleObj.origType;
  15930. ret = handleObj.handler.apply( this, arguments );
  15931. event.type = fix;
  15932. }
  15933. return ret;
  15934. }
  15935. };
  15936. } );
  15937. jQuery.fn.extend( {
  15938. on: function( types, selector, data, fn ) {
  15939. return on( this, types, selector, data, fn );
  15940. },
  15941. one: function( types, selector, data, fn ) {
  15942. return on( this, types, selector, data, fn, 1 );
  15943. },
  15944. off: function( types, selector, fn ) {
  15945. var handleObj, type;
  15946. if ( types && types.preventDefault && types.handleObj ) {
  15947. // ( event ) dispatched jQuery.Event
  15948. handleObj = types.handleObj;
  15949. jQuery( types.delegateTarget ).off(
  15950. handleObj.namespace ?
  15951. handleObj.origType + "." + handleObj.namespace :
  15952. handleObj.origType,
  15953. handleObj.selector,
  15954. handleObj.handler
  15955. );
  15956. return this;
  15957. }
  15958. if ( typeof types === "object" ) {
  15959. // ( types-object [, selector] )
  15960. for ( type in types ) {
  15961. this.off( type, selector, types[ type ] );
  15962. }
  15963. return this;
  15964. }
  15965. if ( selector === false || typeof selector === "function" ) {
  15966. // ( types [, fn] )
  15967. fn = selector;
  15968. selector = undefined;
  15969. }
  15970. if ( fn === false ) {
  15971. fn = returnFalse;
  15972. }
  15973. return this.each( function() {
  15974. jQuery.event.remove( this, types, fn, selector );
  15975. } );
  15976. }
  15977. } );
  15978. var
  15979. // Support: IE <=10 - 11, Edge 12 - 13 only
  15980. // In IE/Edge using regex groups here causes severe slowdowns.
  15981. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  15982. rnoInnerhtml = /<script|<style|<link/i,
  15983. // checked="checked" or checked
  15984. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  15985. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  15986. // Prefer a tbody over its parent table for containing new rows
  15987. function manipulationTarget( elem, content ) {
  15988. if ( nodeName( elem, "table" ) &&
  15989. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  15990. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  15991. }
  15992. return elem;
  15993. }
  15994. // Replace/restore the type attribute of script elements for safe DOM manipulation
  15995. function disableScript( elem ) {
  15996. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  15997. return elem;
  15998. }
  15999. function restoreScript( elem ) {
  16000. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  16001. elem.type = elem.type.slice( 5 );
  16002. } else {
  16003. elem.removeAttribute( "type" );
  16004. }
  16005. return elem;
  16006. }
  16007. function cloneCopyEvent( src, dest ) {
  16008. var i, l, type, pdataOld, udataOld, udataCur, events;
  16009. if ( dest.nodeType !== 1 ) {
  16010. return;
  16011. }
  16012. // 1. Copy private data: events, handlers, etc.
  16013. if ( dataPriv.hasData( src ) ) {
  16014. pdataOld = dataPriv.get( src );
  16015. events = pdataOld.events;
  16016. if ( events ) {
  16017. dataPriv.remove( dest, "handle events" );
  16018. for ( type in events ) {
  16019. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  16020. jQuery.event.add( dest, type, events[ type ][ i ] );
  16021. }
  16022. }
  16023. }
  16024. }
  16025. // 2. Copy user data
  16026. if ( dataUser.hasData( src ) ) {
  16027. udataOld = dataUser.access( src );
  16028. udataCur = jQuery.extend( {}, udataOld );
  16029. dataUser.set( dest, udataCur );
  16030. }
  16031. }
  16032. // Fix IE bugs, see support tests
  16033. function fixInput( src, dest ) {
  16034. var nodeName = dest.nodeName.toLowerCase();
  16035. // Fails to persist the checked state of a cloned checkbox or radio button.
  16036. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  16037. dest.checked = src.checked;
  16038. // Fails to return the selected option to the default selected state when cloning options
  16039. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  16040. dest.defaultValue = src.defaultValue;
  16041. }
  16042. }
  16043. function domManip( collection, args, callback, ignored ) {
  16044. // Flatten any nested arrays
  16045. args = flat( args );
  16046. var fragment, first, scripts, hasScripts, node, doc,
  16047. i = 0,
  16048. l = collection.length,
  16049. iNoClone = l - 1,
  16050. value = args[ 0 ],
  16051. valueIsFunction = isFunction( value );
  16052. // We can't cloneNode fragments that contain checked, in WebKit
  16053. if ( valueIsFunction ||
  16054. ( l > 1 && typeof value === "string" &&
  16055. !support.checkClone && rchecked.test( value ) ) ) {
  16056. return collection.each( function( index ) {
  16057. var self = collection.eq( index );
  16058. if ( valueIsFunction ) {
  16059. args[ 0 ] = value.call( this, index, self.html() );
  16060. }
  16061. domManip( self, args, callback, ignored );
  16062. } );
  16063. }
  16064. if ( l ) {
  16065. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  16066. first = fragment.firstChild;
  16067. if ( fragment.childNodes.length === 1 ) {
  16068. fragment = first;
  16069. }
  16070. // Require either new content or an interest in ignored elements to invoke the callback
  16071. if ( first || ignored ) {
  16072. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  16073. hasScripts = scripts.length;
  16074. // Use the original fragment for the last item
  16075. // instead of the first because it can end up
  16076. // being emptied incorrectly in certain situations (#8070).
  16077. for ( ; i < l; i++ ) {
  16078. node = fragment;
  16079. if ( i !== iNoClone ) {
  16080. node = jQuery.clone( node, true, true );
  16081. // Keep references to cloned scripts for later restoration
  16082. if ( hasScripts ) {
  16083. // Support: Android <=4.0 only, PhantomJS 1 only
  16084. // push.apply(_, arraylike) throws on ancient WebKit
  16085. jQuery.merge( scripts, getAll( node, "script" ) );
  16086. }
  16087. }
  16088. callback.call( collection[ i ], node, i );
  16089. }
  16090. if ( hasScripts ) {
  16091. doc = scripts[ scripts.length - 1 ].ownerDocument;
  16092. // Reenable scripts
  16093. jQuery.map( scripts, restoreScript );
  16094. // Evaluate executable scripts on first document insertion
  16095. for ( i = 0; i < hasScripts; i++ ) {
  16096. node = scripts[ i ];
  16097. if ( rscriptType.test( node.type || "" ) &&
  16098. !dataPriv.access( node, "globalEval" ) &&
  16099. jQuery.contains( doc, node ) ) {
  16100. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  16101. // Optional AJAX dependency, but won't run scripts if not present
  16102. if ( jQuery._evalUrl && !node.noModule ) {
  16103. jQuery._evalUrl( node.src, {
  16104. nonce: node.nonce || node.getAttribute( "nonce" )
  16105. }, doc );
  16106. }
  16107. } else {
  16108. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  16109. }
  16110. }
  16111. }
  16112. }
  16113. }
  16114. }
  16115. return collection;
  16116. }
  16117. function remove( elem, selector, keepData ) {
  16118. var node,
  16119. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  16120. i = 0;
  16121. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  16122. if ( !keepData && node.nodeType === 1 ) {
  16123. jQuery.cleanData( getAll( node ) );
  16124. }
  16125. if ( node.parentNode ) {
  16126. if ( keepData && isAttached( node ) ) {
  16127. setGlobalEval( getAll( node, "script" ) );
  16128. }
  16129. node.parentNode.removeChild( node );
  16130. }
  16131. }
  16132. return elem;
  16133. }
  16134. jQuery.extend( {
  16135. htmlPrefilter: function( html ) {
  16136. return html;
  16137. },
  16138. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  16139. var i, l, srcElements, destElements,
  16140. clone = elem.cloneNode( true ),
  16141. inPage = isAttached( elem );
  16142. // Fix IE cloning issues
  16143. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  16144. !jQuery.isXMLDoc( elem ) ) {
  16145. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  16146. destElements = getAll( clone );
  16147. srcElements = getAll( elem );
  16148. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  16149. fixInput( srcElements[ i ], destElements[ i ] );
  16150. }
  16151. }
  16152. // Copy the events from the original to the clone
  16153. if ( dataAndEvents ) {
  16154. if ( deepDataAndEvents ) {
  16155. srcElements = srcElements || getAll( elem );
  16156. destElements = destElements || getAll( clone );
  16157. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  16158. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  16159. }
  16160. } else {
  16161. cloneCopyEvent( elem, clone );
  16162. }
  16163. }
  16164. // Preserve script evaluation history
  16165. destElements = getAll( clone, "script" );
  16166. if ( destElements.length > 0 ) {
  16167. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  16168. }
  16169. // Return the cloned set
  16170. return clone;
  16171. },
  16172. cleanData: function( elems ) {
  16173. var data, elem, type,
  16174. special = jQuery.event.special,
  16175. i = 0;
  16176. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  16177. if ( acceptData( elem ) ) {
  16178. if ( ( data = elem[ dataPriv.expando ] ) ) {
  16179. if ( data.events ) {
  16180. for ( type in data.events ) {
  16181. if ( special[ type ] ) {
  16182. jQuery.event.remove( elem, type );
  16183. // This is a shortcut to avoid jQuery.event.remove's overhead
  16184. } else {
  16185. jQuery.removeEvent( elem, type, data.handle );
  16186. }
  16187. }
  16188. }
  16189. // Support: Chrome <=35 - 45+
  16190. // Assign undefined instead of using delete, see Data#remove
  16191. elem[ dataPriv.expando ] = undefined;
  16192. }
  16193. if ( elem[ dataUser.expando ] ) {
  16194. // Support: Chrome <=35 - 45+
  16195. // Assign undefined instead of using delete, see Data#remove
  16196. elem[ dataUser.expando ] = undefined;
  16197. }
  16198. }
  16199. }
  16200. }
  16201. } );
  16202. jQuery.fn.extend( {
  16203. detach: function( selector ) {
  16204. return remove( this, selector, true );
  16205. },
  16206. remove: function( selector ) {
  16207. return remove( this, selector );
  16208. },
  16209. text: function( value ) {
  16210. return access( this, function( value ) {
  16211. return value === undefined ?
  16212. jQuery.text( this ) :
  16213. this.empty().each( function() {
  16214. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  16215. this.textContent = value;
  16216. }
  16217. } );
  16218. }, null, value, arguments.length );
  16219. },
  16220. append: function() {
  16221. return domManip( this, arguments, function( elem ) {
  16222. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  16223. var target = manipulationTarget( this, elem );
  16224. target.appendChild( elem );
  16225. }
  16226. } );
  16227. },
  16228. prepend: function() {
  16229. return domManip( this, arguments, function( elem ) {
  16230. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  16231. var target = manipulationTarget( this, elem );
  16232. target.insertBefore( elem, target.firstChild );
  16233. }
  16234. } );
  16235. },
  16236. before: function() {
  16237. return domManip( this, arguments, function( elem ) {
  16238. if ( this.parentNode ) {
  16239. this.parentNode.insertBefore( elem, this );
  16240. }
  16241. } );
  16242. },
  16243. after: function() {
  16244. return domManip( this, arguments, function( elem ) {
  16245. if ( this.parentNode ) {
  16246. this.parentNode.insertBefore( elem, this.nextSibling );
  16247. }
  16248. } );
  16249. },
  16250. empty: function() {
  16251. var elem,
  16252. i = 0;
  16253. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  16254. if ( elem.nodeType === 1 ) {
  16255. // Prevent memory leaks
  16256. jQuery.cleanData( getAll( elem, false ) );
  16257. // Remove any remaining nodes
  16258. elem.textContent = "";
  16259. }
  16260. }
  16261. return this;
  16262. },
  16263. clone: function( dataAndEvents, deepDataAndEvents ) {
  16264. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  16265. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  16266. return this.map( function() {
  16267. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  16268. } );
  16269. },
  16270. html: function( value ) {
  16271. return access( this, function( value ) {
  16272. var elem = this[ 0 ] || {},
  16273. i = 0,
  16274. l = this.length;
  16275. if ( value === undefined && elem.nodeType === 1 ) {
  16276. return elem.innerHTML;
  16277. }
  16278. // See if we can take a shortcut and just use innerHTML
  16279. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  16280. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  16281. value = jQuery.htmlPrefilter( value );
  16282. try {
  16283. for ( ; i < l; i++ ) {
  16284. elem = this[ i ] || {};
  16285. // Remove element nodes and prevent memory leaks
  16286. if ( elem.nodeType === 1 ) {
  16287. jQuery.cleanData( getAll( elem, false ) );
  16288. elem.innerHTML = value;
  16289. }
  16290. }
  16291. elem = 0;
  16292. // If using innerHTML throws an exception, use the fallback method
  16293. } catch ( e ) {}
  16294. }
  16295. if ( elem ) {
  16296. this.empty().append( value );
  16297. }
  16298. }, null, value, arguments.length );
  16299. },
  16300. replaceWith: function() {
  16301. var ignored = [];
  16302. // Make the changes, replacing each non-ignored context element with the new content
  16303. return domManip( this, arguments, function( elem ) {
  16304. var parent = this.parentNode;
  16305. if ( jQuery.inArray( this, ignored ) < 0 ) {
  16306. jQuery.cleanData( getAll( this ) );
  16307. if ( parent ) {
  16308. parent.replaceChild( elem, this );
  16309. }
  16310. }
  16311. // Force callback invocation
  16312. }, ignored );
  16313. }
  16314. } );
  16315. jQuery.each( {
  16316. appendTo: "append",
  16317. prependTo: "prepend",
  16318. insertBefore: "before",
  16319. insertAfter: "after",
  16320. replaceAll: "replaceWith"
  16321. }, function( name, original ) {
  16322. jQuery.fn[ name ] = function( selector ) {
  16323. var elems,
  16324. ret = [],
  16325. insert = jQuery( selector ),
  16326. last = insert.length - 1,
  16327. i = 0;
  16328. for ( ; i <= last; i++ ) {
  16329. elems = i === last ? this : this.clone( true );
  16330. jQuery( insert[ i ] )[ original ]( elems );
  16331. // Support: Android <=4.0 only, PhantomJS 1 only
  16332. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  16333. push.apply( ret, elems.get() );
  16334. }
  16335. return this.pushStack( ret );
  16336. };
  16337. } );
  16338. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  16339. var getStyles = function( elem ) {
  16340. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  16341. // IE throws on elements created in popups
  16342. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  16343. var view = elem.ownerDocument.defaultView;
  16344. if ( !view || !view.opener ) {
  16345. view = window;
  16346. }
  16347. return view.getComputedStyle( elem );
  16348. };
  16349. var swap = function( elem, options, callback ) {
  16350. var ret, name,
  16351. old = {};
  16352. // Remember the old values, and insert the new ones
  16353. for ( name in options ) {
  16354. old[ name ] = elem.style[ name ];
  16355. elem.style[ name ] = options[ name ];
  16356. }
  16357. ret = callback.call( elem );
  16358. // Revert the old values
  16359. for ( name in options ) {
  16360. elem.style[ name ] = old[ name ];
  16361. }
  16362. return ret;
  16363. };
  16364. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  16365. ( function() {
  16366. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  16367. // so they're executed at the same time to save the second computation.
  16368. function computeStyleTests() {
  16369. // This is a singleton, we need to execute it only once
  16370. if ( !div ) {
  16371. return;
  16372. }
  16373. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  16374. "margin-top:1px;padding:0;border:0";
  16375. div.style.cssText =
  16376. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  16377. "margin:auto;border:1px;padding:1px;" +
  16378. "width:60%;top:1%";
  16379. documentElement.appendChild( container ).appendChild( div );
  16380. var divStyle = window.getComputedStyle( div );
  16381. pixelPositionVal = divStyle.top !== "1%";
  16382. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  16383. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  16384. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  16385. // Some styles come back with percentage values, even though they shouldn't
  16386. div.style.right = "60%";
  16387. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  16388. // Support: IE 9 - 11 only
  16389. // Detect misreporting of content dimensions for box-sizing:border-box elements
  16390. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  16391. // Support: IE 9 only
  16392. // Detect overflow:scroll screwiness (gh-3699)
  16393. // Support: Chrome <=64
  16394. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  16395. div.style.position = "absolute";
  16396. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  16397. documentElement.removeChild( container );
  16398. // Nullify the div so it wouldn't be stored in the memory and
  16399. // it will also be a sign that checks already performed
  16400. div = null;
  16401. }
  16402. function roundPixelMeasures( measure ) {
  16403. return Math.round( parseFloat( measure ) );
  16404. }
  16405. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  16406. reliableTrDimensionsVal, reliableMarginLeftVal,
  16407. container = document.createElement( "div" ),
  16408. div = document.createElement( "div" );
  16409. // Finish early in limited (non-browser) environments
  16410. if ( !div.style ) {
  16411. return;
  16412. }
  16413. // Support: IE <=9 - 11 only
  16414. // Style of cloned element affects source element cloned (#8908)
  16415. div.style.backgroundClip = "content-box";
  16416. div.cloneNode( true ).style.backgroundClip = "";
  16417. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  16418. jQuery.extend( support, {
  16419. boxSizingReliable: function() {
  16420. computeStyleTests();
  16421. return boxSizingReliableVal;
  16422. },
  16423. pixelBoxStyles: function() {
  16424. computeStyleTests();
  16425. return pixelBoxStylesVal;
  16426. },
  16427. pixelPosition: function() {
  16428. computeStyleTests();
  16429. return pixelPositionVal;
  16430. },
  16431. reliableMarginLeft: function() {
  16432. computeStyleTests();
  16433. return reliableMarginLeftVal;
  16434. },
  16435. scrollboxSize: function() {
  16436. computeStyleTests();
  16437. return scrollboxSizeVal;
  16438. },
  16439. // Support: IE 9 - 11+, Edge 15 - 18+
  16440. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  16441. // set in CSS while `offset*` properties report correct values.
  16442. // Behavior in IE 9 is more subtle than in newer versions & it passes
  16443. // some versions of this test; make sure not to make it pass there!
  16444. reliableTrDimensions: function() {
  16445. var table, tr, trChild, trStyle;
  16446. if ( reliableTrDimensionsVal == null ) {
  16447. table = document.createElement( "table" );
  16448. tr = document.createElement( "tr" );
  16449. trChild = document.createElement( "div" );
  16450. table.style.cssText = "position:absolute;left:-11111px";
  16451. tr.style.height = "1px";
  16452. trChild.style.height = "9px";
  16453. documentElement
  16454. .appendChild( table )
  16455. .appendChild( tr )
  16456. .appendChild( trChild );
  16457. trStyle = window.getComputedStyle( tr );
  16458. reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
  16459. documentElement.removeChild( table );
  16460. }
  16461. return reliableTrDimensionsVal;
  16462. }
  16463. } );
  16464. } )();
  16465. function curCSS( elem, name, computed ) {
  16466. var width, minWidth, maxWidth, ret,
  16467. // Support: Firefox 51+
  16468. // Retrieving style before computed somehow
  16469. // fixes an issue with getting wrong values
  16470. // on detached elements
  16471. style = elem.style;
  16472. computed = computed || getStyles( elem );
  16473. // getPropertyValue is needed for:
  16474. // .css('filter') (IE 9 only, #12537)
  16475. // .css('--customProperty) (#3144)
  16476. if ( computed ) {
  16477. ret = computed.getPropertyValue( name ) || computed[ name ];
  16478. if ( ret === "" && !isAttached( elem ) ) {
  16479. ret = jQuery.style( elem, name );
  16480. }
  16481. // A tribute to the "awesome hack by Dean Edwards"
  16482. // Android Browser returns percentage for some values,
  16483. // but width seems to be reliably pixels.
  16484. // This is against the CSSOM draft spec:
  16485. // https://drafts.csswg.org/cssom/#resolved-values
  16486. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  16487. // Remember the original values
  16488. width = style.width;
  16489. minWidth = style.minWidth;
  16490. maxWidth = style.maxWidth;
  16491. // Put in the new values to get a computed value out
  16492. style.minWidth = style.maxWidth = style.width = ret;
  16493. ret = computed.width;
  16494. // Revert the changed values
  16495. style.width = width;
  16496. style.minWidth = minWidth;
  16497. style.maxWidth = maxWidth;
  16498. }
  16499. }
  16500. return ret !== undefined ?
  16501. // Support: IE <=9 - 11 only
  16502. // IE returns zIndex value as an integer.
  16503. ret + "" :
  16504. ret;
  16505. }
  16506. function addGetHookIf( conditionFn, hookFn ) {
  16507. // Define the hook, we'll check on the first run if it's really needed.
  16508. return {
  16509. get: function() {
  16510. if ( conditionFn() ) {
  16511. // Hook not needed (or it's not possible to use it due
  16512. // to missing dependency), remove it.
  16513. delete this.get;
  16514. return;
  16515. }
  16516. // Hook needed; redefine it so that the support test is not executed again.
  16517. return ( this.get = hookFn ).apply( this, arguments );
  16518. }
  16519. };
  16520. }
  16521. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  16522. emptyStyle = document.createElement( "div" ).style,
  16523. vendorProps = {};
  16524. // Return a vendor-prefixed property or undefined
  16525. function vendorPropName( name ) {
  16526. // Check for vendor prefixed names
  16527. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  16528. i = cssPrefixes.length;
  16529. while ( i-- ) {
  16530. name = cssPrefixes[ i ] + capName;
  16531. if ( name in emptyStyle ) {
  16532. return name;
  16533. }
  16534. }
  16535. }
  16536. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  16537. function finalPropName( name ) {
  16538. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  16539. if ( final ) {
  16540. return final;
  16541. }
  16542. if ( name in emptyStyle ) {
  16543. return name;
  16544. }
  16545. return vendorProps[ name ] = vendorPropName( name ) || name;
  16546. }
  16547. var
  16548. // Swappable if display is none or starts with table
  16549. // except "table", "table-cell", or "table-caption"
  16550. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  16551. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  16552. rcustomProp = /^--/,
  16553. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  16554. cssNormalTransform = {
  16555. letterSpacing: "0",
  16556. fontWeight: "400"
  16557. };
  16558. function setPositiveNumber( _elem, value, subtract ) {
  16559. // Any relative (+/-) values have already been
  16560. // normalized at this point
  16561. var matches = rcssNum.exec( value );
  16562. return matches ?
  16563. // Guard against undefined "subtract", e.g., when used as in cssHooks
  16564. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  16565. value;
  16566. }
  16567. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  16568. var i = dimension === "width" ? 1 : 0,
  16569. extra = 0,
  16570. delta = 0;
  16571. // Adjustment may not be necessary
  16572. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  16573. return 0;
  16574. }
  16575. for ( ; i < 4; i += 2 ) {
  16576. // Both box models exclude margin
  16577. if ( box === "margin" ) {
  16578. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  16579. }
  16580. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  16581. if ( !isBorderBox ) {
  16582. // Add padding
  16583. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  16584. // For "border" or "margin", add border
  16585. if ( box !== "padding" ) {
  16586. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  16587. // But still keep track of it otherwise
  16588. } else {
  16589. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  16590. }
  16591. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  16592. // "padding" or "margin"
  16593. } else {
  16594. // For "content", subtract padding
  16595. if ( box === "content" ) {
  16596. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  16597. }
  16598. // For "content" or "padding", subtract border
  16599. if ( box !== "margin" ) {
  16600. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  16601. }
  16602. }
  16603. }
  16604. // Account for positive content-box scroll gutter when requested by providing computedVal
  16605. if ( !isBorderBox && computedVal >= 0 ) {
  16606. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  16607. // Assuming integer scroll gutter, subtract the rest and round down
  16608. delta += Math.max( 0, Math.ceil(
  16609. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  16610. computedVal -
  16611. delta -
  16612. extra -
  16613. 0.5
  16614. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  16615. // Use an explicit zero to avoid NaN (gh-3964)
  16616. ) ) || 0;
  16617. }
  16618. return delta;
  16619. }
  16620. function getWidthOrHeight( elem, dimension, extra ) {
  16621. // Start with computed style
  16622. var styles = getStyles( elem ),
  16623. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  16624. // Fake content-box until we know it's needed to know the true value.
  16625. boxSizingNeeded = !support.boxSizingReliable() || extra,
  16626. isBorderBox = boxSizingNeeded &&
  16627. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  16628. valueIsBorderBox = isBorderBox,
  16629. val = curCSS( elem, dimension, styles ),
  16630. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  16631. // Support: Firefox <=54
  16632. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  16633. if ( rnumnonpx.test( val ) ) {
  16634. if ( !extra ) {
  16635. return val;
  16636. }
  16637. val = "auto";
  16638. }
  16639. // Support: IE 9 - 11 only
  16640. // Use offsetWidth/offsetHeight for when box sizing is unreliable.
  16641. // In those cases, the computed value can be trusted to be border-box.
  16642. if ( ( !support.boxSizingReliable() && isBorderBox ||
  16643. // Support: IE 10 - 11+, Edge 15 - 18+
  16644. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  16645. // set in CSS while `offset*` properties report correct values.
  16646. // Interestingly, in some cases IE 9 doesn't suffer from this issue.
  16647. !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
  16648. // Fall back to offsetWidth/offsetHeight when value is "auto"
  16649. // This happens for inline elements with no explicit setting (gh-3571)
  16650. val === "auto" ||
  16651. // Support: Android <=4.1 - 4.3 only
  16652. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  16653. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  16654. // Make sure the element is visible & connected
  16655. elem.getClientRects().length ) {
  16656. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  16657. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  16658. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  16659. // retrieved value as a content box dimension.
  16660. valueIsBorderBox = offsetProp in elem;
  16661. if ( valueIsBorderBox ) {
  16662. val = elem[ offsetProp ];
  16663. }
  16664. }
  16665. // Normalize "" and auto
  16666. val = parseFloat( val ) || 0;
  16667. // Adjust for the element's box model
  16668. return ( val +
  16669. boxModelAdjustment(
  16670. elem,
  16671. dimension,
  16672. extra || ( isBorderBox ? "border" : "content" ),
  16673. valueIsBorderBox,
  16674. styles,
  16675. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  16676. val
  16677. )
  16678. ) + "px";
  16679. }
  16680. jQuery.extend( {
  16681. // Add in style property hooks for overriding the default
  16682. // behavior of getting and setting a style property
  16683. cssHooks: {
  16684. opacity: {
  16685. get: function( elem, computed ) {
  16686. if ( computed ) {
  16687. // We should always get a number back from opacity
  16688. var ret = curCSS( elem, "opacity" );
  16689. return ret === "" ? "1" : ret;
  16690. }
  16691. }
  16692. }
  16693. },
  16694. // Don't automatically add "px" to these possibly-unitless properties
  16695. cssNumber: {
  16696. "animationIterationCount": true,
  16697. "columnCount": true,
  16698. "fillOpacity": true,
  16699. "flexGrow": true,
  16700. "flexShrink": true,
  16701. "fontWeight": true,
  16702. "gridArea": true,
  16703. "gridColumn": true,
  16704. "gridColumnEnd": true,
  16705. "gridColumnStart": true,
  16706. "gridRow": true,
  16707. "gridRowEnd": true,
  16708. "gridRowStart": true,
  16709. "lineHeight": true,
  16710. "opacity": true,
  16711. "order": true,
  16712. "orphans": true,
  16713. "widows": true,
  16714. "zIndex": true,
  16715. "zoom": true
  16716. },
  16717. // Add in properties whose names you wish to fix before
  16718. // setting or getting the value
  16719. cssProps: {},
  16720. // Get and set the style property on a DOM Node
  16721. style: function( elem, name, value, extra ) {
  16722. // Don't set styles on text and comment nodes
  16723. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  16724. return;
  16725. }
  16726. // Make sure that we're working with the right name
  16727. var ret, type, hooks,
  16728. origName = camelCase( name ),
  16729. isCustomProp = rcustomProp.test( name ),
  16730. style = elem.style;
  16731. // Make sure that we're working with the right name. We don't
  16732. // want to query the value if it is a CSS custom property
  16733. // since they are user-defined.
  16734. if ( !isCustomProp ) {
  16735. name = finalPropName( origName );
  16736. }
  16737. // Gets hook for the prefixed version, then unprefixed version
  16738. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  16739. // Check if we're setting a value
  16740. if ( value !== undefined ) {
  16741. type = typeof value;
  16742. // Convert "+=" or "-=" to relative numbers (#7345)
  16743. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  16744. value = adjustCSS( elem, name, ret );
  16745. // Fixes bug #9237
  16746. type = "number";
  16747. }
  16748. // Make sure that null and NaN values aren't set (#7116)
  16749. if ( value == null || value !== value ) {
  16750. return;
  16751. }
  16752. // If a number was passed in, add the unit (except for certain CSS properties)
  16753. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  16754. // "px" to a few hardcoded values.
  16755. if ( type === "number" && !isCustomProp ) {
  16756. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  16757. }
  16758. // background-* props affect original clone's values
  16759. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  16760. style[ name ] = "inherit";
  16761. }
  16762. // If a hook was provided, use that value, otherwise just set the specified value
  16763. if ( !hooks || !( "set" in hooks ) ||
  16764. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  16765. if ( isCustomProp ) {
  16766. style.setProperty( name, value );
  16767. } else {
  16768. style[ name ] = value;
  16769. }
  16770. }
  16771. } else {
  16772. // If a hook was provided get the non-computed value from there
  16773. if ( hooks && "get" in hooks &&
  16774. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  16775. return ret;
  16776. }
  16777. // Otherwise just get the value from the style object
  16778. return style[ name ];
  16779. }
  16780. },
  16781. css: function( elem, name, extra, styles ) {
  16782. var val, num, hooks,
  16783. origName = camelCase( name ),
  16784. isCustomProp = rcustomProp.test( name );
  16785. // Make sure that we're working with the right name. We don't
  16786. // want to modify the value if it is a CSS custom property
  16787. // since they are user-defined.
  16788. if ( !isCustomProp ) {
  16789. name = finalPropName( origName );
  16790. }
  16791. // Try prefixed name followed by the unprefixed name
  16792. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  16793. // If a hook was provided get the computed value from there
  16794. if ( hooks && "get" in hooks ) {
  16795. val = hooks.get( elem, true, extra );
  16796. }
  16797. // Otherwise, if a way to get the computed value exists, use that
  16798. if ( val === undefined ) {
  16799. val = curCSS( elem, name, styles );
  16800. }
  16801. // Convert "normal" to computed value
  16802. if ( val === "normal" && name in cssNormalTransform ) {
  16803. val = cssNormalTransform[ name ];
  16804. }
  16805. // Make numeric if forced or a qualifier was provided and val looks numeric
  16806. if ( extra === "" || extra ) {
  16807. num = parseFloat( val );
  16808. return extra === true || isFinite( num ) ? num || 0 : val;
  16809. }
  16810. return val;
  16811. }
  16812. } );
  16813. jQuery.each( [ "height", "width" ], function( _i, dimension ) {
  16814. jQuery.cssHooks[ dimension ] = {
  16815. get: function( elem, computed, extra ) {
  16816. if ( computed ) {
  16817. // Certain elements can have dimension info if we invisibly show them
  16818. // but it must have a current display style that would benefit
  16819. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  16820. // Support: Safari 8+
  16821. // Table columns in Safari have non-zero offsetWidth & zero
  16822. // getBoundingClientRect().width unless display is changed.
  16823. // Support: IE <=11 only
  16824. // Running getBoundingClientRect on a disconnected node
  16825. // in IE throws an error.
  16826. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  16827. swap( elem, cssShow, function() {
  16828. return getWidthOrHeight( elem, dimension, extra );
  16829. } ) :
  16830. getWidthOrHeight( elem, dimension, extra );
  16831. }
  16832. },
  16833. set: function( elem, value, extra ) {
  16834. var matches,
  16835. styles = getStyles( elem ),
  16836. // Only read styles.position if the test has a chance to fail
  16837. // to avoid forcing a reflow.
  16838. scrollboxSizeBuggy = !support.scrollboxSize() &&
  16839. styles.position === "absolute",
  16840. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  16841. boxSizingNeeded = scrollboxSizeBuggy || extra,
  16842. isBorderBox = boxSizingNeeded &&
  16843. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  16844. subtract = extra ?
  16845. boxModelAdjustment(
  16846. elem,
  16847. dimension,
  16848. extra,
  16849. isBorderBox,
  16850. styles
  16851. ) :
  16852. 0;
  16853. // Account for unreliable border-box dimensions by comparing offset* to computed and
  16854. // faking a content-box to get border and padding (gh-3699)
  16855. if ( isBorderBox && scrollboxSizeBuggy ) {
  16856. subtract -= Math.ceil(
  16857. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  16858. parseFloat( styles[ dimension ] ) -
  16859. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  16860. 0.5
  16861. );
  16862. }
  16863. // Convert to pixels if value adjustment is needed
  16864. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  16865. ( matches[ 3 ] || "px" ) !== "px" ) {
  16866. elem.style[ dimension ] = value;
  16867. value = jQuery.css( elem, dimension );
  16868. }
  16869. return setPositiveNumber( elem, value, subtract );
  16870. }
  16871. };
  16872. } );
  16873. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  16874. function( elem, computed ) {
  16875. if ( computed ) {
  16876. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  16877. elem.getBoundingClientRect().left -
  16878. swap( elem, { marginLeft: 0 }, function() {
  16879. return elem.getBoundingClientRect().left;
  16880. } )
  16881. ) + "px";
  16882. }
  16883. }
  16884. );
  16885. // These hooks are used by animate to expand properties
  16886. jQuery.each( {
  16887. margin: "",
  16888. padding: "",
  16889. border: "Width"
  16890. }, function( prefix, suffix ) {
  16891. jQuery.cssHooks[ prefix + suffix ] = {
  16892. expand: function( value ) {
  16893. var i = 0,
  16894. expanded = {},
  16895. // Assumes a single number if not a string
  16896. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  16897. for ( ; i < 4; i++ ) {
  16898. expanded[ prefix + cssExpand[ i ] + suffix ] =
  16899. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  16900. }
  16901. return expanded;
  16902. }
  16903. };
  16904. if ( prefix !== "margin" ) {
  16905. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  16906. }
  16907. } );
  16908. jQuery.fn.extend( {
  16909. css: function( name, value ) {
  16910. return access( this, function( elem, name, value ) {
  16911. var styles, len,
  16912. map = {},
  16913. i = 0;
  16914. if ( Array.isArray( name ) ) {
  16915. styles = getStyles( elem );
  16916. len = name.length;
  16917. for ( ; i < len; i++ ) {
  16918. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  16919. }
  16920. return map;
  16921. }
  16922. return value !== undefined ?
  16923. jQuery.style( elem, name, value ) :
  16924. jQuery.css( elem, name );
  16925. }, name, value, arguments.length > 1 );
  16926. }
  16927. } );
  16928. function Tween( elem, options, prop, end, easing ) {
  16929. return new Tween.prototype.init( elem, options, prop, end, easing );
  16930. }
  16931. jQuery.Tween = Tween;
  16932. Tween.prototype = {
  16933. constructor: Tween,
  16934. init: function( elem, options, prop, end, easing, unit ) {
  16935. this.elem = elem;
  16936. this.prop = prop;
  16937. this.easing = easing || jQuery.easing._default;
  16938. this.options = options;
  16939. this.start = this.now = this.cur();
  16940. this.end = end;
  16941. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  16942. },
  16943. cur: function() {
  16944. var hooks = Tween.propHooks[ this.prop ];
  16945. return hooks && hooks.get ?
  16946. hooks.get( this ) :
  16947. Tween.propHooks._default.get( this );
  16948. },
  16949. run: function( percent ) {
  16950. var eased,
  16951. hooks = Tween.propHooks[ this.prop ];
  16952. if ( this.options.duration ) {
  16953. this.pos = eased = jQuery.easing[ this.easing ](
  16954. percent, this.options.duration * percent, 0, 1, this.options.duration
  16955. );
  16956. } else {
  16957. this.pos = eased = percent;
  16958. }
  16959. this.now = ( this.end - this.start ) * eased + this.start;
  16960. if ( this.options.step ) {
  16961. this.options.step.call( this.elem, this.now, this );
  16962. }
  16963. if ( hooks && hooks.set ) {
  16964. hooks.set( this );
  16965. } else {
  16966. Tween.propHooks._default.set( this );
  16967. }
  16968. return this;
  16969. }
  16970. };
  16971. Tween.prototype.init.prototype = Tween.prototype;
  16972. Tween.propHooks = {
  16973. _default: {
  16974. get: function( tween ) {
  16975. var result;
  16976. // Use a property on the element directly when it is not a DOM element,
  16977. // or when there is no matching style property that exists.
  16978. if ( tween.elem.nodeType !== 1 ||
  16979. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  16980. return tween.elem[ tween.prop ];
  16981. }
  16982. // Passing an empty string as a 3rd parameter to .css will automatically
  16983. // attempt a parseFloat and fallback to a string if the parse fails.
  16984. // Simple values such as "10px" are parsed to Float;
  16985. // complex values such as "rotate(1rad)" are returned as-is.
  16986. result = jQuery.css( tween.elem, tween.prop, "" );
  16987. // Empty strings, null, undefined and "auto" are converted to 0.
  16988. return !result || result === "auto" ? 0 : result;
  16989. },
  16990. set: function( tween ) {
  16991. // Use step hook for back compat.
  16992. // Use cssHook if its there.
  16993. // Use .style if available and use plain properties where available.
  16994. if ( jQuery.fx.step[ tween.prop ] ) {
  16995. jQuery.fx.step[ tween.prop ]( tween );
  16996. } else if ( tween.elem.nodeType === 1 && (
  16997. jQuery.cssHooks[ tween.prop ] ||
  16998. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  16999. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  17000. } else {
  17001. tween.elem[ tween.prop ] = tween.now;
  17002. }
  17003. }
  17004. }
  17005. };
  17006. // Support: IE <=9 only
  17007. // Panic based approach to setting things on disconnected nodes
  17008. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  17009. set: function( tween ) {
  17010. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  17011. tween.elem[ tween.prop ] = tween.now;
  17012. }
  17013. }
  17014. };
  17015. jQuery.easing = {
  17016. linear: function( p ) {
  17017. return p;
  17018. },
  17019. swing: function( p ) {
  17020. return 0.5 - Math.cos( p * Math.PI ) / 2;
  17021. },
  17022. _default: "swing"
  17023. };
  17024. jQuery.fx = Tween.prototype.init;
  17025. // Back compat <1.8 extension point
  17026. jQuery.fx.step = {};
  17027. var
  17028. fxNow, inProgress,
  17029. rfxtypes = /^(?:toggle|show|hide)$/,
  17030. rrun = /queueHooks$/;
  17031. function schedule() {
  17032. if ( inProgress ) {
  17033. if ( document.hidden === false && window.requestAnimationFrame ) {
  17034. window.requestAnimationFrame( schedule );
  17035. } else {
  17036. window.setTimeout( schedule, jQuery.fx.interval );
  17037. }
  17038. jQuery.fx.tick();
  17039. }
  17040. }
  17041. // Animations created synchronously will run synchronously
  17042. function createFxNow() {
  17043. window.setTimeout( function() {
  17044. fxNow = undefined;
  17045. } );
  17046. return ( fxNow = Date.now() );
  17047. }
  17048. // Generate parameters to create a standard animation
  17049. function genFx( type, includeWidth ) {
  17050. var which,
  17051. i = 0,
  17052. attrs = { height: type };
  17053. // If we include width, step value is 1 to do all cssExpand values,
  17054. // otherwise step value is 2 to skip over Left and Right
  17055. includeWidth = includeWidth ? 1 : 0;
  17056. for ( ; i < 4; i += 2 - includeWidth ) {
  17057. which = cssExpand[ i ];
  17058. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  17059. }
  17060. if ( includeWidth ) {
  17061. attrs.opacity = attrs.width = type;
  17062. }
  17063. return attrs;
  17064. }
  17065. function createTween( value, prop, animation ) {
  17066. var tween,
  17067. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  17068. index = 0,
  17069. length = collection.length;
  17070. for ( ; index < length; index++ ) {
  17071. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  17072. // We're done with this property
  17073. return tween;
  17074. }
  17075. }
  17076. }
  17077. function defaultPrefilter( elem, props, opts ) {
  17078. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  17079. isBox = "width" in props || "height" in props,
  17080. anim = this,
  17081. orig = {},
  17082. style = elem.style,
  17083. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  17084. dataShow = dataPriv.get( elem, "fxshow" );
  17085. // Queue-skipping animations hijack the fx hooks
  17086. if ( !opts.queue ) {
  17087. hooks = jQuery._queueHooks( elem, "fx" );
  17088. if ( hooks.unqueued == null ) {
  17089. hooks.unqueued = 0;
  17090. oldfire = hooks.empty.fire;
  17091. hooks.empty.fire = function() {
  17092. if ( !hooks.unqueued ) {
  17093. oldfire();
  17094. }
  17095. };
  17096. }
  17097. hooks.unqueued++;
  17098. anim.always( function() {
  17099. // Ensure the complete handler is called before this completes
  17100. anim.always( function() {
  17101. hooks.unqueued--;
  17102. if ( !jQuery.queue( elem, "fx" ).length ) {
  17103. hooks.empty.fire();
  17104. }
  17105. } );
  17106. } );
  17107. }
  17108. // Detect show/hide animations
  17109. for ( prop in props ) {
  17110. value = props[ prop ];
  17111. if ( rfxtypes.test( value ) ) {
  17112. delete props[ prop ];
  17113. toggle = toggle || value === "toggle";
  17114. if ( value === ( hidden ? "hide" : "show" ) ) {
  17115. // Pretend to be hidden if this is a "show" and
  17116. // there is still data from a stopped show/hide
  17117. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  17118. hidden = true;
  17119. // Ignore all other no-op show/hide data
  17120. } else {
  17121. continue;
  17122. }
  17123. }
  17124. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  17125. }
  17126. }
  17127. // Bail out if this is a no-op like .hide().hide()
  17128. propTween = !jQuery.isEmptyObject( props );
  17129. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  17130. return;
  17131. }
  17132. // Restrict "overflow" and "display" styles during box animations
  17133. if ( isBox && elem.nodeType === 1 ) {
  17134. // Support: IE <=9 - 11, Edge 12 - 15
  17135. // Record all 3 overflow attributes because IE does not infer the shorthand
  17136. // from identically-valued overflowX and overflowY and Edge just mirrors
  17137. // the overflowX value there.
  17138. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  17139. // Identify a display type, preferring old show/hide data over the CSS cascade
  17140. restoreDisplay = dataShow && dataShow.display;
  17141. if ( restoreDisplay == null ) {
  17142. restoreDisplay = dataPriv.get( elem, "display" );
  17143. }
  17144. display = jQuery.css( elem, "display" );
  17145. if ( display === "none" ) {
  17146. if ( restoreDisplay ) {
  17147. display = restoreDisplay;
  17148. } else {
  17149. // Get nonempty value(s) by temporarily forcing visibility
  17150. showHide( [ elem ], true );
  17151. restoreDisplay = elem.style.display || restoreDisplay;
  17152. display = jQuery.css( elem, "display" );
  17153. showHide( [ elem ] );
  17154. }
  17155. }
  17156. // Animate inline elements as inline-block
  17157. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  17158. if ( jQuery.css( elem, "float" ) === "none" ) {
  17159. // Restore the original display value at the end of pure show/hide animations
  17160. if ( !propTween ) {
  17161. anim.done( function() {
  17162. style.display = restoreDisplay;
  17163. } );
  17164. if ( restoreDisplay == null ) {
  17165. display = style.display;
  17166. restoreDisplay = display === "none" ? "" : display;
  17167. }
  17168. }
  17169. style.display = "inline-block";
  17170. }
  17171. }
  17172. }
  17173. if ( opts.overflow ) {
  17174. style.overflow = "hidden";
  17175. anim.always( function() {
  17176. style.overflow = opts.overflow[ 0 ];
  17177. style.overflowX = opts.overflow[ 1 ];
  17178. style.overflowY = opts.overflow[ 2 ];
  17179. } );
  17180. }
  17181. // Implement show/hide animations
  17182. propTween = false;
  17183. for ( prop in orig ) {
  17184. // General show/hide setup for this element animation
  17185. if ( !propTween ) {
  17186. if ( dataShow ) {
  17187. if ( "hidden" in dataShow ) {
  17188. hidden = dataShow.hidden;
  17189. }
  17190. } else {
  17191. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  17192. }
  17193. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  17194. if ( toggle ) {
  17195. dataShow.hidden = !hidden;
  17196. }
  17197. // Show elements before animating them
  17198. if ( hidden ) {
  17199. showHide( [ elem ], true );
  17200. }
  17201. /* eslint-disable no-loop-func */
  17202. anim.done( function() {
  17203. /* eslint-enable no-loop-func */
  17204. // The final step of a "hide" animation is actually hiding the element
  17205. if ( !hidden ) {
  17206. showHide( [ elem ] );
  17207. }
  17208. dataPriv.remove( elem, "fxshow" );
  17209. for ( prop in orig ) {
  17210. jQuery.style( elem, prop, orig[ prop ] );
  17211. }
  17212. } );
  17213. }
  17214. // Per-property setup
  17215. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  17216. if ( !( prop in dataShow ) ) {
  17217. dataShow[ prop ] = propTween.start;
  17218. if ( hidden ) {
  17219. propTween.end = propTween.start;
  17220. propTween.start = 0;
  17221. }
  17222. }
  17223. }
  17224. }
  17225. function propFilter( props, specialEasing ) {
  17226. var index, name, easing, value, hooks;
  17227. // camelCase, specialEasing and expand cssHook pass
  17228. for ( index in props ) {
  17229. name = camelCase( index );
  17230. easing = specialEasing[ name ];
  17231. value = props[ index ];
  17232. if ( Array.isArray( value ) ) {
  17233. easing = value[ 1 ];
  17234. value = props[ index ] = value[ 0 ];
  17235. }
  17236. if ( index !== name ) {
  17237. props[ name ] = value;
  17238. delete props[ index ];
  17239. }
  17240. hooks = jQuery.cssHooks[ name ];
  17241. if ( hooks && "expand" in hooks ) {
  17242. value = hooks.expand( value );
  17243. delete props[ name ];
  17244. // Not quite $.extend, this won't overwrite existing keys.
  17245. // Reusing 'index' because we have the correct "name"
  17246. for ( index in value ) {
  17247. if ( !( index in props ) ) {
  17248. props[ index ] = value[ index ];
  17249. specialEasing[ index ] = easing;
  17250. }
  17251. }
  17252. } else {
  17253. specialEasing[ name ] = easing;
  17254. }
  17255. }
  17256. }
  17257. function Animation( elem, properties, options ) {
  17258. var result,
  17259. stopped,
  17260. index = 0,
  17261. length = Animation.prefilters.length,
  17262. deferred = jQuery.Deferred().always( function() {
  17263. // Don't match elem in the :animated selector
  17264. delete tick.elem;
  17265. } ),
  17266. tick = function() {
  17267. if ( stopped ) {
  17268. return false;
  17269. }
  17270. var currentTime = fxNow || createFxNow(),
  17271. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  17272. // Support: Android 2.3 only
  17273. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  17274. temp = remaining / animation.duration || 0,
  17275. percent = 1 - temp,
  17276. index = 0,
  17277. length = animation.tweens.length;
  17278. for ( ; index < length; index++ ) {
  17279. animation.tweens[ index ].run( percent );
  17280. }
  17281. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  17282. // If there's more to do, yield
  17283. if ( percent < 1 && length ) {
  17284. return remaining;
  17285. }
  17286. // If this was an empty animation, synthesize a final progress notification
  17287. if ( !length ) {
  17288. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  17289. }
  17290. // Resolve the animation and report its conclusion
  17291. deferred.resolveWith( elem, [ animation ] );
  17292. return false;
  17293. },
  17294. animation = deferred.promise( {
  17295. elem: elem,
  17296. props: jQuery.extend( {}, properties ),
  17297. opts: jQuery.extend( true, {
  17298. specialEasing: {},
  17299. easing: jQuery.easing._default
  17300. }, options ),
  17301. originalProperties: properties,
  17302. originalOptions: options,
  17303. startTime: fxNow || createFxNow(),
  17304. duration: options.duration,
  17305. tweens: [],
  17306. createTween: function( prop, end ) {
  17307. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  17308. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  17309. animation.tweens.push( tween );
  17310. return tween;
  17311. },
  17312. stop: function( gotoEnd ) {
  17313. var index = 0,
  17314. // If we are going to the end, we want to run all the tweens
  17315. // otherwise we skip this part
  17316. length = gotoEnd ? animation.tweens.length : 0;
  17317. if ( stopped ) {
  17318. return this;
  17319. }
  17320. stopped = true;
  17321. for ( ; index < length; index++ ) {
  17322. animation.tweens[ index ].run( 1 );
  17323. }
  17324. // Resolve when we played the last frame; otherwise, reject
  17325. if ( gotoEnd ) {
  17326. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  17327. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  17328. } else {
  17329. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  17330. }
  17331. return this;
  17332. }
  17333. } ),
  17334. props = animation.props;
  17335. propFilter( props, animation.opts.specialEasing );
  17336. for ( ; index < length; index++ ) {
  17337. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  17338. if ( result ) {
  17339. if ( isFunction( result.stop ) ) {
  17340. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  17341. result.stop.bind( result );
  17342. }
  17343. return result;
  17344. }
  17345. }
  17346. jQuery.map( props, createTween, animation );
  17347. if ( isFunction( animation.opts.start ) ) {
  17348. animation.opts.start.call( elem, animation );
  17349. }
  17350. // Attach callbacks from options
  17351. animation
  17352. .progress( animation.opts.progress )
  17353. .done( animation.opts.done, animation.opts.complete )
  17354. .fail( animation.opts.fail )
  17355. .always( animation.opts.always );
  17356. jQuery.fx.timer(
  17357. jQuery.extend( tick, {
  17358. elem: elem,
  17359. anim: animation,
  17360. queue: animation.opts.queue
  17361. } )
  17362. );
  17363. return animation;
  17364. }
  17365. jQuery.Animation = jQuery.extend( Animation, {
  17366. tweeners: {
  17367. "*": [ function( prop, value ) {
  17368. var tween = this.createTween( prop, value );
  17369. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  17370. return tween;
  17371. } ]
  17372. },
  17373. tweener: function( props, callback ) {
  17374. if ( isFunction( props ) ) {
  17375. callback = props;
  17376. props = [ "*" ];
  17377. } else {
  17378. props = props.match( rnothtmlwhite );
  17379. }
  17380. var prop,
  17381. index = 0,
  17382. length = props.length;
  17383. for ( ; index < length; index++ ) {
  17384. prop = props[ index ];
  17385. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  17386. Animation.tweeners[ prop ].unshift( callback );
  17387. }
  17388. },
  17389. prefilters: [ defaultPrefilter ],
  17390. prefilter: function( callback, prepend ) {
  17391. if ( prepend ) {
  17392. Animation.prefilters.unshift( callback );
  17393. } else {
  17394. Animation.prefilters.push( callback );
  17395. }
  17396. }
  17397. } );
  17398. jQuery.speed = function( speed, easing, fn ) {
  17399. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  17400. complete: fn || !fn && easing ||
  17401. isFunction( speed ) && speed,
  17402. duration: speed,
  17403. easing: fn && easing || easing && !isFunction( easing ) && easing
  17404. };
  17405. // Go to the end state if fx are off
  17406. if ( jQuery.fx.off ) {
  17407. opt.duration = 0;
  17408. } else {
  17409. if ( typeof opt.duration !== "number" ) {
  17410. if ( opt.duration in jQuery.fx.speeds ) {
  17411. opt.duration = jQuery.fx.speeds[ opt.duration ];
  17412. } else {
  17413. opt.duration = jQuery.fx.speeds._default;
  17414. }
  17415. }
  17416. }
  17417. // Normalize opt.queue - true/undefined/null -> "fx"
  17418. if ( opt.queue == null || opt.queue === true ) {
  17419. opt.queue = "fx";
  17420. }
  17421. // Queueing
  17422. opt.old = opt.complete;
  17423. opt.complete = function() {
  17424. if ( isFunction( opt.old ) ) {
  17425. opt.old.call( this );
  17426. }
  17427. if ( opt.queue ) {
  17428. jQuery.dequeue( this, opt.queue );
  17429. }
  17430. };
  17431. return opt;
  17432. };
  17433. jQuery.fn.extend( {
  17434. fadeTo: function( speed, to, easing, callback ) {
  17435. // Show any hidden elements after setting opacity to 0
  17436. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  17437. // Animate to the value specified
  17438. .end().animate( { opacity: to }, speed, easing, callback );
  17439. },
  17440. animate: function( prop, speed, easing, callback ) {
  17441. var empty = jQuery.isEmptyObject( prop ),
  17442. optall = jQuery.speed( speed, easing, callback ),
  17443. doAnimation = function() {
  17444. // Operate on a copy of prop so per-property easing won't be lost
  17445. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  17446. // Empty animations, or finishing resolves immediately
  17447. if ( empty || dataPriv.get( this, "finish" ) ) {
  17448. anim.stop( true );
  17449. }
  17450. };
  17451. doAnimation.finish = doAnimation;
  17452. return empty || optall.queue === false ?
  17453. this.each( doAnimation ) :
  17454. this.queue( optall.queue, doAnimation );
  17455. },
  17456. stop: function( type, clearQueue, gotoEnd ) {
  17457. var stopQueue = function( hooks ) {
  17458. var stop = hooks.stop;
  17459. delete hooks.stop;
  17460. stop( gotoEnd );
  17461. };
  17462. if ( typeof type !== "string" ) {
  17463. gotoEnd = clearQueue;
  17464. clearQueue = type;
  17465. type = undefined;
  17466. }
  17467. if ( clearQueue ) {
  17468. this.queue( type || "fx", [] );
  17469. }
  17470. return this.each( function() {
  17471. var dequeue = true,
  17472. index = type != null && type + "queueHooks",
  17473. timers = jQuery.timers,
  17474. data = dataPriv.get( this );
  17475. if ( index ) {
  17476. if ( data[ index ] && data[ index ].stop ) {
  17477. stopQueue( data[ index ] );
  17478. }
  17479. } else {
  17480. for ( index in data ) {
  17481. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  17482. stopQueue( data[ index ] );
  17483. }
  17484. }
  17485. }
  17486. for ( index = timers.length; index--; ) {
  17487. if ( timers[ index ].elem === this &&
  17488. ( type == null || timers[ index ].queue === type ) ) {
  17489. timers[ index ].anim.stop( gotoEnd );
  17490. dequeue = false;
  17491. timers.splice( index, 1 );
  17492. }
  17493. }
  17494. // Start the next in the queue if the last step wasn't forced.
  17495. // Timers currently will call their complete callbacks, which
  17496. // will dequeue but only if they were gotoEnd.
  17497. if ( dequeue || !gotoEnd ) {
  17498. jQuery.dequeue( this, type );
  17499. }
  17500. } );
  17501. },
  17502. finish: function( type ) {
  17503. if ( type !== false ) {
  17504. type = type || "fx";
  17505. }
  17506. return this.each( function() {
  17507. var index,
  17508. data = dataPriv.get( this ),
  17509. queue = data[ type + "queue" ],
  17510. hooks = data[ type + "queueHooks" ],
  17511. timers = jQuery.timers,
  17512. length = queue ? queue.length : 0;
  17513. // Enable finishing flag on private data
  17514. data.finish = true;
  17515. // Empty the queue first
  17516. jQuery.queue( this, type, [] );
  17517. if ( hooks && hooks.stop ) {
  17518. hooks.stop.call( this, true );
  17519. }
  17520. // Look for any active animations, and finish them
  17521. for ( index = timers.length; index--; ) {
  17522. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  17523. timers[ index ].anim.stop( true );
  17524. timers.splice( index, 1 );
  17525. }
  17526. }
  17527. // Look for any animations in the old queue and finish them
  17528. for ( index = 0; index < length; index++ ) {
  17529. if ( queue[ index ] && queue[ index ].finish ) {
  17530. queue[ index ].finish.call( this );
  17531. }
  17532. }
  17533. // Turn off finishing flag
  17534. delete data.finish;
  17535. } );
  17536. }
  17537. } );
  17538. jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
  17539. var cssFn = jQuery.fn[ name ];
  17540. jQuery.fn[ name ] = function( speed, easing, callback ) {
  17541. return speed == null || typeof speed === "boolean" ?
  17542. cssFn.apply( this, arguments ) :
  17543. this.animate( genFx( name, true ), speed, easing, callback );
  17544. };
  17545. } );
  17546. // Generate shortcuts for custom animations
  17547. jQuery.each( {
  17548. slideDown: genFx( "show" ),
  17549. slideUp: genFx( "hide" ),
  17550. slideToggle: genFx( "toggle" ),
  17551. fadeIn: { opacity: "show" },
  17552. fadeOut: { opacity: "hide" },
  17553. fadeToggle: { opacity: "toggle" }
  17554. }, function( name, props ) {
  17555. jQuery.fn[ name ] = function( speed, easing, callback ) {
  17556. return this.animate( props, speed, easing, callback );
  17557. };
  17558. } );
  17559. jQuery.timers = [];
  17560. jQuery.fx.tick = function() {
  17561. var timer,
  17562. i = 0,
  17563. timers = jQuery.timers;
  17564. fxNow = Date.now();
  17565. for ( ; i < timers.length; i++ ) {
  17566. timer = timers[ i ];
  17567. // Run the timer and safely remove it when done (allowing for external removal)
  17568. if ( !timer() && timers[ i ] === timer ) {
  17569. timers.splice( i--, 1 );
  17570. }
  17571. }
  17572. if ( !timers.length ) {
  17573. jQuery.fx.stop();
  17574. }
  17575. fxNow = undefined;
  17576. };
  17577. jQuery.fx.timer = function( timer ) {
  17578. jQuery.timers.push( timer );
  17579. jQuery.fx.start();
  17580. };
  17581. jQuery.fx.interval = 13;
  17582. jQuery.fx.start = function() {
  17583. if ( inProgress ) {
  17584. return;
  17585. }
  17586. inProgress = true;
  17587. schedule();
  17588. };
  17589. jQuery.fx.stop = function() {
  17590. inProgress = null;
  17591. };
  17592. jQuery.fx.speeds = {
  17593. slow: 600,
  17594. fast: 200,
  17595. // Default speed
  17596. _default: 400
  17597. };
  17598. // Based off of the plugin by Clint Helfers, with permission.
  17599. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  17600. jQuery.fn.delay = function( time, type ) {
  17601. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  17602. type = type || "fx";
  17603. return this.queue( type, function( next, hooks ) {
  17604. var timeout = window.setTimeout( next, time );
  17605. hooks.stop = function() {
  17606. window.clearTimeout( timeout );
  17607. };
  17608. } );
  17609. };
  17610. ( function() {
  17611. var input = document.createElement( "input" ),
  17612. select = document.createElement( "select" ),
  17613. opt = select.appendChild( document.createElement( "option" ) );
  17614. input.type = "checkbox";
  17615. // Support: Android <=4.3 only
  17616. // Default value for a checkbox should be "on"
  17617. support.checkOn = input.value !== "";
  17618. // Support: IE <=11 only
  17619. // Must access selectedIndex to make default options select
  17620. support.optSelected = opt.selected;
  17621. // Support: IE <=11 only
  17622. // An input loses its value after becoming a radio
  17623. input = document.createElement( "input" );
  17624. input.value = "t";
  17625. input.type = "radio";
  17626. support.radioValue = input.value === "t";
  17627. } )();
  17628. var boolHook,
  17629. attrHandle = jQuery.expr.attrHandle;
  17630. jQuery.fn.extend( {
  17631. attr: function( name, value ) {
  17632. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  17633. },
  17634. removeAttr: function( name ) {
  17635. return this.each( function() {
  17636. jQuery.removeAttr( this, name );
  17637. } );
  17638. }
  17639. } );
  17640. jQuery.extend( {
  17641. attr: function( elem, name, value ) {
  17642. var ret, hooks,
  17643. nType = elem.nodeType;
  17644. // Don't get/set attributes on text, comment and attribute nodes
  17645. if ( nType === 3 || nType === 8 || nType === 2 ) {
  17646. return;
  17647. }
  17648. // Fallback to prop when attributes are not supported
  17649. if ( typeof elem.getAttribute === "undefined" ) {
  17650. return jQuery.prop( elem, name, value );
  17651. }
  17652. // Attribute hooks are determined by the lowercase version
  17653. // Grab necessary hook if one is defined
  17654. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  17655. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  17656. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  17657. }
  17658. if ( value !== undefined ) {
  17659. if ( value === null ) {
  17660. jQuery.removeAttr( elem, name );
  17661. return;
  17662. }
  17663. if ( hooks && "set" in hooks &&
  17664. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  17665. return ret;
  17666. }
  17667. elem.setAttribute( name, value + "" );
  17668. return value;
  17669. }
  17670. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  17671. return ret;
  17672. }
  17673. ret = jQuery.find.attr( elem, name );
  17674. // Non-existent attributes return null, we normalize to undefined
  17675. return ret == null ? undefined : ret;
  17676. },
  17677. attrHooks: {
  17678. type: {
  17679. set: function( elem, value ) {
  17680. if ( !support.radioValue && value === "radio" &&
  17681. nodeName( elem, "input" ) ) {
  17682. var val = elem.value;
  17683. elem.setAttribute( "type", value );
  17684. if ( val ) {
  17685. elem.value = val;
  17686. }
  17687. return value;
  17688. }
  17689. }
  17690. }
  17691. },
  17692. removeAttr: function( elem, value ) {
  17693. var name,
  17694. i = 0,
  17695. // Attribute names can contain non-HTML whitespace characters
  17696. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  17697. attrNames = value && value.match( rnothtmlwhite );
  17698. if ( attrNames && elem.nodeType === 1 ) {
  17699. while ( ( name = attrNames[ i++ ] ) ) {
  17700. elem.removeAttribute( name );
  17701. }
  17702. }
  17703. }
  17704. } );
  17705. // Hooks for boolean attributes
  17706. boolHook = {
  17707. set: function( elem, value, name ) {
  17708. if ( value === false ) {
  17709. // Remove boolean attributes when set to false
  17710. jQuery.removeAttr( elem, name );
  17711. } else {
  17712. elem.setAttribute( name, name );
  17713. }
  17714. return name;
  17715. }
  17716. };
  17717. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
  17718. var getter = attrHandle[ name ] || jQuery.find.attr;
  17719. attrHandle[ name ] = function( elem, name, isXML ) {
  17720. var ret, handle,
  17721. lowercaseName = name.toLowerCase();
  17722. if ( !isXML ) {
  17723. // Avoid an infinite loop by temporarily removing this function from the getter
  17724. handle = attrHandle[ lowercaseName ];
  17725. attrHandle[ lowercaseName ] = ret;
  17726. ret = getter( elem, name, isXML ) != null ?
  17727. lowercaseName :
  17728. null;
  17729. attrHandle[ lowercaseName ] = handle;
  17730. }
  17731. return ret;
  17732. };
  17733. } );
  17734. var rfocusable = /^(?:input|select|textarea|button)$/i,
  17735. rclickable = /^(?:a|area)$/i;
  17736. jQuery.fn.extend( {
  17737. prop: function( name, value ) {
  17738. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  17739. },
  17740. removeProp: function( name ) {
  17741. return this.each( function() {
  17742. delete this[ jQuery.propFix[ name ] || name ];
  17743. } );
  17744. }
  17745. } );
  17746. jQuery.extend( {
  17747. prop: function( elem, name, value ) {
  17748. var ret, hooks,
  17749. nType = elem.nodeType;
  17750. // Don't get/set properties on text, comment and attribute nodes
  17751. if ( nType === 3 || nType === 8 || nType === 2 ) {
  17752. return;
  17753. }
  17754. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  17755. // Fix name and attach hooks
  17756. name = jQuery.propFix[ name ] || name;
  17757. hooks = jQuery.propHooks[ name ];
  17758. }
  17759. if ( value !== undefined ) {
  17760. if ( hooks && "set" in hooks &&
  17761. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  17762. return ret;
  17763. }
  17764. return ( elem[ name ] = value );
  17765. }
  17766. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  17767. return ret;
  17768. }
  17769. return elem[ name ];
  17770. },
  17771. propHooks: {
  17772. tabIndex: {
  17773. get: function( elem ) {
  17774. // Support: IE <=9 - 11 only
  17775. // elem.tabIndex doesn't always return the
  17776. // correct value when it hasn't been explicitly set
  17777. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  17778. // Use proper attribute retrieval(#12072)
  17779. var tabindex = jQuery.find.attr( elem, "tabindex" );
  17780. if ( tabindex ) {
  17781. return parseInt( tabindex, 10 );
  17782. }
  17783. if (
  17784. rfocusable.test( elem.nodeName ) ||
  17785. rclickable.test( elem.nodeName ) &&
  17786. elem.href
  17787. ) {
  17788. return 0;
  17789. }
  17790. return -1;
  17791. }
  17792. }
  17793. },
  17794. propFix: {
  17795. "for": "htmlFor",
  17796. "class": "className"
  17797. }
  17798. } );
  17799. // Support: IE <=11 only
  17800. // Accessing the selectedIndex property
  17801. // forces the browser to respect setting selected
  17802. // on the option
  17803. // The getter ensures a default option is selected
  17804. // when in an optgroup
  17805. // eslint rule "no-unused-expressions" is disabled for this code
  17806. // since it considers such accessions noop
  17807. if ( !support.optSelected ) {
  17808. jQuery.propHooks.selected = {
  17809. get: function( elem ) {
  17810. /* eslint no-unused-expressions: "off" */
  17811. var parent = elem.parentNode;
  17812. if ( parent && parent.parentNode ) {
  17813. parent.parentNode.selectedIndex;
  17814. }
  17815. return null;
  17816. },
  17817. set: function( elem ) {
  17818. /* eslint no-unused-expressions: "off" */
  17819. var parent = elem.parentNode;
  17820. if ( parent ) {
  17821. parent.selectedIndex;
  17822. if ( parent.parentNode ) {
  17823. parent.parentNode.selectedIndex;
  17824. }
  17825. }
  17826. }
  17827. };
  17828. }
  17829. jQuery.each( [
  17830. "tabIndex",
  17831. "readOnly",
  17832. "maxLength",
  17833. "cellSpacing",
  17834. "cellPadding",
  17835. "rowSpan",
  17836. "colSpan",
  17837. "useMap",
  17838. "frameBorder",
  17839. "contentEditable"
  17840. ], function() {
  17841. jQuery.propFix[ this.toLowerCase() ] = this;
  17842. } );
  17843. // Strip and collapse whitespace according to HTML spec
  17844. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  17845. function stripAndCollapse( value ) {
  17846. var tokens = value.match( rnothtmlwhite ) || [];
  17847. return tokens.join( " " );
  17848. }
  17849. function getClass( elem ) {
  17850. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  17851. }
  17852. function classesToArray( value ) {
  17853. if ( Array.isArray( value ) ) {
  17854. return value;
  17855. }
  17856. if ( typeof value === "string" ) {
  17857. return value.match( rnothtmlwhite ) || [];
  17858. }
  17859. return [];
  17860. }
  17861. jQuery.fn.extend( {
  17862. addClass: function( value ) {
  17863. var classes, elem, cur, curValue, clazz, j, finalValue,
  17864. i = 0;
  17865. if ( isFunction( value ) ) {
  17866. return this.each( function( j ) {
  17867. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  17868. } );
  17869. }
  17870. classes = classesToArray( value );
  17871. if ( classes.length ) {
  17872. while ( ( elem = this[ i++ ] ) ) {
  17873. curValue = getClass( elem );
  17874. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  17875. if ( cur ) {
  17876. j = 0;
  17877. while ( ( clazz = classes[ j++ ] ) ) {
  17878. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  17879. cur += clazz + " ";
  17880. }
  17881. }
  17882. // Only assign if different to avoid unneeded rendering.
  17883. finalValue = stripAndCollapse( cur );
  17884. if ( curValue !== finalValue ) {
  17885. elem.setAttribute( "class", finalValue );
  17886. }
  17887. }
  17888. }
  17889. }
  17890. return this;
  17891. },
  17892. removeClass: function( value ) {
  17893. var classes, elem, cur, curValue, clazz, j, finalValue,
  17894. i = 0;
  17895. if ( isFunction( value ) ) {
  17896. return this.each( function( j ) {
  17897. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  17898. } );
  17899. }
  17900. if ( !arguments.length ) {
  17901. return this.attr( "class", "" );
  17902. }
  17903. classes = classesToArray( value );
  17904. if ( classes.length ) {
  17905. while ( ( elem = this[ i++ ] ) ) {
  17906. curValue = getClass( elem );
  17907. // This expression is here for better compressibility (see addClass)
  17908. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  17909. if ( cur ) {
  17910. j = 0;
  17911. while ( ( clazz = classes[ j++ ] ) ) {
  17912. // Remove *all* instances
  17913. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  17914. cur = cur.replace( " " + clazz + " ", " " );
  17915. }
  17916. }
  17917. // Only assign if different to avoid unneeded rendering.
  17918. finalValue = stripAndCollapse( cur );
  17919. if ( curValue !== finalValue ) {
  17920. elem.setAttribute( "class", finalValue );
  17921. }
  17922. }
  17923. }
  17924. }
  17925. return this;
  17926. },
  17927. toggleClass: function( value, stateVal ) {
  17928. var type = typeof value,
  17929. isValidValue = type === "string" || Array.isArray( value );
  17930. if ( typeof stateVal === "boolean" && isValidValue ) {
  17931. return stateVal ? this.addClass( value ) : this.removeClass( value );
  17932. }
  17933. if ( isFunction( value ) ) {
  17934. return this.each( function( i ) {
  17935. jQuery( this ).toggleClass(
  17936. value.call( this, i, getClass( this ), stateVal ),
  17937. stateVal
  17938. );
  17939. } );
  17940. }
  17941. return this.each( function() {
  17942. var className, i, self, classNames;
  17943. if ( isValidValue ) {
  17944. // Toggle individual class names
  17945. i = 0;
  17946. self = jQuery( this );
  17947. classNames = classesToArray( value );
  17948. while ( ( className = classNames[ i++ ] ) ) {
  17949. // Check each className given, space separated list
  17950. if ( self.hasClass( className ) ) {
  17951. self.removeClass( className );
  17952. } else {
  17953. self.addClass( className );
  17954. }
  17955. }
  17956. // Toggle whole class name
  17957. } else if ( value === undefined || type === "boolean" ) {
  17958. className = getClass( this );
  17959. if ( className ) {
  17960. // Store className if set
  17961. dataPriv.set( this, "__className__", className );
  17962. }
  17963. // If the element has a class name or if we're passed `false`,
  17964. // then remove the whole classname (if there was one, the above saved it).
  17965. // Otherwise bring back whatever was previously saved (if anything),
  17966. // falling back to the empty string if nothing was stored.
  17967. if ( this.setAttribute ) {
  17968. this.setAttribute( "class",
  17969. className || value === false ?
  17970. "" :
  17971. dataPriv.get( this, "__className__" ) || ""
  17972. );
  17973. }
  17974. }
  17975. } );
  17976. },
  17977. hasClass: function( selector ) {
  17978. var className, elem,
  17979. i = 0;
  17980. className = " " + selector + " ";
  17981. while ( ( elem = this[ i++ ] ) ) {
  17982. if ( elem.nodeType === 1 &&
  17983. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  17984. return true;
  17985. }
  17986. }
  17987. return false;
  17988. }
  17989. } );
  17990. var rreturn = /\r/g;
  17991. jQuery.fn.extend( {
  17992. val: function( value ) {
  17993. var hooks, ret, valueIsFunction,
  17994. elem = this[ 0 ];
  17995. if ( !arguments.length ) {
  17996. if ( elem ) {
  17997. hooks = jQuery.valHooks[ elem.type ] ||
  17998. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  17999. if ( hooks &&
  18000. "get" in hooks &&
  18001. ( ret = hooks.get( elem, "value" ) ) !== undefined
  18002. ) {
  18003. return ret;
  18004. }
  18005. ret = elem.value;
  18006. // Handle most common string cases
  18007. if ( typeof ret === "string" ) {
  18008. return ret.replace( rreturn, "" );
  18009. }
  18010. // Handle cases where value is null/undef or number
  18011. return ret == null ? "" : ret;
  18012. }
  18013. return;
  18014. }
  18015. valueIsFunction = isFunction( value );
  18016. return this.each( function( i ) {
  18017. var val;
  18018. if ( this.nodeType !== 1 ) {
  18019. return;
  18020. }
  18021. if ( valueIsFunction ) {
  18022. val = value.call( this, i, jQuery( this ).val() );
  18023. } else {
  18024. val = value;
  18025. }
  18026. // Treat null/undefined as ""; convert numbers to string
  18027. if ( val == null ) {
  18028. val = "";
  18029. } else if ( typeof val === "number" ) {
  18030. val += "";
  18031. } else if ( Array.isArray( val ) ) {
  18032. val = jQuery.map( val, function( value ) {
  18033. return value == null ? "" : value + "";
  18034. } );
  18035. }
  18036. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  18037. // If set returns undefined, fall back to normal setting
  18038. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  18039. this.value = val;
  18040. }
  18041. } );
  18042. }
  18043. } );
  18044. jQuery.extend( {
  18045. valHooks: {
  18046. option: {
  18047. get: function( elem ) {
  18048. var val = jQuery.find.attr( elem, "value" );
  18049. return val != null ?
  18050. val :
  18051. // Support: IE <=10 - 11 only
  18052. // option.text throws exceptions (#14686, #14858)
  18053. // Strip and collapse whitespace
  18054. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  18055. stripAndCollapse( jQuery.text( elem ) );
  18056. }
  18057. },
  18058. select: {
  18059. get: function( elem ) {
  18060. var value, option, i,
  18061. options = elem.options,
  18062. index = elem.selectedIndex,
  18063. one = elem.type === "select-one",
  18064. values = one ? null : [],
  18065. max = one ? index + 1 : options.length;
  18066. if ( index < 0 ) {
  18067. i = max;
  18068. } else {
  18069. i = one ? index : 0;
  18070. }
  18071. // Loop through all the selected options
  18072. for ( ; i < max; i++ ) {
  18073. option = options[ i ];
  18074. // Support: IE <=9 only
  18075. // IE8-9 doesn't update selected after form reset (#2551)
  18076. if ( ( option.selected || i === index ) &&
  18077. // Don't return options that are disabled or in a disabled optgroup
  18078. !option.disabled &&
  18079. ( !option.parentNode.disabled ||
  18080. !nodeName( option.parentNode, "optgroup" ) ) ) {
  18081. // Get the specific value for the option
  18082. value = jQuery( option ).val();
  18083. // We don't need an array for one selects
  18084. if ( one ) {
  18085. return value;
  18086. }
  18087. // Multi-Selects return an array
  18088. values.push( value );
  18089. }
  18090. }
  18091. return values;
  18092. },
  18093. set: function( elem, value ) {
  18094. var optionSet, option,
  18095. options = elem.options,
  18096. values = jQuery.makeArray( value ),
  18097. i = options.length;
  18098. while ( i-- ) {
  18099. option = options[ i ];
  18100. /* eslint-disable no-cond-assign */
  18101. if ( option.selected =
  18102. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  18103. ) {
  18104. optionSet = true;
  18105. }
  18106. /* eslint-enable no-cond-assign */
  18107. }
  18108. // Force browsers to behave consistently when non-matching value is set
  18109. if ( !optionSet ) {
  18110. elem.selectedIndex = -1;
  18111. }
  18112. return values;
  18113. }
  18114. }
  18115. }
  18116. } );
  18117. // Radios and checkboxes getter/setter
  18118. jQuery.each( [ "radio", "checkbox" ], function() {
  18119. jQuery.valHooks[ this ] = {
  18120. set: function( elem, value ) {
  18121. if ( Array.isArray( value ) ) {
  18122. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  18123. }
  18124. }
  18125. };
  18126. if ( !support.checkOn ) {
  18127. jQuery.valHooks[ this ].get = function( elem ) {
  18128. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  18129. };
  18130. }
  18131. } );
  18132. // Return jQuery for attributes-only inclusion
  18133. support.focusin = "onfocusin" in window;
  18134. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  18135. stopPropagationCallback = function( e ) {
  18136. e.stopPropagation();
  18137. };
  18138. jQuery.extend( jQuery.event, {
  18139. trigger: function( event, data, elem, onlyHandlers ) {
  18140. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  18141. eventPath = [ elem || document ],
  18142. type = hasOwn.call( event, "type" ) ? event.type : event,
  18143. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  18144. cur = lastElement = tmp = elem = elem || document;
  18145. // Don't do events on text and comment nodes
  18146. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  18147. return;
  18148. }
  18149. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  18150. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  18151. return;
  18152. }
  18153. if ( type.indexOf( "." ) > -1 ) {
  18154. // Namespaced trigger; create a regexp to match event type in handle()
  18155. namespaces = type.split( "." );
  18156. type = namespaces.shift();
  18157. namespaces.sort();
  18158. }
  18159. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  18160. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  18161. event = event[ jQuery.expando ] ?
  18162. event :
  18163. new jQuery.Event( type, typeof event === "object" && event );
  18164. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  18165. event.isTrigger = onlyHandlers ? 2 : 3;
  18166. event.namespace = namespaces.join( "." );
  18167. event.rnamespace = event.namespace ?
  18168. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  18169. null;
  18170. // Clean up the event in case it is being reused
  18171. event.result = undefined;
  18172. if ( !event.target ) {
  18173. event.target = elem;
  18174. }
  18175. // Clone any incoming data and prepend the event, creating the handler arg list
  18176. data = data == null ?
  18177. [ event ] :
  18178. jQuery.makeArray( data, [ event ] );
  18179. // Allow special events to draw outside the lines
  18180. special = jQuery.event.special[ type ] || {};
  18181. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  18182. return;
  18183. }
  18184. // Determine event propagation path in advance, per W3C events spec (#9951)
  18185. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  18186. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  18187. bubbleType = special.delegateType || type;
  18188. if ( !rfocusMorph.test( bubbleType + type ) ) {
  18189. cur = cur.parentNode;
  18190. }
  18191. for ( ; cur; cur = cur.parentNode ) {
  18192. eventPath.push( cur );
  18193. tmp = cur;
  18194. }
  18195. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  18196. if ( tmp === ( elem.ownerDocument || document ) ) {
  18197. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  18198. }
  18199. }
  18200. // Fire handlers on the event path
  18201. i = 0;
  18202. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  18203. lastElement = cur;
  18204. event.type = i > 1 ?
  18205. bubbleType :
  18206. special.bindType || type;
  18207. // jQuery handler
  18208. handle = (
  18209. dataPriv.get( cur, "events" ) || Object.create( null )
  18210. )[ event.type ] &&
  18211. dataPriv.get( cur, "handle" );
  18212. if ( handle ) {
  18213. handle.apply( cur, data );
  18214. }
  18215. // Native handler
  18216. handle = ontype && cur[ ontype ];
  18217. if ( handle && handle.apply && acceptData( cur ) ) {
  18218. event.result = handle.apply( cur, data );
  18219. if ( event.result === false ) {
  18220. event.preventDefault();
  18221. }
  18222. }
  18223. }
  18224. event.type = type;
  18225. // If nobody prevented the default action, do it now
  18226. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  18227. if ( ( !special._default ||
  18228. special._default.apply( eventPath.pop(), data ) === false ) &&
  18229. acceptData( elem ) ) {
  18230. // Call a native DOM method on the target with the same name as the event.
  18231. // Don't do default actions on window, that's where global variables be (#6170)
  18232. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  18233. // Don't re-trigger an onFOO event when we call its FOO() method
  18234. tmp = elem[ ontype ];
  18235. if ( tmp ) {
  18236. elem[ ontype ] = null;
  18237. }
  18238. // Prevent re-triggering of the same event, since we already bubbled it above
  18239. jQuery.event.triggered = type;
  18240. if ( event.isPropagationStopped() ) {
  18241. lastElement.addEventListener( type, stopPropagationCallback );
  18242. }
  18243. elem[ type ]();
  18244. if ( event.isPropagationStopped() ) {
  18245. lastElement.removeEventListener( type, stopPropagationCallback );
  18246. }
  18247. jQuery.event.triggered = undefined;
  18248. if ( tmp ) {
  18249. elem[ ontype ] = tmp;
  18250. }
  18251. }
  18252. }
  18253. }
  18254. return event.result;
  18255. },
  18256. // Piggyback on a donor event to simulate a different one
  18257. // Used only for `focus(in | out)` events
  18258. simulate: function( type, elem, event ) {
  18259. var e = jQuery.extend(
  18260. new jQuery.Event(),
  18261. event,
  18262. {
  18263. type: type,
  18264. isSimulated: true
  18265. }
  18266. );
  18267. jQuery.event.trigger( e, null, elem );
  18268. }
  18269. } );
  18270. jQuery.fn.extend( {
  18271. trigger: function( type, data ) {
  18272. return this.each( function() {
  18273. jQuery.event.trigger( type, data, this );
  18274. } );
  18275. },
  18276. triggerHandler: function( type, data ) {
  18277. var elem = this[ 0 ];
  18278. if ( elem ) {
  18279. return jQuery.event.trigger( type, data, elem, true );
  18280. }
  18281. }
  18282. } );
  18283. // Support: Firefox <=44
  18284. // Firefox doesn't have focus(in | out) events
  18285. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  18286. //
  18287. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  18288. // focus(in | out) events fire after focus & blur events,
  18289. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  18290. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  18291. if ( !support.focusin ) {
  18292. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  18293. // Attach a single capturing handler on the document while someone wants focusin/focusout
  18294. var handler = function( event ) {
  18295. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  18296. };
  18297. jQuery.event.special[ fix ] = {
  18298. setup: function() {
  18299. // Handle: regular nodes (via `this.ownerDocument`), window
  18300. // (via `this.document`) & document (via `this`).
  18301. var doc = this.ownerDocument || this.document || this,
  18302. attaches = dataPriv.access( doc, fix );
  18303. if ( !attaches ) {
  18304. doc.addEventListener( orig, handler, true );
  18305. }
  18306. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  18307. },
  18308. teardown: function() {
  18309. var doc = this.ownerDocument || this.document || this,
  18310. attaches = dataPriv.access( doc, fix ) - 1;
  18311. if ( !attaches ) {
  18312. doc.removeEventListener( orig, handler, true );
  18313. dataPriv.remove( doc, fix );
  18314. } else {
  18315. dataPriv.access( doc, fix, attaches );
  18316. }
  18317. }
  18318. };
  18319. } );
  18320. }
  18321. var location = window.location;
  18322. var nonce = { guid: Date.now() };
  18323. var rquery = ( /\?/ );
  18324. // Cross-browser xml parsing
  18325. jQuery.parseXML = function( data ) {
  18326. var xml;
  18327. if ( !data || typeof data !== "string" ) {
  18328. return null;
  18329. }
  18330. // Support: IE 9 - 11 only
  18331. // IE throws on parseFromString with invalid input.
  18332. try {
  18333. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  18334. } catch ( e ) {
  18335. xml = undefined;
  18336. }
  18337. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  18338. jQuery.error( "Invalid XML: " + data );
  18339. }
  18340. return xml;
  18341. };
  18342. var
  18343. rbracket = /\[\]$/,
  18344. rCRLF = /\r?\n/g,
  18345. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  18346. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  18347. function buildParams( prefix, obj, traditional, add ) {
  18348. var name;
  18349. if ( Array.isArray( obj ) ) {
  18350. // Serialize array item.
  18351. jQuery.each( obj, function( i, v ) {
  18352. if ( traditional || rbracket.test( prefix ) ) {
  18353. // Treat each array item as a scalar.
  18354. add( prefix, v );
  18355. } else {
  18356. // Item is non-scalar (array or object), encode its numeric index.
  18357. buildParams(
  18358. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  18359. v,
  18360. traditional,
  18361. add
  18362. );
  18363. }
  18364. } );
  18365. } else if ( !traditional && toType( obj ) === "object" ) {
  18366. // Serialize object item.
  18367. for ( name in obj ) {
  18368. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  18369. }
  18370. } else {
  18371. // Serialize scalar item.
  18372. add( prefix, obj );
  18373. }
  18374. }
  18375. // Serialize an array of form elements or a set of
  18376. // key/values into a query string
  18377. jQuery.param = function( a, traditional ) {
  18378. var prefix,
  18379. s = [],
  18380. add = function( key, valueOrFunction ) {
  18381. // If value is a function, invoke it and use its return value
  18382. var value = isFunction( valueOrFunction ) ?
  18383. valueOrFunction() :
  18384. valueOrFunction;
  18385. s[ s.length ] = encodeURIComponent( key ) + "=" +
  18386. encodeURIComponent( value == null ? "" : value );
  18387. };
  18388. if ( a == null ) {
  18389. return "";
  18390. }
  18391. // If an array was passed in, assume that it is an array of form elements.
  18392. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  18393. // Serialize the form elements
  18394. jQuery.each( a, function() {
  18395. add( this.name, this.value );
  18396. } );
  18397. } else {
  18398. // If traditional, encode the "old" way (the way 1.3.2 or older
  18399. // did it), otherwise encode params recursively.
  18400. for ( prefix in a ) {
  18401. buildParams( prefix, a[ prefix ], traditional, add );
  18402. }
  18403. }
  18404. // Return the resulting serialization
  18405. return s.join( "&" );
  18406. };
  18407. jQuery.fn.extend( {
  18408. serialize: function() {
  18409. return jQuery.param( this.serializeArray() );
  18410. },
  18411. serializeArray: function() {
  18412. return this.map( function() {
  18413. // Can add propHook for "elements" to filter or add form elements
  18414. var elements = jQuery.prop( this, "elements" );
  18415. return elements ? jQuery.makeArray( elements ) : this;
  18416. } )
  18417. .filter( function() {
  18418. var type = this.type;
  18419. // Use .is( ":disabled" ) so that fieldset[disabled] works
  18420. return this.name && !jQuery( this ).is( ":disabled" ) &&
  18421. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  18422. ( this.checked || !rcheckableType.test( type ) );
  18423. } )
  18424. .map( function( _i, elem ) {
  18425. var val = jQuery( this ).val();
  18426. if ( val == null ) {
  18427. return null;
  18428. }
  18429. if ( Array.isArray( val ) ) {
  18430. return jQuery.map( val, function( val ) {
  18431. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  18432. } );
  18433. }
  18434. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  18435. } ).get();
  18436. }
  18437. } );
  18438. var
  18439. r20 = /%20/g,
  18440. rhash = /#.*$/,
  18441. rantiCache = /([?&])_=[^&]*/,
  18442. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  18443. // #7653, #8125, #8152: local protocol detection
  18444. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  18445. rnoContent = /^(?:GET|HEAD)$/,
  18446. rprotocol = /^\/\//,
  18447. /* Prefilters
  18448. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  18449. * 2) These are called:
  18450. * - BEFORE asking for a transport
  18451. * - AFTER param serialization (s.data is a string if s.processData is true)
  18452. * 3) key is the dataType
  18453. * 4) the catchall symbol "*" can be used
  18454. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  18455. */
  18456. prefilters = {},
  18457. /* Transports bindings
  18458. * 1) key is the dataType
  18459. * 2) the catchall symbol "*" can be used
  18460. * 3) selection will start with transport dataType and THEN go to "*" if needed
  18461. */
  18462. transports = {},
  18463. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  18464. allTypes = "*/".concat( "*" ),
  18465. // Anchor tag for parsing the document origin
  18466. originAnchor = document.createElement( "a" );
  18467. originAnchor.href = location.href;
  18468. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  18469. function addToPrefiltersOrTransports( structure ) {
  18470. // dataTypeExpression is optional and defaults to "*"
  18471. return function( dataTypeExpression, func ) {
  18472. if ( typeof dataTypeExpression !== "string" ) {
  18473. func = dataTypeExpression;
  18474. dataTypeExpression = "*";
  18475. }
  18476. var dataType,
  18477. i = 0,
  18478. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  18479. if ( isFunction( func ) ) {
  18480. // For each dataType in the dataTypeExpression
  18481. while ( ( dataType = dataTypes[ i++ ] ) ) {
  18482. // Prepend if requested
  18483. if ( dataType[ 0 ] === "+" ) {
  18484. dataType = dataType.slice( 1 ) || "*";
  18485. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  18486. // Otherwise append
  18487. } else {
  18488. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  18489. }
  18490. }
  18491. }
  18492. };
  18493. }
  18494. // Base inspection function for prefilters and transports
  18495. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  18496. var inspected = {},
  18497. seekingTransport = ( structure === transports );
  18498. function inspect( dataType ) {
  18499. var selected;
  18500. inspected[ dataType ] = true;
  18501. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  18502. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  18503. if ( typeof dataTypeOrTransport === "string" &&
  18504. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  18505. options.dataTypes.unshift( dataTypeOrTransport );
  18506. inspect( dataTypeOrTransport );
  18507. return false;
  18508. } else if ( seekingTransport ) {
  18509. return !( selected = dataTypeOrTransport );
  18510. }
  18511. } );
  18512. return selected;
  18513. }
  18514. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  18515. }
  18516. // A special extend for ajax options
  18517. // that takes "flat" options (not to be deep extended)
  18518. // Fixes #9887
  18519. function ajaxExtend( target, src ) {
  18520. var key, deep,
  18521. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  18522. for ( key in src ) {
  18523. if ( src[ key ] !== undefined ) {
  18524. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  18525. }
  18526. }
  18527. if ( deep ) {
  18528. jQuery.extend( true, target, deep );
  18529. }
  18530. return target;
  18531. }
  18532. /* Handles responses to an ajax request:
  18533. * - finds the right dataType (mediates between content-type and expected dataType)
  18534. * - returns the corresponding response
  18535. */
  18536. function ajaxHandleResponses( s, jqXHR, responses ) {
  18537. var ct, type, finalDataType, firstDataType,
  18538. contents = s.contents,
  18539. dataTypes = s.dataTypes;
  18540. // Remove auto dataType and get content-type in the process
  18541. while ( dataTypes[ 0 ] === "*" ) {
  18542. dataTypes.shift();
  18543. if ( ct === undefined ) {
  18544. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  18545. }
  18546. }
  18547. // Check if we're dealing with a known content-type
  18548. if ( ct ) {
  18549. for ( type in contents ) {
  18550. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  18551. dataTypes.unshift( type );
  18552. break;
  18553. }
  18554. }
  18555. }
  18556. // Check to see if we have a response for the expected dataType
  18557. if ( dataTypes[ 0 ] in responses ) {
  18558. finalDataType = dataTypes[ 0 ];
  18559. } else {
  18560. // Try convertible dataTypes
  18561. for ( type in responses ) {
  18562. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  18563. finalDataType = type;
  18564. break;
  18565. }
  18566. if ( !firstDataType ) {
  18567. firstDataType = type;
  18568. }
  18569. }
  18570. // Or just use first one
  18571. finalDataType = finalDataType || firstDataType;
  18572. }
  18573. // If we found a dataType
  18574. // We add the dataType to the list if needed
  18575. // and return the corresponding response
  18576. if ( finalDataType ) {
  18577. if ( finalDataType !== dataTypes[ 0 ] ) {
  18578. dataTypes.unshift( finalDataType );
  18579. }
  18580. return responses[ finalDataType ];
  18581. }
  18582. }
  18583. /* Chain conversions given the request and the original response
  18584. * Also sets the responseXXX fields on the jqXHR instance
  18585. */
  18586. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  18587. var conv2, current, conv, tmp, prev,
  18588. converters = {},
  18589. // Work with a copy of dataTypes in case we need to modify it for conversion
  18590. dataTypes = s.dataTypes.slice();
  18591. // Create converters map with lowercased keys
  18592. if ( dataTypes[ 1 ] ) {
  18593. for ( conv in s.converters ) {
  18594. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  18595. }
  18596. }
  18597. current = dataTypes.shift();
  18598. // Convert to each sequential dataType
  18599. while ( current ) {
  18600. if ( s.responseFields[ current ] ) {
  18601. jqXHR[ s.responseFields[ current ] ] = response;
  18602. }
  18603. // Apply the dataFilter if provided
  18604. if ( !prev && isSuccess && s.dataFilter ) {
  18605. response = s.dataFilter( response, s.dataType );
  18606. }
  18607. prev = current;
  18608. current = dataTypes.shift();
  18609. if ( current ) {
  18610. // There's only work to do if current dataType is non-auto
  18611. if ( current === "*" ) {
  18612. current = prev;
  18613. // Convert response if prev dataType is non-auto and differs from current
  18614. } else if ( prev !== "*" && prev !== current ) {
  18615. // Seek a direct converter
  18616. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  18617. // If none found, seek a pair
  18618. if ( !conv ) {
  18619. for ( conv2 in converters ) {
  18620. // If conv2 outputs current
  18621. tmp = conv2.split( " " );
  18622. if ( tmp[ 1 ] === current ) {
  18623. // If prev can be converted to accepted input
  18624. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  18625. converters[ "* " + tmp[ 0 ] ];
  18626. if ( conv ) {
  18627. // Condense equivalence converters
  18628. if ( conv === true ) {
  18629. conv = converters[ conv2 ];
  18630. // Otherwise, insert the intermediate dataType
  18631. } else if ( converters[ conv2 ] !== true ) {
  18632. current = tmp[ 0 ];
  18633. dataTypes.unshift( tmp[ 1 ] );
  18634. }
  18635. break;
  18636. }
  18637. }
  18638. }
  18639. }
  18640. // Apply converter (if not an equivalence)
  18641. if ( conv !== true ) {
  18642. // Unless errors are allowed to bubble, catch and return them
  18643. if ( conv && s.throws ) {
  18644. response = conv( response );
  18645. } else {
  18646. try {
  18647. response = conv( response );
  18648. } catch ( e ) {
  18649. return {
  18650. state: "parsererror",
  18651. error: conv ? e : "No conversion from " + prev + " to " + current
  18652. };
  18653. }
  18654. }
  18655. }
  18656. }
  18657. }
  18658. }
  18659. return { state: "success", data: response };
  18660. }
  18661. jQuery.extend( {
  18662. // Counter for holding the number of active queries
  18663. active: 0,
  18664. // Last-Modified header cache for next request
  18665. lastModified: {},
  18666. etag: {},
  18667. ajaxSettings: {
  18668. url: location.href,
  18669. type: "GET",
  18670. isLocal: rlocalProtocol.test( location.protocol ),
  18671. global: true,
  18672. processData: true,
  18673. async: true,
  18674. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  18675. /*
  18676. timeout: 0,
  18677. data: null,
  18678. dataType: null,
  18679. username: null,
  18680. password: null,
  18681. cache: null,
  18682. throws: false,
  18683. traditional: false,
  18684. headers: {},
  18685. */
  18686. accepts: {
  18687. "*": allTypes,
  18688. text: "text/plain",
  18689. html: "text/html",
  18690. xml: "application/xml, text/xml",
  18691. json: "application/json, text/javascript"
  18692. },
  18693. contents: {
  18694. xml: /\bxml\b/,
  18695. html: /\bhtml/,
  18696. json: /\bjson\b/
  18697. },
  18698. responseFields: {
  18699. xml: "responseXML",
  18700. text: "responseText",
  18701. json: "responseJSON"
  18702. },
  18703. // Data converters
  18704. // Keys separate source (or catchall "*") and destination types with a single space
  18705. converters: {
  18706. // Convert anything to text
  18707. "* text": String,
  18708. // Text to html (true = no transformation)
  18709. "text html": true,
  18710. // Evaluate text as a json expression
  18711. "text json": JSON.parse,
  18712. // Parse text as xml
  18713. "text xml": jQuery.parseXML
  18714. },
  18715. // For options that shouldn't be deep extended:
  18716. // you can add your own custom options here if
  18717. // and when you create one that shouldn't be
  18718. // deep extended (see ajaxExtend)
  18719. flatOptions: {
  18720. url: true,
  18721. context: true
  18722. }
  18723. },
  18724. // Creates a full fledged settings object into target
  18725. // with both ajaxSettings and settings fields.
  18726. // If target is omitted, writes into ajaxSettings.
  18727. ajaxSetup: function( target, settings ) {
  18728. return settings ?
  18729. // Building a settings object
  18730. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  18731. // Extending ajaxSettings
  18732. ajaxExtend( jQuery.ajaxSettings, target );
  18733. },
  18734. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  18735. ajaxTransport: addToPrefiltersOrTransports( transports ),
  18736. // Main method
  18737. ajax: function( url, options ) {
  18738. // If url is an object, simulate pre-1.5 signature
  18739. if ( typeof url === "object" ) {
  18740. options = url;
  18741. url = undefined;
  18742. }
  18743. // Force options to be an object
  18744. options = options || {};
  18745. var transport,
  18746. // URL without anti-cache param
  18747. cacheURL,
  18748. // Response headers
  18749. responseHeadersString,
  18750. responseHeaders,
  18751. // timeout handle
  18752. timeoutTimer,
  18753. // Url cleanup var
  18754. urlAnchor,
  18755. // Request state (becomes false upon send and true upon completion)
  18756. completed,
  18757. // To know if global events are to be dispatched
  18758. fireGlobals,
  18759. // Loop variable
  18760. i,
  18761. // uncached part of the url
  18762. uncached,
  18763. // Create the final options object
  18764. s = jQuery.ajaxSetup( {}, options ),
  18765. // Callbacks context
  18766. callbackContext = s.context || s,
  18767. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  18768. globalEventContext = s.context &&
  18769. ( callbackContext.nodeType || callbackContext.jquery ) ?
  18770. jQuery( callbackContext ) :
  18771. jQuery.event,
  18772. // Deferreds
  18773. deferred = jQuery.Deferred(),
  18774. completeDeferred = jQuery.Callbacks( "once memory" ),
  18775. // Status-dependent callbacks
  18776. statusCode = s.statusCode || {},
  18777. // Headers (they are sent all at once)
  18778. requestHeaders = {},
  18779. requestHeadersNames = {},
  18780. // Default abort message
  18781. strAbort = "canceled",
  18782. // Fake xhr
  18783. jqXHR = {
  18784. readyState: 0,
  18785. // Builds headers hashtable if needed
  18786. getResponseHeader: function( key ) {
  18787. var match;
  18788. if ( completed ) {
  18789. if ( !responseHeaders ) {
  18790. responseHeaders = {};
  18791. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  18792. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  18793. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  18794. .concat( match[ 2 ] );
  18795. }
  18796. }
  18797. match = responseHeaders[ key.toLowerCase() + " " ];
  18798. }
  18799. return match == null ? null : match.join( ", " );
  18800. },
  18801. // Raw string
  18802. getAllResponseHeaders: function() {
  18803. return completed ? responseHeadersString : null;
  18804. },
  18805. // Caches the header
  18806. setRequestHeader: function( name, value ) {
  18807. if ( completed == null ) {
  18808. name = requestHeadersNames[ name.toLowerCase() ] =
  18809. requestHeadersNames[ name.toLowerCase() ] || name;
  18810. requestHeaders[ name ] = value;
  18811. }
  18812. return this;
  18813. },
  18814. // Overrides response content-type header
  18815. overrideMimeType: function( type ) {
  18816. if ( completed == null ) {
  18817. s.mimeType = type;
  18818. }
  18819. return this;
  18820. },
  18821. // Status-dependent callbacks
  18822. statusCode: function( map ) {
  18823. var code;
  18824. if ( map ) {
  18825. if ( completed ) {
  18826. // Execute the appropriate callbacks
  18827. jqXHR.always( map[ jqXHR.status ] );
  18828. } else {
  18829. // Lazy-add the new callbacks in a way that preserves old ones
  18830. for ( code in map ) {
  18831. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  18832. }
  18833. }
  18834. }
  18835. return this;
  18836. },
  18837. // Cancel the request
  18838. abort: function( statusText ) {
  18839. var finalText = statusText || strAbort;
  18840. if ( transport ) {
  18841. transport.abort( finalText );
  18842. }
  18843. done( 0, finalText );
  18844. return this;
  18845. }
  18846. };
  18847. // Attach deferreds
  18848. deferred.promise( jqXHR );
  18849. // Add protocol if not provided (prefilters might expect it)
  18850. // Handle falsy url in the settings object (#10093: consistency with old signature)
  18851. // We also use the url parameter if available
  18852. s.url = ( ( url || s.url || location.href ) + "" )
  18853. .replace( rprotocol, location.protocol + "//" );
  18854. // Alias method option to type as per ticket #12004
  18855. s.type = options.method || options.type || s.method || s.type;
  18856. // Extract dataTypes list
  18857. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  18858. // A cross-domain request is in order when the origin doesn't match the current origin.
  18859. if ( s.crossDomain == null ) {
  18860. urlAnchor = document.createElement( "a" );
  18861. // Support: IE <=8 - 11, Edge 12 - 15
  18862. // IE throws exception on accessing the href property if url is malformed,
  18863. // e.g. http://example.com:80x/
  18864. try {
  18865. urlAnchor.href = s.url;
  18866. // Support: IE <=8 - 11 only
  18867. // Anchor's host property isn't correctly set when s.url is relative
  18868. urlAnchor.href = urlAnchor.href;
  18869. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  18870. urlAnchor.protocol + "//" + urlAnchor.host;
  18871. } catch ( e ) {
  18872. // If there is an error parsing the URL, assume it is crossDomain,
  18873. // it can be rejected by the transport if it is invalid
  18874. s.crossDomain = true;
  18875. }
  18876. }
  18877. // Convert data if not already a string
  18878. if ( s.data && s.processData && typeof s.data !== "string" ) {
  18879. s.data = jQuery.param( s.data, s.traditional );
  18880. }
  18881. // Apply prefilters
  18882. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  18883. // If request was aborted inside a prefilter, stop there
  18884. if ( completed ) {
  18885. return jqXHR;
  18886. }
  18887. // We can fire global events as of now if asked to
  18888. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  18889. fireGlobals = jQuery.event && s.global;
  18890. // Watch for a new set of requests
  18891. if ( fireGlobals && jQuery.active++ === 0 ) {
  18892. jQuery.event.trigger( "ajaxStart" );
  18893. }
  18894. // Uppercase the type
  18895. s.type = s.type.toUpperCase();
  18896. // Determine if request has content
  18897. s.hasContent = !rnoContent.test( s.type );
  18898. // Save the URL in case we're toying with the If-Modified-Since
  18899. // and/or If-None-Match header later on
  18900. // Remove hash to simplify url manipulation
  18901. cacheURL = s.url.replace( rhash, "" );
  18902. // More options handling for requests with no content
  18903. if ( !s.hasContent ) {
  18904. // Remember the hash so we can put it back
  18905. uncached = s.url.slice( cacheURL.length );
  18906. // If data is available and should be processed, append data to url
  18907. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  18908. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  18909. // #9682: remove data so that it's not used in an eventual retry
  18910. delete s.data;
  18911. }
  18912. // Add or update anti-cache param if needed
  18913. if ( s.cache === false ) {
  18914. cacheURL = cacheURL.replace( rantiCache, "$1" );
  18915. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
  18916. uncached;
  18917. }
  18918. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  18919. s.url = cacheURL + uncached;
  18920. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  18921. } else if ( s.data && s.processData &&
  18922. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  18923. s.data = s.data.replace( r20, "+" );
  18924. }
  18925. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  18926. if ( s.ifModified ) {
  18927. if ( jQuery.lastModified[ cacheURL ] ) {
  18928. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  18929. }
  18930. if ( jQuery.etag[ cacheURL ] ) {
  18931. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  18932. }
  18933. }
  18934. // Set the correct header, if data is being sent
  18935. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  18936. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  18937. }
  18938. // Set the Accepts header for the server, depending on the dataType
  18939. jqXHR.setRequestHeader(
  18940. "Accept",
  18941. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  18942. s.accepts[ s.dataTypes[ 0 ] ] +
  18943. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  18944. s.accepts[ "*" ]
  18945. );
  18946. // Check for headers option
  18947. for ( i in s.headers ) {
  18948. jqXHR.setRequestHeader( i, s.headers[ i ] );
  18949. }
  18950. // Allow custom headers/mimetypes and early abort
  18951. if ( s.beforeSend &&
  18952. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  18953. // Abort if not done already and return
  18954. return jqXHR.abort();
  18955. }
  18956. // Aborting is no longer a cancellation
  18957. strAbort = "abort";
  18958. // Install callbacks on deferreds
  18959. completeDeferred.add( s.complete );
  18960. jqXHR.done( s.success );
  18961. jqXHR.fail( s.error );
  18962. // Get transport
  18963. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  18964. // If no transport, we auto-abort
  18965. if ( !transport ) {
  18966. done( -1, "No Transport" );
  18967. } else {
  18968. jqXHR.readyState = 1;
  18969. // Send global event
  18970. if ( fireGlobals ) {
  18971. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  18972. }
  18973. // If request was aborted inside ajaxSend, stop there
  18974. if ( completed ) {
  18975. return jqXHR;
  18976. }
  18977. // Timeout
  18978. if ( s.async && s.timeout > 0 ) {
  18979. timeoutTimer = window.setTimeout( function() {
  18980. jqXHR.abort( "timeout" );
  18981. }, s.timeout );
  18982. }
  18983. try {
  18984. completed = false;
  18985. transport.send( requestHeaders, done );
  18986. } catch ( e ) {
  18987. // Rethrow post-completion exceptions
  18988. if ( completed ) {
  18989. throw e;
  18990. }
  18991. // Propagate others as results
  18992. done( -1, e );
  18993. }
  18994. }
  18995. // Callback for when everything is done
  18996. function done( status, nativeStatusText, responses, headers ) {
  18997. var isSuccess, success, error, response, modified,
  18998. statusText = nativeStatusText;
  18999. // Ignore repeat invocations
  19000. if ( completed ) {
  19001. return;
  19002. }
  19003. completed = true;
  19004. // Clear timeout if it exists
  19005. if ( timeoutTimer ) {
  19006. window.clearTimeout( timeoutTimer );
  19007. }
  19008. // Dereference transport for early garbage collection
  19009. // (no matter how long the jqXHR object will be used)
  19010. transport = undefined;
  19011. // Cache response headers
  19012. responseHeadersString = headers || "";
  19013. // Set readyState
  19014. jqXHR.readyState = status > 0 ? 4 : 0;
  19015. // Determine if successful
  19016. isSuccess = status >= 200 && status < 300 || status === 304;
  19017. // Get response data
  19018. if ( responses ) {
  19019. response = ajaxHandleResponses( s, jqXHR, responses );
  19020. }
  19021. // Use a noop converter for missing script
  19022. if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
  19023. s.converters[ "text script" ] = function() {};
  19024. }
  19025. // Convert no matter what (that way responseXXX fields are always set)
  19026. response = ajaxConvert( s, response, jqXHR, isSuccess );
  19027. // If successful, handle type chaining
  19028. if ( isSuccess ) {
  19029. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  19030. if ( s.ifModified ) {
  19031. modified = jqXHR.getResponseHeader( "Last-Modified" );
  19032. if ( modified ) {
  19033. jQuery.lastModified[ cacheURL ] = modified;
  19034. }
  19035. modified = jqXHR.getResponseHeader( "etag" );
  19036. if ( modified ) {
  19037. jQuery.etag[ cacheURL ] = modified;
  19038. }
  19039. }
  19040. // if no content
  19041. if ( status === 204 || s.type === "HEAD" ) {
  19042. statusText = "nocontent";
  19043. // if not modified
  19044. } else if ( status === 304 ) {
  19045. statusText = "notmodified";
  19046. // If we have data, let's convert it
  19047. } else {
  19048. statusText = response.state;
  19049. success = response.data;
  19050. error = response.error;
  19051. isSuccess = !error;
  19052. }
  19053. } else {
  19054. // Extract error from statusText and normalize for non-aborts
  19055. error = statusText;
  19056. if ( status || !statusText ) {
  19057. statusText = "error";
  19058. if ( status < 0 ) {
  19059. status = 0;
  19060. }
  19061. }
  19062. }
  19063. // Set data for the fake xhr object
  19064. jqXHR.status = status;
  19065. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  19066. // Success/Error
  19067. if ( isSuccess ) {
  19068. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  19069. } else {
  19070. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  19071. }
  19072. // Status-dependent callbacks
  19073. jqXHR.statusCode( statusCode );
  19074. statusCode = undefined;
  19075. if ( fireGlobals ) {
  19076. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  19077. [ jqXHR, s, isSuccess ? success : error ] );
  19078. }
  19079. // Complete
  19080. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  19081. if ( fireGlobals ) {
  19082. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  19083. // Handle the global AJAX counter
  19084. if ( !( --jQuery.active ) ) {
  19085. jQuery.event.trigger( "ajaxStop" );
  19086. }
  19087. }
  19088. }
  19089. return jqXHR;
  19090. },
  19091. getJSON: function( url, data, callback ) {
  19092. return jQuery.get( url, data, callback, "json" );
  19093. },
  19094. getScript: function( url, callback ) {
  19095. return jQuery.get( url, undefined, callback, "script" );
  19096. }
  19097. } );
  19098. jQuery.each( [ "get", "post" ], function( _i, method ) {
  19099. jQuery[ method ] = function( url, data, callback, type ) {
  19100. // Shift arguments if data argument was omitted
  19101. if ( isFunction( data ) ) {
  19102. type = type || callback;
  19103. callback = data;
  19104. data = undefined;
  19105. }
  19106. // The url can be an options object (which then must have .url)
  19107. return jQuery.ajax( jQuery.extend( {
  19108. url: url,
  19109. type: method,
  19110. dataType: type,
  19111. data: data,
  19112. success: callback
  19113. }, jQuery.isPlainObject( url ) && url ) );
  19114. };
  19115. } );
  19116. jQuery.ajaxPrefilter( function( s ) {
  19117. var i;
  19118. for ( i in s.headers ) {
  19119. if ( i.toLowerCase() === "content-type" ) {
  19120. s.contentType = s.headers[ i ] || "";
  19121. }
  19122. }
  19123. } );
  19124. jQuery._evalUrl = function( url, options, doc ) {
  19125. return jQuery.ajax( {
  19126. url: url,
  19127. // Make this explicit, since user can override this through ajaxSetup (#11264)
  19128. type: "GET",
  19129. dataType: "script",
  19130. cache: true,
  19131. async: false,
  19132. global: false,
  19133. // Only evaluate the response if it is successful (gh-4126)
  19134. // dataFilter is not invoked for failure responses, so using it instead
  19135. // of the default converter is kludgy but it works.
  19136. converters: {
  19137. "text script": function() {}
  19138. },
  19139. dataFilter: function( response ) {
  19140. jQuery.globalEval( response, options, doc );
  19141. }
  19142. } );
  19143. };
  19144. jQuery.fn.extend( {
  19145. wrapAll: function( html ) {
  19146. var wrap;
  19147. if ( this[ 0 ] ) {
  19148. if ( isFunction( html ) ) {
  19149. html = html.call( this[ 0 ] );
  19150. }
  19151. // The elements to wrap the target around
  19152. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  19153. if ( this[ 0 ].parentNode ) {
  19154. wrap.insertBefore( this[ 0 ] );
  19155. }
  19156. wrap.map( function() {
  19157. var elem = this;
  19158. while ( elem.firstElementChild ) {
  19159. elem = elem.firstElementChild;
  19160. }
  19161. return elem;
  19162. } ).append( this );
  19163. }
  19164. return this;
  19165. },
  19166. wrapInner: function( html ) {
  19167. if ( isFunction( html ) ) {
  19168. return this.each( function( i ) {
  19169. jQuery( this ).wrapInner( html.call( this, i ) );
  19170. } );
  19171. }
  19172. return this.each( function() {
  19173. var self = jQuery( this ),
  19174. contents = self.contents();
  19175. if ( contents.length ) {
  19176. contents.wrapAll( html );
  19177. } else {
  19178. self.append( html );
  19179. }
  19180. } );
  19181. },
  19182. wrap: function( html ) {
  19183. var htmlIsFunction = isFunction( html );
  19184. return this.each( function( i ) {
  19185. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  19186. } );
  19187. },
  19188. unwrap: function( selector ) {
  19189. this.parent( selector ).not( "body" ).each( function() {
  19190. jQuery( this ).replaceWith( this.childNodes );
  19191. } );
  19192. return this;
  19193. }
  19194. } );
  19195. jQuery.expr.pseudos.hidden = function( elem ) {
  19196. return !jQuery.expr.pseudos.visible( elem );
  19197. };
  19198. jQuery.expr.pseudos.visible = function( elem ) {
  19199. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  19200. };
  19201. jQuery.ajaxSettings.xhr = function() {
  19202. try {
  19203. return new window.XMLHttpRequest();
  19204. } catch ( e ) {}
  19205. };
  19206. var xhrSuccessStatus = {
  19207. // File protocol always yields status code 0, assume 200
  19208. 0: 200,
  19209. // Support: IE <=9 only
  19210. // #1450: sometimes IE returns 1223 when it should be 204
  19211. 1223: 204
  19212. },
  19213. xhrSupported = jQuery.ajaxSettings.xhr();
  19214. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  19215. support.ajax = xhrSupported = !!xhrSupported;
  19216. jQuery.ajaxTransport( function( options ) {
  19217. var callback, errorCallback;
  19218. // Cross domain only allowed if supported through XMLHttpRequest
  19219. if ( support.cors || xhrSupported && !options.crossDomain ) {
  19220. return {
  19221. send: function( headers, complete ) {
  19222. var i,
  19223. xhr = options.xhr();
  19224. xhr.open(
  19225. options.type,
  19226. options.url,
  19227. options.async,
  19228. options.username,
  19229. options.password
  19230. );
  19231. // Apply custom fields if provided
  19232. if ( options.xhrFields ) {
  19233. for ( i in options.xhrFields ) {
  19234. xhr[ i ] = options.xhrFields[ i ];
  19235. }
  19236. }
  19237. // Override mime type if needed
  19238. if ( options.mimeType && xhr.overrideMimeType ) {
  19239. xhr.overrideMimeType( options.mimeType );
  19240. }
  19241. // X-Requested-With header
  19242. // For cross-domain requests, seeing as conditions for a preflight are
  19243. // akin to a jigsaw puzzle, we simply never set it to be sure.
  19244. // (it can always be set on a per-request basis or even using ajaxSetup)
  19245. // For same-domain requests, won't change header if already provided.
  19246. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  19247. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  19248. }
  19249. // Set headers
  19250. for ( i in headers ) {
  19251. xhr.setRequestHeader( i, headers[ i ] );
  19252. }
  19253. // Callback
  19254. callback = function( type ) {
  19255. return function() {
  19256. if ( callback ) {
  19257. callback = errorCallback = xhr.onload =
  19258. xhr.onerror = xhr.onabort = xhr.ontimeout =
  19259. xhr.onreadystatechange = null;
  19260. if ( type === "abort" ) {
  19261. xhr.abort();
  19262. } else if ( type === "error" ) {
  19263. // Support: IE <=9 only
  19264. // On a manual native abort, IE9 throws
  19265. // errors on any property access that is not readyState
  19266. if ( typeof xhr.status !== "number" ) {
  19267. complete( 0, "error" );
  19268. } else {
  19269. complete(
  19270. // File: protocol always yields status 0; see #8605, #14207
  19271. xhr.status,
  19272. xhr.statusText
  19273. );
  19274. }
  19275. } else {
  19276. complete(
  19277. xhrSuccessStatus[ xhr.status ] || xhr.status,
  19278. xhr.statusText,
  19279. // Support: IE <=9 only
  19280. // IE9 has no XHR2 but throws on binary (trac-11426)
  19281. // For XHR2 non-text, let the caller handle it (gh-2498)
  19282. ( xhr.responseType || "text" ) !== "text" ||
  19283. typeof xhr.responseText !== "string" ?
  19284. { binary: xhr.response } :
  19285. { text: xhr.responseText },
  19286. xhr.getAllResponseHeaders()
  19287. );
  19288. }
  19289. }
  19290. };
  19291. };
  19292. // Listen to events
  19293. xhr.onload = callback();
  19294. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  19295. // Support: IE 9 only
  19296. // Use onreadystatechange to replace onabort
  19297. // to handle uncaught aborts
  19298. if ( xhr.onabort !== undefined ) {
  19299. xhr.onabort = errorCallback;
  19300. } else {
  19301. xhr.onreadystatechange = function() {
  19302. // Check readyState before timeout as it changes
  19303. if ( xhr.readyState === 4 ) {
  19304. // Allow onerror to be called first,
  19305. // but that will not handle a native abort
  19306. // Also, save errorCallback to a variable
  19307. // as xhr.onerror cannot be accessed
  19308. window.setTimeout( function() {
  19309. if ( callback ) {
  19310. errorCallback();
  19311. }
  19312. } );
  19313. }
  19314. };
  19315. }
  19316. // Create the abort callback
  19317. callback = callback( "abort" );
  19318. try {
  19319. // Do send the request (this may raise an exception)
  19320. xhr.send( options.hasContent && options.data || null );
  19321. } catch ( e ) {
  19322. // #14683: Only rethrow if this hasn't been notified as an error yet
  19323. if ( callback ) {
  19324. throw e;
  19325. }
  19326. }
  19327. },
  19328. abort: function() {
  19329. if ( callback ) {
  19330. callback();
  19331. }
  19332. }
  19333. };
  19334. }
  19335. } );
  19336. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  19337. jQuery.ajaxPrefilter( function( s ) {
  19338. if ( s.crossDomain ) {
  19339. s.contents.script = false;
  19340. }
  19341. } );
  19342. // Install script dataType
  19343. jQuery.ajaxSetup( {
  19344. accepts: {
  19345. script: "text/javascript, application/javascript, " +
  19346. "application/ecmascript, application/x-ecmascript"
  19347. },
  19348. contents: {
  19349. script: /\b(?:java|ecma)script\b/
  19350. },
  19351. converters: {
  19352. "text script": function( text ) {
  19353. jQuery.globalEval( text );
  19354. return text;
  19355. }
  19356. }
  19357. } );
  19358. // Handle cache's special case and crossDomain
  19359. jQuery.ajaxPrefilter( "script", function( s ) {
  19360. if ( s.cache === undefined ) {
  19361. s.cache = false;
  19362. }
  19363. if ( s.crossDomain ) {
  19364. s.type = "GET";
  19365. }
  19366. } );
  19367. // Bind script tag hack transport
  19368. jQuery.ajaxTransport( "script", function( s ) {
  19369. // This transport only deals with cross domain or forced-by-attrs requests
  19370. if ( s.crossDomain || s.scriptAttrs ) {
  19371. var script, callback;
  19372. return {
  19373. send: function( _, complete ) {
  19374. script = jQuery( "<script>" )
  19375. .attr( s.scriptAttrs || {} )
  19376. .prop( { charset: s.scriptCharset, src: s.url } )
  19377. .on( "load error", callback = function( evt ) {
  19378. script.remove();
  19379. callback = null;
  19380. if ( evt ) {
  19381. complete( evt.type === "error" ? 404 : 200, evt.type );
  19382. }
  19383. } );
  19384. // Use native DOM manipulation to avoid our domManip AJAX trickery
  19385. document.head.appendChild( script[ 0 ] );
  19386. },
  19387. abort: function() {
  19388. if ( callback ) {
  19389. callback();
  19390. }
  19391. }
  19392. };
  19393. }
  19394. } );
  19395. var oldCallbacks = [],
  19396. rjsonp = /(=)\?(?=&|$)|\?\?/;
  19397. // Default jsonp settings
  19398. jQuery.ajaxSetup( {
  19399. jsonp: "callback",
  19400. jsonpCallback: function() {
  19401. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
  19402. this[ callback ] = true;
  19403. return callback;
  19404. }
  19405. } );
  19406. // Detect, normalize options and install callbacks for jsonp requests
  19407. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  19408. var callbackName, overwritten, responseContainer,
  19409. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  19410. "url" :
  19411. typeof s.data === "string" &&
  19412. ( s.contentType || "" )
  19413. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  19414. rjsonp.test( s.data ) && "data"
  19415. );
  19416. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  19417. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  19418. // Get callback name, remembering preexisting value associated with it
  19419. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  19420. s.jsonpCallback() :
  19421. s.jsonpCallback;
  19422. // Insert callback into url or form data
  19423. if ( jsonProp ) {
  19424. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  19425. } else if ( s.jsonp !== false ) {
  19426. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  19427. }
  19428. // Use data converter to retrieve json after script execution
  19429. s.converters[ "script json" ] = function() {
  19430. if ( !responseContainer ) {
  19431. jQuery.error( callbackName + " was not called" );
  19432. }
  19433. return responseContainer[ 0 ];
  19434. };
  19435. // Force json dataType
  19436. s.dataTypes[ 0 ] = "json";
  19437. // Install callback
  19438. overwritten = window[ callbackName ];
  19439. window[ callbackName ] = function() {
  19440. responseContainer = arguments;
  19441. };
  19442. // Clean-up function (fires after converters)
  19443. jqXHR.always( function() {
  19444. // If previous value didn't exist - remove it
  19445. if ( overwritten === undefined ) {
  19446. jQuery( window ).removeProp( callbackName );
  19447. // Otherwise restore preexisting value
  19448. } else {
  19449. window[ callbackName ] = overwritten;
  19450. }
  19451. // Save back as free
  19452. if ( s[ callbackName ] ) {
  19453. // Make sure that re-using the options doesn't screw things around
  19454. s.jsonpCallback = originalSettings.jsonpCallback;
  19455. // Save the callback name for future use
  19456. oldCallbacks.push( callbackName );
  19457. }
  19458. // Call if it was a function and we have a response
  19459. if ( responseContainer && isFunction( overwritten ) ) {
  19460. overwritten( responseContainer[ 0 ] );
  19461. }
  19462. responseContainer = overwritten = undefined;
  19463. } );
  19464. // Delegate to script
  19465. return "script";
  19466. }
  19467. } );
  19468. // Support: Safari 8 only
  19469. // In Safari 8 documents created via document.implementation.createHTMLDocument
  19470. // collapse sibling forms: the second one becomes a child of the first one.
  19471. // Because of that, this security measure has to be disabled in Safari 8.
  19472. // https://bugs.webkit.org/show_bug.cgi?id=137337
  19473. support.createHTMLDocument = ( function() {
  19474. var body = document.implementation.createHTMLDocument( "" ).body;
  19475. body.innerHTML = "<form></form><form></form>";
  19476. return body.childNodes.length === 2;
  19477. } )();
  19478. // Argument "data" should be string of html
  19479. // context (optional): If specified, the fragment will be created in this context,
  19480. // defaults to document
  19481. // keepScripts (optional): If true, will include scripts passed in the html string
  19482. jQuery.parseHTML = function( data, context, keepScripts ) {
  19483. if ( typeof data !== "string" ) {
  19484. return [];
  19485. }
  19486. if ( typeof context === "boolean" ) {
  19487. keepScripts = context;
  19488. context = false;
  19489. }
  19490. var base, parsed, scripts;
  19491. if ( !context ) {
  19492. // Stop scripts or inline event handlers from being executed immediately
  19493. // by using document.implementation
  19494. if ( support.createHTMLDocument ) {
  19495. context = document.implementation.createHTMLDocument( "" );
  19496. // Set the base href for the created document
  19497. // so any parsed elements with URLs
  19498. // are based on the document's URL (gh-2965)
  19499. base = context.createElement( "base" );
  19500. base.href = document.location.href;
  19501. context.head.appendChild( base );
  19502. } else {
  19503. context = document;
  19504. }
  19505. }
  19506. parsed = rsingleTag.exec( data );
  19507. scripts = !keepScripts && [];
  19508. // Single tag
  19509. if ( parsed ) {
  19510. return [ context.createElement( parsed[ 1 ] ) ];
  19511. }
  19512. parsed = buildFragment( [ data ], context, scripts );
  19513. if ( scripts && scripts.length ) {
  19514. jQuery( scripts ).remove();
  19515. }
  19516. return jQuery.merge( [], parsed.childNodes );
  19517. };
  19518. /**
  19519. * Load a url into a page
  19520. */
  19521. jQuery.fn.load = function( url, params, callback ) {
  19522. var selector, type, response,
  19523. self = this,
  19524. off = url.indexOf( " " );
  19525. if ( off > -1 ) {
  19526. selector = stripAndCollapse( url.slice( off ) );
  19527. url = url.slice( 0, off );
  19528. }
  19529. // If it's a function
  19530. if ( isFunction( params ) ) {
  19531. // We assume that it's the callback
  19532. callback = params;
  19533. params = undefined;
  19534. // Otherwise, build a param string
  19535. } else if ( params && typeof params === "object" ) {
  19536. type = "POST";
  19537. }
  19538. // If we have elements to modify, make the request
  19539. if ( self.length > 0 ) {
  19540. jQuery.ajax( {
  19541. url: url,
  19542. // If "type" variable is undefined, then "GET" method will be used.
  19543. // Make value of this field explicit since
  19544. // user can override it through ajaxSetup method
  19545. type: type || "GET",
  19546. dataType: "html",
  19547. data: params
  19548. } ).done( function( responseText ) {
  19549. // Save response for use in complete callback
  19550. response = arguments;
  19551. self.html( selector ?
  19552. // If a selector was specified, locate the right elements in a dummy div
  19553. // Exclude scripts to avoid IE 'Permission Denied' errors
  19554. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  19555. // Otherwise use the full result
  19556. responseText );
  19557. // If the request succeeds, this function gets "data", "status", "jqXHR"
  19558. // but they are ignored because response was set above.
  19559. // If it fails, this function gets "jqXHR", "status", "error"
  19560. } ).always( callback && function( jqXHR, status ) {
  19561. self.each( function() {
  19562. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  19563. } );
  19564. } );
  19565. }
  19566. return this;
  19567. };
  19568. jQuery.expr.pseudos.animated = function( elem ) {
  19569. return jQuery.grep( jQuery.timers, function( fn ) {
  19570. return elem === fn.elem;
  19571. } ).length;
  19572. };
  19573. jQuery.offset = {
  19574. setOffset: function( elem, options, i ) {
  19575. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  19576. position = jQuery.css( elem, "position" ),
  19577. curElem = jQuery( elem ),
  19578. props = {};
  19579. // Set position first, in-case top/left are set even on static elem
  19580. if ( position === "static" ) {
  19581. elem.style.position = "relative";
  19582. }
  19583. curOffset = curElem.offset();
  19584. curCSSTop = jQuery.css( elem, "top" );
  19585. curCSSLeft = jQuery.css( elem, "left" );
  19586. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  19587. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  19588. // Need to be able to calculate position if either
  19589. // top or left is auto and position is either absolute or fixed
  19590. if ( calculatePosition ) {
  19591. curPosition = curElem.position();
  19592. curTop = curPosition.top;
  19593. curLeft = curPosition.left;
  19594. } else {
  19595. curTop = parseFloat( curCSSTop ) || 0;
  19596. curLeft = parseFloat( curCSSLeft ) || 0;
  19597. }
  19598. if ( isFunction( options ) ) {
  19599. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  19600. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  19601. }
  19602. if ( options.top != null ) {
  19603. props.top = ( options.top - curOffset.top ) + curTop;
  19604. }
  19605. if ( options.left != null ) {
  19606. props.left = ( options.left - curOffset.left ) + curLeft;
  19607. }
  19608. if ( "using" in options ) {
  19609. options.using.call( elem, props );
  19610. } else {
  19611. if ( typeof props.top === "number" ) {
  19612. props.top += "px";
  19613. }
  19614. if ( typeof props.left === "number" ) {
  19615. props.left += "px";
  19616. }
  19617. curElem.css( props );
  19618. }
  19619. }
  19620. };
  19621. jQuery.fn.extend( {
  19622. // offset() relates an element's border box to the document origin
  19623. offset: function( options ) {
  19624. // Preserve chaining for setter
  19625. if ( arguments.length ) {
  19626. return options === undefined ?
  19627. this :
  19628. this.each( function( i ) {
  19629. jQuery.offset.setOffset( this, options, i );
  19630. } );
  19631. }
  19632. var rect, win,
  19633. elem = this[ 0 ];
  19634. if ( !elem ) {
  19635. return;
  19636. }
  19637. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  19638. // Support: IE <=11 only
  19639. // Running getBoundingClientRect on a
  19640. // disconnected node in IE throws an error
  19641. if ( !elem.getClientRects().length ) {
  19642. return { top: 0, left: 0 };
  19643. }
  19644. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  19645. rect = elem.getBoundingClientRect();
  19646. win = elem.ownerDocument.defaultView;
  19647. return {
  19648. top: rect.top + win.pageYOffset,
  19649. left: rect.left + win.pageXOffset
  19650. };
  19651. },
  19652. // position() relates an element's margin box to its offset parent's padding box
  19653. // This corresponds to the behavior of CSS absolute positioning
  19654. position: function() {
  19655. if ( !this[ 0 ] ) {
  19656. return;
  19657. }
  19658. var offsetParent, offset, doc,
  19659. elem = this[ 0 ],
  19660. parentOffset = { top: 0, left: 0 };
  19661. // position:fixed elements are offset from the viewport, which itself always has zero offset
  19662. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  19663. // Assume position:fixed implies availability of getBoundingClientRect
  19664. offset = elem.getBoundingClientRect();
  19665. } else {
  19666. offset = this.offset();
  19667. // Account for the *real* offset parent, which can be the document or its root element
  19668. // when a statically positioned element is identified
  19669. doc = elem.ownerDocument;
  19670. offsetParent = elem.offsetParent || doc.documentElement;
  19671. while ( offsetParent &&
  19672. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  19673. jQuery.css( offsetParent, "position" ) === "static" ) {
  19674. offsetParent = offsetParent.parentNode;
  19675. }
  19676. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  19677. // Incorporate borders into its offset, since they are outside its content origin
  19678. parentOffset = jQuery( offsetParent ).offset();
  19679. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  19680. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  19681. }
  19682. }
  19683. // Subtract parent offsets and element margins
  19684. return {
  19685. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  19686. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  19687. };
  19688. },
  19689. // This method will return documentElement in the following cases:
  19690. // 1) For the element inside the iframe without offsetParent, this method will return
  19691. // documentElement of the parent window
  19692. // 2) For the hidden or detached element
  19693. // 3) For body or html element, i.e. in case of the html node - it will return itself
  19694. //
  19695. // but those exceptions were never presented as a real life use-cases
  19696. // and might be considered as more preferable results.
  19697. //
  19698. // This logic, however, is not guaranteed and can change at any point in the future
  19699. offsetParent: function() {
  19700. return this.map( function() {
  19701. var offsetParent = this.offsetParent;
  19702. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  19703. offsetParent = offsetParent.offsetParent;
  19704. }
  19705. return offsetParent || documentElement;
  19706. } );
  19707. }
  19708. } );
  19709. // Create scrollLeft and scrollTop methods
  19710. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  19711. var top = "pageYOffset" === prop;
  19712. jQuery.fn[ method ] = function( val ) {
  19713. return access( this, function( elem, method, val ) {
  19714. // Coalesce documents and windows
  19715. var win;
  19716. if ( isWindow( elem ) ) {
  19717. win = elem;
  19718. } else if ( elem.nodeType === 9 ) {
  19719. win = elem.defaultView;
  19720. }
  19721. if ( val === undefined ) {
  19722. return win ? win[ prop ] : elem[ method ];
  19723. }
  19724. if ( win ) {
  19725. win.scrollTo(
  19726. !top ? val : win.pageXOffset,
  19727. top ? val : win.pageYOffset
  19728. );
  19729. } else {
  19730. elem[ method ] = val;
  19731. }
  19732. }, method, val, arguments.length );
  19733. };
  19734. } );
  19735. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  19736. // Add the top/left cssHooks using jQuery.fn.position
  19737. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  19738. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  19739. // getComputedStyle returns percent when specified for top/left/bottom/right;
  19740. // rather than make the css module depend on the offset module, just check for it here
  19741. jQuery.each( [ "top", "left" ], function( _i, prop ) {
  19742. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  19743. function( elem, computed ) {
  19744. if ( computed ) {
  19745. computed = curCSS( elem, prop );
  19746. // If curCSS returns percentage, fallback to offset
  19747. return rnumnonpx.test( computed ) ?
  19748. jQuery( elem ).position()[ prop ] + "px" :
  19749. computed;
  19750. }
  19751. }
  19752. );
  19753. } );
  19754. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  19755. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  19756. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  19757. function( defaultExtra, funcName ) {
  19758. // Margin is only for outerHeight, outerWidth
  19759. jQuery.fn[ funcName ] = function( margin, value ) {
  19760. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  19761. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  19762. return access( this, function( elem, type, value ) {
  19763. var doc;
  19764. if ( isWindow( elem ) ) {
  19765. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  19766. return funcName.indexOf( "outer" ) === 0 ?
  19767. elem[ "inner" + name ] :
  19768. elem.document.documentElement[ "client" + name ];
  19769. }
  19770. // Get document width or height
  19771. if ( elem.nodeType === 9 ) {
  19772. doc = elem.documentElement;
  19773. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  19774. // whichever is greatest
  19775. return Math.max(
  19776. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  19777. elem.body[ "offset" + name ], doc[ "offset" + name ],
  19778. doc[ "client" + name ]
  19779. );
  19780. }
  19781. return value === undefined ?
  19782. // Get width or height on the element, requesting but not forcing parseFloat
  19783. jQuery.css( elem, type, extra ) :
  19784. // Set width or height on the element
  19785. jQuery.style( elem, type, value, extra );
  19786. }, type, chainable ? margin : undefined, chainable );
  19787. };
  19788. } );
  19789. } );
  19790. jQuery.each( [
  19791. "ajaxStart",
  19792. "ajaxStop",
  19793. "ajaxComplete",
  19794. "ajaxError",
  19795. "ajaxSuccess",
  19796. "ajaxSend"
  19797. ], function( _i, type ) {
  19798. jQuery.fn[ type ] = function( fn ) {
  19799. return this.on( type, fn );
  19800. };
  19801. } );
  19802. jQuery.fn.extend( {
  19803. bind: function( types, data, fn ) {
  19804. return this.on( types, null, data, fn );
  19805. },
  19806. unbind: function( types, fn ) {
  19807. return this.off( types, null, fn );
  19808. },
  19809. delegate: function( selector, types, data, fn ) {
  19810. return this.on( types, selector, data, fn );
  19811. },
  19812. undelegate: function( selector, types, fn ) {
  19813. // ( namespace ) or ( selector, types [, fn] )
  19814. return arguments.length === 1 ?
  19815. this.off( selector, "**" ) :
  19816. this.off( types, selector || "**", fn );
  19817. },
  19818. hover: function( fnOver, fnOut ) {
  19819. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  19820. }
  19821. } );
  19822. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  19823. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  19824. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  19825. function( _i, name ) {
  19826. // Handle event binding
  19827. jQuery.fn[ name ] = function( data, fn ) {
  19828. return arguments.length > 0 ?
  19829. this.on( name, null, data, fn ) :
  19830. this.trigger( name );
  19831. };
  19832. } );
  19833. // Support: Android <=4.0 only
  19834. // Make sure we trim BOM and NBSP
  19835. var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  19836. // Bind a function to a context, optionally partially applying any
  19837. // arguments.
  19838. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  19839. // However, it is not slated for removal any time soon
  19840. jQuery.proxy = function( fn, context ) {
  19841. var tmp, args, proxy;
  19842. if ( typeof context === "string" ) {
  19843. tmp = fn[ context ];
  19844. context = fn;
  19845. fn = tmp;
  19846. }
  19847. // Quick check to determine if target is callable, in the spec
  19848. // this throws a TypeError, but we will just return undefined.
  19849. if ( !isFunction( fn ) ) {
  19850. return undefined;
  19851. }
  19852. // Simulated bind
  19853. args = slice.call( arguments, 2 );
  19854. proxy = function() {
  19855. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  19856. };
  19857. // Set the guid of unique handler to the same of original handler, so it can be removed
  19858. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  19859. return proxy;
  19860. };
  19861. jQuery.holdReady = function( hold ) {
  19862. if ( hold ) {
  19863. jQuery.readyWait++;
  19864. } else {
  19865. jQuery.ready( true );
  19866. }
  19867. };
  19868. jQuery.isArray = Array.isArray;
  19869. jQuery.parseJSON = JSON.parse;
  19870. jQuery.nodeName = nodeName;
  19871. jQuery.isFunction = isFunction;
  19872. jQuery.isWindow = isWindow;
  19873. jQuery.camelCase = camelCase;
  19874. jQuery.type = toType;
  19875. jQuery.now = Date.now;
  19876. jQuery.isNumeric = function( obj ) {
  19877. // As of jQuery 3.0, isNumeric is limited to
  19878. // strings and numbers (primitives or objects)
  19879. // that can be coerced to finite numbers (gh-2662)
  19880. var type = jQuery.type( obj );
  19881. return ( type === "number" || type === "string" ) &&
  19882. // parseFloat NaNs numeric-cast false positives ("")
  19883. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  19884. // subtraction forces infinities to NaN
  19885. !isNaN( obj - parseFloat( obj ) );
  19886. };
  19887. jQuery.trim = function( text ) {
  19888. return text == null ?
  19889. "" :
  19890. ( text + "" ).replace( rtrim, "" );
  19891. };
  19892. // Register as a named AMD module, since jQuery can be concatenated with other
  19893. // files that may use define, but not via a proper concatenation script that
  19894. // understands anonymous AMD modules. A named AMD is safest and most robust
  19895. // way to register. Lowercase jquery is used because AMD module names are
  19896. // derived from file names, and jQuery is normally delivered in a lowercase
  19897. // file name. Do this after creating the global so that if an AMD module wants
  19898. // to call noConflict to hide this version of jQuery, it will work.
  19899. // Note that for maximum portability, libraries that are not jQuery should
  19900. // declare themselves as anonymous modules, and avoid setting a global if an
  19901. // AMD loader is present. jQuery is a special case. For more information, see
  19902. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  19903. if ( true ) {
  19904. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  19905. return jQuery;
  19906. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  19907. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  19908. }
  19909. var
  19910. // Map over jQuery in case of overwrite
  19911. _jQuery = window.jQuery,
  19912. // Map over the $ in case of overwrite
  19913. _$ = window.$;
  19914. jQuery.noConflict = function( deep ) {
  19915. if ( window.$ === jQuery ) {
  19916. window.$ = _$;
  19917. }
  19918. if ( deep && window.jQuery === jQuery ) {
  19919. window.jQuery = _jQuery;
  19920. }
  19921. return jQuery;
  19922. };
  19923. // Expose jQuery and $ identifiers, even in AMD
  19924. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  19925. // and CommonJS for browser emulators (#13566)
  19926. if ( typeof noGlobal === "undefined" ) {
  19927. window.jQuery = window.$ = jQuery;
  19928. }
  19929. return jQuery;
  19930. } );
  19931. /***/ }),
  19932. /***/ "./node_modules/js-cookie/src/js.cookie.js":
  19933. /*!*************************************************!*\
  19934. !*** ./node_modules/js-cookie/src/js.cookie.js ***!
  19935. \*************************************************/
  19936. /*! no static exports found */
  19937. /***/ (function(module, exports, __webpack_require__) {
  19938. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  19939. * JavaScript Cookie v2.2.1
  19940. * https://github.com/js-cookie/js-cookie
  19941. *
  19942. * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
  19943. * Released under the MIT license
  19944. */
  19945. ;(function (factory) {
  19946. var registeredInModuleLoader;
  19947. if (true) {
  19948. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  19949. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  19950. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  19951. __WEBPACK_AMD_DEFINE_FACTORY__),
  19952. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  19953. registeredInModuleLoader = true;
  19954. }
  19955. if (true) {
  19956. module.exports = factory();
  19957. registeredInModuleLoader = true;
  19958. }
  19959. if (!registeredInModuleLoader) {
  19960. var OldCookies = window.Cookies;
  19961. var api = window.Cookies = factory();
  19962. api.noConflict = function () {
  19963. window.Cookies = OldCookies;
  19964. return api;
  19965. };
  19966. }
  19967. }(function () {
  19968. function extend () {
  19969. var i = 0;
  19970. var result = {};
  19971. for (; i < arguments.length; i++) {
  19972. var attributes = arguments[ i ];
  19973. for (var key in attributes) {
  19974. result[key] = attributes[key];
  19975. }
  19976. }
  19977. return result;
  19978. }
  19979. function decode (s) {
  19980. return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
  19981. }
  19982. function init (converter) {
  19983. function api() {}
  19984. function set (key, value, attributes) {
  19985. if (typeof document === 'undefined') {
  19986. return;
  19987. }
  19988. attributes = extend({
  19989. path: '/'
  19990. }, api.defaults, attributes);
  19991. if (typeof attributes.expires === 'number') {
  19992. attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
  19993. }
  19994. // We're using "expires" because "max-age" is not supported by IE
  19995. attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
  19996. try {
  19997. var result = JSON.stringify(value);
  19998. if (/^[\{\[]/.test(result)) {
  19999. value = result;
  20000. }
  20001. } catch (e) {}
  20002. value = converter.write ?
  20003. converter.write(value, key) :
  20004. encodeURIComponent(String(value))
  20005. .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
  20006. key = encodeURIComponent(String(key))
  20007. .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
  20008. .replace(/[\(\)]/g, escape);
  20009. var stringifiedAttributes = '';
  20010. for (var attributeName in attributes) {
  20011. if (!attributes[attributeName]) {
  20012. continue;
  20013. }
  20014. stringifiedAttributes += '; ' + attributeName;
  20015. if (attributes[attributeName] === true) {
  20016. continue;
  20017. }
  20018. // Considers RFC 6265 section 5.2:
  20019. // ...
  20020. // 3. If the remaining unparsed-attributes contains a %x3B (";")
  20021. // character:
  20022. // Consume the characters of the unparsed-attributes up to,
  20023. // not including, the first %x3B (";") character.
  20024. // ...
  20025. stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
  20026. }
  20027. return (document.cookie = key + '=' + value + stringifiedAttributes);
  20028. }
  20029. function get (key, json) {
  20030. if (typeof document === 'undefined') {
  20031. return;
  20032. }
  20033. var jar = {};
  20034. // To prevent the for loop in the first place assign an empty array
  20035. // in case there are no cookies at all.
  20036. var cookies = document.cookie ? document.cookie.split('; ') : [];
  20037. var i = 0;
  20038. for (; i < cookies.length; i++) {
  20039. var parts = cookies[i].split('=');
  20040. var cookie = parts.slice(1).join('=');
  20041. if (!json && cookie.charAt(0) === '"') {
  20042. cookie = cookie.slice(1, -1);
  20043. }
  20044. try {
  20045. var name = decode(parts[0]);
  20046. cookie = (converter.read || converter)(cookie, name) ||
  20047. decode(cookie);
  20048. if (json) {
  20049. try {
  20050. cookie = JSON.parse(cookie);
  20051. } catch (e) {}
  20052. }
  20053. jar[name] = cookie;
  20054. if (key === name) {
  20055. break;
  20056. }
  20057. } catch (e) {}
  20058. }
  20059. return key ? jar[key] : jar;
  20060. }
  20061. api.set = set;
  20062. api.get = function (key) {
  20063. return get(key, false /* read as raw */);
  20064. };
  20065. api.getJSON = function (key) {
  20066. return get(key, true /* read as json */);
  20067. };
  20068. api.remove = function (key, attributes) {
  20069. set(key, '', extend(attributes, {
  20070. expires: -1
  20071. }));
  20072. };
  20073. api.defaults = {};
  20074. api.withConverter = init;
  20075. return api;
  20076. }
  20077. return init(function () {});
  20078. }));
  20079. /***/ }),
  20080. /***/ "./node_modules/laravel-echo/dist/echo.js":
  20081. /*!************************************************!*\
  20082. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  20083. \************************************************/
  20084. /*! exports provided: default */
  20085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20086. "use strict";
  20087. __webpack_require__.r(__webpack_exports__);
  20088. function _classCallCheck(instance, Constructor) {
  20089. if (!(instance instanceof Constructor)) {
  20090. throw new TypeError("Cannot call a class as a function");
  20091. }
  20092. }
  20093. function _defineProperties(target, props) {
  20094. for (var i = 0; i < props.length; i++) {
  20095. var descriptor = props[i];
  20096. descriptor.enumerable = descriptor.enumerable || false;
  20097. descriptor.configurable = true;
  20098. if ("value" in descriptor) descriptor.writable = true;
  20099. Object.defineProperty(target, descriptor.key, descriptor);
  20100. }
  20101. }
  20102. function _createClass(Constructor, protoProps, staticProps) {
  20103. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  20104. if (staticProps) _defineProperties(Constructor, staticProps);
  20105. return Constructor;
  20106. }
  20107. function _extends() {
  20108. _extends = Object.assign || function (target) {
  20109. for (var i = 1; i < arguments.length; i++) {
  20110. var source = arguments[i];
  20111. for (var key in source) {
  20112. if (Object.prototype.hasOwnProperty.call(source, key)) {
  20113. target[key] = source[key];
  20114. }
  20115. }
  20116. }
  20117. return target;
  20118. };
  20119. return _extends.apply(this, arguments);
  20120. }
  20121. function _inherits(subClass, superClass) {
  20122. if (typeof superClass !== "function" && superClass !== null) {
  20123. throw new TypeError("Super expression must either be null or a function");
  20124. }
  20125. subClass.prototype = Object.create(superClass && superClass.prototype, {
  20126. constructor: {
  20127. value: subClass,
  20128. writable: true,
  20129. configurable: true
  20130. }
  20131. });
  20132. if (superClass) _setPrototypeOf(subClass, superClass);
  20133. }
  20134. function _getPrototypeOf(o) {
  20135. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  20136. return o.__proto__ || Object.getPrototypeOf(o);
  20137. };
  20138. return _getPrototypeOf(o);
  20139. }
  20140. function _setPrototypeOf(o, p) {
  20141. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  20142. o.__proto__ = p;
  20143. return o;
  20144. };
  20145. return _setPrototypeOf(o, p);
  20146. }
  20147. function _isNativeReflectConstruct() {
  20148. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  20149. if (Reflect.construct.sham) return false;
  20150. if (typeof Proxy === "function") return true;
  20151. try {
  20152. Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
  20153. return true;
  20154. } catch (e) {
  20155. return false;
  20156. }
  20157. }
  20158. function _assertThisInitialized(self) {
  20159. if (self === void 0) {
  20160. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  20161. }
  20162. return self;
  20163. }
  20164. function _possibleConstructorReturn(self, call) {
  20165. if (call && (typeof call === "object" || typeof call === "function")) {
  20166. return call;
  20167. }
  20168. return _assertThisInitialized(self);
  20169. }
  20170. function _createSuper(Derived) {
  20171. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  20172. return function () {
  20173. var Super = _getPrototypeOf(Derived),
  20174. result;
  20175. if (hasNativeReflectConstruct) {
  20176. var NewTarget = _getPrototypeOf(this).constructor;
  20177. result = Reflect.construct(Super, arguments, NewTarget);
  20178. } else {
  20179. result = Super.apply(this, arguments);
  20180. }
  20181. return _possibleConstructorReturn(this, result);
  20182. };
  20183. }
  20184. var Connector = /*#__PURE__*/function () {
  20185. /**
  20186. * Create a new class instance.
  20187. */
  20188. function Connector(options) {
  20189. _classCallCheck(this, Connector);
  20190. /**
  20191. * Default connector options.
  20192. */
  20193. this._defaultOptions = {
  20194. auth: {
  20195. headers: {}
  20196. },
  20197. authEndpoint: '/broadcasting/auth',
  20198. broadcaster: 'pusher',
  20199. csrfToken: null,
  20200. host: null,
  20201. key: null,
  20202. namespace: 'App.Events'
  20203. };
  20204. this.setOptions(options);
  20205. this.connect();
  20206. }
  20207. /**
  20208. * Merge the custom options with the defaults.
  20209. */
  20210. _createClass(Connector, [{
  20211. key: "setOptions",
  20212. value: function setOptions(options) {
  20213. this.options = _extends(this._defaultOptions, options);
  20214. if (this.csrfToken()) {
  20215. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  20216. }
  20217. return options;
  20218. }
  20219. /**
  20220. * Extract the CSRF token from the page.
  20221. */
  20222. }, {
  20223. key: "csrfToken",
  20224. value: function csrfToken() {
  20225. var selector;
  20226. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  20227. return window['Laravel'].csrfToken;
  20228. } else if (this.options.csrfToken) {
  20229. return this.options.csrfToken;
  20230. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  20231. return selector.getAttribute('content');
  20232. }
  20233. return null;
  20234. }
  20235. }]);
  20236. return Connector;
  20237. }();
  20238. /**
  20239. * This class represents a basic channel.
  20240. */
  20241. var Channel = /*#__PURE__*/function () {
  20242. function Channel() {
  20243. _classCallCheck(this, Channel);
  20244. }
  20245. _createClass(Channel, [{
  20246. key: "listenForWhisper",
  20247. /**
  20248. * Listen for a whisper event on the channel instance.
  20249. */
  20250. value: function listenForWhisper(event, callback) {
  20251. return this.listen('.client-' + event, callback);
  20252. }
  20253. /**
  20254. * Listen for an event on the channel instance.
  20255. */
  20256. }, {
  20257. key: "notification",
  20258. value: function notification(callback) {
  20259. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  20260. }
  20261. /**
  20262. * Stop listening for a whispser event on the channel instance.
  20263. */
  20264. }, {
  20265. key: "stopListeningForWhisper",
  20266. value: function stopListeningForWhisper(event) {
  20267. return this.stopListening('.client-' + event);
  20268. }
  20269. }]);
  20270. return Channel;
  20271. }();
  20272. /**
  20273. * Event name formatter
  20274. */
  20275. var EventFormatter = /*#__PURE__*/function () {
  20276. /**
  20277. * Create a new class instance.
  20278. */
  20279. function EventFormatter(namespace) {
  20280. _classCallCheck(this, EventFormatter);
  20281. this.setNamespace(namespace);
  20282. }
  20283. /**
  20284. * Format the given event name.
  20285. */
  20286. _createClass(EventFormatter, [{
  20287. key: "format",
  20288. value: function format(event) {
  20289. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  20290. return event.substr(1);
  20291. } else if (this.namespace) {
  20292. event = this.namespace + '.' + event;
  20293. }
  20294. return event.replace(/\./g, '\\');
  20295. }
  20296. /**
  20297. * Set the event namespace.
  20298. */
  20299. }, {
  20300. key: "setNamespace",
  20301. value: function setNamespace(value) {
  20302. this.namespace = value;
  20303. }
  20304. }]);
  20305. return EventFormatter;
  20306. }();
  20307. /**
  20308. * This class represents a Pusher channel.
  20309. */
  20310. var PusherChannel = /*#__PURE__*/function (_Channel) {
  20311. _inherits(PusherChannel, _Channel);
  20312. var _super = _createSuper(PusherChannel);
  20313. /**
  20314. * Create a new class instance.
  20315. */
  20316. function PusherChannel(pusher, name, options) {
  20317. var _this;
  20318. _classCallCheck(this, PusherChannel);
  20319. _this = _super.call(this);
  20320. _this.name = name;
  20321. _this.pusher = pusher;
  20322. _this.options = options;
  20323. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  20324. _this.subscribe();
  20325. return _this;
  20326. }
  20327. /**
  20328. * Subscribe to a Pusher channel.
  20329. */
  20330. _createClass(PusherChannel, [{
  20331. key: "subscribe",
  20332. value: function subscribe() {
  20333. this.subscription = this.pusher.subscribe(this.name);
  20334. }
  20335. /**
  20336. * Unsubscribe from a Pusher channel.
  20337. */
  20338. }, {
  20339. key: "unsubscribe",
  20340. value: function unsubscribe() {
  20341. this.pusher.unsubscribe(this.name);
  20342. }
  20343. /**
  20344. * Listen for an event on the channel instance.
  20345. */
  20346. }, {
  20347. key: "listen",
  20348. value: function listen(event, callback) {
  20349. this.on(this.eventFormatter.format(event), callback);
  20350. return this;
  20351. }
  20352. /**
  20353. * Stop listening for an event on the channel instance.
  20354. */
  20355. }, {
  20356. key: "stopListening",
  20357. value: function stopListening(event) {
  20358. this.subscription.unbind(this.eventFormatter.format(event));
  20359. return this;
  20360. }
  20361. /**
  20362. * Bind a channel to an event.
  20363. */
  20364. }, {
  20365. key: "on",
  20366. value: function on(event, callback) {
  20367. this.subscription.bind(event, callback);
  20368. return this;
  20369. }
  20370. }]);
  20371. return PusherChannel;
  20372. }(Channel);
  20373. /**
  20374. * This class represents a Pusher private channel.
  20375. */
  20376. var PusherPrivateChannel = /*#__PURE__*/function (_PusherChannel) {
  20377. _inherits(PusherPrivateChannel, _PusherChannel);
  20378. var _super = _createSuper(PusherPrivateChannel);
  20379. function PusherPrivateChannel() {
  20380. _classCallCheck(this, PusherPrivateChannel);
  20381. return _super.apply(this, arguments);
  20382. }
  20383. _createClass(PusherPrivateChannel, [{
  20384. key: "whisper",
  20385. /**
  20386. * Trigger client event on the channel.
  20387. */
  20388. value: function whisper(eventName, data) {
  20389. this.pusher.channels.channels[this.name].trigger("client-".concat(eventName), data);
  20390. return this;
  20391. }
  20392. }]);
  20393. return PusherPrivateChannel;
  20394. }(PusherChannel);
  20395. /**
  20396. * This class represents a Pusher private channel.
  20397. */
  20398. var PusherEncryptedPrivateChannel = /*#__PURE__*/function (_PusherChannel) {
  20399. _inherits(PusherEncryptedPrivateChannel, _PusherChannel);
  20400. var _super = _createSuper(PusherEncryptedPrivateChannel);
  20401. function PusherEncryptedPrivateChannel() {
  20402. _classCallCheck(this, PusherEncryptedPrivateChannel);
  20403. return _super.apply(this, arguments);
  20404. }
  20405. _createClass(PusherEncryptedPrivateChannel, [{
  20406. key: "whisper",
  20407. /**
  20408. * Trigger client event on the channel.
  20409. */
  20410. value: function whisper(eventName, data) {
  20411. this.pusher.channels.channels[this.name].trigger("client-".concat(eventName), data);
  20412. return this;
  20413. }
  20414. }]);
  20415. return PusherEncryptedPrivateChannel;
  20416. }(PusherChannel);
  20417. /**
  20418. * This class represents a Pusher presence channel.
  20419. */
  20420. var PusherPresenceChannel = /*#__PURE__*/function (_PusherChannel) {
  20421. _inherits(PusherPresenceChannel, _PusherChannel);
  20422. var _super = _createSuper(PusherPresenceChannel);
  20423. function PusherPresenceChannel() {
  20424. _classCallCheck(this, PusherPresenceChannel);
  20425. return _super.apply(this, arguments);
  20426. }
  20427. _createClass(PusherPresenceChannel, [{
  20428. key: "here",
  20429. /**
  20430. * Register a callback to be called anytime the member list changes.
  20431. */
  20432. value: function here(callback) {
  20433. this.on('pusher:subscription_succeeded', function (data) {
  20434. callback(Object.keys(data.members).map(function (k) {
  20435. return data.members[k];
  20436. }));
  20437. });
  20438. return this;
  20439. }
  20440. /**
  20441. * Listen for someone joining the channel.
  20442. */
  20443. }, {
  20444. key: "joining",
  20445. value: function joining(callback) {
  20446. this.on('pusher:member_added', function (member) {
  20447. callback(member.info);
  20448. });
  20449. return this;
  20450. }
  20451. /**
  20452. * Listen for someone leaving the channel.
  20453. */
  20454. }, {
  20455. key: "leaving",
  20456. value: function leaving(callback) {
  20457. this.on('pusher:member_removed', function (member) {
  20458. callback(member.info);
  20459. });
  20460. return this;
  20461. }
  20462. /**
  20463. * Trigger client event on the channel.
  20464. */
  20465. }, {
  20466. key: "whisper",
  20467. value: function whisper(eventName, data) {
  20468. this.pusher.channels.channels[this.name].trigger("client-".concat(eventName), data);
  20469. return this;
  20470. }
  20471. }]);
  20472. return PusherPresenceChannel;
  20473. }(PusherChannel);
  20474. /**
  20475. * This class represents a Socket.io channel.
  20476. */
  20477. var SocketIoChannel = /*#__PURE__*/function (_Channel) {
  20478. _inherits(SocketIoChannel, _Channel);
  20479. var _super = _createSuper(SocketIoChannel);
  20480. /**
  20481. * Create a new class instance.
  20482. */
  20483. function SocketIoChannel(socket, name, options) {
  20484. var _this;
  20485. _classCallCheck(this, SocketIoChannel);
  20486. _this = _super.call(this);
  20487. /**
  20488. * The event callbacks applied to the channel.
  20489. */
  20490. _this.events = {};
  20491. _this.name = name;
  20492. _this.socket = socket;
  20493. _this.options = options;
  20494. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  20495. _this.subscribe();
  20496. _this.configureReconnector();
  20497. return _this;
  20498. }
  20499. /**
  20500. * Subscribe to a Socket.io channel.
  20501. */
  20502. _createClass(SocketIoChannel, [{
  20503. key: "subscribe",
  20504. value: function subscribe() {
  20505. this.socket.emit('subscribe', {
  20506. channel: this.name,
  20507. auth: this.options.auth || {}
  20508. });
  20509. }
  20510. /**
  20511. * Unsubscribe from channel and ubind event callbacks.
  20512. */
  20513. }, {
  20514. key: "unsubscribe",
  20515. value: function unsubscribe() {
  20516. this.unbind();
  20517. this.socket.emit('unsubscribe', {
  20518. channel: this.name,
  20519. auth: this.options.auth || {}
  20520. });
  20521. }
  20522. /**
  20523. * Listen for an event on the channel instance.
  20524. */
  20525. }, {
  20526. key: "listen",
  20527. value: function listen(event, callback) {
  20528. this.on(this.eventFormatter.format(event), callback);
  20529. return this;
  20530. }
  20531. /**
  20532. * Stop listening for an event on the channel instance.
  20533. */
  20534. }, {
  20535. key: "stopListening",
  20536. value: function stopListening(event) {
  20537. var name = this.eventFormatter.format(event);
  20538. this.socket.removeListener(name);
  20539. delete this.events[name];
  20540. return this;
  20541. }
  20542. /**
  20543. * Bind the channel's socket to an event and store the callback.
  20544. */
  20545. }, {
  20546. key: "on",
  20547. value: function on(event, callback) {
  20548. var _this2 = this;
  20549. var listener = function listener(channel, data) {
  20550. if (_this2.name == channel) {
  20551. callback(data);
  20552. }
  20553. };
  20554. this.socket.on(event, listener);
  20555. this.bind(event, listener);
  20556. }
  20557. /**
  20558. * Attach a 'reconnect' listener and bind the event.
  20559. */
  20560. }, {
  20561. key: "configureReconnector",
  20562. value: function configureReconnector() {
  20563. var _this3 = this;
  20564. var listener = function listener() {
  20565. _this3.subscribe();
  20566. };
  20567. this.socket.on('reconnect', listener);
  20568. this.bind('reconnect', listener);
  20569. }
  20570. /**
  20571. * Bind the channel's socket to an event and store the callback.
  20572. */
  20573. }, {
  20574. key: "bind",
  20575. value: function bind(event, callback) {
  20576. this.events[event] = this.events[event] || [];
  20577. this.events[event].push(callback);
  20578. }
  20579. /**
  20580. * Unbind the channel's socket from all stored event callbacks.
  20581. */
  20582. }, {
  20583. key: "unbind",
  20584. value: function unbind() {
  20585. var _this4 = this;
  20586. Object.keys(this.events).forEach(function (event) {
  20587. _this4.events[event].forEach(function (callback) {
  20588. _this4.socket.removeListener(event, callback);
  20589. });
  20590. delete _this4.events[event];
  20591. });
  20592. }
  20593. }]);
  20594. return SocketIoChannel;
  20595. }(Channel);
  20596. /**
  20597. * This class represents a Socket.io presence channel.
  20598. */
  20599. var SocketIoPrivateChannel = /*#__PURE__*/function (_SocketIoChannel) {
  20600. _inherits(SocketIoPrivateChannel, _SocketIoChannel);
  20601. var _super = _createSuper(SocketIoPrivateChannel);
  20602. function SocketIoPrivateChannel() {
  20603. _classCallCheck(this, SocketIoPrivateChannel);
  20604. return _super.apply(this, arguments);
  20605. }
  20606. _createClass(SocketIoPrivateChannel, [{
  20607. key: "whisper",
  20608. /**
  20609. * Trigger client event on the channel.
  20610. */
  20611. value: function whisper(eventName, data) {
  20612. this.socket.emit('client event', {
  20613. channel: this.name,
  20614. event: "client-".concat(eventName),
  20615. data: data
  20616. });
  20617. return this;
  20618. }
  20619. }]);
  20620. return SocketIoPrivateChannel;
  20621. }(SocketIoChannel);
  20622. /**
  20623. * This class represents a Socket.io presence channel.
  20624. */
  20625. var SocketIoPresenceChannel = /*#__PURE__*/function (_SocketIoPrivateChann) {
  20626. _inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  20627. var _super = _createSuper(SocketIoPresenceChannel);
  20628. function SocketIoPresenceChannel() {
  20629. _classCallCheck(this, SocketIoPresenceChannel);
  20630. return _super.apply(this, arguments);
  20631. }
  20632. _createClass(SocketIoPresenceChannel, [{
  20633. key: "here",
  20634. /**
  20635. * Register a callback to be called anytime the member list changes.
  20636. */
  20637. value: function here(callback) {
  20638. this.on('presence:subscribed', function (members) {
  20639. callback(members.map(function (m) {
  20640. return m.user_info;
  20641. }));
  20642. });
  20643. return this;
  20644. }
  20645. /**
  20646. * Listen for someone joining the channel.
  20647. */
  20648. }, {
  20649. key: "joining",
  20650. value: function joining(callback) {
  20651. this.on('presence:joining', function (member) {
  20652. return callback(member.user_info);
  20653. });
  20654. return this;
  20655. }
  20656. /**
  20657. * Listen for someone leaving the channel.
  20658. */
  20659. }, {
  20660. key: "leaving",
  20661. value: function leaving(callback) {
  20662. this.on('presence:leaving', function (member) {
  20663. return callback(member.user_info);
  20664. });
  20665. return this;
  20666. }
  20667. }]);
  20668. return SocketIoPresenceChannel;
  20669. }(SocketIoPrivateChannel);
  20670. /**
  20671. * This class represents a null channel.
  20672. */
  20673. var NullChannel = /*#__PURE__*/function (_Channel) {
  20674. _inherits(NullChannel, _Channel);
  20675. var _super = _createSuper(NullChannel);
  20676. function NullChannel() {
  20677. _classCallCheck(this, NullChannel);
  20678. return _super.apply(this, arguments);
  20679. }
  20680. _createClass(NullChannel, [{
  20681. key: "subscribe",
  20682. /**
  20683. * Subscribe to a channel.
  20684. */
  20685. value: function subscribe() {} //
  20686. /**
  20687. * Unsubscribe from a channel.
  20688. */
  20689. }, {
  20690. key: "unsubscribe",
  20691. value: function unsubscribe() {} //
  20692. /**
  20693. * Listen for an event on the channel instance.
  20694. */
  20695. }, {
  20696. key: "listen",
  20697. value: function listen(event, callback) {
  20698. return this;
  20699. }
  20700. /**
  20701. * Stop listening for an event on the channel instance.
  20702. */
  20703. }, {
  20704. key: "stopListening",
  20705. value: function stopListening(event) {
  20706. return this;
  20707. }
  20708. /**
  20709. * Bind a channel to an event.
  20710. */
  20711. }, {
  20712. key: "on",
  20713. value: function on(event, callback) {
  20714. return this;
  20715. }
  20716. }]);
  20717. return NullChannel;
  20718. }(Channel);
  20719. /**
  20720. * This class represents a null private channel.
  20721. */
  20722. var NullPrivateChannel = /*#__PURE__*/function (_NullChannel) {
  20723. _inherits(NullPrivateChannel, _NullChannel);
  20724. var _super = _createSuper(NullPrivateChannel);
  20725. function NullPrivateChannel() {
  20726. _classCallCheck(this, NullPrivateChannel);
  20727. return _super.apply(this, arguments);
  20728. }
  20729. _createClass(NullPrivateChannel, [{
  20730. key: "whisper",
  20731. /**
  20732. * Trigger client event on the channel.
  20733. */
  20734. value: function whisper(eventName, data) {
  20735. return this;
  20736. }
  20737. }]);
  20738. return NullPrivateChannel;
  20739. }(NullChannel);
  20740. /**
  20741. * This class represents a null presence channel.
  20742. */
  20743. var NullPresenceChannel = /*#__PURE__*/function (_NullChannel) {
  20744. _inherits(NullPresenceChannel, _NullChannel);
  20745. var _super = _createSuper(NullPresenceChannel);
  20746. function NullPresenceChannel() {
  20747. _classCallCheck(this, NullPresenceChannel);
  20748. return _super.apply(this, arguments);
  20749. }
  20750. _createClass(NullPresenceChannel, [{
  20751. key: "here",
  20752. /**
  20753. * Register a callback to be called anytime the member list changes.
  20754. */
  20755. value: function here(callback) {
  20756. return this;
  20757. }
  20758. /**
  20759. * Listen for someone joining the channel.
  20760. */
  20761. }, {
  20762. key: "joining",
  20763. value: function joining(callback) {
  20764. return this;
  20765. }
  20766. /**
  20767. * Listen for someone leaving the channel.
  20768. */
  20769. }, {
  20770. key: "leaving",
  20771. value: function leaving(callback) {
  20772. return this;
  20773. }
  20774. /**
  20775. * Trigger client event on the channel.
  20776. */
  20777. }, {
  20778. key: "whisper",
  20779. value: function whisper(eventName, data) {
  20780. return this;
  20781. }
  20782. }]);
  20783. return NullPresenceChannel;
  20784. }(NullChannel);
  20785. /**
  20786. * This class creates a connector to Pusher.
  20787. */
  20788. var PusherConnector = /*#__PURE__*/function (_Connector) {
  20789. _inherits(PusherConnector, _Connector);
  20790. var _super = _createSuper(PusherConnector);
  20791. function PusherConnector() {
  20792. var _this;
  20793. _classCallCheck(this, PusherConnector);
  20794. _this = _super.apply(this, arguments);
  20795. /**
  20796. * All of the subscribed channel names.
  20797. */
  20798. _this.channels = {};
  20799. return _this;
  20800. }
  20801. /**
  20802. * Create a fresh Pusher connection.
  20803. */
  20804. _createClass(PusherConnector, [{
  20805. key: "connect",
  20806. value: function connect() {
  20807. if (typeof this.options.client !== 'undefined') {
  20808. this.pusher = this.options.client;
  20809. } else {
  20810. this.pusher = new Pusher(this.options.key, this.options);
  20811. }
  20812. }
  20813. /**
  20814. * Listen for an event on a channel instance.
  20815. */
  20816. }, {
  20817. key: "listen",
  20818. value: function listen(name, event, callback) {
  20819. return this.channel(name).listen(event, callback);
  20820. }
  20821. /**
  20822. * Get a channel instance by name.
  20823. */
  20824. }, {
  20825. key: "channel",
  20826. value: function channel(name) {
  20827. if (!this.channels[name]) {
  20828. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  20829. }
  20830. return this.channels[name];
  20831. }
  20832. /**
  20833. * Get a private channel instance by name.
  20834. */
  20835. }, {
  20836. key: "privateChannel",
  20837. value: function privateChannel(name) {
  20838. if (!this.channels['private-' + name]) {
  20839. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  20840. }
  20841. return this.channels['private-' + name];
  20842. }
  20843. /**
  20844. * Get a private encrypted channel instance by name.
  20845. */
  20846. }, {
  20847. key: "encryptedPrivateChannel",
  20848. value: function encryptedPrivateChannel(name) {
  20849. if (!this.channels['private-encrypted-' + name]) {
  20850. this.channels['private-encrypted-' + name] = new PusherEncryptedPrivateChannel(this.pusher, 'private-encrypted-' + name, this.options);
  20851. }
  20852. return this.channels['private-encrypted-' + name];
  20853. }
  20854. /**
  20855. * Get a presence channel instance by name.
  20856. */
  20857. }, {
  20858. key: "presenceChannel",
  20859. value: function presenceChannel(name) {
  20860. if (!this.channels['presence-' + name]) {
  20861. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  20862. }
  20863. return this.channels['presence-' + name];
  20864. }
  20865. /**
  20866. * Leave the given channel, as well as its private and presence variants.
  20867. */
  20868. }, {
  20869. key: "leave",
  20870. value: function leave(name) {
  20871. var _this2 = this;
  20872. var channels = [name, 'private-' + name, 'presence-' + name];
  20873. channels.forEach(function (name, index) {
  20874. _this2.leaveChannel(name);
  20875. });
  20876. }
  20877. /**
  20878. * Leave the given channel.
  20879. */
  20880. }, {
  20881. key: "leaveChannel",
  20882. value: function leaveChannel(name) {
  20883. if (this.channels[name]) {
  20884. this.channels[name].unsubscribe();
  20885. delete this.channels[name];
  20886. }
  20887. }
  20888. /**
  20889. * Get the socket ID for the connection.
  20890. */
  20891. }, {
  20892. key: "socketId",
  20893. value: function socketId() {
  20894. return this.pusher.connection.socket_id;
  20895. }
  20896. /**
  20897. * Disconnect Pusher connection.
  20898. */
  20899. }, {
  20900. key: "disconnect",
  20901. value: function disconnect() {
  20902. this.pusher.disconnect();
  20903. }
  20904. }]);
  20905. return PusherConnector;
  20906. }(Connector);
  20907. /**
  20908. * This class creates a connnector to a Socket.io server.
  20909. */
  20910. var SocketIoConnector = /*#__PURE__*/function (_Connector) {
  20911. _inherits(SocketIoConnector, _Connector);
  20912. var _super = _createSuper(SocketIoConnector);
  20913. function SocketIoConnector() {
  20914. var _this;
  20915. _classCallCheck(this, SocketIoConnector);
  20916. _this = _super.apply(this, arguments);
  20917. /**
  20918. * All of the subscribed channel names.
  20919. */
  20920. _this.channels = {};
  20921. return _this;
  20922. }
  20923. /**
  20924. * Create a fresh Socket.io connection.
  20925. */
  20926. _createClass(SocketIoConnector, [{
  20927. key: "connect",
  20928. value: function connect() {
  20929. var io = this.getSocketIO();
  20930. this.socket = io(this.options.host, this.options);
  20931. return this.socket;
  20932. }
  20933. /**
  20934. * Get socket.io module from global scope or options.
  20935. */
  20936. }, {
  20937. key: "getSocketIO",
  20938. value: function getSocketIO() {
  20939. if (typeof this.options.client !== 'undefined') {
  20940. return this.options.client;
  20941. }
  20942. if (typeof io !== 'undefined') {
  20943. return io;
  20944. }
  20945. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  20946. }
  20947. /**
  20948. * Listen for an event on a channel instance.
  20949. */
  20950. }, {
  20951. key: "listen",
  20952. value: function listen(name, event, callback) {
  20953. return this.channel(name).listen(event, callback);
  20954. }
  20955. /**
  20956. * Get a channel instance by name.
  20957. */
  20958. }, {
  20959. key: "channel",
  20960. value: function channel(name) {
  20961. if (!this.channels[name]) {
  20962. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  20963. }
  20964. return this.channels[name];
  20965. }
  20966. /**
  20967. * Get a private channel instance by name.
  20968. */
  20969. }, {
  20970. key: "privateChannel",
  20971. value: function privateChannel(name) {
  20972. if (!this.channels['private-' + name]) {
  20973. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  20974. }
  20975. return this.channels['private-' + name];
  20976. }
  20977. /**
  20978. * Get a presence channel instance by name.
  20979. */
  20980. }, {
  20981. key: "presenceChannel",
  20982. value: function presenceChannel(name) {
  20983. if (!this.channels['presence-' + name]) {
  20984. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  20985. }
  20986. return this.channels['presence-' + name];
  20987. }
  20988. /**
  20989. * Leave the given channel, as well as its private and presence variants.
  20990. */
  20991. }, {
  20992. key: "leave",
  20993. value: function leave(name) {
  20994. var _this2 = this;
  20995. var channels = [name, 'private-' + name, 'presence-' + name];
  20996. channels.forEach(function (name) {
  20997. _this2.leaveChannel(name);
  20998. });
  20999. }
  21000. /**
  21001. * Leave the given channel.
  21002. */
  21003. }, {
  21004. key: "leaveChannel",
  21005. value: function leaveChannel(name) {
  21006. if (this.channels[name]) {
  21007. this.channels[name].unsubscribe();
  21008. delete this.channels[name];
  21009. }
  21010. }
  21011. /**
  21012. * Get the socket ID for the connection.
  21013. */
  21014. }, {
  21015. key: "socketId",
  21016. value: function socketId() {
  21017. return this.socket.id;
  21018. }
  21019. /**
  21020. * Disconnect Socketio connection.
  21021. */
  21022. }, {
  21023. key: "disconnect",
  21024. value: function disconnect() {
  21025. this.socket.disconnect();
  21026. }
  21027. }]);
  21028. return SocketIoConnector;
  21029. }(Connector);
  21030. /**
  21031. * This class creates a null connector.
  21032. */
  21033. var NullConnector = /*#__PURE__*/function (_Connector) {
  21034. _inherits(NullConnector, _Connector);
  21035. var _super = _createSuper(NullConnector);
  21036. function NullConnector() {
  21037. var _this;
  21038. _classCallCheck(this, NullConnector);
  21039. _this = _super.apply(this, arguments);
  21040. /**
  21041. * All of the subscribed channel names.
  21042. */
  21043. _this.channels = {};
  21044. return _this;
  21045. }
  21046. /**
  21047. * Create a fresh connection.
  21048. */
  21049. _createClass(NullConnector, [{
  21050. key: "connect",
  21051. value: function connect() {} //
  21052. /**
  21053. * Listen for an event on a channel instance.
  21054. */
  21055. }, {
  21056. key: "listen",
  21057. value: function listen(name, event, callback) {
  21058. return new NullChannel();
  21059. }
  21060. /**
  21061. * Get a channel instance by name.
  21062. */
  21063. }, {
  21064. key: "channel",
  21065. value: function channel(name) {
  21066. return new NullChannel();
  21067. }
  21068. /**
  21069. * Get a private channel instance by name.
  21070. */
  21071. }, {
  21072. key: "privateChannel",
  21073. value: function privateChannel(name) {
  21074. return new NullPrivateChannel();
  21075. }
  21076. /**
  21077. * Get a presence channel instance by name.
  21078. */
  21079. }, {
  21080. key: "presenceChannel",
  21081. value: function presenceChannel(name) {
  21082. return new NullPresenceChannel();
  21083. }
  21084. /**
  21085. * Leave the given channel, as well as its private and presence variants.
  21086. */
  21087. }, {
  21088. key: "leave",
  21089. value: function leave(name) {} //
  21090. /**
  21091. * Leave the given channel.
  21092. */
  21093. }, {
  21094. key: "leaveChannel",
  21095. value: function leaveChannel(name) {} //
  21096. /**
  21097. * Get the socket ID for the connection.
  21098. */
  21099. }, {
  21100. key: "socketId",
  21101. value: function socketId() {
  21102. return 'fake-socket-id';
  21103. }
  21104. /**
  21105. * Disconnect the connection.
  21106. */
  21107. }, {
  21108. key: "disconnect",
  21109. value: function disconnect() {//
  21110. }
  21111. }]);
  21112. return NullConnector;
  21113. }(Connector);
  21114. /**
  21115. * This class is the primary API for interacting with broadcasting.
  21116. */
  21117. var Echo = /*#__PURE__*/function () {
  21118. /**
  21119. * Create a new class instance.
  21120. */
  21121. function Echo(options) {
  21122. _classCallCheck(this, Echo);
  21123. this.options = options;
  21124. this.connect();
  21125. if (!this.options.withoutInterceptors) {
  21126. this.registerInterceptors();
  21127. }
  21128. }
  21129. /**
  21130. * Get a channel instance by name.
  21131. */
  21132. _createClass(Echo, [{
  21133. key: "channel",
  21134. value: function channel(_channel) {
  21135. return this.connector.channel(_channel);
  21136. }
  21137. /**
  21138. * Create a new connection.
  21139. */
  21140. }, {
  21141. key: "connect",
  21142. value: function connect() {
  21143. if (this.options.broadcaster == 'pusher') {
  21144. this.connector = new PusherConnector(this.options);
  21145. } else if (this.options.broadcaster == 'socket.io') {
  21146. this.connector = new SocketIoConnector(this.options);
  21147. } else if (this.options.broadcaster == 'null') {
  21148. this.connector = new NullConnector(this.options);
  21149. } else if (typeof this.options.broadcaster == 'function') {
  21150. this.connector = new this.options.broadcaster(this.options);
  21151. }
  21152. }
  21153. /**
  21154. * Disconnect from the Echo server.
  21155. */
  21156. }, {
  21157. key: "disconnect",
  21158. value: function disconnect() {
  21159. this.connector.disconnect();
  21160. }
  21161. /**
  21162. * Get a presence channel instance by name.
  21163. */
  21164. }, {
  21165. key: "join",
  21166. value: function join(channel) {
  21167. return this.connector.presenceChannel(channel);
  21168. }
  21169. /**
  21170. * Leave the given channel, as well as its private and presence variants.
  21171. */
  21172. }, {
  21173. key: "leave",
  21174. value: function leave(channel) {
  21175. this.connector.leave(channel);
  21176. }
  21177. /**
  21178. * Leave the given channel.
  21179. */
  21180. }, {
  21181. key: "leaveChannel",
  21182. value: function leaveChannel(channel) {
  21183. this.connector.leaveChannel(channel);
  21184. }
  21185. /**
  21186. * Listen for an event on a channel instance.
  21187. */
  21188. }, {
  21189. key: "listen",
  21190. value: function listen(channel, event, callback) {
  21191. return this.connector.listen(channel, event, callback);
  21192. }
  21193. /**
  21194. * Get a private channel instance by name.
  21195. */
  21196. }, {
  21197. key: "private",
  21198. value: function _private(channel) {
  21199. return this.connector.privateChannel(channel);
  21200. }
  21201. /**
  21202. * Get a private encrypted channel instance by name.
  21203. */
  21204. }, {
  21205. key: "encryptedPrivate",
  21206. value: function encryptedPrivate(channel) {
  21207. return this.connector.encryptedPrivateChannel(channel);
  21208. }
  21209. /**
  21210. * Get the Socket ID for the connection.
  21211. */
  21212. }, {
  21213. key: "socketId",
  21214. value: function socketId() {
  21215. return this.connector.socketId();
  21216. }
  21217. /**
  21218. * Register 3rd party request interceptiors. These are used to automatically
  21219. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  21220. */
  21221. }, {
  21222. key: "registerInterceptors",
  21223. value: function registerInterceptors() {
  21224. if (typeof Vue === 'function' && Vue.http) {
  21225. this.registerVueRequestInterceptor();
  21226. }
  21227. if (typeof axios === 'function') {
  21228. this.registerAxiosRequestInterceptor();
  21229. }
  21230. if (typeof jQuery === 'function') {
  21231. this.registerjQueryAjaxSetup();
  21232. }
  21233. }
  21234. /**
  21235. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  21236. */
  21237. }, {
  21238. key: "registerVueRequestInterceptor",
  21239. value: function registerVueRequestInterceptor() {
  21240. var _this = this;
  21241. Vue.http.interceptors.push(function (request, next) {
  21242. if (_this.socketId()) {
  21243. request.headers.set('X-Socket-ID', _this.socketId());
  21244. }
  21245. next();
  21246. });
  21247. }
  21248. /**
  21249. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  21250. */
  21251. }, {
  21252. key: "registerAxiosRequestInterceptor",
  21253. value: function registerAxiosRequestInterceptor() {
  21254. var _this2 = this;
  21255. axios.interceptors.request.use(function (config) {
  21256. if (_this2.socketId()) {
  21257. config.headers['X-Socket-Id'] = _this2.socketId();
  21258. }
  21259. return config;
  21260. });
  21261. }
  21262. /**
  21263. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  21264. */
  21265. }, {
  21266. key: "registerjQueryAjaxSetup",
  21267. value: function registerjQueryAjaxSetup() {
  21268. var _this3 = this;
  21269. if (typeof jQuery.ajax != 'undefined') {
  21270. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  21271. if (_this3.socketId()) {
  21272. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  21273. }
  21274. });
  21275. }
  21276. }
  21277. }]);
  21278. return Echo;
  21279. }();
  21280. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  21281. /***/ }),
  21282. /***/ "./node_modules/lodash/lodash.js":
  21283. /*!***************************************!*\
  21284. !*** ./node_modules/lodash/lodash.js ***!
  21285. \***************************************/
  21286. /*! no static exports found */
  21287. /***/ (function(module, exports, __webpack_require__) {
  21288. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  21289. * @license
  21290. * Lodash <https://lodash.com/>
  21291. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  21292. * Released under MIT license <https://lodash.com/license>
  21293. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  21294. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  21295. */
  21296. ;(function() {
  21297. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  21298. var undefined;
  21299. /** Used as the semantic version number. */
  21300. var VERSION = '4.17.15';
  21301. /** Used as the size to enable large array optimizations. */
  21302. var LARGE_ARRAY_SIZE = 200;
  21303. /** Error message constants. */
  21304. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  21305. FUNC_ERROR_TEXT = 'Expected a function';
  21306. /** Used to stand-in for `undefined` hash values. */
  21307. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  21308. /** Used as the maximum memoize cache size. */
  21309. var MAX_MEMOIZE_SIZE = 500;
  21310. /** Used as the internal argument placeholder. */
  21311. var PLACEHOLDER = '__lodash_placeholder__';
  21312. /** Used to compose bitmasks for cloning. */
  21313. var CLONE_DEEP_FLAG = 1,
  21314. CLONE_FLAT_FLAG = 2,
  21315. CLONE_SYMBOLS_FLAG = 4;
  21316. /** Used to compose bitmasks for value comparisons. */
  21317. var COMPARE_PARTIAL_FLAG = 1,
  21318. COMPARE_UNORDERED_FLAG = 2;
  21319. /** Used to compose bitmasks for function metadata. */
  21320. var WRAP_BIND_FLAG = 1,
  21321. WRAP_BIND_KEY_FLAG = 2,
  21322. WRAP_CURRY_BOUND_FLAG = 4,
  21323. WRAP_CURRY_FLAG = 8,
  21324. WRAP_CURRY_RIGHT_FLAG = 16,
  21325. WRAP_PARTIAL_FLAG = 32,
  21326. WRAP_PARTIAL_RIGHT_FLAG = 64,
  21327. WRAP_ARY_FLAG = 128,
  21328. WRAP_REARG_FLAG = 256,
  21329. WRAP_FLIP_FLAG = 512;
  21330. /** Used as default options for `_.truncate`. */
  21331. var DEFAULT_TRUNC_LENGTH = 30,
  21332. DEFAULT_TRUNC_OMISSION = '...';
  21333. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  21334. var HOT_COUNT = 800,
  21335. HOT_SPAN = 16;
  21336. /** Used to indicate the type of lazy iteratees. */
  21337. var LAZY_FILTER_FLAG = 1,
  21338. LAZY_MAP_FLAG = 2,
  21339. LAZY_WHILE_FLAG = 3;
  21340. /** Used as references for various `Number` constants. */
  21341. var INFINITY = 1 / 0,
  21342. MAX_SAFE_INTEGER = 9007199254740991,
  21343. MAX_INTEGER = 1.7976931348623157e+308,
  21344. NAN = 0 / 0;
  21345. /** Used as references for the maximum length and index of an array. */
  21346. var MAX_ARRAY_LENGTH = 4294967295,
  21347. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  21348. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  21349. /** Used to associate wrap methods with their bit flags. */
  21350. var wrapFlags = [
  21351. ['ary', WRAP_ARY_FLAG],
  21352. ['bind', WRAP_BIND_FLAG],
  21353. ['bindKey', WRAP_BIND_KEY_FLAG],
  21354. ['curry', WRAP_CURRY_FLAG],
  21355. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  21356. ['flip', WRAP_FLIP_FLAG],
  21357. ['partial', WRAP_PARTIAL_FLAG],
  21358. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  21359. ['rearg', WRAP_REARG_FLAG]
  21360. ];
  21361. /** `Object#toString` result references. */
  21362. var argsTag = '[object Arguments]',
  21363. arrayTag = '[object Array]',
  21364. asyncTag = '[object AsyncFunction]',
  21365. boolTag = '[object Boolean]',
  21366. dateTag = '[object Date]',
  21367. domExcTag = '[object DOMException]',
  21368. errorTag = '[object Error]',
  21369. funcTag = '[object Function]',
  21370. genTag = '[object GeneratorFunction]',
  21371. mapTag = '[object Map]',
  21372. numberTag = '[object Number]',
  21373. nullTag = '[object Null]',
  21374. objectTag = '[object Object]',
  21375. promiseTag = '[object Promise]',
  21376. proxyTag = '[object Proxy]',
  21377. regexpTag = '[object RegExp]',
  21378. setTag = '[object Set]',
  21379. stringTag = '[object String]',
  21380. symbolTag = '[object Symbol]',
  21381. undefinedTag = '[object Undefined]',
  21382. weakMapTag = '[object WeakMap]',
  21383. weakSetTag = '[object WeakSet]';
  21384. var arrayBufferTag = '[object ArrayBuffer]',
  21385. dataViewTag = '[object DataView]',
  21386. float32Tag = '[object Float32Array]',
  21387. float64Tag = '[object Float64Array]',
  21388. int8Tag = '[object Int8Array]',
  21389. int16Tag = '[object Int16Array]',
  21390. int32Tag = '[object Int32Array]',
  21391. uint8Tag = '[object Uint8Array]',
  21392. uint8ClampedTag = '[object Uint8ClampedArray]',
  21393. uint16Tag = '[object Uint16Array]',
  21394. uint32Tag = '[object Uint32Array]';
  21395. /** Used to match empty string literals in compiled template source. */
  21396. var reEmptyStringLeading = /\b__p \+= '';/g,
  21397. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  21398. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  21399. /** Used to match HTML entities and HTML characters. */
  21400. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  21401. reUnescapedHtml = /[&<>"']/g,
  21402. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  21403. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  21404. /** Used to match template delimiters. */
  21405. var reEscape = /<%-([\s\S]+?)%>/g,
  21406. reEvaluate = /<%([\s\S]+?)%>/g,
  21407. reInterpolate = /<%=([\s\S]+?)%>/g;
  21408. /** Used to match property names within property paths. */
  21409. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  21410. reIsPlainProp = /^\w*$/,
  21411. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  21412. /**
  21413. * Used to match `RegExp`
  21414. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  21415. */
  21416. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  21417. reHasRegExpChar = RegExp(reRegExpChar.source);
  21418. /** Used to match leading and trailing whitespace. */
  21419. var reTrim = /^\s+|\s+$/g,
  21420. reTrimStart = /^\s+/,
  21421. reTrimEnd = /\s+$/;
  21422. /** Used to match wrap detail comments. */
  21423. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  21424. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  21425. reSplitDetails = /,? & /;
  21426. /** Used to match words composed of alphanumeric characters. */
  21427. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  21428. /** Used to match backslashes in property paths. */
  21429. var reEscapeChar = /\\(\\)?/g;
  21430. /**
  21431. * Used to match
  21432. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  21433. */
  21434. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  21435. /** Used to match `RegExp` flags from their coerced string values. */
  21436. var reFlags = /\w*$/;
  21437. /** Used to detect bad signed hexadecimal string values. */
  21438. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  21439. /** Used to detect binary string values. */
  21440. var reIsBinary = /^0b[01]+$/i;
  21441. /** Used to detect host constructors (Safari). */
  21442. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  21443. /** Used to detect octal string values. */
  21444. var reIsOctal = /^0o[0-7]+$/i;
  21445. /** Used to detect unsigned integer values. */
  21446. var reIsUint = /^(?:0|[1-9]\d*)$/;
  21447. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  21448. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  21449. /** Used to ensure capturing order of template delimiters. */
  21450. var reNoMatch = /($^)/;
  21451. /** Used to match unescaped characters in compiled string literals. */
  21452. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  21453. /** Used to compose unicode character classes. */
  21454. var rsAstralRange = '\\ud800-\\udfff',
  21455. rsComboMarksRange = '\\u0300-\\u036f',
  21456. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  21457. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  21458. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  21459. rsDingbatRange = '\\u2700-\\u27bf',
  21460. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  21461. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  21462. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  21463. rsPunctuationRange = '\\u2000-\\u206f',
  21464. 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',
  21465. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  21466. rsVarRange = '\\ufe0e\\ufe0f',
  21467. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  21468. /** Used to compose unicode capture groups. */
  21469. var rsApos = "['\u2019]",
  21470. rsAstral = '[' + rsAstralRange + ']',
  21471. rsBreak = '[' + rsBreakRange + ']',
  21472. rsCombo = '[' + rsComboRange + ']',
  21473. rsDigits = '\\d+',
  21474. rsDingbat = '[' + rsDingbatRange + ']',
  21475. rsLower = '[' + rsLowerRange + ']',
  21476. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  21477. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  21478. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  21479. rsNonAstral = '[^' + rsAstralRange + ']',
  21480. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  21481. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  21482. rsUpper = '[' + rsUpperRange + ']',
  21483. rsZWJ = '\\u200d';
  21484. /** Used to compose unicode regexes. */
  21485. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  21486. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  21487. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  21488. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  21489. reOptMod = rsModifier + '?',
  21490. rsOptVar = '[' + rsVarRange + ']?',
  21491. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  21492. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  21493. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  21494. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  21495. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  21496. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  21497. /** Used to match apostrophes. */
  21498. var reApos = RegExp(rsApos, 'g');
  21499. /**
  21500. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  21501. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  21502. */
  21503. var reComboMark = RegExp(rsCombo, 'g');
  21504. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  21505. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  21506. /** Used to match complex or compound words. */
  21507. var reUnicodeWord = RegExp([
  21508. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  21509. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  21510. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  21511. rsUpper + '+' + rsOptContrUpper,
  21512. rsOrdUpper,
  21513. rsOrdLower,
  21514. rsDigits,
  21515. rsEmoji
  21516. ].join('|'), 'g');
  21517. /** 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/). */
  21518. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  21519. /** Used to detect strings that need a more robust regexp to match words. */
  21520. 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 ]/;
  21521. /** Used to assign default `context` object properties. */
  21522. var contextProps = [
  21523. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  21524. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  21525. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  21526. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  21527. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  21528. ];
  21529. /** Used to make template sourceURLs easier to identify. */
  21530. var templateCounter = -1;
  21531. /** Used to identify `toStringTag` values of typed arrays. */
  21532. var typedArrayTags = {};
  21533. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  21534. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  21535. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  21536. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  21537. typedArrayTags[uint32Tag] = true;
  21538. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  21539. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  21540. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  21541. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  21542. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  21543. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  21544. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  21545. typedArrayTags[weakMapTag] = false;
  21546. /** Used to identify `toStringTag` values supported by `_.clone`. */
  21547. var cloneableTags = {};
  21548. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  21549. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  21550. cloneableTags[boolTag] = cloneableTags[dateTag] =
  21551. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  21552. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  21553. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  21554. cloneableTags[numberTag] = cloneableTags[objectTag] =
  21555. cloneableTags[regexpTag] = cloneableTags[setTag] =
  21556. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  21557. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  21558. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  21559. cloneableTags[errorTag] = cloneableTags[funcTag] =
  21560. cloneableTags[weakMapTag] = false;
  21561. /** Used to map Latin Unicode letters to basic Latin letters. */
  21562. var deburredLetters = {
  21563. // Latin-1 Supplement block.
  21564. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  21565. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  21566. '\xc7': 'C', '\xe7': 'c',
  21567. '\xd0': 'D', '\xf0': 'd',
  21568. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  21569. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  21570. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  21571. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  21572. '\xd1': 'N', '\xf1': 'n',
  21573. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  21574. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  21575. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  21576. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  21577. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  21578. '\xc6': 'Ae', '\xe6': 'ae',
  21579. '\xde': 'Th', '\xfe': 'th',
  21580. '\xdf': 'ss',
  21581. // Latin Extended-A block.
  21582. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  21583. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  21584. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  21585. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  21586. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  21587. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  21588. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  21589. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  21590. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  21591. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  21592. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  21593. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  21594. '\u0134': 'J', '\u0135': 'j',
  21595. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  21596. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  21597. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  21598. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  21599. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  21600. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  21601. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  21602. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  21603. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  21604. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  21605. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  21606. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  21607. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  21608. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  21609. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  21610. '\u0174': 'W', '\u0175': 'w',
  21611. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  21612. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  21613. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  21614. '\u0132': 'IJ', '\u0133': 'ij',
  21615. '\u0152': 'Oe', '\u0153': 'oe',
  21616. '\u0149': "'n", '\u017f': 's'
  21617. };
  21618. /** Used to map characters to HTML entities. */
  21619. var htmlEscapes = {
  21620. '&': '&amp;',
  21621. '<': '&lt;',
  21622. '>': '&gt;',
  21623. '"': '&quot;',
  21624. "'": '&#39;'
  21625. };
  21626. /** Used to map HTML entities to characters. */
  21627. var htmlUnescapes = {
  21628. '&amp;': '&',
  21629. '&lt;': '<',
  21630. '&gt;': '>',
  21631. '&quot;': '"',
  21632. '&#39;': "'"
  21633. };
  21634. /** Used to escape characters for inclusion in compiled string literals. */
  21635. var stringEscapes = {
  21636. '\\': '\\',
  21637. "'": "'",
  21638. '\n': 'n',
  21639. '\r': 'r',
  21640. '\u2028': 'u2028',
  21641. '\u2029': 'u2029'
  21642. };
  21643. /** Built-in method references without a dependency on `root`. */
  21644. var freeParseFloat = parseFloat,
  21645. freeParseInt = parseInt;
  21646. /** Detect free variable `global` from Node.js. */
  21647. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  21648. /** Detect free variable `self`. */
  21649. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  21650. /** Used as a reference to the global object. */
  21651. var root = freeGlobal || freeSelf || Function('return this')();
  21652. /** Detect free variable `exports`. */
  21653. var freeExports = true && exports && !exports.nodeType && exports;
  21654. /** Detect free variable `module`. */
  21655. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  21656. /** Detect the popular CommonJS extension `module.exports`. */
  21657. var moduleExports = freeModule && freeModule.exports === freeExports;
  21658. /** Detect free variable `process` from Node.js. */
  21659. var freeProcess = moduleExports && freeGlobal.process;
  21660. /** Used to access faster Node.js helpers. */
  21661. var nodeUtil = (function() {
  21662. try {
  21663. // Use `util.types` for Node.js 10+.
  21664. var types = freeModule && freeModule.require && freeModule.require('util').types;
  21665. if (types) {
  21666. return types;
  21667. }
  21668. // Legacy `process.binding('util')` for Node.js < 10.
  21669. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  21670. } catch (e) {}
  21671. }());
  21672. /* Node.js helper references. */
  21673. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  21674. nodeIsDate = nodeUtil && nodeUtil.isDate,
  21675. nodeIsMap = nodeUtil && nodeUtil.isMap,
  21676. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  21677. nodeIsSet = nodeUtil && nodeUtil.isSet,
  21678. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  21679. /*--------------------------------------------------------------------------*/
  21680. /**
  21681. * A faster alternative to `Function#apply`, this function invokes `func`
  21682. * with the `this` binding of `thisArg` and the arguments of `args`.
  21683. *
  21684. * @private
  21685. * @param {Function} func The function to invoke.
  21686. * @param {*} thisArg The `this` binding of `func`.
  21687. * @param {Array} args The arguments to invoke `func` with.
  21688. * @returns {*} Returns the result of `func`.
  21689. */
  21690. function apply(func, thisArg, args) {
  21691. switch (args.length) {
  21692. case 0: return func.call(thisArg);
  21693. case 1: return func.call(thisArg, args[0]);
  21694. case 2: return func.call(thisArg, args[0], args[1]);
  21695. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  21696. }
  21697. return func.apply(thisArg, args);
  21698. }
  21699. /**
  21700. * A specialized version of `baseAggregator` for arrays.
  21701. *
  21702. * @private
  21703. * @param {Array} [array] The array to iterate over.
  21704. * @param {Function} setter The function to set `accumulator` values.
  21705. * @param {Function} iteratee The iteratee to transform keys.
  21706. * @param {Object} accumulator The initial aggregated object.
  21707. * @returns {Function} Returns `accumulator`.
  21708. */
  21709. function arrayAggregator(array, setter, iteratee, accumulator) {
  21710. var index = -1,
  21711. length = array == null ? 0 : array.length;
  21712. while (++index < length) {
  21713. var value = array[index];
  21714. setter(accumulator, value, iteratee(value), array);
  21715. }
  21716. return accumulator;
  21717. }
  21718. /**
  21719. * A specialized version of `_.forEach` for arrays without support for
  21720. * iteratee shorthands.
  21721. *
  21722. * @private
  21723. * @param {Array} [array] The array to iterate over.
  21724. * @param {Function} iteratee The function invoked per iteration.
  21725. * @returns {Array} Returns `array`.
  21726. */
  21727. function arrayEach(array, iteratee) {
  21728. var index = -1,
  21729. length = array == null ? 0 : array.length;
  21730. while (++index < length) {
  21731. if (iteratee(array[index], index, array) === false) {
  21732. break;
  21733. }
  21734. }
  21735. return array;
  21736. }
  21737. /**
  21738. * A specialized version of `_.forEachRight` for arrays without support for
  21739. * iteratee shorthands.
  21740. *
  21741. * @private
  21742. * @param {Array} [array] The array to iterate over.
  21743. * @param {Function} iteratee The function invoked per iteration.
  21744. * @returns {Array} Returns `array`.
  21745. */
  21746. function arrayEachRight(array, iteratee) {
  21747. var length = array == null ? 0 : array.length;
  21748. while (length--) {
  21749. if (iteratee(array[length], length, array) === false) {
  21750. break;
  21751. }
  21752. }
  21753. return array;
  21754. }
  21755. /**
  21756. * A specialized version of `_.every` for arrays without support for
  21757. * iteratee shorthands.
  21758. *
  21759. * @private
  21760. * @param {Array} [array] The array to iterate over.
  21761. * @param {Function} predicate The function invoked per iteration.
  21762. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  21763. * else `false`.
  21764. */
  21765. function arrayEvery(array, predicate) {
  21766. var index = -1,
  21767. length = array == null ? 0 : array.length;
  21768. while (++index < length) {
  21769. if (!predicate(array[index], index, array)) {
  21770. return false;
  21771. }
  21772. }
  21773. return true;
  21774. }
  21775. /**
  21776. * A specialized version of `_.filter` for arrays without support for
  21777. * iteratee shorthands.
  21778. *
  21779. * @private
  21780. * @param {Array} [array] The array to iterate over.
  21781. * @param {Function} predicate The function invoked per iteration.
  21782. * @returns {Array} Returns the new filtered array.
  21783. */
  21784. function arrayFilter(array, predicate) {
  21785. var index = -1,
  21786. length = array == null ? 0 : array.length,
  21787. resIndex = 0,
  21788. result = [];
  21789. while (++index < length) {
  21790. var value = array[index];
  21791. if (predicate(value, index, array)) {
  21792. result[resIndex++] = value;
  21793. }
  21794. }
  21795. return result;
  21796. }
  21797. /**
  21798. * A specialized version of `_.includes` for arrays without support for
  21799. * specifying an index to search from.
  21800. *
  21801. * @private
  21802. * @param {Array} [array] The array to inspect.
  21803. * @param {*} target The value to search for.
  21804. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  21805. */
  21806. function arrayIncludes(array, value) {
  21807. var length = array == null ? 0 : array.length;
  21808. return !!length && baseIndexOf(array, value, 0) > -1;
  21809. }
  21810. /**
  21811. * This function is like `arrayIncludes` except that it accepts a comparator.
  21812. *
  21813. * @private
  21814. * @param {Array} [array] The array to inspect.
  21815. * @param {*} target The value to search for.
  21816. * @param {Function} comparator The comparator invoked per element.
  21817. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  21818. */
  21819. function arrayIncludesWith(array, value, comparator) {
  21820. var index = -1,
  21821. length = array == null ? 0 : array.length;
  21822. while (++index < length) {
  21823. if (comparator(value, array[index])) {
  21824. return true;
  21825. }
  21826. }
  21827. return false;
  21828. }
  21829. /**
  21830. * A specialized version of `_.map` for arrays without support for iteratee
  21831. * shorthands.
  21832. *
  21833. * @private
  21834. * @param {Array} [array] The array to iterate over.
  21835. * @param {Function} iteratee The function invoked per iteration.
  21836. * @returns {Array} Returns the new mapped array.
  21837. */
  21838. function arrayMap(array, iteratee) {
  21839. var index = -1,
  21840. length = array == null ? 0 : array.length,
  21841. result = Array(length);
  21842. while (++index < length) {
  21843. result[index] = iteratee(array[index], index, array);
  21844. }
  21845. return result;
  21846. }
  21847. /**
  21848. * Appends the elements of `values` to `array`.
  21849. *
  21850. * @private
  21851. * @param {Array} array The array to modify.
  21852. * @param {Array} values The values to append.
  21853. * @returns {Array} Returns `array`.
  21854. */
  21855. function arrayPush(array, values) {
  21856. var index = -1,
  21857. length = values.length,
  21858. offset = array.length;
  21859. while (++index < length) {
  21860. array[offset + index] = values[index];
  21861. }
  21862. return array;
  21863. }
  21864. /**
  21865. * A specialized version of `_.reduce` for arrays without support for
  21866. * iteratee shorthands.
  21867. *
  21868. * @private
  21869. * @param {Array} [array] The array to iterate over.
  21870. * @param {Function} iteratee The function invoked per iteration.
  21871. * @param {*} [accumulator] The initial value.
  21872. * @param {boolean} [initAccum] Specify using the first element of `array` as
  21873. * the initial value.
  21874. * @returns {*} Returns the accumulated value.
  21875. */
  21876. function arrayReduce(array, iteratee, accumulator, initAccum) {
  21877. var index = -1,
  21878. length = array == null ? 0 : array.length;
  21879. if (initAccum && length) {
  21880. accumulator = array[++index];
  21881. }
  21882. while (++index < length) {
  21883. accumulator = iteratee(accumulator, array[index], index, array);
  21884. }
  21885. return accumulator;
  21886. }
  21887. /**
  21888. * A specialized version of `_.reduceRight` for arrays without support for
  21889. * iteratee shorthands.
  21890. *
  21891. * @private
  21892. * @param {Array} [array] The array to iterate over.
  21893. * @param {Function} iteratee The function invoked per iteration.
  21894. * @param {*} [accumulator] The initial value.
  21895. * @param {boolean} [initAccum] Specify using the last element of `array` as
  21896. * the initial value.
  21897. * @returns {*} Returns the accumulated value.
  21898. */
  21899. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  21900. var length = array == null ? 0 : array.length;
  21901. if (initAccum && length) {
  21902. accumulator = array[--length];
  21903. }
  21904. while (length--) {
  21905. accumulator = iteratee(accumulator, array[length], length, array);
  21906. }
  21907. return accumulator;
  21908. }
  21909. /**
  21910. * A specialized version of `_.some` for arrays without support for iteratee
  21911. * shorthands.
  21912. *
  21913. * @private
  21914. * @param {Array} [array] The array to iterate over.
  21915. * @param {Function} predicate The function invoked per iteration.
  21916. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21917. * else `false`.
  21918. */
  21919. function arraySome(array, predicate) {
  21920. var index = -1,
  21921. length = array == null ? 0 : array.length;
  21922. while (++index < length) {
  21923. if (predicate(array[index], index, array)) {
  21924. return true;
  21925. }
  21926. }
  21927. return false;
  21928. }
  21929. /**
  21930. * Gets the size of an ASCII `string`.
  21931. *
  21932. * @private
  21933. * @param {string} string The string inspect.
  21934. * @returns {number} Returns the string size.
  21935. */
  21936. var asciiSize = baseProperty('length');
  21937. /**
  21938. * Converts an ASCII `string` to an array.
  21939. *
  21940. * @private
  21941. * @param {string} string The string to convert.
  21942. * @returns {Array} Returns the converted array.
  21943. */
  21944. function asciiToArray(string) {
  21945. return string.split('');
  21946. }
  21947. /**
  21948. * Splits an ASCII `string` into an array of its words.
  21949. *
  21950. * @private
  21951. * @param {string} The string to inspect.
  21952. * @returns {Array} Returns the words of `string`.
  21953. */
  21954. function asciiWords(string) {
  21955. return string.match(reAsciiWord) || [];
  21956. }
  21957. /**
  21958. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  21959. * without support for iteratee shorthands, which iterates over `collection`
  21960. * using `eachFunc`.
  21961. *
  21962. * @private
  21963. * @param {Array|Object} collection The collection to inspect.
  21964. * @param {Function} predicate The function invoked per iteration.
  21965. * @param {Function} eachFunc The function to iterate over `collection`.
  21966. * @returns {*} Returns the found element or its key, else `undefined`.
  21967. */
  21968. function baseFindKey(collection, predicate, eachFunc) {
  21969. var result;
  21970. eachFunc(collection, function(value, key, collection) {
  21971. if (predicate(value, key, collection)) {
  21972. result = key;
  21973. return false;
  21974. }
  21975. });
  21976. return result;
  21977. }
  21978. /**
  21979. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  21980. * support for iteratee shorthands.
  21981. *
  21982. * @private
  21983. * @param {Array} array The array to inspect.
  21984. * @param {Function} predicate The function invoked per iteration.
  21985. * @param {number} fromIndex The index to search from.
  21986. * @param {boolean} [fromRight] Specify iterating from right to left.
  21987. * @returns {number} Returns the index of the matched value, else `-1`.
  21988. */
  21989. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  21990. var length = array.length,
  21991. index = fromIndex + (fromRight ? 1 : -1);
  21992. while ((fromRight ? index-- : ++index < length)) {
  21993. if (predicate(array[index], index, array)) {
  21994. return index;
  21995. }
  21996. }
  21997. return -1;
  21998. }
  21999. /**
  22000. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  22001. *
  22002. * @private
  22003. * @param {Array} array The array to inspect.
  22004. * @param {*} value The value to search for.
  22005. * @param {number} fromIndex The index to search from.
  22006. * @returns {number} Returns the index of the matched value, else `-1`.
  22007. */
  22008. function baseIndexOf(array, value, fromIndex) {
  22009. return value === value
  22010. ? strictIndexOf(array, value, fromIndex)
  22011. : baseFindIndex(array, baseIsNaN, fromIndex);
  22012. }
  22013. /**
  22014. * This function is like `baseIndexOf` except that it accepts a comparator.
  22015. *
  22016. * @private
  22017. * @param {Array} array The array to inspect.
  22018. * @param {*} value The value to search for.
  22019. * @param {number} fromIndex The index to search from.
  22020. * @param {Function} comparator The comparator invoked per element.
  22021. * @returns {number} Returns the index of the matched value, else `-1`.
  22022. */
  22023. function baseIndexOfWith(array, value, fromIndex, comparator) {
  22024. var index = fromIndex - 1,
  22025. length = array.length;
  22026. while (++index < length) {
  22027. if (comparator(array[index], value)) {
  22028. return index;
  22029. }
  22030. }
  22031. return -1;
  22032. }
  22033. /**
  22034. * The base implementation of `_.isNaN` without support for number objects.
  22035. *
  22036. * @private
  22037. * @param {*} value The value to check.
  22038. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  22039. */
  22040. function baseIsNaN(value) {
  22041. return value !== value;
  22042. }
  22043. /**
  22044. * The base implementation of `_.mean` and `_.meanBy` without support for
  22045. * iteratee shorthands.
  22046. *
  22047. * @private
  22048. * @param {Array} array The array to iterate over.
  22049. * @param {Function} iteratee The function invoked per iteration.
  22050. * @returns {number} Returns the mean.
  22051. */
  22052. function baseMean(array, iteratee) {
  22053. var length = array == null ? 0 : array.length;
  22054. return length ? (baseSum(array, iteratee) / length) : NAN;
  22055. }
  22056. /**
  22057. * The base implementation of `_.property` without support for deep paths.
  22058. *
  22059. * @private
  22060. * @param {string} key The key of the property to get.
  22061. * @returns {Function} Returns the new accessor function.
  22062. */
  22063. function baseProperty(key) {
  22064. return function(object) {
  22065. return object == null ? undefined : object[key];
  22066. };
  22067. }
  22068. /**
  22069. * The base implementation of `_.propertyOf` without support for deep paths.
  22070. *
  22071. * @private
  22072. * @param {Object} object The object to query.
  22073. * @returns {Function} Returns the new accessor function.
  22074. */
  22075. function basePropertyOf(object) {
  22076. return function(key) {
  22077. return object == null ? undefined : object[key];
  22078. };
  22079. }
  22080. /**
  22081. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  22082. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  22083. *
  22084. * @private
  22085. * @param {Array|Object} collection The collection to iterate over.
  22086. * @param {Function} iteratee The function invoked per iteration.
  22087. * @param {*} accumulator The initial value.
  22088. * @param {boolean} initAccum Specify using the first or last element of
  22089. * `collection` as the initial value.
  22090. * @param {Function} eachFunc The function to iterate over `collection`.
  22091. * @returns {*} Returns the accumulated value.
  22092. */
  22093. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  22094. eachFunc(collection, function(value, index, collection) {
  22095. accumulator = initAccum
  22096. ? (initAccum = false, value)
  22097. : iteratee(accumulator, value, index, collection);
  22098. });
  22099. return accumulator;
  22100. }
  22101. /**
  22102. * The base implementation of `_.sortBy` which uses `comparer` to define the
  22103. * sort order of `array` and replaces criteria objects with their corresponding
  22104. * values.
  22105. *
  22106. * @private
  22107. * @param {Array} array The array to sort.
  22108. * @param {Function} comparer The function to define sort order.
  22109. * @returns {Array} Returns `array`.
  22110. */
  22111. function baseSortBy(array, comparer) {
  22112. var length = array.length;
  22113. array.sort(comparer);
  22114. while (length--) {
  22115. array[length] = array[length].value;
  22116. }
  22117. return array;
  22118. }
  22119. /**
  22120. * The base implementation of `_.sum` and `_.sumBy` without support for
  22121. * iteratee shorthands.
  22122. *
  22123. * @private
  22124. * @param {Array} array The array to iterate over.
  22125. * @param {Function} iteratee The function invoked per iteration.
  22126. * @returns {number} Returns the sum.
  22127. */
  22128. function baseSum(array, iteratee) {
  22129. var result,
  22130. index = -1,
  22131. length = array.length;
  22132. while (++index < length) {
  22133. var current = iteratee(array[index]);
  22134. if (current !== undefined) {
  22135. result = result === undefined ? current : (result + current);
  22136. }
  22137. }
  22138. return result;
  22139. }
  22140. /**
  22141. * The base implementation of `_.times` without support for iteratee shorthands
  22142. * or max array length checks.
  22143. *
  22144. * @private
  22145. * @param {number} n The number of times to invoke `iteratee`.
  22146. * @param {Function} iteratee The function invoked per iteration.
  22147. * @returns {Array} Returns the array of results.
  22148. */
  22149. function baseTimes(n, iteratee) {
  22150. var index = -1,
  22151. result = Array(n);
  22152. while (++index < n) {
  22153. result[index] = iteratee(index);
  22154. }
  22155. return result;
  22156. }
  22157. /**
  22158. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  22159. * of key-value pairs for `object` corresponding to the property names of `props`.
  22160. *
  22161. * @private
  22162. * @param {Object} object The object to query.
  22163. * @param {Array} props The property names to get values for.
  22164. * @returns {Object} Returns the key-value pairs.
  22165. */
  22166. function baseToPairs(object, props) {
  22167. return arrayMap(props, function(key) {
  22168. return [key, object[key]];
  22169. });
  22170. }
  22171. /**
  22172. * The base implementation of `_.unary` without support for storing metadata.
  22173. *
  22174. * @private
  22175. * @param {Function} func The function to cap arguments for.
  22176. * @returns {Function} Returns the new capped function.
  22177. */
  22178. function baseUnary(func) {
  22179. return function(value) {
  22180. return func(value);
  22181. };
  22182. }
  22183. /**
  22184. * The base implementation of `_.values` and `_.valuesIn` which creates an
  22185. * array of `object` property values corresponding to the property names
  22186. * of `props`.
  22187. *
  22188. * @private
  22189. * @param {Object} object The object to query.
  22190. * @param {Array} props The property names to get values for.
  22191. * @returns {Object} Returns the array of property values.
  22192. */
  22193. function baseValues(object, props) {
  22194. return arrayMap(props, function(key) {
  22195. return object[key];
  22196. });
  22197. }
  22198. /**
  22199. * Checks if a `cache` value for `key` exists.
  22200. *
  22201. * @private
  22202. * @param {Object} cache The cache to query.
  22203. * @param {string} key The key of the entry to check.
  22204. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  22205. */
  22206. function cacheHas(cache, key) {
  22207. return cache.has(key);
  22208. }
  22209. /**
  22210. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  22211. * that is not found in the character symbols.
  22212. *
  22213. * @private
  22214. * @param {Array} strSymbols The string symbols to inspect.
  22215. * @param {Array} chrSymbols The character symbols to find.
  22216. * @returns {number} Returns the index of the first unmatched string symbol.
  22217. */
  22218. function charsStartIndex(strSymbols, chrSymbols) {
  22219. var index = -1,
  22220. length = strSymbols.length;
  22221. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  22222. return index;
  22223. }
  22224. /**
  22225. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  22226. * that is not found in the character symbols.
  22227. *
  22228. * @private
  22229. * @param {Array} strSymbols The string symbols to inspect.
  22230. * @param {Array} chrSymbols The character symbols to find.
  22231. * @returns {number} Returns the index of the last unmatched string symbol.
  22232. */
  22233. function charsEndIndex(strSymbols, chrSymbols) {
  22234. var index = strSymbols.length;
  22235. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  22236. return index;
  22237. }
  22238. /**
  22239. * Gets the number of `placeholder` occurrences in `array`.
  22240. *
  22241. * @private
  22242. * @param {Array} array The array to inspect.
  22243. * @param {*} placeholder The placeholder to search for.
  22244. * @returns {number} Returns the placeholder count.
  22245. */
  22246. function countHolders(array, placeholder) {
  22247. var length = array.length,
  22248. result = 0;
  22249. while (length--) {
  22250. if (array[length] === placeholder) {
  22251. ++result;
  22252. }
  22253. }
  22254. return result;
  22255. }
  22256. /**
  22257. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  22258. * letters to basic Latin letters.
  22259. *
  22260. * @private
  22261. * @param {string} letter The matched letter to deburr.
  22262. * @returns {string} Returns the deburred letter.
  22263. */
  22264. var deburrLetter = basePropertyOf(deburredLetters);
  22265. /**
  22266. * Used by `_.escape` to convert characters to HTML entities.
  22267. *
  22268. * @private
  22269. * @param {string} chr The matched character to escape.
  22270. * @returns {string} Returns the escaped character.
  22271. */
  22272. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  22273. /**
  22274. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  22275. *
  22276. * @private
  22277. * @param {string} chr The matched character to escape.
  22278. * @returns {string} Returns the escaped character.
  22279. */
  22280. function escapeStringChar(chr) {
  22281. return '\\' + stringEscapes[chr];
  22282. }
  22283. /**
  22284. * Gets the value at `key` of `object`.
  22285. *
  22286. * @private
  22287. * @param {Object} [object] The object to query.
  22288. * @param {string} key The key of the property to get.
  22289. * @returns {*} Returns the property value.
  22290. */
  22291. function getValue(object, key) {
  22292. return object == null ? undefined : object[key];
  22293. }
  22294. /**
  22295. * Checks if `string` contains Unicode symbols.
  22296. *
  22297. * @private
  22298. * @param {string} string The string to inspect.
  22299. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  22300. */
  22301. function hasUnicode(string) {
  22302. return reHasUnicode.test(string);
  22303. }
  22304. /**
  22305. * Checks if `string` contains a word composed of Unicode symbols.
  22306. *
  22307. * @private
  22308. * @param {string} string The string to inspect.
  22309. * @returns {boolean} Returns `true` if a word is found, else `false`.
  22310. */
  22311. function hasUnicodeWord(string) {
  22312. return reHasUnicodeWord.test(string);
  22313. }
  22314. /**
  22315. * Converts `iterator` to an array.
  22316. *
  22317. * @private
  22318. * @param {Object} iterator The iterator to convert.
  22319. * @returns {Array} Returns the converted array.
  22320. */
  22321. function iteratorToArray(iterator) {
  22322. var data,
  22323. result = [];
  22324. while (!(data = iterator.next()).done) {
  22325. result.push(data.value);
  22326. }
  22327. return result;
  22328. }
  22329. /**
  22330. * Converts `map` to its key-value pairs.
  22331. *
  22332. * @private
  22333. * @param {Object} map The map to convert.
  22334. * @returns {Array} Returns the key-value pairs.
  22335. */
  22336. function mapToArray(map) {
  22337. var index = -1,
  22338. result = Array(map.size);
  22339. map.forEach(function(value, key) {
  22340. result[++index] = [key, value];
  22341. });
  22342. return result;
  22343. }
  22344. /**
  22345. * Creates a unary function that invokes `func` with its argument transformed.
  22346. *
  22347. * @private
  22348. * @param {Function} func The function to wrap.
  22349. * @param {Function} transform The argument transform.
  22350. * @returns {Function} Returns the new function.
  22351. */
  22352. function overArg(func, transform) {
  22353. return function(arg) {
  22354. return func(transform(arg));
  22355. };
  22356. }
  22357. /**
  22358. * Replaces all `placeholder` elements in `array` with an internal placeholder
  22359. * and returns an array of their indexes.
  22360. *
  22361. * @private
  22362. * @param {Array} array The array to modify.
  22363. * @param {*} placeholder The placeholder to replace.
  22364. * @returns {Array} Returns the new array of placeholder indexes.
  22365. */
  22366. function replaceHolders(array, placeholder) {
  22367. var index = -1,
  22368. length = array.length,
  22369. resIndex = 0,
  22370. result = [];
  22371. while (++index < length) {
  22372. var value = array[index];
  22373. if (value === placeholder || value === PLACEHOLDER) {
  22374. array[index] = PLACEHOLDER;
  22375. result[resIndex++] = index;
  22376. }
  22377. }
  22378. return result;
  22379. }
  22380. /**
  22381. * Converts `set` to an array of its values.
  22382. *
  22383. * @private
  22384. * @param {Object} set The set to convert.
  22385. * @returns {Array} Returns the values.
  22386. */
  22387. function setToArray(set) {
  22388. var index = -1,
  22389. result = Array(set.size);
  22390. set.forEach(function(value) {
  22391. result[++index] = value;
  22392. });
  22393. return result;
  22394. }
  22395. /**
  22396. * Converts `set` to its value-value pairs.
  22397. *
  22398. * @private
  22399. * @param {Object} set The set to convert.
  22400. * @returns {Array} Returns the value-value pairs.
  22401. */
  22402. function setToPairs(set) {
  22403. var index = -1,
  22404. result = Array(set.size);
  22405. set.forEach(function(value) {
  22406. result[++index] = [value, value];
  22407. });
  22408. return result;
  22409. }
  22410. /**
  22411. * A specialized version of `_.indexOf` which performs strict equality
  22412. * comparisons of values, i.e. `===`.
  22413. *
  22414. * @private
  22415. * @param {Array} array The array to inspect.
  22416. * @param {*} value The value to search for.
  22417. * @param {number} fromIndex The index to search from.
  22418. * @returns {number} Returns the index of the matched value, else `-1`.
  22419. */
  22420. function strictIndexOf(array, value, fromIndex) {
  22421. var index = fromIndex - 1,
  22422. length = array.length;
  22423. while (++index < length) {
  22424. if (array[index] === value) {
  22425. return index;
  22426. }
  22427. }
  22428. return -1;
  22429. }
  22430. /**
  22431. * A specialized version of `_.lastIndexOf` which performs strict equality
  22432. * comparisons of values, i.e. `===`.
  22433. *
  22434. * @private
  22435. * @param {Array} array The array to inspect.
  22436. * @param {*} value The value to search for.
  22437. * @param {number} fromIndex The index to search from.
  22438. * @returns {number} Returns the index of the matched value, else `-1`.
  22439. */
  22440. function strictLastIndexOf(array, value, fromIndex) {
  22441. var index = fromIndex + 1;
  22442. while (index--) {
  22443. if (array[index] === value) {
  22444. return index;
  22445. }
  22446. }
  22447. return index;
  22448. }
  22449. /**
  22450. * Gets the number of symbols in `string`.
  22451. *
  22452. * @private
  22453. * @param {string} string The string to inspect.
  22454. * @returns {number} Returns the string size.
  22455. */
  22456. function stringSize(string) {
  22457. return hasUnicode(string)
  22458. ? unicodeSize(string)
  22459. : asciiSize(string);
  22460. }
  22461. /**
  22462. * Converts `string` to an array.
  22463. *
  22464. * @private
  22465. * @param {string} string The string to convert.
  22466. * @returns {Array} Returns the converted array.
  22467. */
  22468. function stringToArray(string) {
  22469. return hasUnicode(string)
  22470. ? unicodeToArray(string)
  22471. : asciiToArray(string);
  22472. }
  22473. /**
  22474. * Used by `_.unescape` to convert HTML entities to characters.
  22475. *
  22476. * @private
  22477. * @param {string} chr The matched character to unescape.
  22478. * @returns {string} Returns the unescaped character.
  22479. */
  22480. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  22481. /**
  22482. * Gets the size of a Unicode `string`.
  22483. *
  22484. * @private
  22485. * @param {string} string The string inspect.
  22486. * @returns {number} Returns the string size.
  22487. */
  22488. function unicodeSize(string) {
  22489. var result = reUnicode.lastIndex = 0;
  22490. while (reUnicode.test(string)) {
  22491. ++result;
  22492. }
  22493. return result;
  22494. }
  22495. /**
  22496. * Converts a Unicode `string` to an array.
  22497. *
  22498. * @private
  22499. * @param {string} string The string to convert.
  22500. * @returns {Array} Returns the converted array.
  22501. */
  22502. function unicodeToArray(string) {
  22503. return string.match(reUnicode) || [];
  22504. }
  22505. /**
  22506. * Splits a Unicode `string` into an array of its words.
  22507. *
  22508. * @private
  22509. * @param {string} The string to inspect.
  22510. * @returns {Array} Returns the words of `string`.
  22511. */
  22512. function unicodeWords(string) {
  22513. return string.match(reUnicodeWord) || [];
  22514. }
  22515. /*--------------------------------------------------------------------------*/
  22516. /**
  22517. * Create a new pristine `lodash` function using the `context` object.
  22518. *
  22519. * @static
  22520. * @memberOf _
  22521. * @since 1.1.0
  22522. * @category Util
  22523. * @param {Object} [context=root] The context object.
  22524. * @returns {Function} Returns a new `lodash` function.
  22525. * @example
  22526. *
  22527. * _.mixin({ 'foo': _.constant('foo') });
  22528. *
  22529. * var lodash = _.runInContext();
  22530. * lodash.mixin({ 'bar': lodash.constant('bar') });
  22531. *
  22532. * _.isFunction(_.foo);
  22533. * // => true
  22534. * _.isFunction(_.bar);
  22535. * // => false
  22536. *
  22537. * lodash.isFunction(lodash.foo);
  22538. * // => false
  22539. * lodash.isFunction(lodash.bar);
  22540. * // => true
  22541. *
  22542. * // Create a suped-up `defer` in Node.js.
  22543. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  22544. */
  22545. var runInContext = (function runInContext(context) {
  22546. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  22547. /** Built-in constructor references. */
  22548. var Array = context.Array,
  22549. Date = context.Date,
  22550. Error = context.Error,
  22551. Function = context.Function,
  22552. Math = context.Math,
  22553. Object = context.Object,
  22554. RegExp = context.RegExp,
  22555. String = context.String,
  22556. TypeError = context.TypeError;
  22557. /** Used for built-in method references. */
  22558. var arrayProto = Array.prototype,
  22559. funcProto = Function.prototype,
  22560. objectProto = Object.prototype;
  22561. /** Used to detect overreaching core-js shims. */
  22562. var coreJsData = context['__core-js_shared__'];
  22563. /** Used to resolve the decompiled source of functions. */
  22564. var funcToString = funcProto.toString;
  22565. /** Used to check objects for own properties. */
  22566. var hasOwnProperty = objectProto.hasOwnProperty;
  22567. /** Used to generate unique IDs. */
  22568. var idCounter = 0;
  22569. /** Used to detect methods masquerading as native. */
  22570. var maskSrcKey = (function() {
  22571. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  22572. return uid ? ('Symbol(src)_1.' + uid) : '';
  22573. }());
  22574. /**
  22575. * Used to resolve the
  22576. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  22577. * of values.
  22578. */
  22579. var nativeObjectToString = objectProto.toString;
  22580. /** Used to infer the `Object` constructor. */
  22581. var objectCtorString = funcToString.call(Object);
  22582. /** Used to restore the original `_` reference in `_.noConflict`. */
  22583. var oldDash = root._;
  22584. /** Used to detect if a method is native. */
  22585. var reIsNative = RegExp('^' +
  22586. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  22587. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  22588. );
  22589. /** Built-in value references. */
  22590. var Buffer = moduleExports ? context.Buffer : undefined,
  22591. Symbol = context.Symbol,
  22592. Uint8Array = context.Uint8Array,
  22593. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  22594. getPrototype = overArg(Object.getPrototypeOf, Object),
  22595. objectCreate = Object.create,
  22596. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  22597. splice = arrayProto.splice,
  22598. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  22599. symIterator = Symbol ? Symbol.iterator : undefined,
  22600. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  22601. var defineProperty = (function() {
  22602. try {
  22603. var func = getNative(Object, 'defineProperty');
  22604. func({}, '', {});
  22605. return func;
  22606. } catch (e) {}
  22607. }());
  22608. /** Mocked built-ins. */
  22609. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  22610. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  22611. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  22612. /* Built-in method references for those with the same name as other `lodash` methods. */
  22613. var nativeCeil = Math.ceil,
  22614. nativeFloor = Math.floor,
  22615. nativeGetSymbols = Object.getOwnPropertySymbols,
  22616. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  22617. nativeIsFinite = context.isFinite,
  22618. nativeJoin = arrayProto.join,
  22619. nativeKeys = overArg(Object.keys, Object),
  22620. nativeMax = Math.max,
  22621. nativeMin = Math.min,
  22622. nativeNow = Date.now,
  22623. nativeParseInt = context.parseInt,
  22624. nativeRandom = Math.random,
  22625. nativeReverse = arrayProto.reverse;
  22626. /* Built-in method references that are verified to be native. */
  22627. var DataView = getNative(context, 'DataView'),
  22628. Map = getNative(context, 'Map'),
  22629. Promise = getNative(context, 'Promise'),
  22630. Set = getNative(context, 'Set'),
  22631. WeakMap = getNative(context, 'WeakMap'),
  22632. nativeCreate = getNative(Object, 'create');
  22633. /** Used to store function metadata. */
  22634. var metaMap = WeakMap && new WeakMap;
  22635. /** Used to lookup unminified function names. */
  22636. var realNames = {};
  22637. /** Used to detect maps, sets, and weakmaps. */
  22638. var dataViewCtorString = toSource(DataView),
  22639. mapCtorString = toSource(Map),
  22640. promiseCtorString = toSource(Promise),
  22641. setCtorString = toSource(Set),
  22642. weakMapCtorString = toSource(WeakMap);
  22643. /** Used to convert symbols to primitives and strings. */
  22644. var symbolProto = Symbol ? Symbol.prototype : undefined,
  22645. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  22646. symbolToString = symbolProto ? symbolProto.toString : undefined;
  22647. /*------------------------------------------------------------------------*/
  22648. /**
  22649. * Creates a `lodash` object which wraps `value` to enable implicit method
  22650. * chain sequences. Methods that operate on and return arrays, collections,
  22651. * and functions can be chained together. Methods that retrieve a single value
  22652. * or may return a primitive value will automatically end the chain sequence
  22653. * and return the unwrapped value. Otherwise, the value must be unwrapped
  22654. * with `_#value`.
  22655. *
  22656. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  22657. * enabled using `_.chain`.
  22658. *
  22659. * The execution of chained methods is lazy, that is, it's deferred until
  22660. * `_#value` is implicitly or explicitly called.
  22661. *
  22662. * Lazy evaluation allows several methods to support shortcut fusion.
  22663. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  22664. * the creation of intermediate arrays and can greatly reduce the number of
  22665. * iteratee executions. Sections of a chain sequence qualify for shortcut
  22666. * fusion if the section is applied to an array and iteratees accept only
  22667. * one argument. The heuristic for whether a section qualifies for shortcut
  22668. * fusion is subject to change.
  22669. *
  22670. * Chaining is supported in custom builds as long as the `_#value` method is
  22671. * directly or indirectly included in the build.
  22672. *
  22673. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  22674. *
  22675. * The wrapper `Array` methods are:
  22676. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  22677. *
  22678. * The wrapper `String` methods are:
  22679. * `replace` and `split`
  22680. *
  22681. * The wrapper methods that support shortcut fusion are:
  22682. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  22683. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  22684. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  22685. *
  22686. * The chainable wrapper methods are:
  22687. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  22688. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  22689. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  22690. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  22691. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  22692. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  22693. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  22694. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  22695. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  22696. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  22697. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  22698. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  22699. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  22700. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  22701. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  22702. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  22703. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  22704. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  22705. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  22706. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  22707. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  22708. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  22709. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  22710. * `zipObject`, `zipObjectDeep`, and `zipWith`
  22711. *
  22712. * The wrapper methods that are **not** chainable by default are:
  22713. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  22714. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  22715. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  22716. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  22717. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  22718. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  22719. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  22720. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  22721. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  22722. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  22723. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  22724. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  22725. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  22726. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  22727. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  22728. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  22729. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  22730. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  22731. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  22732. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  22733. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  22734. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  22735. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  22736. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  22737. * `upperFirst`, `value`, and `words`
  22738. *
  22739. * @name _
  22740. * @constructor
  22741. * @category Seq
  22742. * @param {*} value The value to wrap in a `lodash` instance.
  22743. * @returns {Object} Returns the new `lodash` wrapper instance.
  22744. * @example
  22745. *
  22746. * function square(n) {
  22747. * return n * n;
  22748. * }
  22749. *
  22750. * var wrapped = _([1, 2, 3]);
  22751. *
  22752. * // Returns an unwrapped value.
  22753. * wrapped.reduce(_.add);
  22754. * // => 6
  22755. *
  22756. * // Returns a wrapped value.
  22757. * var squares = wrapped.map(square);
  22758. *
  22759. * _.isArray(squares);
  22760. * // => false
  22761. *
  22762. * _.isArray(squares.value());
  22763. * // => true
  22764. */
  22765. function lodash(value) {
  22766. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  22767. if (value instanceof LodashWrapper) {
  22768. return value;
  22769. }
  22770. if (hasOwnProperty.call(value, '__wrapped__')) {
  22771. return wrapperClone(value);
  22772. }
  22773. }
  22774. return new LodashWrapper(value);
  22775. }
  22776. /**
  22777. * The base implementation of `_.create` without support for assigning
  22778. * properties to the created object.
  22779. *
  22780. * @private
  22781. * @param {Object} proto The object to inherit from.
  22782. * @returns {Object} Returns the new object.
  22783. */
  22784. var baseCreate = (function() {
  22785. function object() {}
  22786. return function(proto) {
  22787. if (!isObject(proto)) {
  22788. return {};
  22789. }
  22790. if (objectCreate) {
  22791. return objectCreate(proto);
  22792. }
  22793. object.prototype = proto;
  22794. var result = new object;
  22795. object.prototype = undefined;
  22796. return result;
  22797. };
  22798. }());
  22799. /**
  22800. * The function whose prototype chain sequence wrappers inherit from.
  22801. *
  22802. * @private
  22803. */
  22804. function baseLodash() {
  22805. // No operation performed.
  22806. }
  22807. /**
  22808. * The base constructor for creating `lodash` wrapper objects.
  22809. *
  22810. * @private
  22811. * @param {*} value The value to wrap.
  22812. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  22813. */
  22814. function LodashWrapper(value, chainAll) {
  22815. this.__wrapped__ = value;
  22816. this.__actions__ = [];
  22817. this.__chain__ = !!chainAll;
  22818. this.__index__ = 0;
  22819. this.__values__ = undefined;
  22820. }
  22821. /**
  22822. * By default, the template delimiters used by lodash are like those in
  22823. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  22824. * following template settings to use alternative delimiters.
  22825. *
  22826. * @static
  22827. * @memberOf _
  22828. * @type {Object}
  22829. */
  22830. lodash.templateSettings = {
  22831. /**
  22832. * Used to detect `data` property values to be HTML-escaped.
  22833. *
  22834. * @memberOf _.templateSettings
  22835. * @type {RegExp}
  22836. */
  22837. 'escape': reEscape,
  22838. /**
  22839. * Used to detect code to be evaluated.
  22840. *
  22841. * @memberOf _.templateSettings
  22842. * @type {RegExp}
  22843. */
  22844. 'evaluate': reEvaluate,
  22845. /**
  22846. * Used to detect `data` property values to inject.
  22847. *
  22848. * @memberOf _.templateSettings
  22849. * @type {RegExp}
  22850. */
  22851. 'interpolate': reInterpolate,
  22852. /**
  22853. * Used to reference the data object in the template text.
  22854. *
  22855. * @memberOf _.templateSettings
  22856. * @type {string}
  22857. */
  22858. 'variable': '',
  22859. /**
  22860. * Used to import variables into the compiled template.
  22861. *
  22862. * @memberOf _.templateSettings
  22863. * @type {Object}
  22864. */
  22865. 'imports': {
  22866. /**
  22867. * A reference to the `lodash` function.
  22868. *
  22869. * @memberOf _.templateSettings.imports
  22870. * @type {Function}
  22871. */
  22872. '_': lodash
  22873. }
  22874. };
  22875. // Ensure wrappers are instances of `baseLodash`.
  22876. lodash.prototype = baseLodash.prototype;
  22877. lodash.prototype.constructor = lodash;
  22878. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  22879. LodashWrapper.prototype.constructor = LodashWrapper;
  22880. /*------------------------------------------------------------------------*/
  22881. /**
  22882. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  22883. *
  22884. * @private
  22885. * @constructor
  22886. * @param {*} value The value to wrap.
  22887. */
  22888. function LazyWrapper(value) {
  22889. this.__wrapped__ = value;
  22890. this.__actions__ = [];
  22891. this.__dir__ = 1;
  22892. this.__filtered__ = false;
  22893. this.__iteratees__ = [];
  22894. this.__takeCount__ = MAX_ARRAY_LENGTH;
  22895. this.__views__ = [];
  22896. }
  22897. /**
  22898. * Creates a clone of the lazy wrapper object.
  22899. *
  22900. * @private
  22901. * @name clone
  22902. * @memberOf LazyWrapper
  22903. * @returns {Object} Returns the cloned `LazyWrapper` object.
  22904. */
  22905. function lazyClone() {
  22906. var result = new LazyWrapper(this.__wrapped__);
  22907. result.__actions__ = copyArray(this.__actions__);
  22908. result.__dir__ = this.__dir__;
  22909. result.__filtered__ = this.__filtered__;
  22910. result.__iteratees__ = copyArray(this.__iteratees__);
  22911. result.__takeCount__ = this.__takeCount__;
  22912. result.__views__ = copyArray(this.__views__);
  22913. return result;
  22914. }
  22915. /**
  22916. * Reverses the direction of lazy iteration.
  22917. *
  22918. * @private
  22919. * @name reverse
  22920. * @memberOf LazyWrapper
  22921. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  22922. */
  22923. function lazyReverse() {
  22924. if (this.__filtered__) {
  22925. var result = new LazyWrapper(this);
  22926. result.__dir__ = -1;
  22927. result.__filtered__ = true;
  22928. } else {
  22929. result = this.clone();
  22930. result.__dir__ *= -1;
  22931. }
  22932. return result;
  22933. }
  22934. /**
  22935. * Extracts the unwrapped value from its lazy wrapper.
  22936. *
  22937. * @private
  22938. * @name value
  22939. * @memberOf LazyWrapper
  22940. * @returns {*} Returns the unwrapped value.
  22941. */
  22942. function lazyValue() {
  22943. var array = this.__wrapped__.value(),
  22944. dir = this.__dir__,
  22945. isArr = isArray(array),
  22946. isRight = dir < 0,
  22947. arrLength = isArr ? array.length : 0,
  22948. view = getView(0, arrLength, this.__views__),
  22949. start = view.start,
  22950. end = view.end,
  22951. length = end - start,
  22952. index = isRight ? end : (start - 1),
  22953. iteratees = this.__iteratees__,
  22954. iterLength = iteratees.length,
  22955. resIndex = 0,
  22956. takeCount = nativeMin(length, this.__takeCount__);
  22957. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  22958. return baseWrapperValue(array, this.__actions__);
  22959. }
  22960. var result = [];
  22961. outer:
  22962. while (length-- && resIndex < takeCount) {
  22963. index += dir;
  22964. var iterIndex = -1,
  22965. value = array[index];
  22966. while (++iterIndex < iterLength) {
  22967. var data = iteratees[iterIndex],
  22968. iteratee = data.iteratee,
  22969. type = data.type,
  22970. computed = iteratee(value);
  22971. if (type == LAZY_MAP_FLAG) {
  22972. value = computed;
  22973. } else if (!computed) {
  22974. if (type == LAZY_FILTER_FLAG) {
  22975. continue outer;
  22976. } else {
  22977. break outer;
  22978. }
  22979. }
  22980. }
  22981. result[resIndex++] = value;
  22982. }
  22983. return result;
  22984. }
  22985. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  22986. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  22987. LazyWrapper.prototype.constructor = LazyWrapper;
  22988. /*------------------------------------------------------------------------*/
  22989. /**
  22990. * Creates a hash object.
  22991. *
  22992. * @private
  22993. * @constructor
  22994. * @param {Array} [entries] The key-value pairs to cache.
  22995. */
  22996. function Hash(entries) {
  22997. var index = -1,
  22998. length = entries == null ? 0 : entries.length;
  22999. this.clear();
  23000. while (++index < length) {
  23001. var entry = entries[index];
  23002. this.set(entry[0], entry[1]);
  23003. }
  23004. }
  23005. /**
  23006. * Removes all key-value entries from the hash.
  23007. *
  23008. * @private
  23009. * @name clear
  23010. * @memberOf Hash
  23011. */
  23012. function hashClear() {
  23013. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  23014. this.size = 0;
  23015. }
  23016. /**
  23017. * Removes `key` and its value from the hash.
  23018. *
  23019. * @private
  23020. * @name delete
  23021. * @memberOf Hash
  23022. * @param {Object} hash The hash to modify.
  23023. * @param {string} key The key of the value to remove.
  23024. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  23025. */
  23026. function hashDelete(key) {
  23027. var result = this.has(key) && delete this.__data__[key];
  23028. this.size -= result ? 1 : 0;
  23029. return result;
  23030. }
  23031. /**
  23032. * Gets the hash value for `key`.
  23033. *
  23034. * @private
  23035. * @name get
  23036. * @memberOf Hash
  23037. * @param {string} key The key of the value to get.
  23038. * @returns {*} Returns the entry value.
  23039. */
  23040. function hashGet(key) {
  23041. var data = this.__data__;
  23042. if (nativeCreate) {
  23043. var result = data[key];
  23044. return result === HASH_UNDEFINED ? undefined : result;
  23045. }
  23046. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  23047. }
  23048. /**
  23049. * Checks if a hash value for `key` exists.
  23050. *
  23051. * @private
  23052. * @name has
  23053. * @memberOf Hash
  23054. * @param {string} key The key of the entry to check.
  23055. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  23056. */
  23057. function hashHas(key) {
  23058. var data = this.__data__;
  23059. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  23060. }
  23061. /**
  23062. * Sets the hash `key` to `value`.
  23063. *
  23064. * @private
  23065. * @name set
  23066. * @memberOf Hash
  23067. * @param {string} key The key of the value to set.
  23068. * @param {*} value The value to set.
  23069. * @returns {Object} Returns the hash instance.
  23070. */
  23071. function hashSet(key, value) {
  23072. var data = this.__data__;
  23073. this.size += this.has(key) ? 0 : 1;
  23074. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  23075. return this;
  23076. }
  23077. // Add methods to `Hash`.
  23078. Hash.prototype.clear = hashClear;
  23079. Hash.prototype['delete'] = hashDelete;
  23080. Hash.prototype.get = hashGet;
  23081. Hash.prototype.has = hashHas;
  23082. Hash.prototype.set = hashSet;
  23083. /*------------------------------------------------------------------------*/
  23084. /**
  23085. * Creates an list cache object.
  23086. *
  23087. * @private
  23088. * @constructor
  23089. * @param {Array} [entries] The key-value pairs to cache.
  23090. */
  23091. function ListCache(entries) {
  23092. var index = -1,
  23093. length = entries == null ? 0 : entries.length;
  23094. this.clear();
  23095. while (++index < length) {
  23096. var entry = entries[index];
  23097. this.set(entry[0], entry[1]);
  23098. }
  23099. }
  23100. /**
  23101. * Removes all key-value entries from the list cache.
  23102. *
  23103. * @private
  23104. * @name clear
  23105. * @memberOf ListCache
  23106. */
  23107. function listCacheClear() {
  23108. this.__data__ = [];
  23109. this.size = 0;
  23110. }
  23111. /**
  23112. * Removes `key` and its value from the list cache.
  23113. *
  23114. * @private
  23115. * @name delete
  23116. * @memberOf ListCache
  23117. * @param {string} key The key of the value to remove.
  23118. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  23119. */
  23120. function listCacheDelete(key) {
  23121. var data = this.__data__,
  23122. index = assocIndexOf(data, key);
  23123. if (index < 0) {
  23124. return false;
  23125. }
  23126. var lastIndex = data.length - 1;
  23127. if (index == lastIndex) {
  23128. data.pop();
  23129. } else {
  23130. splice.call(data, index, 1);
  23131. }
  23132. --this.size;
  23133. return true;
  23134. }
  23135. /**
  23136. * Gets the list cache value for `key`.
  23137. *
  23138. * @private
  23139. * @name get
  23140. * @memberOf ListCache
  23141. * @param {string} key The key of the value to get.
  23142. * @returns {*} Returns the entry value.
  23143. */
  23144. function listCacheGet(key) {
  23145. var data = this.__data__,
  23146. index = assocIndexOf(data, key);
  23147. return index < 0 ? undefined : data[index][1];
  23148. }
  23149. /**
  23150. * Checks if a list cache value for `key` exists.
  23151. *
  23152. * @private
  23153. * @name has
  23154. * @memberOf ListCache
  23155. * @param {string} key The key of the entry to check.
  23156. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  23157. */
  23158. function listCacheHas(key) {
  23159. return assocIndexOf(this.__data__, key) > -1;
  23160. }
  23161. /**
  23162. * Sets the list cache `key` to `value`.
  23163. *
  23164. * @private
  23165. * @name set
  23166. * @memberOf ListCache
  23167. * @param {string} key The key of the value to set.
  23168. * @param {*} value The value to set.
  23169. * @returns {Object} Returns the list cache instance.
  23170. */
  23171. function listCacheSet(key, value) {
  23172. var data = this.__data__,
  23173. index = assocIndexOf(data, key);
  23174. if (index < 0) {
  23175. ++this.size;
  23176. data.push([key, value]);
  23177. } else {
  23178. data[index][1] = value;
  23179. }
  23180. return this;
  23181. }
  23182. // Add methods to `ListCache`.
  23183. ListCache.prototype.clear = listCacheClear;
  23184. ListCache.prototype['delete'] = listCacheDelete;
  23185. ListCache.prototype.get = listCacheGet;
  23186. ListCache.prototype.has = listCacheHas;
  23187. ListCache.prototype.set = listCacheSet;
  23188. /*------------------------------------------------------------------------*/
  23189. /**
  23190. * Creates a map cache object to store key-value pairs.
  23191. *
  23192. * @private
  23193. * @constructor
  23194. * @param {Array} [entries] The key-value pairs to cache.
  23195. */
  23196. function MapCache(entries) {
  23197. var index = -1,
  23198. length = entries == null ? 0 : entries.length;
  23199. this.clear();
  23200. while (++index < length) {
  23201. var entry = entries[index];
  23202. this.set(entry[0], entry[1]);
  23203. }
  23204. }
  23205. /**
  23206. * Removes all key-value entries from the map.
  23207. *
  23208. * @private
  23209. * @name clear
  23210. * @memberOf MapCache
  23211. */
  23212. function mapCacheClear() {
  23213. this.size = 0;
  23214. this.__data__ = {
  23215. 'hash': new Hash,
  23216. 'map': new (Map || ListCache),
  23217. 'string': new Hash
  23218. };
  23219. }
  23220. /**
  23221. * Removes `key` and its value from the map.
  23222. *
  23223. * @private
  23224. * @name delete
  23225. * @memberOf MapCache
  23226. * @param {string} key The key of the value to remove.
  23227. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  23228. */
  23229. function mapCacheDelete(key) {
  23230. var result = getMapData(this, key)['delete'](key);
  23231. this.size -= result ? 1 : 0;
  23232. return result;
  23233. }
  23234. /**
  23235. * Gets the map value for `key`.
  23236. *
  23237. * @private
  23238. * @name get
  23239. * @memberOf MapCache
  23240. * @param {string} key The key of the value to get.
  23241. * @returns {*} Returns the entry value.
  23242. */
  23243. function mapCacheGet(key) {
  23244. return getMapData(this, key).get(key);
  23245. }
  23246. /**
  23247. * Checks if a map value for `key` exists.
  23248. *
  23249. * @private
  23250. * @name has
  23251. * @memberOf MapCache
  23252. * @param {string} key The key of the entry to check.
  23253. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  23254. */
  23255. function mapCacheHas(key) {
  23256. return getMapData(this, key).has(key);
  23257. }
  23258. /**
  23259. * Sets the map `key` to `value`.
  23260. *
  23261. * @private
  23262. * @name set
  23263. * @memberOf MapCache
  23264. * @param {string} key The key of the value to set.
  23265. * @param {*} value The value to set.
  23266. * @returns {Object} Returns the map cache instance.
  23267. */
  23268. function mapCacheSet(key, value) {
  23269. var data = getMapData(this, key),
  23270. size = data.size;
  23271. data.set(key, value);
  23272. this.size += data.size == size ? 0 : 1;
  23273. return this;
  23274. }
  23275. // Add methods to `MapCache`.
  23276. MapCache.prototype.clear = mapCacheClear;
  23277. MapCache.prototype['delete'] = mapCacheDelete;
  23278. MapCache.prototype.get = mapCacheGet;
  23279. MapCache.prototype.has = mapCacheHas;
  23280. MapCache.prototype.set = mapCacheSet;
  23281. /*------------------------------------------------------------------------*/
  23282. /**
  23283. *
  23284. * Creates an array cache object to store unique values.
  23285. *
  23286. * @private
  23287. * @constructor
  23288. * @param {Array} [values] The values to cache.
  23289. */
  23290. function SetCache(values) {
  23291. var index = -1,
  23292. length = values == null ? 0 : values.length;
  23293. this.__data__ = new MapCache;
  23294. while (++index < length) {
  23295. this.add(values[index]);
  23296. }
  23297. }
  23298. /**
  23299. * Adds `value` to the array cache.
  23300. *
  23301. * @private
  23302. * @name add
  23303. * @memberOf SetCache
  23304. * @alias push
  23305. * @param {*} value The value to cache.
  23306. * @returns {Object} Returns the cache instance.
  23307. */
  23308. function setCacheAdd(value) {
  23309. this.__data__.set(value, HASH_UNDEFINED);
  23310. return this;
  23311. }
  23312. /**
  23313. * Checks if `value` is in the array cache.
  23314. *
  23315. * @private
  23316. * @name has
  23317. * @memberOf SetCache
  23318. * @param {*} value The value to search for.
  23319. * @returns {number} Returns `true` if `value` is found, else `false`.
  23320. */
  23321. function setCacheHas(value) {
  23322. return this.__data__.has(value);
  23323. }
  23324. // Add methods to `SetCache`.
  23325. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  23326. SetCache.prototype.has = setCacheHas;
  23327. /*------------------------------------------------------------------------*/
  23328. /**
  23329. * Creates a stack cache object to store key-value pairs.
  23330. *
  23331. * @private
  23332. * @constructor
  23333. * @param {Array} [entries] The key-value pairs to cache.
  23334. */
  23335. function Stack(entries) {
  23336. var data = this.__data__ = new ListCache(entries);
  23337. this.size = data.size;
  23338. }
  23339. /**
  23340. * Removes all key-value entries from the stack.
  23341. *
  23342. * @private
  23343. * @name clear
  23344. * @memberOf Stack
  23345. */
  23346. function stackClear() {
  23347. this.__data__ = new ListCache;
  23348. this.size = 0;
  23349. }
  23350. /**
  23351. * Removes `key` and its value from the stack.
  23352. *
  23353. * @private
  23354. * @name delete
  23355. * @memberOf Stack
  23356. * @param {string} key The key of the value to remove.
  23357. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  23358. */
  23359. function stackDelete(key) {
  23360. var data = this.__data__,
  23361. result = data['delete'](key);
  23362. this.size = data.size;
  23363. return result;
  23364. }
  23365. /**
  23366. * Gets the stack value for `key`.
  23367. *
  23368. * @private
  23369. * @name get
  23370. * @memberOf Stack
  23371. * @param {string} key The key of the value to get.
  23372. * @returns {*} Returns the entry value.
  23373. */
  23374. function stackGet(key) {
  23375. return this.__data__.get(key);
  23376. }
  23377. /**
  23378. * Checks if a stack value for `key` exists.
  23379. *
  23380. * @private
  23381. * @name has
  23382. * @memberOf Stack
  23383. * @param {string} key The key of the entry to check.
  23384. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  23385. */
  23386. function stackHas(key) {
  23387. return this.__data__.has(key);
  23388. }
  23389. /**
  23390. * Sets the stack `key` to `value`.
  23391. *
  23392. * @private
  23393. * @name set
  23394. * @memberOf Stack
  23395. * @param {string} key The key of the value to set.
  23396. * @param {*} value The value to set.
  23397. * @returns {Object} Returns the stack cache instance.
  23398. */
  23399. function stackSet(key, value) {
  23400. var data = this.__data__;
  23401. if (data instanceof ListCache) {
  23402. var pairs = data.__data__;
  23403. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  23404. pairs.push([key, value]);
  23405. this.size = ++data.size;
  23406. return this;
  23407. }
  23408. data = this.__data__ = new MapCache(pairs);
  23409. }
  23410. data.set(key, value);
  23411. this.size = data.size;
  23412. return this;
  23413. }
  23414. // Add methods to `Stack`.
  23415. Stack.prototype.clear = stackClear;
  23416. Stack.prototype['delete'] = stackDelete;
  23417. Stack.prototype.get = stackGet;
  23418. Stack.prototype.has = stackHas;
  23419. Stack.prototype.set = stackSet;
  23420. /*------------------------------------------------------------------------*/
  23421. /**
  23422. * Creates an array of the enumerable property names of the array-like `value`.
  23423. *
  23424. * @private
  23425. * @param {*} value The value to query.
  23426. * @param {boolean} inherited Specify returning inherited property names.
  23427. * @returns {Array} Returns the array of property names.
  23428. */
  23429. function arrayLikeKeys(value, inherited) {
  23430. var isArr = isArray(value),
  23431. isArg = !isArr && isArguments(value),
  23432. isBuff = !isArr && !isArg && isBuffer(value),
  23433. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  23434. skipIndexes = isArr || isArg || isBuff || isType,
  23435. result = skipIndexes ? baseTimes(value.length, String) : [],
  23436. length = result.length;
  23437. for (var key in value) {
  23438. if ((inherited || hasOwnProperty.call(value, key)) &&
  23439. !(skipIndexes && (
  23440. // Safari 9 has enumerable `arguments.length` in strict mode.
  23441. key == 'length' ||
  23442. // Node.js 0.10 has enumerable non-index properties on buffers.
  23443. (isBuff && (key == 'offset' || key == 'parent')) ||
  23444. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  23445. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  23446. // Skip index properties.
  23447. isIndex(key, length)
  23448. ))) {
  23449. result.push(key);
  23450. }
  23451. }
  23452. return result;
  23453. }
  23454. /**
  23455. * A specialized version of `_.sample` for arrays.
  23456. *
  23457. * @private
  23458. * @param {Array} array The array to sample.
  23459. * @returns {*} Returns the random element.
  23460. */
  23461. function arraySample(array) {
  23462. var length = array.length;
  23463. return length ? array[baseRandom(0, length - 1)] : undefined;
  23464. }
  23465. /**
  23466. * A specialized version of `_.sampleSize` for arrays.
  23467. *
  23468. * @private
  23469. * @param {Array} array The array to sample.
  23470. * @param {number} n The number of elements to sample.
  23471. * @returns {Array} Returns the random elements.
  23472. */
  23473. function arraySampleSize(array, n) {
  23474. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  23475. }
  23476. /**
  23477. * A specialized version of `_.shuffle` for arrays.
  23478. *
  23479. * @private
  23480. * @param {Array} array The array to shuffle.
  23481. * @returns {Array} Returns the new shuffled array.
  23482. */
  23483. function arrayShuffle(array) {
  23484. return shuffleSelf(copyArray(array));
  23485. }
  23486. /**
  23487. * This function is like `assignValue` except that it doesn't assign
  23488. * `undefined` values.
  23489. *
  23490. * @private
  23491. * @param {Object} object The object to modify.
  23492. * @param {string} key The key of the property to assign.
  23493. * @param {*} value The value to assign.
  23494. */
  23495. function assignMergeValue(object, key, value) {
  23496. if ((value !== undefined && !eq(object[key], value)) ||
  23497. (value === undefined && !(key in object))) {
  23498. baseAssignValue(object, key, value);
  23499. }
  23500. }
  23501. /**
  23502. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  23503. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23504. * for equality comparisons.
  23505. *
  23506. * @private
  23507. * @param {Object} object The object to modify.
  23508. * @param {string} key The key of the property to assign.
  23509. * @param {*} value The value to assign.
  23510. */
  23511. function assignValue(object, key, value) {
  23512. var objValue = object[key];
  23513. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  23514. (value === undefined && !(key in object))) {
  23515. baseAssignValue(object, key, value);
  23516. }
  23517. }
  23518. /**
  23519. * Gets the index at which the `key` is found in `array` of key-value pairs.
  23520. *
  23521. * @private
  23522. * @param {Array} array The array to inspect.
  23523. * @param {*} key The key to search for.
  23524. * @returns {number} Returns the index of the matched value, else `-1`.
  23525. */
  23526. function assocIndexOf(array, key) {
  23527. var length = array.length;
  23528. while (length--) {
  23529. if (eq(array[length][0], key)) {
  23530. return length;
  23531. }
  23532. }
  23533. return -1;
  23534. }
  23535. /**
  23536. * Aggregates elements of `collection` on `accumulator` with keys transformed
  23537. * by `iteratee` and values set by `setter`.
  23538. *
  23539. * @private
  23540. * @param {Array|Object} collection The collection to iterate over.
  23541. * @param {Function} setter The function to set `accumulator` values.
  23542. * @param {Function} iteratee The iteratee to transform keys.
  23543. * @param {Object} accumulator The initial aggregated object.
  23544. * @returns {Function} Returns `accumulator`.
  23545. */
  23546. function baseAggregator(collection, setter, iteratee, accumulator) {
  23547. baseEach(collection, function(value, key, collection) {
  23548. setter(accumulator, value, iteratee(value), collection);
  23549. });
  23550. return accumulator;
  23551. }
  23552. /**
  23553. * The base implementation of `_.assign` without support for multiple sources
  23554. * or `customizer` functions.
  23555. *
  23556. * @private
  23557. * @param {Object} object The destination object.
  23558. * @param {Object} source The source object.
  23559. * @returns {Object} Returns `object`.
  23560. */
  23561. function baseAssign(object, source) {
  23562. return object && copyObject(source, keys(source), object);
  23563. }
  23564. /**
  23565. * The base implementation of `_.assignIn` without support for multiple sources
  23566. * or `customizer` functions.
  23567. *
  23568. * @private
  23569. * @param {Object} object The destination object.
  23570. * @param {Object} source The source object.
  23571. * @returns {Object} Returns `object`.
  23572. */
  23573. function baseAssignIn(object, source) {
  23574. return object && copyObject(source, keysIn(source), object);
  23575. }
  23576. /**
  23577. * The base implementation of `assignValue` and `assignMergeValue` without
  23578. * value checks.
  23579. *
  23580. * @private
  23581. * @param {Object} object The object to modify.
  23582. * @param {string} key The key of the property to assign.
  23583. * @param {*} value The value to assign.
  23584. */
  23585. function baseAssignValue(object, key, value) {
  23586. if (key == '__proto__' && defineProperty) {
  23587. defineProperty(object, key, {
  23588. 'configurable': true,
  23589. 'enumerable': true,
  23590. 'value': value,
  23591. 'writable': true
  23592. });
  23593. } else {
  23594. object[key] = value;
  23595. }
  23596. }
  23597. /**
  23598. * The base implementation of `_.at` without support for individual paths.
  23599. *
  23600. * @private
  23601. * @param {Object} object The object to iterate over.
  23602. * @param {string[]} paths The property paths to pick.
  23603. * @returns {Array} Returns the picked elements.
  23604. */
  23605. function baseAt(object, paths) {
  23606. var index = -1,
  23607. length = paths.length,
  23608. result = Array(length),
  23609. skip = object == null;
  23610. while (++index < length) {
  23611. result[index] = skip ? undefined : get(object, paths[index]);
  23612. }
  23613. return result;
  23614. }
  23615. /**
  23616. * The base implementation of `_.clamp` which doesn't coerce arguments.
  23617. *
  23618. * @private
  23619. * @param {number} number The number to clamp.
  23620. * @param {number} [lower] The lower bound.
  23621. * @param {number} upper The upper bound.
  23622. * @returns {number} Returns the clamped number.
  23623. */
  23624. function baseClamp(number, lower, upper) {
  23625. if (number === number) {
  23626. if (upper !== undefined) {
  23627. number = number <= upper ? number : upper;
  23628. }
  23629. if (lower !== undefined) {
  23630. number = number >= lower ? number : lower;
  23631. }
  23632. }
  23633. return number;
  23634. }
  23635. /**
  23636. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  23637. * traversed objects.
  23638. *
  23639. * @private
  23640. * @param {*} value The value to clone.
  23641. * @param {boolean} bitmask The bitmask flags.
  23642. * 1 - Deep clone
  23643. * 2 - Flatten inherited properties
  23644. * 4 - Clone symbols
  23645. * @param {Function} [customizer] The function to customize cloning.
  23646. * @param {string} [key] The key of `value`.
  23647. * @param {Object} [object] The parent object of `value`.
  23648. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  23649. * @returns {*} Returns the cloned value.
  23650. */
  23651. function baseClone(value, bitmask, customizer, key, object, stack) {
  23652. var result,
  23653. isDeep = bitmask & CLONE_DEEP_FLAG,
  23654. isFlat = bitmask & CLONE_FLAT_FLAG,
  23655. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  23656. if (customizer) {
  23657. result = object ? customizer(value, key, object, stack) : customizer(value);
  23658. }
  23659. if (result !== undefined) {
  23660. return result;
  23661. }
  23662. if (!isObject(value)) {
  23663. return value;
  23664. }
  23665. var isArr = isArray(value);
  23666. if (isArr) {
  23667. result = initCloneArray(value);
  23668. if (!isDeep) {
  23669. return copyArray(value, result);
  23670. }
  23671. } else {
  23672. var tag = getTag(value),
  23673. isFunc = tag == funcTag || tag == genTag;
  23674. if (isBuffer(value)) {
  23675. return cloneBuffer(value, isDeep);
  23676. }
  23677. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  23678. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  23679. if (!isDeep) {
  23680. return isFlat
  23681. ? copySymbolsIn(value, baseAssignIn(result, value))
  23682. : copySymbols(value, baseAssign(result, value));
  23683. }
  23684. } else {
  23685. if (!cloneableTags[tag]) {
  23686. return object ? value : {};
  23687. }
  23688. result = initCloneByTag(value, tag, isDeep);
  23689. }
  23690. }
  23691. // Check for circular references and return its corresponding clone.
  23692. stack || (stack = new Stack);
  23693. var stacked = stack.get(value);
  23694. if (stacked) {
  23695. return stacked;
  23696. }
  23697. stack.set(value, result);
  23698. if (isSet(value)) {
  23699. value.forEach(function(subValue) {
  23700. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  23701. });
  23702. } else if (isMap(value)) {
  23703. value.forEach(function(subValue, key) {
  23704. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  23705. });
  23706. }
  23707. var keysFunc = isFull
  23708. ? (isFlat ? getAllKeysIn : getAllKeys)
  23709. : (isFlat ? keysIn : keys);
  23710. var props = isArr ? undefined : keysFunc(value);
  23711. arrayEach(props || value, function(subValue, key) {
  23712. if (props) {
  23713. key = subValue;
  23714. subValue = value[key];
  23715. }
  23716. // Recursively populate clone (susceptible to call stack limits).
  23717. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  23718. });
  23719. return result;
  23720. }
  23721. /**
  23722. * The base implementation of `_.conforms` which doesn't clone `source`.
  23723. *
  23724. * @private
  23725. * @param {Object} source The object of property predicates to conform to.
  23726. * @returns {Function} Returns the new spec function.
  23727. */
  23728. function baseConforms(source) {
  23729. var props = keys(source);
  23730. return function(object) {
  23731. return baseConformsTo(object, source, props);
  23732. };
  23733. }
  23734. /**
  23735. * The base implementation of `_.conformsTo` which accepts `props` to check.
  23736. *
  23737. * @private
  23738. * @param {Object} object The object to inspect.
  23739. * @param {Object} source The object of property predicates to conform to.
  23740. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  23741. */
  23742. function baseConformsTo(object, source, props) {
  23743. var length = props.length;
  23744. if (object == null) {
  23745. return !length;
  23746. }
  23747. object = Object(object);
  23748. while (length--) {
  23749. var key = props[length],
  23750. predicate = source[key],
  23751. value = object[key];
  23752. if ((value === undefined && !(key in object)) || !predicate(value)) {
  23753. return false;
  23754. }
  23755. }
  23756. return true;
  23757. }
  23758. /**
  23759. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  23760. * to provide to `func`.
  23761. *
  23762. * @private
  23763. * @param {Function} func The function to delay.
  23764. * @param {number} wait The number of milliseconds to delay invocation.
  23765. * @param {Array} args The arguments to provide to `func`.
  23766. * @returns {number|Object} Returns the timer id or timeout object.
  23767. */
  23768. function baseDelay(func, wait, args) {
  23769. if (typeof func != 'function') {
  23770. throw new TypeError(FUNC_ERROR_TEXT);
  23771. }
  23772. return setTimeout(function() { func.apply(undefined, args); }, wait);
  23773. }
  23774. /**
  23775. * The base implementation of methods like `_.difference` without support
  23776. * for excluding multiple arrays or iteratee shorthands.
  23777. *
  23778. * @private
  23779. * @param {Array} array The array to inspect.
  23780. * @param {Array} values The values to exclude.
  23781. * @param {Function} [iteratee] The iteratee invoked per element.
  23782. * @param {Function} [comparator] The comparator invoked per element.
  23783. * @returns {Array} Returns the new array of filtered values.
  23784. */
  23785. function baseDifference(array, values, iteratee, comparator) {
  23786. var index = -1,
  23787. includes = arrayIncludes,
  23788. isCommon = true,
  23789. length = array.length,
  23790. result = [],
  23791. valuesLength = values.length;
  23792. if (!length) {
  23793. return result;
  23794. }
  23795. if (iteratee) {
  23796. values = arrayMap(values, baseUnary(iteratee));
  23797. }
  23798. if (comparator) {
  23799. includes = arrayIncludesWith;
  23800. isCommon = false;
  23801. }
  23802. else if (values.length >= LARGE_ARRAY_SIZE) {
  23803. includes = cacheHas;
  23804. isCommon = false;
  23805. values = new SetCache(values);
  23806. }
  23807. outer:
  23808. while (++index < length) {
  23809. var value = array[index],
  23810. computed = iteratee == null ? value : iteratee(value);
  23811. value = (comparator || value !== 0) ? value : 0;
  23812. if (isCommon && computed === computed) {
  23813. var valuesIndex = valuesLength;
  23814. while (valuesIndex--) {
  23815. if (values[valuesIndex] === computed) {
  23816. continue outer;
  23817. }
  23818. }
  23819. result.push(value);
  23820. }
  23821. else if (!includes(values, computed, comparator)) {
  23822. result.push(value);
  23823. }
  23824. }
  23825. return result;
  23826. }
  23827. /**
  23828. * The base implementation of `_.forEach` without support for iteratee shorthands.
  23829. *
  23830. * @private
  23831. * @param {Array|Object} collection The collection to iterate over.
  23832. * @param {Function} iteratee The function invoked per iteration.
  23833. * @returns {Array|Object} Returns `collection`.
  23834. */
  23835. var baseEach = createBaseEach(baseForOwn);
  23836. /**
  23837. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  23838. *
  23839. * @private
  23840. * @param {Array|Object} collection The collection to iterate over.
  23841. * @param {Function} iteratee The function invoked per iteration.
  23842. * @returns {Array|Object} Returns `collection`.
  23843. */
  23844. var baseEachRight = createBaseEach(baseForOwnRight, true);
  23845. /**
  23846. * The base implementation of `_.every` without support for iteratee shorthands.
  23847. *
  23848. * @private
  23849. * @param {Array|Object} collection The collection to iterate over.
  23850. * @param {Function} predicate The function invoked per iteration.
  23851. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  23852. * else `false`
  23853. */
  23854. function baseEvery(collection, predicate) {
  23855. var result = true;
  23856. baseEach(collection, function(value, index, collection) {
  23857. result = !!predicate(value, index, collection);
  23858. return result;
  23859. });
  23860. return result;
  23861. }
  23862. /**
  23863. * The base implementation of methods like `_.max` and `_.min` which accepts a
  23864. * `comparator` to determine the extremum value.
  23865. *
  23866. * @private
  23867. * @param {Array} array The array to iterate over.
  23868. * @param {Function} iteratee The iteratee invoked per iteration.
  23869. * @param {Function} comparator The comparator used to compare values.
  23870. * @returns {*} Returns the extremum value.
  23871. */
  23872. function baseExtremum(array, iteratee, comparator) {
  23873. var index = -1,
  23874. length = array.length;
  23875. while (++index < length) {
  23876. var value = array[index],
  23877. current = iteratee(value);
  23878. if (current != null && (computed === undefined
  23879. ? (current === current && !isSymbol(current))
  23880. : comparator(current, computed)
  23881. )) {
  23882. var computed = current,
  23883. result = value;
  23884. }
  23885. }
  23886. return result;
  23887. }
  23888. /**
  23889. * The base implementation of `_.fill` without an iteratee call guard.
  23890. *
  23891. * @private
  23892. * @param {Array} array The array to fill.
  23893. * @param {*} value The value to fill `array` with.
  23894. * @param {number} [start=0] The start position.
  23895. * @param {number} [end=array.length] The end position.
  23896. * @returns {Array} Returns `array`.
  23897. */
  23898. function baseFill(array, value, start, end) {
  23899. var length = array.length;
  23900. start = toInteger(start);
  23901. if (start < 0) {
  23902. start = -start > length ? 0 : (length + start);
  23903. }
  23904. end = (end === undefined || end > length) ? length : toInteger(end);
  23905. if (end < 0) {
  23906. end += length;
  23907. }
  23908. end = start > end ? 0 : toLength(end);
  23909. while (start < end) {
  23910. array[start++] = value;
  23911. }
  23912. return array;
  23913. }
  23914. /**
  23915. * The base implementation of `_.filter` without support for iteratee shorthands.
  23916. *
  23917. * @private
  23918. * @param {Array|Object} collection The collection to iterate over.
  23919. * @param {Function} predicate The function invoked per iteration.
  23920. * @returns {Array} Returns the new filtered array.
  23921. */
  23922. function baseFilter(collection, predicate) {
  23923. var result = [];
  23924. baseEach(collection, function(value, index, collection) {
  23925. if (predicate(value, index, collection)) {
  23926. result.push(value);
  23927. }
  23928. });
  23929. return result;
  23930. }
  23931. /**
  23932. * The base implementation of `_.flatten` with support for restricting flattening.
  23933. *
  23934. * @private
  23935. * @param {Array} array The array to flatten.
  23936. * @param {number} depth The maximum recursion depth.
  23937. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  23938. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  23939. * @param {Array} [result=[]] The initial result value.
  23940. * @returns {Array} Returns the new flattened array.
  23941. */
  23942. function baseFlatten(array, depth, predicate, isStrict, result) {
  23943. var index = -1,
  23944. length = array.length;
  23945. predicate || (predicate = isFlattenable);
  23946. result || (result = []);
  23947. while (++index < length) {
  23948. var value = array[index];
  23949. if (depth > 0 && predicate(value)) {
  23950. if (depth > 1) {
  23951. // Recursively flatten arrays (susceptible to call stack limits).
  23952. baseFlatten(value, depth - 1, predicate, isStrict, result);
  23953. } else {
  23954. arrayPush(result, value);
  23955. }
  23956. } else if (!isStrict) {
  23957. result[result.length] = value;
  23958. }
  23959. }
  23960. return result;
  23961. }
  23962. /**
  23963. * The base implementation of `baseForOwn` which iterates over `object`
  23964. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  23965. * Iteratee functions may exit iteration early by explicitly returning `false`.
  23966. *
  23967. * @private
  23968. * @param {Object} object The object to iterate over.
  23969. * @param {Function} iteratee The function invoked per iteration.
  23970. * @param {Function} keysFunc The function to get the keys of `object`.
  23971. * @returns {Object} Returns `object`.
  23972. */
  23973. var baseFor = createBaseFor();
  23974. /**
  23975. * This function is like `baseFor` except that it iterates over properties
  23976. * in the opposite order.
  23977. *
  23978. * @private
  23979. * @param {Object} object The object to iterate over.
  23980. * @param {Function} iteratee The function invoked per iteration.
  23981. * @param {Function} keysFunc The function to get the keys of `object`.
  23982. * @returns {Object} Returns `object`.
  23983. */
  23984. var baseForRight = createBaseFor(true);
  23985. /**
  23986. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  23987. *
  23988. * @private
  23989. * @param {Object} object The object to iterate over.
  23990. * @param {Function} iteratee The function invoked per iteration.
  23991. * @returns {Object} Returns `object`.
  23992. */
  23993. function baseForOwn(object, iteratee) {
  23994. return object && baseFor(object, iteratee, keys);
  23995. }
  23996. /**
  23997. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  23998. *
  23999. * @private
  24000. * @param {Object} object The object to iterate over.
  24001. * @param {Function} iteratee The function invoked per iteration.
  24002. * @returns {Object} Returns `object`.
  24003. */
  24004. function baseForOwnRight(object, iteratee) {
  24005. return object && baseForRight(object, iteratee, keys);
  24006. }
  24007. /**
  24008. * The base implementation of `_.functions` which creates an array of
  24009. * `object` function property names filtered from `props`.
  24010. *
  24011. * @private
  24012. * @param {Object} object The object to inspect.
  24013. * @param {Array} props The property names to filter.
  24014. * @returns {Array} Returns the function names.
  24015. */
  24016. function baseFunctions(object, props) {
  24017. return arrayFilter(props, function(key) {
  24018. return isFunction(object[key]);
  24019. });
  24020. }
  24021. /**
  24022. * The base implementation of `_.get` without support for default values.
  24023. *
  24024. * @private
  24025. * @param {Object} object The object to query.
  24026. * @param {Array|string} path The path of the property to get.
  24027. * @returns {*} Returns the resolved value.
  24028. */
  24029. function baseGet(object, path) {
  24030. path = castPath(path, object);
  24031. var index = 0,
  24032. length = path.length;
  24033. while (object != null && index < length) {
  24034. object = object[toKey(path[index++])];
  24035. }
  24036. return (index && index == length) ? object : undefined;
  24037. }
  24038. /**
  24039. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  24040. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  24041. * symbols of `object`.
  24042. *
  24043. * @private
  24044. * @param {Object} object The object to query.
  24045. * @param {Function} keysFunc The function to get the keys of `object`.
  24046. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  24047. * @returns {Array} Returns the array of property names and symbols.
  24048. */
  24049. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  24050. var result = keysFunc(object);
  24051. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  24052. }
  24053. /**
  24054. * The base implementation of `getTag` without fallbacks for buggy environments.
  24055. *
  24056. * @private
  24057. * @param {*} value The value to query.
  24058. * @returns {string} Returns the `toStringTag`.
  24059. */
  24060. function baseGetTag(value) {
  24061. if (value == null) {
  24062. return value === undefined ? undefinedTag : nullTag;
  24063. }
  24064. return (symToStringTag && symToStringTag in Object(value))
  24065. ? getRawTag(value)
  24066. : objectToString(value);
  24067. }
  24068. /**
  24069. * The base implementation of `_.gt` which doesn't coerce arguments.
  24070. *
  24071. * @private
  24072. * @param {*} value The value to compare.
  24073. * @param {*} other The other value to compare.
  24074. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  24075. * else `false`.
  24076. */
  24077. function baseGt(value, other) {
  24078. return value > other;
  24079. }
  24080. /**
  24081. * The base implementation of `_.has` without support for deep paths.
  24082. *
  24083. * @private
  24084. * @param {Object} [object] The object to query.
  24085. * @param {Array|string} key The key to check.
  24086. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  24087. */
  24088. function baseHas(object, key) {
  24089. return object != null && hasOwnProperty.call(object, key);
  24090. }
  24091. /**
  24092. * The base implementation of `_.hasIn` without support for deep paths.
  24093. *
  24094. * @private
  24095. * @param {Object} [object] The object to query.
  24096. * @param {Array|string} key The key to check.
  24097. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  24098. */
  24099. function baseHasIn(object, key) {
  24100. return object != null && key in Object(object);
  24101. }
  24102. /**
  24103. * The base implementation of `_.inRange` which doesn't coerce arguments.
  24104. *
  24105. * @private
  24106. * @param {number} number The number to check.
  24107. * @param {number} start The start of the range.
  24108. * @param {number} end The end of the range.
  24109. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  24110. */
  24111. function baseInRange(number, start, end) {
  24112. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  24113. }
  24114. /**
  24115. * The base implementation of methods like `_.intersection`, without support
  24116. * for iteratee shorthands, that accepts an array of arrays to inspect.
  24117. *
  24118. * @private
  24119. * @param {Array} arrays The arrays to inspect.
  24120. * @param {Function} [iteratee] The iteratee invoked per element.
  24121. * @param {Function} [comparator] The comparator invoked per element.
  24122. * @returns {Array} Returns the new array of shared values.
  24123. */
  24124. function baseIntersection(arrays, iteratee, comparator) {
  24125. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  24126. length = arrays[0].length,
  24127. othLength = arrays.length,
  24128. othIndex = othLength,
  24129. caches = Array(othLength),
  24130. maxLength = Infinity,
  24131. result = [];
  24132. while (othIndex--) {
  24133. var array = arrays[othIndex];
  24134. if (othIndex && iteratee) {
  24135. array = arrayMap(array, baseUnary(iteratee));
  24136. }
  24137. maxLength = nativeMin(array.length, maxLength);
  24138. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  24139. ? new SetCache(othIndex && array)
  24140. : undefined;
  24141. }
  24142. array = arrays[0];
  24143. var index = -1,
  24144. seen = caches[0];
  24145. outer:
  24146. while (++index < length && result.length < maxLength) {
  24147. var value = array[index],
  24148. computed = iteratee ? iteratee(value) : value;
  24149. value = (comparator || value !== 0) ? value : 0;
  24150. if (!(seen
  24151. ? cacheHas(seen, computed)
  24152. : includes(result, computed, comparator)
  24153. )) {
  24154. othIndex = othLength;
  24155. while (--othIndex) {
  24156. var cache = caches[othIndex];
  24157. if (!(cache
  24158. ? cacheHas(cache, computed)
  24159. : includes(arrays[othIndex], computed, comparator))
  24160. ) {
  24161. continue outer;
  24162. }
  24163. }
  24164. if (seen) {
  24165. seen.push(computed);
  24166. }
  24167. result.push(value);
  24168. }
  24169. }
  24170. return result;
  24171. }
  24172. /**
  24173. * The base implementation of `_.invert` and `_.invertBy` which inverts
  24174. * `object` with values transformed by `iteratee` and set by `setter`.
  24175. *
  24176. * @private
  24177. * @param {Object} object The object to iterate over.
  24178. * @param {Function} setter The function to set `accumulator` values.
  24179. * @param {Function} iteratee The iteratee to transform values.
  24180. * @param {Object} accumulator The initial inverted object.
  24181. * @returns {Function} Returns `accumulator`.
  24182. */
  24183. function baseInverter(object, setter, iteratee, accumulator) {
  24184. baseForOwn(object, function(value, key, object) {
  24185. setter(accumulator, iteratee(value), key, object);
  24186. });
  24187. return accumulator;
  24188. }
  24189. /**
  24190. * The base implementation of `_.invoke` without support for individual
  24191. * method arguments.
  24192. *
  24193. * @private
  24194. * @param {Object} object The object to query.
  24195. * @param {Array|string} path The path of the method to invoke.
  24196. * @param {Array} args The arguments to invoke the method with.
  24197. * @returns {*} Returns the result of the invoked method.
  24198. */
  24199. function baseInvoke(object, path, args) {
  24200. path = castPath(path, object);
  24201. object = parent(object, path);
  24202. var func = object == null ? object : object[toKey(last(path))];
  24203. return func == null ? undefined : apply(func, object, args);
  24204. }
  24205. /**
  24206. * The base implementation of `_.isArguments`.
  24207. *
  24208. * @private
  24209. * @param {*} value The value to check.
  24210. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  24211. */
  24212. function baseIsArguments(value) {
  24213. return isObjectLike(value) && baseGetTag(value) == argsTag;
  24214. }
  24215. /**
  24216. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  24217. *
  24218. * @private
  24219. * @param {*} value The value to check.
  24220. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  24221. */
  24222. function baseIsArrayBuffer(value) {
  24223. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  24224. }
  24225. /**
  24226. * The base implementation of `_.isDate` without Node.js optimizations.
  24227. *
  24228. * @private
  24229. * @param {*} value The value to check.
  24230. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  24231. */
  24232. function baseIsDate(value) {
  24233. return isObjectLike(value) && baseGetTag(value) == dateTag;
  24234. }
  24235. /**
  24236. * The base implementation of `_.isEqual` which supports partial comparisons
  24237. * and tracks traversed objects.
  24238. *
  24239. * @private
  24240. * @param {*} value The value to compare.
  24241. * @param {*} other The other value to compare.
  24242. * @param {boolean} bitmask The bitmask flags.
  24243. * 1 - Unordered comparison
  24244. * 2 - Partial comparison
  24245. * @param {Function} [customizer] The function to customize comparisons.
  24246. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  24247. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24248. */
  24249. function baseIsEqual(value, other, bitmask, customizer, stack) {
  24250. if (value === other) {
  24251. return true;
  24252. }
  24253. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  24254. return value !== value && other !== other;
  24255. }
  24256. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  24257. }
  24258. /**
  24259. * A specialized version of `baseIsEqual` for arrays and objects which performs
  24260. * deep comparisons and tracks traversed objects enabling objects with circular
  24261. * references to be compared.
  24262. *
  24263. * @private
  24264. * @param {Object} object The object to compare.
  24265. * @param {Object} other The other object to compare.
  24266. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  24267. * @param {Function} customizer The function to customize comparisons.
  24268. * @param {Function} equalFunc The function to determine equivalents of values.
  24269. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  24270. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  24271. */
  24272. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  24273. var objIsArr = isArray(object),
  24274. othIsArr = isArray(other),
  24275. objTag = objIsArr ? arrayTag : getTag(object),
  24276. othTag = othIsArr ? arrayTag : getTag(other);
  24277. objTag = objTag == argsTag ? objectTag : objTag;
  24278. othTag = othTag == argsTag ? objectTag : othTag;
  24279. var objIsObj = objTag == objectTag,
  24280. othIsObj = othTag == objectTag,
  24281. isSameTag = objTag == othTag;
  24282. if (isSameTag && isBuffer(object)) {
  24283. if (!isBuffer(other)) {
  24284. return false;
  24285. }
  24286. objIsArr = true;
  24287. objIsObj = false;
  24288. }
  24289. if (isSameTag && !objIsObj) {
  24290. stack || (stack = new Stack);
  24291. return (objIsArr || isTypedArray(object))
  24292. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  24293. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  24294. }
  24295. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  24296. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  24297. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  24298. if (objIsWrapped || othIsWrapped) {
  24299. var objUnwrapped = objIsWrapped ? object.value() : object,
  24300. othUnwrapped = othIsWrapped ? other.value() : other;
  24301. stack || (stack = new Stack);
  24302. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  24303. }
  24304. }
  24305. if (!isSameTag) {
  24306. return false;
  24307. }
  24308. stack || (stack = new Stack);
  24309. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  24310. }
  24311. /**
  24312. * The base implementation of `_.isMap` without Node.js optimizations.
  24313. *
  24314. * @private
  24315. * @param {*} value The value to check.
  24316. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  24317. */
  24318. function baseIsMap(value) {
  24319. return isObjectLike(value) && getTag(value) == mapTag;
  24320. }
  24321. /**
  24322. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  24323. *
  24324. * @private
  24325. * @param {Object} object The object to inspect.
  24326. * @param {Object} source The object of property values to match.
  24327. * @param {Array} matchData The property names, values, and compare flags to match.
  24328. * @param {Function} [customizer] The function to customize comparisons.
  24329. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24330. */
  24331. function baseIsMatch(object, source, matchData, customizer) {
  24332. var index = matchData.length,
  24333. length = index,
  24334. noCustomizer = !customizer;
  24335. if (object == null) {
  24336. return !length;
  24337. }
  24338. object = Object(object);
  24339. while (index--) {
  24340. var data = matchData[index];
  24341. if ((noCustomizer && data[2])
  24342. ? data[1] !== object[data[0]]
  24343. : !(data[0] in object)
  24344. ) {
  24345. return false;
  24346. }
  24347. }
  24348. while (++index < length) {
  24349. data = matchData[index];
  24350. var key = data[0],
  24351. objValue = object[key],
  24352. srcValue = data[1];
  24353. if (noCustomizer && data[2]) {
  24354. if (objValue === undefined && !(key in object)) {
  24355. return false;
  24356. }
  24357. } else {
  24358. var stack = new Stack;
  24359. if (customizer) {
  24360. var result = customizer(objValue, srcValue, key, object, source, stack);
  24361. }
  24362. if (!(result === undefined
  24363. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  24364. : result
  24365. )) {
  24366. return false;
  24367. }
  24368. }
  24369. }
  24370. return true;
  24371. }
  24372. /**
  24373. * The base implementation of `_.isNative` without bad shim checks.
  24374. *
  24375. * @private
  24376. * @param {*} value The value to check.
  24377. * @returns {boolean} Returns `true` if `value` is a native function,
  24378. * else `false`.
  24379. */
  24380. function baseIsNative(value) {
  24381. if (!isObject(value) || isMasked(value)) {
  24382. return false;
  24383. }
  24384. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  24385. return pattern.test(toSource(value));
  24386. }
  24387. /**
  24388. * The base implementation of `_.isRegExp` without Node.js optimizations.
  24389. *
  24390. * @private
  24391. * @param {*} value The value to check.
  24392. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  24393. */
  24394. function baseIsRegExp(value) {
  24395. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  24396. }
  24397. /**
  24398. * The base implementation of `_.isSet` without Node.js optimizations.
  24399. *
  24400. * @private
  24401. * @param {*} value The value to check.
  24402. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  24403. */
  24404. function baseIsSet(value) {
  24405. return isObjectLike(value) && getTag(value) == setTag;
  24406. }
  24407. /**
  24408. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  24409. *
  24410. * @private
  24411. * @param {*} value The value to check.
  24412. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  24413. */
  24414. function baseIsTypedArray(value) {
  24415. return isObjectLike(value) &&
  24416. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  24417. }
  24418. /**
  24419. * The base implementation of `_.iteratee`.
  24420. *
  24421. * @private
  24422. * @param {*} [value=_.identity] The value to convert to an iteratee.
  24423. * @returns {Function} Returns the iteratee.
  24424. */
  24425. function baseIteratee(value) {
  24426. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  24427. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  24428. if (typeof value == 'function') {
  24429. return value;
  24430. }
  24431. if (value == null) {
  24432. return identity;
  24433. }
  24434. if (typeof value == 'object') {
  24435. return isArray(value)
  24436. ? baseMatchesProperty(value[0], value[1])
  24437. : baseMatches(value);
  24438. }
  24439. return property(value);
  24440. }
  24441. /**
  24442. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  24443. *
  24444. * @private
  24445. * @param {Object} object The object to query.
  24446. * @returns {Array} Returns the array of property names.
  24447. */
  24448. function baseKeys(object) {
  24449. if (!isPrototype(object)) {
  24450. return nativeKeys(object);
  24451. }
  24452. var result = [];
  24453. for (var key in Object(object)) {
  24454. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  24455. result.push(key);
  24456. }
  24457. }
  24458. return result;
  24459. }
  24460. /**
  24461. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  24462. *
  24463. * @private
  24464. * @param {Object} object The object to query.
  24465. * @returns {Array} Returns the array of property names.
  24466. */
  24467. function baseKeysIn(object) {
  24468. if (!isObject(object)) {
  24469. return nativeKeysIn(object);
  24470. }
  24471. var isProto = isPrototype(object),
  24472. result = [];
  24473. for (var key in object) {
  24474. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  24475. result.push(key);
  24476. }
  24477. }
  24478. return result;
  24479. }
  24480. /**
  24481. * The base implementation of `_.lt` which doesn't coerce arguments.
  24482. *
  24483. * @private
  24484. * @param {*} value The value to compare.
  24485. * @param {*} other The other value to compare.
  24486. * @returns {boolean} Returns `true` if `value` is less than `other`,
  24487. * else `false`.
  24488. */
  24489. function baseLt(value, other) {
  24490. return value < other;
  24491. }
  24492. /**
  24493. * The base implementation of `_.map` without support for iteratee shorthands.
  24494. *
  24495. * @private
  24496. * @param {Array|Object} collection The collection to iterate over.
  24497. * @param {Function} iteratee The function invoked per iteration.
  24498. * @returns {Array} Returns the new mapped array.
  24499. */
  24500. function baseMap(collection, iteratee) {
  24501. var index = -1,
  24502. result = isArrayLike(collection) ? Array(collection.length) : [];
  24503. baseEach(collection, function(value, key, collection) {
  24504. result[++index] = iteratee(value, key, collection);
  24505. });
  24506. return result;
  24507. }
  24508. /**
  24509. * The base implementation of `_.matches` which doesn't clone `source`.
  24510. *
  24511. * @private
  24512. * @param {Object} source The object of property values to match.
  24513. * @returns {Function} Returns the new spec function.
  24514. */
  24515. function baseMatches(source) {
  24516. var matchData = getMatchData(source);
  24517. if (matchData.length == 1 && matchData[0][2]) {
  24518. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  24519. }
  24520. return function(object) {
  24521. return object === source || baseIsMatch(object, source, matchData);
  24522. };
  24523. }
  24524. /**
  24525. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  24526. *
  24527. * @private
  24528. * @param {string} path The path of the property to get.
  24529. * @param {*} srcValue The value to match.
  24530. * @returns {Function} Returns the new spec function.
  24531. */
  24532. function baseMatchesProperty(path, srcValue) {
  24533. if (isKey(path) && isStrictComparable(srcValue)) {
  24534. return matchesStrictComparable(toKey(path), srcValue);
  24535. }
  24536. return function(object) {
  24537. var objValue = get(object, path);
  24538. return (objValue === undefined && objValue === srcValue)
  24539. ? hasIn(object, path)
  24540. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  24541. };
  24542. }
  24543. /**
  24544. * The base implementation of `_.merge` without support for multiple sources.
  24545. *
  24546. * @private
  24547. * @param {Object} object The destination object.
  24548. * @param {Object} source The source object.
  24549. * @param {number} srcIndex The index of `source`.
  24550. * @param {Function} [customizer] The function to customize merged values.
  24551. * @param {Object} [stack] Tracks traversed source values and their merged
  24552. * counterparts.
  24553. */
  24554. function baseMerge(object, source, srcIndex, customizer, stack) {
  24555. if (object === source) {
  24556. return;
  24557. }
  24558. baseFor(source, function(srcValue, key) {
  24559. stack || (stack = new Stack);
  24560. if (isObject(srcValue)) {
  24561. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  24562. }
  24563. else {
  24564. var newValue = customizer
  24565. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  24566. : undefined;
  24567. if (newValue === undefined) {
  24568. newValue = srcValue;
  24569. }
  24570. assignMergeValue(object, key, newValue);
  24571. }
  24572. }, keysIn);
  24573. }
  24574. /**
  24575. * A specialized version of `baseMerge` for arrays and objects which performs
  24576. * deep merges and tracks traversed objects enabling objects with circular
  24577. * references to be merged.
  24578. *
  24579. * @private
  24580. * @param {Object} object The destination object.
  24581. * @param {Object} source The source object.
  24582. * @param {string} key The key of the value to merge.
  24583. * @param {number} srcIndex The index of `source`.
  24584. * @param {Function} mergeFunc The function to merge values.
  24585. * @param {Function} [customizer] The function to customize assigned values.
  24586. * @param {Object} [stack] Tracks traversed source values and their merged
  24587. * counterparts.
  24588. */
  24589. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  24590. var objValue = safeGet(object, key),
  24591. srcValue = safeGet(source, key),
  24592. stacked = stack.get(srcValue);
  24593. if (stacked) {
  24594. assignMergeValue(object, key, stacked);
  24595. return;
  24596. }
  24597. var newValue = customizer
  24598. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  24599. : undefined;
  24600. var isCommon = newValue === undefined;
  24601. if (isCommon) {
  24602. var isArr = isArray(srcValue),
  24603. isBuff = !isArr && isBuffer(srcValue),
  24604. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  24605. newValue = srcValue;
  24606. if (isArr || isBuff || isTyped) {
  24607. if (isArray(objValue)) {
  24608. newValue = objValue;
  24609. }
  24610. else if (isArrayLikeObject(objValue)) {
  24611. newValue = copyArray(objValue);
  24612. }
  24613. else if (isBuff) {
  24614. isCommon = false;
  24615. newValue = cloneBuffer(srcValue, true);
  24616. }
  24617. else if (isTyped) {
  24618. isCommon = false;
  24619. newValue = cloneTypedArray(srcValue, true);
  24620. }
  24621. else {
  24622. newValue = [];
  24623. }
  24624. }
  24625. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  24626. newValue = objValue;
  24627. if (isArguments(objValue)) {
  24628. newValue = toPlainObject(objValue);
  24629. }
  24630. else if (!isObject(objValue) || isFunction(objValue)) {
  24631. newValue = initCloneObject(srcValue);
  24632. }
  24633. }
  24634. else {
  24635. isCommon = false;
  24636. }
  24637. }
  24638. if (isCommon) {
  24639. // Recursively merge objects and arrays (susceptible to call stack limits).
  24640. stack.set(srcValue, newValue);
  24641. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  24642. stack['delete'](srcValue);
  24643. }
  24644. assignMergeValue(object, key, newValue);
  24645. }
  24646. /**
  24647. * The base implementation of `_.nth` which doesn't coerce arguments.
  24648. *
  24649. * @private
  24650. * @param {Array} array The array to query.
  24651. * @param {number} n The index of the element to return.
  24652. * @returns {*} Returns the nth element of `array`.
  24653. */
  24654. function baseNth(array, n) {
  24655. var length = array.length;
  24656. if (!length) {
  24657. return;
  24658. }
  24659. n += n < 0 ? length : 0;
  24660. return isIndex(n, length) ? array[n] : undefined;
  24661. }
  24662. /**
  24663. * The base implementation of `_.orderBy` without param guards.
  24664. *
  24665. * @private
  24666. * @param {Array|Object} collection The collection to iterate over.
  24667. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  24668. * @param {string[]} orders The sort orders of `iteratees`.
  24669. * @returns {Array} Returns the new sorted array.
  24670. */
  24671. function baseOrderBy(collection, iteratees, orders) {
  24672. var index = -1;
  24673. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  24674. var result = baseMap(collection, function(value, key, collection) {
  24675. var criteria = arrayMap(iteratees, function(iteratee) {
  24676. return iteratee(value);
  24677. });
  24678. return { 'criteria': criteria, 'index': ++index, 'value': value };
  24679. });
  24680. return baseSortBy(result, function(object, other) {
  24681. return compareMultiple(object, other, orders);
  24682. });
  24683. }
  24684. /**
  24685. * The base implementation of `_.pick` without support for individual
  24686. * property identifiers.
  24687. *
  24688. * @private
  24689. * @param {Object} object The source object.
  24690. * @param {string[]} paths The property paths to pick.
  24691. * @returns {Object} Returns the new object.
  24692. */
  24693. function basePick(object, paths) {
  24694. return basePickBy(object, paths, function(value, path) {
  24695. return hasIn(object, path);
  24696. });
  24697. }
  24698. /**
  24699. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  24700. *
  24701. * @private
  24702. * @param {Object} object The source object.
  24703. * @param {string[]} paths The property paths to pick.
  24704. * @param {Function} predicate The function invoked per property.
  24705. * @returns {Object} Returns the new object.
  24706. */
  24707. function basePickBy(object, paths, predicate) {
  24708. var index = -1,
  24709. length = paths.length,
  24710. result = {};
  24711. while (++index < length) {
  24712. var path = paths[index],
  24713. value = baseGet(object, path);
  24714. if (predicate(value, path)) {
  24715. baseSet(result, castPath(path, object), value);
  24716. }
  24717. }
  24718. return result;
  24719. }
  24720. /**
  24721. * A specialized version of `baseProperty` which supports deep paths.
  24722. *
  24723. * @private
  24724. * @param {Array|string} path The path of the property to get.
  24725. * @returns {Function} Returns the new accessor function.
  24726. */
  24727. function basePropertyDeep(path) {
  24728. return function(object) {
  24729. return baseGet(object, path);
  24730. };
  24731. }
  24732. /**
  24733. * The base implementation of `_.pullAllBy` without support for iteratee
  24734. * shorthands.
  24735. *
  24736. * @private
  24737. * @param {Array} array The array to modify.
  24738. * @param {Array} values The values to remove.
  24739. * @param {Function} [iteratee] The iteratee invoked per element.
  24740. * @param {Function} [comparator] The comparator invoked per element.
  24741. * @returns {Array} Returns `array`.
  24742. */
  24743. function basePullAll(array, values, iteratee, comparator) {
  24744. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  24745. index = -1,
  24746. length = values.length,
  24747. seen = array;
  24748. if (array === values) {
  24749. values = copyArray(values);
  24750. }
  24751. if (iteratee) {
  24752. seen = arrayMap(array, baseUnary(iteratee));
  24753. }
  24754. while (++index < length) {
  24755. var fromIndex = 0,
  24756. value = values[index],
  24757. computed = iteratee ? iteratee(value) : value;
  24758. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  24759. if (seen !== array) {
  24760. splice.call(seen, fromIndex, 1);
  24761. }
  24762. splice.call(array, fromIndex, 1);
  24763. }
  24764. }
  24765. return array;
  24766. }
  24767. /**
  24768. * The base implementation of `_.pullAt` without support for individual
  24769. * indexes or capturing the removed elements.
  24770. *
  24771. * @private
  24772. * @param {Array} array The array to modify.
  24773. * @param {number[]} indexes The indexes of elements to remove.
  24774. * @returns {Array} Returns `array`.
  24775. */
  24776. function basePullAt(array, indexes) {
  24777. var length = array ? indexes.length : 0,
  24778. lastIndex = length - 1;
  24779. while (length--) {
  24780. var index = indexes[length];
  24781. if (length == lastIndex || index !== previous) {
  24782. var previous = index;
  24783. if (isIndex(index)) {
  24784. splice.call(array, index, 1);
  24785. } else {
  24786. baseUnset(array, index);
  24787. }
  24788. }
  24789. }
  24790. return array;
  24791. }
  24792. /**
  24793. * The base implementation of `_.random` without support for returning
  24794. * floating-point numbers.
  24795. *
  24796. * @private
  24797. * @param {number} lower The lower bound.
  24798. * @param {number} upper The upper bound.
  24799. * @returns {number} Returns the random number.
  24800. */
  24801. function baseRandom(lower, upper) {
  24802. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  24803. }
  24804. /**
  24805. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  24806. * coerce arguments.
  24807. *
  24808. * @private
  24809. * @param {number} start The start of the range.
  24810. * @param {number} end The end of the range.
  24811. * @param {number} step The value to increment or decrement by.
  24812. * @param {boolean} [fromRight] Specify iterating from right to left.
  24813. * @returns {Array} Returns the range of numbers.
  24814. */
  24815. function baseRange(start, end, step, fromRight) {
  24816. var index = -1,
  24817. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  24818. result = Array(length);
  24819. while (length--) {
  24820. result[fromRight ? length : ++index] = start;
  24821. start += step;
  24822. }
  24823. return result;
  24824. }
  24825. /**
  24826. * The base implementation of `_.repeat` which doesn't coerce arguments.
  24827. *
  24828. * @private
  24829. * @param {string} string The string to repeat.
  24830. * @param {number} n The number of times to repeat the string.
  24831. * @returns {string} Returns the repeated string.
  24832. */
  24833. function baseRepeat(string, n) {
  24834. var result = '';
  24835. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  24836. return result;
  24837. }
  24838. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  24839. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  24840. do {
  24841. if (n % 2) {
  24842. result += string;
  24843. }
  24844. n = nativeFloor(n / 2);
  24845. if (n) {
  24846. string += string;
  24847. }
  24848. } while (n);
  24849. return result;
  24850. }
  24851. /**
  24852. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  24853. *
  24854. * @private
  24855. * @param {Function} func The function to apply a rest parameter to.
  24856. * @param {number} [start=func.length-1] The start position of the rest parameter.
  24857. * @returns {Function} Returns the new function.
  24858. */
  24859. function baseRest(func, start) {
  24860. return setToString(overRest(func, start, identity), func + '');
  24861. }
  24862. /**
  24863. * The base implementation of `_.sample`.
  24864. *
  24865. * @private
  24866. * @param {Array|Object} collection The collection to sample.
  24867. * @returns {*} Returns the random element.
  24868. */
  24869. function baseSample(collection) {
  24870. return arraySample(values(collection));
  24871. }
  24872. /**
  24873. * The base implementation of `_.sampleSize` without param guards.
  24874. *
  24875. * @private
  24876. * @param {Array|Object} collection The collection to sample.
  24877. * @param {number} n The number of elements to sample.
  24878. * @returns {Array} Returns the random elements.
  24879. */
  24880. function baseSampleSize(collection, n) {
  24881. var array = values(collection);
  24882. return shuffleSelf(array, baseClamp(n, 0, array.length));
  24883. }
  24884. /**
  24885. * The base implementation of `_.set`.
  24886. *
  24887. * @private
  24888. * @param {Object} object The object to modify.
  24889. * @param {Array|string} path The path of the property to set.
  24890. * @param {*} value The value to set.
  24891. * @param {Function} [customizer] The function to customize path creation.
  24892. * @returns {Object} Returns `object`.
  24893. */
  24894. function baseSet(object, path, value, customizer) {
  24895. if (!isObject(object)) {
  24896. return object;
  24897. }
  24898. path = castPath(path, object);
  24899. var index = -1,
  24900. length = path.length,
  24901. lastIndex = length - 1,
  24902. nested = object;
  24903. while (nested != null && ++index < length) {
  24904. var key = toKey(path[index]),
  24905. newValue = value;
  24906. if (index != lastIndex) {
  24907. var objValue = nested[key];
  24908. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  24909. if (newValue === undefined) {
  24910. newValue = isObject(objValue)
  24911. ? objValue
  24912. : (isIndex(path[index + 1]) ? [] : {});
  24913. }
  24914. }
  24915. assignValue(nested, key, newValue);
  24916. nested = nested[key];
  24917. }
  24918. return object;
  24919. }
  24920. /**
  24921. * The base implementation of `setData` without support for hot loop shorting.
  24922. *
  24923. * @private
  24924. * @param {Function} func The function to associate metadata with.
  24925. * @param {*} data The metadata.
  24926. * @returns {Function} Returns `func`.
  24927. */
  24928. var baseSetData = !metaMap ? identity : function(func, data) {
  24929. metaMap.set(func, data);
  24930. return func;
  24931. };
  24932. /**
  24933. * The base implementation of `setToString` without support for hot loop shorting.
  24934. *
  24935. * @private
  24936. * @param {Function} func The function to modify.
  24937. * @param {Function} string The `toString` result.
  24938. * @returns {Function} Returns `func`.
  24939. */
  24940. var baseSetToString = !defineProperty ? identity : function(func, string) {
  24941. return defineProperty(func, 'toString', {
  24942. 'configurable': true,
  24943. 'enumerable': false,
  24944. 'value': constant(string),
  24945. 'writable': true
  24946. });
  24947. };
  24948. /**
  24949. * The base implementation of `_.shuffle`.
  24950. *
  24951. * @private
  24952. * @param {Array|Object} collection The collection to shuffle.
  24953. * @returns {Array} Returns the new shuffled array.
  24954. */
  24955. function baseShuffle(collection) {
  24956. return shuffleSelf(values(collection));
  24957. }
  24958. /**
  24959. * The base implementation of `_.slice` without an iteratee call guard.
  24960. *
  24961. * @private
  24962. * @param {Array} array The array to slice.
  24963. * @param {number} [start=0] The start position.
  24964. * @param {number} [end=array.length] The end position.
  24965. * @returns {Array} Returns the slice of `array`.
  24966. */
  24967. function baseSlice(array, start, end) {
  24968. var index = -1,
  24969. length = array.length;
  24970. if (start < 0) {
  24971. start = -start > length ? 0 : (length + start);
  24972. }
  24973. end = end > length ? length : end;
  24974. if (end < 0) {
  24975. end += length;
  24976. }
  24977. length = start > end ? 0 : ((end - start) >>> 0);
  24978. start >>>= 0;
  24979. var result = Array(length);
  24980. while (++index < length) {
  24981. result[index] = array[index + start];
  24982. }
  24983. return result;
  24984. }
  24985. /**
  24986. * The base implementation of `_.some` without support for iteratee shorthands.
  24987. *
  24988. * @private
  24989. * @param {Array|Object} collection The collection to iterate over.
  24990. * @param {Function} predicate The function invoked per iteration.
  24991. * @returns {boolean} Returns `true` if any element passes the predicate check,
  24992. * else `false`.
  24993. */
  24994. function baseSome(collection, predicate) {
  24995. var result;
  24996. baseEach(collection, function(value, index, collection) {
  24997. result = predicate(value, index, collection);
  24998. return !result;
  24999. });
  25000. return !!result;
  25001. }
  25002. /**
  25003. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  25004. * performs a binary search of `array` to determine the index at which `value`
  25005. * should be inserted into `array` in order to maintain its sort order.
  25006. *
  25007. * @private
  25008. * @param {Array} array The sorted array to inspect.
  25009. * @param {*} value The value to evaluate.
  25010. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  25011. * @returns {number} Returns the index at which `value` should be inserted
  25012. * into `array`.
  25013. */
  25014. function baseSortedIndex(array, value, retHighest) {
  25015. var low = 0,
  25016. high = array == null ? low : array.length;
  25017. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  25018. while (low < high) {
  25019. var mid = (low + high) >>> 1,
  25020. computed = array[mid];
  25021. if (computed !== null && !isSymbol(computed) &&
  25022. (retHighest ? (computed <= value) : (computed < value))) {
  25023. low = mid + 1;
  25024. } else {
  25025. high = mid;
  25026. }
  25027. }
  25028. return high;
  25029. }
  25030. return baseSortedIndexBy(array, value, identity, retHighest);
  25031. }
  25032. /**
  25033. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  25034. * which invokes `iteratee` for `value` and each element of `array` to compute
  25035. * their sort ranking. The iteratee is invoked with one argument; (value).
  25036. *
  25037. * @private
  25038. * @param {Array} array The sorted array to inspect.
  25039. * @param {*} value The value to evaluate.
  25040. * @param {Function} iteratee The iteratee invoked per element.
  25041. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  25042. * @returns {number} Returns the index at which `value` should be inserted
  25043. * into `array`.
  25044. */
  25045. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  25046. value = iteratee(value);
  25047. var low = 0,
  25048. high = array == null ? 0 : array.length,
  25049. valIsNaN = value !== value,
  25050. valIsNull = value === null,
  25051. valIsSymbol = isSymbol(value),
  25052. valIsUndefined = value === undefined;
  25053. while (low < high) {
  25054. var mid = nativeFloor((low + high) / 2),
  25055. computed = iteratee(array[mid]),
  25056. othIsDefined = computed !== undefined,
  25057. othIsNull = computed === null,
  25058. othIsReflexive = computed === computed,
  25059. othIsSymbol = isSymbol(computed);
  25060. if (valIsNaN) {
  25061. var setLow = retHighest || othIsReflexive;
  25062. } else if (valIsUndefined) {
  25063. setLow = othIsReflexive && (retHighest || othIsDefined);
  25064. } else if (valIsNull) {
  25065. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  25066. } else if (valIsSymbol) {
  25067. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  25068. } else if (othIsNull || othIsSymbol) {
  25069. setLow = false;
  25070. } else {
  25071. setLow = retHighest ? (computed <= value) : (computed < value);
  25072. }
  25073. if (setLow) {
  25074. low = mid + 1;
  25075. } else {
  25076. high = mid;
  25077. }
  25078. }
  25079. return nativeMin(high, MAX_ARRAY_INDEX);
  25080. }
  25081. /**
  25082. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  25083. * support for iteratee shorthands.
  25084. *
  25085. * @private
  25086. * @param {Array} array The array to inspect.
  25087. * @param {Function} [iteratee] The iteratee invoked per element.
  25088. * @returns {Array} Returns the new duplicate free array.
  25089. */
  25090. function baseSortedUniq(array, iteratee) {
  25091. var index = -1,
  25092. length = array.length,
  25093. resIndex = 0,
  25094. result = [];
  25095. while (++index < length) {
  25096. var value = array[index],
  25097. computed = iteratee ? iteratee(value) : value;
  25098. if (!index || !eq(computed, seen)) {
  25099. var seen = computed;
  25100. result[resIndex++] = value === 0 ? 0 : value;
  25101. }
  25102. }
  25103. return result;
  25104. }
  25105. /**
  25106. * The base implementation of `_.toNumber` which doesn't ensure correct
  25107. * conversions of binary, hexadecimal, or octal string values.
  25108. *
  25109. * @private
  25110. * @param {*} value The value to process.
  25111. * @returns {number} Returns the number.
  25112. */
  25113. function baseToNumber(value) {
  25114. if (typeof value == 'number') {
  25115. return value;
  25116. }
  25117. if (isSymbol(value)) {
  25118. return NAN;
  25119. }
  25120. return +value;
  25121. }
  25122. /**
  25123. * The base implementation of `_.toString` which doesn't convert nullish
  25124. * values to empty strings.
  25125. *
  25126. * @private
  25127. * @param {*} value The value to process.
  25128. * @returns {string} Returns the string.
  25129. */
  25130. function baseToString(value) {
  25131. // Exit early for strings to avoid a performance hit in some environments.
  25132. if (typeof value == 'string') {
  25133. return value;
  25134. }
  25135. if (isArray(value)) {
  25136. // Recursively convert values (susceptible to call stack limits).
  25137. return arrayMap(value, baseToString) + '';
  25138. }
  25139. if (isSymbol(value)) {
  25140. return symbolToString ? symbolToString.call(value) : '';
  25141. }
  25142. var result = (value + '');
  25143. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  25144. }
  25145. /**
  25146. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  25147. *
  25148. * @private
  25149. * @param {Array} array The array to inspect.
  25150. * @param {Function} [iteratee] The iteratee invoked per element.
  25151. * @param {Function} [comparator] The comparator invoked per element.
  25152. * @returns {Array} Returns the new duplicate free array.
  25153. */
  25154. function baseUniq(array, iteratee, comparator) {
  25155. var index = -1,
  25156. includes = arrayIncludes,
  25157. length = array.length,
  25158. isCommon = true,
  25159. result = [],
  25160. seen = result;
  25161. if (comparator) {
  25162. isCommon = false;
  25163. includes = arrayIncludesWith;
  25164. }
  25165. else if (length >= LARGE_ARRAY_SIZE) {
  25166. var set = iteratee ? null : createSet(array);
  25167. if (set) {
  25168. return setToArray(set);
  25169. }
  25170. isCommon = false;
  25171. includes = cacheHas;
  25172. seen = new SetCache;
  25173. }
  25174. else {
  25175. seen = iteratee ? [] : result;
  25176. }
  25177. outer:
  25178. while (++index < length) {
  25179. var value = array[index],
  25180. computed = iteratee ? iteratee(value) : value;
  25181. value = (comparator || value !== 0) ? value : 0;
  25182. if (isCommon && computed === computed) {
  25183. var seenIndex = seen.length;
  25184. while (seenIndex--) {
  25185. if (seen[seenIndex] === computed) {
  25186. continue outer;
  25187. }
  25188. }
  25189. if (iteratee) {
  25190. seen.push(computed);
  25191. }
  25192. result.push(value);
  25193. }
  25194. else if (!includes(seen, computed, comparator)) {
  25195. if (seen !== result) {
  25196. seen.push(computed);
  25197. }
  25198. result.push(value);
  25199. }
  25200. }
  25201. return result;
  25202. }
  25203. /**
  25204. * The base implementation of `_.unset`.
  25205. *
  25206. * @private
  25207. * @param {Object} object The object to modify.
  25208. * @param {Array|string} path The property path to unset.
  25209. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  25210. */
  25211. function baseUnset(object, path) {
  25212. path = castPath(path, object);
  25213. object = parent(object, path);
  25214. return object == null || delete object[toKey(last(path))];
  25215. }
  25216. /**
  25217. * The base implementation of `_.update`.
  25218. *
  25219. * @private
  25220. * @param {Object} object The object to modify.
  25221. * @param {Array|string} path The path of the property to update.
  25222. * @param {Function} updater The function to produce the updated value.
  25223. * @param {Function} [customizer] The function to customize path creation.
  25224. * @returns {Object} Returns `object`.
  25225. */
  25226. function baseUpdate(object, path, updater, customizer) {
  25227. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  25228. }
  25229. /**
  25230. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  25231. * without support for iteratee shorthands.
  25232. *
  25233. * @private
  25234. * @param {Array} array The array to query.
  25235. * @param {Function} predicate The function invoked per iteration.
  25236. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  25237. * @param {boolean} [fromRight] Specify iterating from right to left.
  25238. * @returns {Array} Returns the slice of `array`.
  25239. */
  25240. function baseWhile(array, predicate, isDrop, fromRight) {
  25241. var length = array.length,
  25242. index = fromRight ? length : -1;
  25243. while ((fromRight ? index-- : ++index < length) &&
  25244. predicate(array[index], index, array)) {}
  25245. return isDrop
  25246. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  25247. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  25248. }
  25249. /**
  25250. * The base implementation of `wrapperValue` which returns the result of
  25251. * performing a sequence of actions on the unwrapped `value`, where each
  25252. * successive action is supplied the return value of the previous.
  25253. *
  25254. * @private
  25255. * @param {*} value The unwrapped value.
  25256. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  25257. * @returns {*} Returns the resolved value.
  25258. */
  25259. function baseWrapperValue(value, actions) {
  25260. var result = value;
  25261. if (result instanceof LazyWrapper) {
  25262. result = result.value();
  25263. }
  25264. return arrayReduce(actions, function(result, action) {
  25265. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  25266. }, result);
  25267. }
  25268. /**
  25269. * The base implementation of methods like `_.xor`, without support for
  25270. * iteratee shorthands, that accepts an array of arrays to inspect.
  25271. *
  25272. * @private
  25273. * @param {Array} arrays The arrays to inspect.
  25274. * @param {Function} [iteratee] The iteratee invoked per element.
  25275. * @param {Function} [comparator] The comparator invoked per element.
  25276. * @returns {Array} Returns the new array of values.
  25277. */
  25278. function baseXor(arrays, iteratee, comparator) {
  25279. var length = arrays.length;
  25280. if (length < 2) {
  25281. return length ? baseUniq(arrays[0]) : [];
  25282. }
  25283. var index = -1,
  25284. result = Array(length);
  25285. while (++index < length) {
  25286. var array = arrays[index],
  25287. othIndex = -1;
  25288. while (++othIndex < length) {
  25289. if (othIndex != index) {
  25290. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  25291. }
  25292. }
  25293. }
  25294. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  25295. }
  25296. /**
  25297. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  25298. *
  25299. * @private
  25300. * @param {Array} props The property identifiers.
  25301. * @param {Array} values The property values.
  25302. * @param {Function} assignFunc The function to assign values.
  25303. * @returns {Object} Returns the new object.
  25304. */
  25305. function baseZipObject(props, values, assignFunc) {
  25306. var index = -1,
  25307. length = props.length,
  25308. valsLength = values.length,
  25309. result = {};
  25310. while (++index < length) {
  25311. var value = index < valsLength ? values[index] : undefined;
  25312. assignFunc(result, props[index], value);
  25313. }
  25314. return result;
  25315. }
  25316. /**
  25317. * Casts `value` to an empty array if it's not an array like object.
  25318. *
  25319. * @private
  25320. * @param {*} value The value to inspect.
  25321. * @returns {Array|Object} Returns the cast array-like object.
  25322. */
  25323. function castArrayLikeObject(value) {
  25324. return isArrayLikeObject(value) ? value : [];
  25325. }
  25326. /**
  25327. * Casts `value` to `identity` if it's not a function.
  25328. *
  25329. * @private
  25330. * @param {*} value The value to inspect.
  25331. * @returns {Function} Returns cast function.
  25332. */
  25333. function castFunction(value) {
  25334. return typeof value == 'function' ? value : identity;
  25335. }
  25336. /**
  25337. * Casts `value` to a path array if it's not one.
  25338. *
  25339. * @private
  25340. * @param {*} value The value to inspect.
  25341. * @param {Object} [object] The object to query keys on.
  25342. * @returns {Array} Returns the cast property path array.
  25343. */
  25344. function castPath(value, object) {
  25345. if (isArray(value)) {
  25346. return value;
  25347. }
  25348. return isKey(value, object) ? [value] : stringToPath(toString(value));
  25349. }
  25350. /**
  25351. * A `baseRest` alias which can be replaced with `identity` by module
  25352. * replacement plugins.
  25353. *
  25354. * @private
  25355. * @type {Function}
  25356. * @param {Function} func The function to apply a rest parameter to.
  25357. * @returns {Function} Returns the new function.
  25358. */
  25359. var castRest = baseRest;
  25360. /**
  25361. * Casts `array` to a slice if it's needed.
  25362. *
  25363. * @private
  25364. * @param {Array} array The array to inspect.
  25365. * @param {number} start The start position.
  25366. * @param {number} [end=array.length] The end position.
  25367. * @returns {Array} Returns the cast slice.
  25368. */
  25369. function castSlice(array, start, end) {
  25370. var length = array.length;
  25371. end = end === undefined ? length : end;
  25372. return (!start && end >= length) ? array : baseSlice(array, start, end);
  25373. }
  25374. /**
  25375. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  25376. *
  25377. * @private
  25378. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  25379. */
  25380. var clearTimeout = ctxClearTimeout || function(id) {
  25381. return root.clearTimeout(id);
  25382. };
  25383. /**
  25384. * Creates a clone of `buffer`.
  25385. *
  25386. * @private
  25387. * @param {Buffer} buffer The buffer to clone.
  25388. * @param {boolean} [isDeep] Specify a deep clone.
  25389. * @returns {Buffer} Returns the cloned buffer.
  25390. */
  25391. function cloneBuffer(buffer, isDeep) {
  25392. if (isDeep) {
  25393. return buffer.slice();
  25394. }
  25395. var length = buffer.length,
  25396. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  25397. buffer.copy(result);
  25398. return result;
  25399. }
  25400. /**
  25401. * Creates a clone of `arrayBuffer`.
  25402. *
  25403. * @private
  25404. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  25405. * @returns {ArrayBuffer} Returns the cloned array buffer.
  25406. */
  25407. function cloneArrayBuffer(arrayBuffer) {
  25408. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  25409. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  25410. return result;
  25411. }
  25412. /**
  25413. * Creates a clone of `dataView`.
  25414. *
  25415. * @private
  25416. * @param {Object} dataView The data view to clone.
  25417. * @param {boolean} [isDeep] Specify a deep clone.
  25418. * @returns {Object} Returns the cloned data view.
  25419. */
  25420. function cloneDataView(dataView, isDeep) {
  25421. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  25422. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  25423. }
  25424. /**
  25425. * Creates a clone of `regexp`.
  25426. *
  25427. * @private
  25428. * @param {Object} regexp The regexp to clone.
  25429. * @returns {Object} Returns the cloned regexp.
  25430. */
  25431. function cloneRegExp(regexp) {
  25432. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  25433. result.lastIndex = regexp.lastIndex;
  25434. return result;
  25435. }
  25436. /**
  25437. * Creates a clone of the `symbol` object.
  25438. *
  25439. * @private
  25440. * @param {Object} symbol The symbol object to clone.
  25441. * @returns {Object} Returns the cloned symbol object.
  25442. */
  25443. function cloneSymbol(symbol) {
  25444. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  25445. }
  25446. /**
  25447. * Creates a clone of `typedArray`.
  25448. *
  25449. * @private
  25450. * @param {Object} typedArray The typed array to clone.
  25451. * @param {boolean} [isDeep] Specify a deep clone.
  25452. * @returns {Object} Returns the cloned typed array.
  25453. */
  25454. function cloneTypedArray(typedArray, isDeep) {
  25455. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  25456. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  25457. }
  25458. /**
  25459. * Compares values to sort them in ascending order.
  25460. *
  25461. * @private
  25462. * @param {*} value The value to compare.
  25463. * @param {*} other The other value to compare.
  25464. * @returns {number} Returns the sort order indicator for `value`.
  25465. */
  25466. function compareAscending(value, other) {
  25467. if (value !== other) {
  25468. var valIsDefined = value !== undefined,
  25469. valIsNull = value === null,
  25470. valIsReflexive = value === value,
  25471. valIsSymbol = isSymbol(value);
  25472. var othIsDefined = other !== undefined,
  25473. othIsNull = other === null,
  25474. othIsReflexive = other === other,
  25475. othIsSymbol = isSymbol(other);
  25476. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  25477. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  25478. (valIsNull && othIsDefined && othIsReflexive) ||
  25479. (!valIsDefined && othIsReflexive) ||
  25480. !valIsReflexive) {
  25481. return 1;
  25482. }
  25483. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  25484. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  25485. (othIsNull && valIsDefined && valIsReflexive) ||
  25486. (!othIsDefined && valIsReflexive) ||
  25487. !othIsReflexive) {
  25488. return -1;
  25489. }
  25490. }
  25491. return 0;
  25492. }
  25493. /**
  25494. * Used by `_.orderBy` to compare multiple properties of a value to another
  25495. * and stable sort them.
  25496. *
  25497. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  25498. * specify an order of "desc" for descending or "asc" for ascending sort order
  25499. * of corresponding values.
  25500. *
  25501. * @private
  25502. * @param {Object} object The object to compare.
  25503. * @param {Object} other The other object to compare.
  25504. * @param {boolean[]|string[]} orders The order to sort by for each property.
  25505. * @returns {number} Returns the sort order indicator for `object`.
  25506. */
  25507. function compareMultiple(object, other, orders) {
  25508. var index = -1,
  25509. objCriteria = object.criteria,
  25510. othCriteria = other.criteria,
  25511. length = objCriteria.length,
  25512. ordersLength = orders.length;
  25513. while (++index < length) {
  25514. var result = compareAscending(objCriteria[index], othCriteria[index]);
  25515. if (result) {
  25516. if (index >= ordersLength) {
  25517. return result;
  25518. }
  25519. var order = orders[index];
  25520. return result * (order == 'desc' ? -1 : 1);
  25521. }
  25522. }
  25523. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  25524. // that causes it, under certain circumstances, to provide the same value for
  25525. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  25526. // for more details.
  25527. //
  25528. // This also ensures a stable sort in V8 and other engines.
  25529. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  25530. return object.index - other.index;
  25531. }
  25532. /**
  25533. * Creates an array that is the composition of partially applied arguments,
  25534. * placeholders, and provided arguments into a single array of arguments.
  25535. *
  25536. * @private
  25537. * @param {Array} args The provided arguments.
  25538. * @param {Array} partials The arguments to prepend to those provided.
  25539. * @param {Array} holders The `partials` placeholder indexes.
  25540. * @params {boolean} [isCurried] Specify composing for a curried function.
  25541. * @returns {Array} Returns the new array of composed arguments.
  25542. */
  25543. function composeArgs(args, partials, holders, isCurried) {
  25544. var argsIndex = -1,
  25545. argsLength = args.length,
  25546. holdersLength = holders.length,
  25547. leftIndex = -1,
  25548. leftLength = partials.length,
  25549. rangeLength = nativeMax(argsLength - holdersLength, 0),
  25550. result = Array(leftLength + rangeLength),
  25551. isUncurried = !isCurried;
  25552. while (++leftIndex < leftLength) {
  25553. result[leftIndex] = partials[leftIndex];
  25554. }
  25555. while (++argsIndex < holdersLength) {
  25556. if (isUncurried || argsIndex < argsLength) {
  25557. result[holders[argsIndex]] = args[argsIndex];
  25558. }
  25559. }
  25560. while (rangeLength--) {
  25561. result[leftIndex++] = args[argsIndex++];
  25562. }
  25563. return result;
  25564. }
  25565. /**
  25566. * This function is like `composeArgs` except that the arguments composition
  25567. * is tailored for `_.partialRight`.
  25568. *
  25569. * @private
  25570. * @param {Array} args The provided arguments.
  25571. * @param {Array} partials The arguments to append to those provided.
  25572. * @param {Array} holders The `partials` placeholder indexes.
  25573. * @params {boolean} [isCurried] Specify composing for a curried function.
  25574. * @returns {Array} Returns the new array of composed arguments.
  25575. */
  25576. function composeArgsRight(args, partials, holders, isCurried) {
  25577. var argsIndex = -1,
  25578. argsLength = args.length,
  25579. holdersIndex = -1,
  25580. holdersLength = holders.length,
  25581. rightIndex = -1,
  25582. rightLength = partials.length,
  25583. rangeLength = nativeMax(argsLength - holdersLength, 0),
  25584. result = Array(rangeLength + rightLength),
  25585. isUncurried = !isCurried;
  25586. while (++argsIndex < rangeLength) {
  25587. result[argsIndex] = args[argsIndex];
  25588. }
  25589. var offset = argsIndex;
  25590. while (++rightIndex < rightLength) {
  25591. result[offset + rightIndex] = partials[rightIndex];
  25592. }
  25593. while (++holdersIndex < holdersLength) {
  25594. if (isUncurried || argsIndex < argsLength) {
  25595. result[offset + holders[holdersIndex]] = args[argsIndex++];
  25596. }
  25597. }
  25598. return result;
  25599. }
  25600. /**
  25601. * Copies the values of `source` to `array`.
  25602. *
  25603. * @private
  25604. * @param {Array} source The array to copy values from.
  25605. * @param {Array} [array=[]] The array to copy values to.
  25606. * @returns {Array} Returns `array`.
  25607. */
  25608. function copyArray(source, array) {
  25609. var index = -1,
  25610. length = source.length;
  25611. array || (array = Array(length));
  25612. while (++index < length) {
  25613. array[index] = source[index];
  25614. }
  25615. return array;
  25616. }
  25617. /**
  25618. * Copies properties of `source` to `object`.
  25619. *
  25620. * @private
  25621. * @param {Object} source The object to copy properties from.
  25622. * @param {Array} props The property identifiers to copy.
  25623. * @param {Object} [object={}] The object to copy properties to.
  25624. * @param {Function} [customizer] The function to customize copied values.
  25625. * @returns {Object} Returns `object`.
  25626. */
  25627. function copyObject(source, props, object, customizer) {
  25628. var isNew = !object;
  25629. object || (object = {});
  25630. var index = -1,
  25631. length = props.length;
  25632. while (++index < length) {
  25633. var key = props[index];
  25634. var newValue = customizer
  25635. ? customizer(object[key], source[key], key, object, source)
  25636. : undefined;
  25637. if (newValue === undefined) {
  25638. newValue = source[key];
  25639. }
  25640. if (isNew) {
  25641. baseAssignValue(object, key, newValue);
  25642. } else {
  25643. assignValue(object, key, newValue);
  25644. }
  25645. }
  25646. return object;
  25647. }
  25648. /**
  25649. * Copies own symbols of `source` to `object`.
  25650. *
  25651. * @private
  25652. * @param {Object} source The object to copy symbols from.
  25653. * @param {Object} [object={}] The object to copy symbols to.
  25654. * @returns {Object} Returns `object`.
  25655. */
  25656. function copySymbols(source, object) {
  25657. return copyObject(source, getSymbols(source), object);
  25658. }
  25659. /**
  25660. * Copies own and inherited symbols of `source` to `object`.
  25661. *
  25662. * @private
  25663. * @param {Object} source The object to copy symbols from.
  25664. * @param {Object} [object={}] The object to copy symbols to.
  25665. * @returns {Object} Returns `object`.
  25666. */
  25667. function copySymbolsIn(source, object) {
  25668. return copyObject(source, getSymbolsIn(source), object);
  25669. }
  25670. /**
  25671. * Creates a function like `_.groupBy`.
  25672. *
  25673. * @private
  25674. * @param {Function} setter The function to set accumulator values.
  25675. * @param {Function} [initializer] The accumulator object initializer.
  25676. * @returns {Function} Returns the new aggregator function.
  25677. */
  25678. function createAggregator(setter, initializer) {
  25679. return function(collection, iteratee) {
  25680. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  25681. accumulator = initializer ? initializer() : {};
  25682. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  25683. };
  25684. }
  25685. /**
  25686. * Creates a function like `_.assign`.
  25687. *
  25688. * @private
  25689. * @param {Function} assigner The function to assign values.
  25690. * @returns {Function} Returns the new assigner function.
  25691. */
  25692. function createAssigner(assigner) {
  25693. return baseRest(function(object, sources) {
  25694. var index = -1,
  25695. length = sources.length,
  25696. customizer = length > 1 ? sources[length - 1] : undefined,
  25697. guard = length > 2 ? sources[2] : undefined;
  25698. customizer = (assigner.length > 3 && typeof customizer == 'function')
  25699. ? (length--, customizer)
  25700. : undefined;
  25701. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  25702. customizer = length < 3 ? undefined : customizer;
  25703. length = 1;
  25704. }
  25705. object = Object(object);
  25706. while (++index < length) {
  25707. var source = sources[index];
  25708. if (source) {
  25709. assigner(object, source, index, customizer);
  25710. }
  25711. }
  25712. return object;
  25713. });
  25714. }
  25715. /**
  25716. * Creates a `baseEach` or `baseEachRight` function.
  25717. *
  25718. * @private
  25719. * @param {Function} eachFunc The function to iterate over a collection.
  25720. * @param {boolean} [fromRight] Specify iterating from right to left.
  25721. * @returns {Function} Returns the new base function.
  25722. */
  25723. function createBaseEach(eachFunc, fromRight) {
  25724. return function(collection, iteratee) {
  25725. if (collection == null) {
  25726. return collection;
  25727. }
  25728. if (!isArrayLike(collection)) {
  25729. return eachFunc(collection, iteratee);
  25730. }
  25731. var length = collection.length,
  25732. index = fromRight ? length : -1,
  25733. iterable = Object(collection);
  25734. while ((fromRight ? index-- : ++index < length)) {
  25735. if (iteratee(iterable[index], index, iterable) === false) {
  25736. break;
  25737. }
  25738. }
  25739. return collection;
  25740. };
  25741. }
  25742. /**
  25743. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  25744. *
  25745. * @private
  25746. * @param {boolean} [fromRight] Specify iterating from right to left.
  25747. * @returns {Function} Returns the new base function.
  25748. */
  25749. function createBaseFor(fromRight) {
  25750. return function(object, iteratee, keysFunc) {
  25751. var index = -1,
  25752. iterable = Object(object),
  25753. props = keysFunc(object),
  25754. length = props.length;
  25755. while (length--) {
  25756. var key = props[fromRight ? length : ++index];
  25757. if (iteratee(iterable[key], key, iterable) === false) {
  25758. break;
  25759. }
  25760. }
  25761. return object;
  25762. };
  25763. }
  25764. /**
  25765. * Creates a function that wraps `func` to invoke it with the optional `this`
  25766. * binding of `thisArg`.
  25767. *
  25768. * @private
  25769. * @param {Function} func The function to wrap.
  25770. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  25771. * @param {*} [thisArg] The `this` binding of `func`.
  25772. * @returns {Function} Returns the new wrapped function.
  25773. */
  25774. function createBind(func, bitmask, thisArg) {
  25775. var isBind = bitmask & WRAP_BIND_FLAG,
  25776. Ctor = createCtor(func);
  25777. function wrapper() {
  25778. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  25779. return fn.apply(isBind ? thisArg : this, arguments);
  25780. }
  25781. return wrapper;
  25782. }
  25783. /**
  25784. * Creates a function like `_.lowerFirst`.
  25785. *
  25786. * @private
  25787. * @param {string} methodName The name of the `String` case method to use.
  25788. * @returns {Function} Returns the new case function.
  25789. */
  25790. function createCaseFirst(methodName) {
  25791. return function(string) {
  25792. string = toString(string);
  25793. var strSymbols = hasUnicode(string)
  25794. ? stringToArray(string)
  25795. : undefined;
  25796. var chr = strSymbols
  25797. ? strSymbols[0]
  25798. : string.charAt(0);
  25799. var trailing = strSymbols
  25800. ? castSlice(strSymbols, 1).join('')
  25801. : string.slice(1);
  25802. return chr[methodName]() + trailing;
  25803. };
  25804. }
  25805. /**
  25806. * Creates a function like `_.camelCase`.
  25807. *
  25808. * @private
  25809. * @param {Function} callback The function to combine each word.
  25810. * @returns {Function} Returns the new compounder function.
  25811. */
  25812. function createCompounder(callback) {
  25813. return function(string) {
  25814. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  25815. };
  25816. }
  25817. /**
  25818. * Creates a function that produces an instance of `Ctor` regardless of
  25819. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  25820. *
  25821. * @private
  25822. * @param {Function} Ctor The constructor to wrap.
  25823. * @returns {Function} Returns the new wrapped function.
  25824. */
  25825. function createCtor(Ctor) {
  25826. return function() {
  25827. // Use a `switch` statement to work with class constructors. See
  25828. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  25829. // for more details.
  25830. var args = arguments;
  25831. switch (args.length) {
  25832. case 0: return new Ctor;
  25833. case 1: return new Ctor(args[0]);
  25834. case 2: return new Ctor(args[0], args[1]);
  25835. case 3: return new Ctor(args[0], args[1], args[2]);
  25836. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  25837. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  25838. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  25839. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  25840. }
  25841. var thisBinding = baseCreate(Ctor.prototype),
  25842. result = Ctor.apply(thisBinding, args);
  25843. // Mimic the constructor's `return` behavior.
  25844. // See https://es5.github.io/#x13.2.2 for more details.
  25845. return isObject(result) ? result : thisBinding;
  25846. };
  25847. }
  25848. /**
  25849. * Creates a function that wraps `func` to enable currying.
  25850. *
  25851. * @private
  25852. * @param {Function} func The function to wrap.
  25853. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  25854. * @param {number} arity The arity of `func`.
  25855. * @returns {Function} Returns the new wrapped function.
  25856. */
  25857. function createCurry(func, bitmask, arity) {
  25858. var Ctor = createCtor(func);
  25859. function wrapper() {
  25860. var length = arguments.length,
  25861. args = Array(length),
  25862. index = length,
  25863. placeholder = getHolder(wrapper);
  25864. while (index--) {
  25865. args[index] = arguments[index];
  25866. }
  25867. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  25868. ? []
  25869. : replaceHolders(args, placeholder);
  25870. length -= holders.length;
  25871. if (length < arity) {
  25872. return createRecurry(
  25873. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  25874. args, holders, undefined, undefined, arity - length);
  25875. }
  25876. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  25877. return apply(fn, this, args);
  25878. }
  25879. return wrapper;
  25880. }
  25881. /**
  25882. * Creates a `_.find` or `_.findLast` function.
  25883. *
  25884. * @private
  25885. * @param {Function} findIndexFunc The function to find the collection index.
  25886. * @returns {Function} Returns the new find function.
  25887. */
  25888. function createFind(findIndexFunc) {
  25889. return function(collection, predicate, fromIndex) {
  25890. var iterable = Object(collection);
  25891. if (!isArrayLike(collection)) {
  25892. var iteratee = getIteratee(predicate, 3);
  25893. collection = keys(collection);
  25894. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  25895. }
  25896. var index = findIndexFunc(collection, predicate, fromIndex);
  25897. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  25898. };
  25899. }
  25900. /**
  25901. * Creates a `_.flow` or `_.flowRight` function.
  25902. *
  25903. * @private
  25904. * @param {boolean} [fromRight] Specify iterating from right to left.
  25905. * @returns {Function} Returns the new flow function.
  25906. */
  25907. function createFlow(fromRight) {
  25908. return flatRest(function(funcs) {
  25909. var length = funcs.length,
  25910. index = length,
  25911. prereq = LodashWrapper.prototype.thru;
  25912. if (fromRight) {
  25913. funcs.reverse();
  25914. }
  25915. while (index--) {
  25916. var func = funcs[index];
  25917. if (typeof func != 'function') {
  25918. throw new TypeError(FUNC_ERROR_TEXT);
  25919. }
  25920. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  25921. var wrapper = new LodashWrapper([], true);
  25922. }
  25923. }
  25924. index = wrapper ? index : length;
  25925. while (++index < length) {
  25926. func = funcs[index];
  25927. var funcName = getFuncName(func),
  25928. data = funcName == 'wrapper' ? getData(func) : undefined;
  25929. if (data && isLaziable(data[0]) &&
  25930. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  25931. !data[4].length && data[9] == 1
  25932. ) {
  25933. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  25934. } else {
  25935. wrapper = (func.length == 1 && isLaziable(func))
  25936. ? wrapper[funcName]()
  25937. : wrapper.thru(func);
  25938. }
  25939. }
  25940. return function() {
  25941. var args = arguments,
  25942. value = args[0];
  25943. if (wrapper && args.length == 1 && isArray(value)) {
  25944. return wrapper.plant(value).value();
  25945. }
  25946. var index = 0,
  25947. result = length ? funcs[index].apply(this, args) : value;
  25948. while (++index < length) {
  25949. result = funcs[index].call(this, result);
  25950. }
  25951. return result;
  25952. };
  25953. });
  25954. }
  25955. /**
  25956. * Creates a function that wraps `func` to invoke it with optional `this`
  25957. * binding of `thisArg`, partial application, and currying.
  25958. *
  25959. * @private
  25960. * @param {Function|string} func The function or method name to wrap.
  25961. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  25962. * @param {*} [thisArg] The `this` binding of `func`.
  25963. * @param {Array} [partials] The arguments to prepend to those provided to
  25964. * the new function.
  25965. * @param {Array} [holders] The `partials` placeholder indexes.
  25966. * @param {Array} [partialsRight] The arguments to append to those provided
  25967. * to the new function.
  25968. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  25969. * @param {Array} [argPos] The argument positions of the new function.
  25970. * @param {number} [ary] The arity cap of `func`.
  25971. * @param {number} [arity] The arity of `func`.
  25972. * @returns {Function} Returns the new wrapped function.
  25973. */
  25974. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  25975. var isAry = bitmask & WRAP_ARY_FLAG,
  25976. isBind = bitmask & WRAP_BIND_FLAG,
  25977. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  25978. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  25979. isFlip = bitmask & WRAP_FLIP_FLAG,
  25980. Ctor = isBindKey ? undefined : createCtor(func);
  25981. function wrapper() {
  25982. var length = arguments.length,
  25983. args = Array(length),
  25984. index = length;
  25985. while (index--) {
  25986. args[index] = arguments[index];
  25987. }
  25988. if (isCurried) {
  25989. var placeholder = getHolder(wrapper),
  25990. holdersCount = countHolders(args, placeholder);
  25991. }
  25992. if (partials) {
  25993. args = composeArgs(args, partials, holders, isCurried);
  25994. }
  25995. if (partialsRight) {
  25996. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  25997. }
  25998. length -= holdersCount;
  25999. if (isCurried && length < arity) {
  26000. var newHolders = replaceHolders(args, placeholder);
  26001. return createRecurry(
  26002. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  26003. args, newHolders, argPos, ary, arity - length
  26004. );
  26005. }
  26006. var thisBinding = isBind ? thisArg : this,
  26007. fn = isBindKey ? thisBinding[func] : func;
  26008. length = args.length;
  26009. if (argPos) {
  26010. args = reorder(args, argPos);
  26011. } else if (isFlip && length > 1) {
  26012. args.reverse();
  26013. }
  26014. if (isAry && ary < length) {
  26015. args.length = ary;
  26016. }
  26017. if (this && this !== root && this instanceof wrapper) {
  26018. fn = Ctor || createCtor(fn);
  26019. }
  26020. return fn.apply(thisBinding, args);
  26021. }
  26022. return wrapper;
  26023. }
  26024. /**
  26025. * Creates a function like `_.invertBy`.
  26026. *
  26027. * @private
  26028. * @param {Function} setter The function to set accumulator values.
  26029. * @param {Function} toIteratee The function to resolve iteratees.
  26030. * @returns {Function} Returns the new inverter function.
  26031. */
  26032. function createInverter(setter, toIteratee) {
  26033. return function(object, iteratee) {
  26034. return baseInverter(object, setter, toIteratee(iteratee), {});
  26035. };
  26036. }
  26037. /**
  26038. * Creates a function that performs a mathematical operation on two values.
  26039. *
  26040. * @private
  26041. * @param {Function} operator The function to perform the operation.
  26042. * @param {number} [defaultValue] The value used for `undefined` arguments.
  26043. * @returns {Function} Returns the new mathematical operation function.
  26044. */
  26045. function createMathOperation(operator, defaultValue) {
  26046. return function(value, other) {
  26047. var result;
  26048. if (value === undefined && other === undefined) {
  26049. return defaultValue;
  26050. }
  26051. if (value !== undefined) {
  26052. result = value;
  26053. }
  26054. if (other !== undefined) {
  26055. if (result === undefined) {
  26056. return other;
  26057. }
  26058. if (typeof value == 'string' || typeof other == 'string') {
  26059. value = baseToString(value);
  26060. other = baseToString(other);
  26061. } else {
  26062. value = baseToNumber(value);
  26063. other = baseToNumber(other);
  26064. }
  26065. result = operator(value, other);
  26066. }
  26067. return result;
  26068. };
  26069. }
  26070. /**
  26071. * Creates a function like `_.over`.
  26072. *
  26073. * @private
  26074. * @param {Function} arrayFunc The function to iterate over iteratees.
  26075. * @returns {Function} Returns the new over function.
  26076. */
  26077. function createOver(arrayFunc) {
  26078. return flatRest(function(iteratees) {
  26079. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  26080. return baseRest(function(args) {
  26081. var thisArg = this;
  26082. return arrayFunc(iteratees, function(iteratee) {
  26083. return apply(iteratee, thisArg, args);
  26084. });
  26085. });
  26086. });
  26087. }
  26088. /**
  26089. * Creates the padding for `string` based on `length`. The `chars` string
  26090. * is truncated if the number of characters exceeds `length`.
  26091. *
  26092. * @private
  26093. * @param {number} length The padding length.
  26094. * @param {string} [chars=' '] The string used as padding.
  26095. * @returns {string} Returns the padding for `string`.
  26096. */
  26097. function createPadding(length, chars) {
  26098. chars = chars === undefined ? ' ' : baseToString(chars);
  26099. var charsLength = chars.length;
  26100. if (charsLength < 2) {
  26101. return charsLength ? baseRepeat(chars, length) : chars;
  26102. }
  26103. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  26104. return hasUnicode(chars)
  26105. ? castSlice(stringToArray(result), 0, length).join('')
  26106. : result.slice(0, length);
  26107. }
  26108. /**
  26109. * Creates a function that wraps `func` to invoke it with the `this` binding
  26110. * of `thisArg` and `partials` prepended to the arguments it receives.
  26111. *
  26112. * @private
  26113. * @param {Function} func The function to wrap.
  26114. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  26115. * @param {*} thisArg The `this` binding of `func`.
  26116. * @param {Array} partials The arguments to prepend to those provided to
  26117. * the new function.
  26118. * @returns {Function} Returns the new wrapped function.
  26119. */
  26120. function createPartial(func, bitmask, thisArg, partials) {
  26121. var isBind = bitmask & WRAP_BIND_FLAG,
  26122. Ctor = createCtor(func);
  26123. function wrapper() {
  26124. var argsIndex = -1,
  26125. argsLength = arguments.length,
  26126. leftIndex = -1,
  26127. leftLength = partials.length,
  26128. args = Array(leftLength + argsLength),
  26129. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  26130. while (++leftIndex < leftLength) {
  26131. args[leftIndex] = partials[leftIndex];
  26132. }
  26133. while (argsLength--) {
  26134. args[leftIndex++] = arguments[++argsIndex];
  26135. }
  26136. return apply(fn, isBind ? thisArg : this, args);
  26137. }
  26138. return wrapper;
  26139. }
  26140. /**
  26141. * Creates a `_.range` or `_.rangeRight` function.
  26142. *
  26143. * @private
  26144. * @param {boolean} [fromRight] Specify iterating from right to left.
  26145. * @returns {Function} Returns the new range function.
  26146. */
  26147. function createRange(fromRight) {
  26148. return function(start, end, step) {
  26149. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  26150. end = step = undefined;
  26151. }
  26152. // Ensure the sign of `-0` is preserved.
  26153. start = toFinite(start);
  26154. if (end === undefined) {
  26155. end = start;
  26156. start = 0;
  26157. } else {
  26158. end = toFinite(end);
  26159. }
  26160. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  26161. return baseRange(start, end, step, fromRight);
  26162. };
  26163. }
  26164. /**
  26165. * Creates a function that performs a relational operation on two values.
  26166. *
  26167. * @private
  26168. * @param {Function} operator The function to perform the operation.
  26169. * @returns {Function} Returns the new relational operation function.
  26170. */
  26171. function createRelationalOperation(operator) {
  26172. return function(value, other) {
  26173. if (!(typeof value == 'string' && typeof other == 'string')) {
  26174. value = toNumber(value);
  26175. other = toNumber(other);
  26176. }
  26177. return operator(value, other);
  26178. };
  26179. }
  26180. /**
  26181. * Creates a function that wraps `func` to continue currying.
  26182. *
  26183. * @private
  26184. * @param {Function} func The function to wrap.
  26185. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  26186. * @param {Function} wrapFunc The function to create the `func` wrapper.
  26187. * @param {*} placeholder The placeholder value.
  26188. * @param {*} [thisArg] The `this` binding of `func`.
  26189. * @param {Array} [partials] The arguments to prepend to those provided to
  26190. * the new function.
  26191. * @param {Array} [holders] The `partials` placeholder indexes.
  26192. * @param {Array} [argPos] The argument positions of the new function.
  26193. * @param {number} [ary] The arity cap of `func`.
  26194. * @param {number} [arity] The arity of `func`.
  26195. * @returns {Function} Returns the new wrapped function.
  26196. */
  26197. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  26198. var isCurry = bitmask & WRAP_CURRY_FLAG,
  26199. newHolders = isCurry ? holders : undefined,
  26200. newHoldersRight = isCurry ? undefined : holders,
  26201. newPartials = isCurry ? partials : undefined,
  26202. newPartialsRight = isCurry ? undefined : partials;
  26203. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  26204. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  26205. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  26206. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  26207. }
  26208. var newData = [
  26209. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  26210. newHoldersRight, argPos, ary, arity
  26211. ];
  26212. var result = wrapFunc.apply(undefined, newData);
  26213. if (isLaziable(func)) {
  26214. setData(result, newData);
  26215. }
  26216. result.placeholder = placeholder;
  26217. return setWrapToString(result, func, bitmask);
  26218. }
  26219. /**
  26220. * Creates a function like `_.round`.
  26221. *
  26222. * @private
  26223. * @param {string} methodName The name of the `Math` method to use when rounding.
  26224. * @returns {Function} Returns the new round function.
  26225. */
  26226. function createRound(methodName) {
  26227. var func = Math[methodName];
  26228. return function(number, precision) {
  26229. number = toNumber(number);
  26230. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  26231. if (precision && nativeIsFinite(number)) {
  26232. // Shift with exponential notation to avoid floating-point issues.
  26233. // See [MDN](https://mdn.io/round#Examples) for more details.
  26234. var pair = (toString(number) + 'e').split('e'),
  26235. value = func(pair[0] + 'e' + (+pair[1] + precision));
  26236. pair = (toString(value) + 'e').split('e');
  26237. return +(pair[0] + 'e' + (+pair[1] - precision));
  26238. }
  26239. return func(number);
  26240. };
  26241. }
  26242. /**
  26243. * Creates a set object of `values`.
  26244. *
  26245. * @private
  26246. * @param {Array} values The values to add to the set.
  26247. * @returns {Object} Returns the new set.
  26248. */
  26249. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  26250. return new Set(values);
  26251. };
  26252. /**
  26253. * Creates a `_.toPairs` or `_.toPairsIn` function.
  26254. *
  26255. * @private
  26256. * @param {Function} keysFunc The function to get the keys of a given object.
  26257. * @returns {Function} Returns the new pairs function.
  26258. */
  26259. function createToPairs(keysFunc) {
  26260. return function(object) {
  26261. var tag = getTag(object);
  26262. if (tag == mapTag) {
  26263. return mapToArray(object);
  26264. }
  26265. if (tag == setTag) {
  26266. return setToPairs(object);
  26267. }
  26268. return baseToPairs(object, keysFunc(object));
  26269. };
  26270. }
  26271. /**
  26272. * Creates a function that either curries or invokes `func` with optional
  26273. * `this` binding and partially applied arguments.
  26274. *
  26275. * @private
  26276. * @param {Function|string} func The function or method name to wrap.
  26277. * @param {number} bitmask The bitmask flags.
  26278. * 1 - `_.bind`
  26279. * 2 - `_.bindKey`
  26280. * 4 - `_.curry` or `_.curryRight` of a bound function
  26281. * 8 - `_.curry`
  26282. * 16 - `_.curryRight`
  26283. * 32 - `_.partial`
  26284. * 64 - `_.partialRight`
  26285. * 128 - `_.rearg`
  26286. * 256 - `_.ary`
  26287. * 512 - `_.flip`
  26288. * @param {*} [thisArg] The `this` binding of `func`.
  26289. * @param {Array} [partials] The arguments to be partially applied.
  26290. * @param {Array} [holders] The `partials` placeholder indexes.
  26291. * @param {Array} [argPos] The argument positions of the new function.
  26292. * @param {number} [ary] The arity cap of `func`.
  26293. * @param {number} [arity] The arity of `func`.
  26294. * @returns {Function} Returns the new wrapped function.
  26295. */
  26296. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  26297. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  26298. if (!isBindKey && typeof func != 'function') {
  26299. throw new TypeError(FUNC_ERROR_TEXT);
  26300. }
  26301. var length = partials ? partials.length : 0;
  26302. if (!length) {
  26303. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  26304. partials = holders = undefined;
  26305. }
  26306. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  26307. arity = arity === undefined ? arity : toInteger(arity);
  26308. length -= holders ? holders.length : 0;
  26309. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  26310. var partialsRight = partials,
  26311. holdersRight = holders;
  26312. partials = holders = undefined;
  26313. }
  26314. var data = isBindKey ? undefined : getData(func);
  26315. var newData = [
  26316. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  26317. argPos, ary, arity
  26318. ];
  26319. if (data) {
  26320. mergeData(newData, data);
  26321. }
  26322. func = newData[0];
  26323. bitmask = newData[1];
  26324. thisArg = newData[2];
  26325. partials = newData[3];
  26326. holders = newData[4];
  26327. arity = newData[9] = newData[9] === undefined
  26328. ? (isBindKey ? 0 : func.length)
  26329. : nativeMax(newData[9] - length, 0);
  26330. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  26331. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  26332. }
  26333. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  26334. var result = createBind(func, bitmask, thisArg);
  26335. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  26336. result = createCurry(func, bitmask, arity);
  26337. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  26338. result = createPartial(func, bitmask, thisArg, partials);
  26339. } else {
  26340. result = createHybrid.apply(undefined, newData);
  26341. }
  26342. var setter = data ? baseSetData : setData;
  26343. return setWrapToString(setter(result, newData), func, bitmask);
  26344. }
  26345. /**
  26346. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  26347. * of source objects to the destination object for all destination properties
  26348. * that resolve to `undefined`.
  26349. *
  26350. * @private
  26351. * @param {*} objValue The destination value.
  26352. * @param {*} srcValue The source value.
  26353. * @param {string} key The key of the property to assign.
  26354. * @param {Object} object The parent object of `objValue`.
  26355. * @returns {*} Returns the value to assign.
  26356. */
  26357. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  26358. if (objValue === undefined ||
  26359. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  26360. return srcValue;
  26361. }
  26362. return objValue;
  26363. }
  26364. /**
  26365. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  26366. * objects into destination objects that are passed thru.
  26367. *
  26368. * @private
  26369. * @param {*} objValue The destination value.
  26370. * @param {*} srcValue The source value.
  26371. * @param {string} key The key of the property to merge.
  26372. * @param {Object} object The parent object of `objValue`.
  26373. * @param {Object} source The parent object of `srcValue`.
  26374. * @param {Object} [stack] Tracks traversed source values and their merged
  26375. * counterparts.
  26376. * @returns {*} Returns the value to assign.
  26377. */
  26378. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  26379. if (isObject(objValue) && isObject(srcValue)) {
  26380. // Recursively merge objects and arrays (susceptible to call stack limits).
  26381. stack.set(srcValue, objValue);
  26382. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  26383. stack['delete'](srcValue);
  26384. }
  26385. return objValue;
  26386. }
  26387. /**
  26388. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  26389. * objects.
  26390. *
  26391. * @private
  26392. * @param {*} value The value to inspect.
  26393. * @param {string} key The key of the property to inspect.
  26394. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  26395. */
  26396. function customOmitClone(value) {
  26397. return isPlainObject(value) ? undefined : value;
  26398. }
  26399. /**
  26400. * A specialized version of `baseIsEqualDeep` for arrays with support for
  26401. * partial deep comparisons.
  26402. *
  26403. * @private
  26404. * @param {Array} array The array to compare.
  26405. * @param {Array} other The other array to compare.
  26406. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  26407. * @param {Function} customizer The function to customize comparisons.
  26408. * @param {Function} equalFunc The function to determine equivalents of values.
  26409. * @param {Object} stack Tracks traversed `array` and `other` objects.
  26410. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  26411. */
  26412. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  26413. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  26414. arrLength = array.length,
  26415. othLength = other.length;
  26416. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  26417. return false;
  26418. }
  26419. // Assume cyclic values are equal.
  26420. var stacked = stack.get(array);
  26421. if (stacked && stack.get(other)) {
  26422. return stacked == other;
  26423. }
  26424. var index = -1,
  26425. result = true,
  26426. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  26427. stack.set(array, other);
  26428. stack.set(other, array);
  26429. // Ignore non-index properties.
  26430. while (++index < arrLength) {
  26431. var arrValue = array[index],
  26432. othValue = other[index];
  26433. if (customizer) {
  26434. var compared = isPartial
  26435. ? customizer(othValue, arrValue, index, other, array, stack)
  26436. : customizer(arrValue, othValue, index, array, other, stack);
  26437. }
  26438. if (compared !== undefined) {
  26439. if (compared) {
  26440. continue;
  26441. }
  26442. result = false;
  26443. break;
  26444. }
  26445. // Recursively compare arrays (susceptible to call stack limits).
  26446. if (seen) {
  26447. if (!arraySome(other, function(othValue, othIndex) {
  26448. if (!cacheHas(seen, othIndex) &&
  26449. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  26450. return seen.push(othIndex);
  26451. }
  26452. })) {
  26453. result = false;
  26454. break;
  26455. }
  26456. } else if (!(
  26457. arrValue === othValue ||
  26458. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  26459. )) {
  26460. result = false;
  26461. break;
  26462. }
  26463. }
  26464. stack['delete'](array);
  26465. stack['delete'](other);
  26466. return result;
  26467. }
  26468. /**
  26469. * A specialized version of `baseIsEqualDeep` for comparing objects of
  26470. * the same `toStringTag`.
  26471. *
  26472. * **Note:** This function only supports comparing values with tags of
  26473. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  26474. *
  26475. * @private
  26476. * @param {Object} object The object to compare.
  26477. * @param {Object} other The other object to compare.
  26478. * @param {string} tag The `toStringTag` of the objects to compare.
  26479. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  26480. * @param {Function} customizer The function to customize comparisons.
  26481. * @param {Function} equalFunc The function to determine equivalents of values.
  26482. * @param {Object} stack Tracks traversed `object` and `other` objects.
  26483. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  26484. */
  26485. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  26486. switch (tag) {
  26487. case dataViewTag:
  26488. if ((object.byteLength != other.byteLength) ||
  26489. (object.byteOffset != other.byteOffset)) {
  26490. return false;
  26491. }
  26492. object = object.buffer;
  26493. other = other.buffer;
  26494. case arrayBufferTag:
  26495. if ((object.byteLength != other.byteLength) ||
  26496. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  26497. return false;
  26498. }
  26499. return true;
  26500. case boolTag:
  26501. case dateTag:
  26502. case numberTag:
  26503. // Coerce booleans to `1` or `0` and dates to milliseconds.
  26504. // Invalid dates are coerced to `NaN`.
  26505. return eq(+object, +other);
  26506. case errorTag:
  26507. return object.name == other.name && object.message == other.message;
  26508. case regexpTag:
  26509. case stringTag:
  26510. // Coerce regexes to strings and treat strings, primitives and objects,
  26511. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  26512. // for more details.
  26513. return object == (other + '');
  26514. case mapTag:
  26515. var convert = mapToArray;
  26516. case setTag:
  26517. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  26518. convert || (convert = setToArray);
  26519. if (object.size != other.size && !isPartial) {
  26520. return false;
  26521. }
  26522. // Assume cyclic values are equal.
  26523. var stacked = stack.get(object);
  26524. if (stacked) {
  26525. return stacked == other;
  26526. }
  26527. bitmask |= COMPARE_UNORDERED_FLAG;
  26528. // Recursively compare objects (susceptible to call stack limits).
  26529. stack.set(object, other);
  26530. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  26531. stack['delete'](object);
  26532. return result;
  26533. case symbolTag:
  26534. if (symbolValueOf) {
  26535. return symbolValueOf.call(object) == symbolValueOf.call(other);
  26536. }
  26537. }
  26538. return false;
  26539. }
  26540. /**
  26541. * A specialized version of `baseIsEqualDeep` for objects with support for
  26542. * partial deep comparisons.
  26543. *
  26544. * @private
  26545. * @param {Object} object The object to compare.
  26546. * @param {Object} other The other object to compare.
  26547. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  26548. * @param {Function} customizer The function to customize comparisons.
  26549. * @param {Function} equalFunc The function to determine equivalents of values.
  26550. * @param {Object} stack Tracks traversed `object` and `other` objects.
  26551. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  26552. */
  26553. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  26554. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  26555. objProps = getAllKeys(object),
  26556. objLength = objProps.length,
  26557. othProps = getAllKeys(other),
  26558. othLength = othProps.length;
  26559. if (objLength != othLength && !isPartial) {
  26560. return false;
  26561. }
  26562. var index = objLength;
  26563. while (index--) {
  26564. var key = objProps[index];
  26565. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  26566. return false;
  26567. }
  26568. }
  26569. // Assume cyclic values are equal.
  26570. var stacked = stack.get(object);
  26571. if (stacked && stack.get(other)) {
  26572. return stacked == other;
  26573. }
  26574. var result = true;
  26575. stack.set(object, other);
  26576. stack.set(other, object);
  26577. var skipCtor = isPartial;
  26578. while (++index < objLength) {
  26579. key = objProps[index];
  26580. var objValue = object[key],
  26581. othValue = other[key];
  26582. if (customizer) {
  26583. var compared = isPartial
  26584. ? customizer(othValue, objValue, key, other, object, stack)
  26585. : customizer(objValue, othValue, key, object, other, stack);
  26586. }
  26587. // Recursively compare objects (susceptible to call stack limits).
  26588. if (!(compared === undefined
  26589. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  26590. : compared
  26591. )) {
  26592. result = false;
  26593. break;
  26594. }
  26595. skipCtor || (skipCtor = key == 'constructor');
  26596. }
  26597. if (result && !skipCtor) {
  26598. var objCtor = object.constructor,
  26599. othCtor = other.constructor;
  26600. // Non `Object` object instances with different constructors are not equal.
  26601. if (objCtor != othCtor &&
  26602. ('constructor' in object && 'constructor' in other) &&
  26603. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  26604. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  26605. result = false;
  26606. }
  26607. }
  26608. stack['delete'](object);
  26609. stack['delete'](other);
  26610. return result;
  26611. }
  26612. /**
  26613. * A specialized version of `baseRest` which flattens the rest array.
  26614. *
  26615. * @private
  26616. * @param {Function} func The function to apply a rest parameter to.
  26617. * @returns {Function} Returns the new function.
  26618. */
  26619. function flatRest(func) {
  26620. return setToString(overRest(func, undefined, flatten), func + '');
  26621. }
  26622. /**
  26623. * Creates an array of own enumerable property names and symbols of `object`.
  26624. *
  26625. * @private
  26626. * @param {Object} object The object to query.
  26627. * @returns {Array} Returns the array of property names and symbols.
  26628. */
  26629. function getAllKeys(object) {
  26630. return baseGetAllKeys(object, keys, getSymbols);
  26631. }
  26632. /**
  26633. * Creates an array of own and inherited enumerable property names and
  26634. * symbols of `object`.
  26635. *
  26636. * @private
  26637. * @param {Object} object The object to query.
  26638. * @returns {Array} Returns the array of property names and symbols.
  26639. */
  26640. function getAllKeysIn(object) {
  26641. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  26642. }
  26643. /**
  26644. * Gets metadata for `func`.
  26645. *
  26646. * @private
  26647. * @param {Function} func The function to query.
  26648. * @returns {*} Returns the metadata for `func`.
  26649. */
  26650. var getData = !metaMap ? noop : function(func) {
  26651. return metaMap.get(func);
  26652. };
  26653. /**
  26654. * Gets the name of `func`.
  26655. *
  26656. * @private
  26657. * @param {Function} func The function to query.
  26658. * @returns {string} Returns the function name.
  26659. */
  26660. function getFuncName(func) {
  26661. var result = (func.name + ''),
  26662. array = realNames[result],
  26663. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  26664. while (length--) {
  26665. var data = array[length],
  26666. otherFunc = data.func;
  26667. if (otherFunc == null || otherFunc == func) {
  26668. return data.name;
  26669. }
  26670. }
  26671. return result;
  26672. }
  26673. /**
  26674. * Gets the argument placeholder value for `func`.
  26675. *
  26676. * @private
  26677. * @param {Function} func The function to inspect.
  26678. * @returns {*} Returns the placeholder value.
  26679. */
  26680. function getHolder(func) {
  26681. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  26682. return object.placeholder;
  26683. }
  26684. /**
  26685. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  26686. * this function returns the custom method, otherwise it returns `baseIteratee`.
  26687. * If arguments are provided, the chosen function is invoked with them and
  26688. * its result is returned.
  26689. *
  26690. * @private
  26691. * @param {*} [value] The value to convert to an iteratee.
  26692. * @param {number} [arity] The arity of the created iteratee.
  26693. * @returns {Function} Returns the chosen function or its result.
  26694. */
  26695. function getIteratee() {
  26696. var result = lodash.iteratee || iteratee;
  26697. result = result === iteratee ? baseIteratee : result;
  26698. return arguments.length ? result(arguments[0], arguments[1]) : result;
  26699. }
  26700. /**
  26701. * Gets the data for `map`.
  26702. *
  26703. * @private
  26704. * @param {Object} map The map to query.
  26705. * @param {string} key The reference key.
  26706. * @returns {*} Returns the map data.
  26707. */
  26708. function getMapData(map, key) {
  26709. var data = map.__data__;
  26710. return isKeyable(key)
  26711. ? data[typeof key == 'string' ? 'string' : 'hash']
  26712. : data.map;
  26713. }
  26714. /**
  26715. * Gets the property names, values, and compare flags of `object`.
  26716. *
  26717. * @private
  26718. * @param {Object} object The object to query.
  26719. * @returns {Array} Returns the match data of `object`.
  26720. */
  26721. function getMatchData(object) {
  26722. var result = keys(object),
  26723. length = result.length;
  26724. while (length--) {
  26725. var key = result[length],
  26726. value = object[key];
  26727. result[length] = [key, value, isStrictComparable(value)];
  26728. }
  26729. return result;
  26730. }
  26731. /**
  26732. * Gets the native function at `key` of `object`.
  26733. *
  26734. * @private
  26735. * @param {Object} object The object to query.
  26736. * @param {string} key The key of the method to get.
  26737. * @returns {*} Returns the function if it's native, else `undefined`.
  26738. */
  26739. function getNative(object, key) {
  26740. var value = getValue(object, key);
  26741. return baseIsNative(value) ? value : undefined;
  26742. }
  26743. /**
  26744. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  26745. *
  26746. * @private
  26747. * @param {*} value The value to query.
  26748. * @returns {string} Returns the raw `toStringTag`.
  26749. */
  26750. function getRawTag(value) {
  26751. var isOwn = hasOwnProperty.call(value, symToStringTag),
  26752. tag = value[symToStringTag];
  26753. try {
  26754. value[symToStringTag] = undefined;
  26755. var unmasked = true;
  26756. } catch (e) {}
  26757. var result = nativeObjectToString.call(value);
  26758. if (unmasked) {
  26759. if (isOwn) {
  26760. value[symToStringTag] = tag;
  26761. } else {
  26762. delete value[symToStringTag];
  26763. }
  26764. }
  26765. return result;
  26766. }
  26767. /**
  26768. * Creates an array of the own enumerable symbols of `object`.
  26769. *
  26770. * @private
  26771. * @param {Object} object The object to query.
  26772. * @returns {Array} Returns the array of symbols.
  26773. */
  26774. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  26775. if (object == null) {
  26776. return [];
  26777. }
  26778. object = Object(object);
  26779. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  26780. return propertyIsEnumerable.call(object, symbol);
  26781. });
  26782. };
  26783. /**
  26784. * Creates an array of the own and inherited enumerable symbols of `object`.
  26785. *
  26786. * @private
  26787. * @param {Object} object The object to query.
  26788. * @returns {Array} Returns the array of symbols.
  26789. */
  26790. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  26791. var result = [];
  26792. while (object) {
  26793. arrayPush(result, getSymbols(object));
  26794. object = getPrototype(object);
  26795. }
  26796. return result;
  26797. };
  26798. /**
  26799. * Gets the `toStringTag` of `value`.
  26800. *
  26801. * @private
  26802. * @param {*} value The value to query.
  26803. * @returns {string} Returns the `toStringTag`.
  26804. */
  26805. var getTag = baseGetTag;
  26806. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  26807. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  26808. (Map && getTag(new Map) != mapTag) ||
  26809. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  26810. (Set && getTag(new Set) != setTag) ||
  26811. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  26812. getTag = function(value) {
  26813. var result = baseGetTag(value),
  26814. Ctor = result == objectTag ? value.constructor : undefined,
  26815. ctorString = Ctor ? toSource(Ctor) : '';
  26816. if (ctorString) {
  26817. switch (ctorString) {
  26818. case dataViewCtorString: return dataViewTag;
  26819. case mapCtorString: return mapTag;
  26820. case promiseCtorString: return promiseTag;
  26821. case setCtorString: return setTag;
  26822. case weakMapCtorString: return weakMapTag;
  26823. }
  26824. }
  26825. return result;
  26826. };
  26827. }
  26828. /**
  26829. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  26830. *
  26831. * @private
  26832. * @param {number} start The start of the view.
  26833. * @param {number} end The end of the view.
  26834. * @param {Array} transforms The transformations to apply to the view.
  26835. * @returns {Object} Returns an object containing the `start` and `end`
  26836. * positions of the view.
  26837. */
  26838. function getView(start, end, transforms) {
  26839. var index = -1,
  26840. length = transforms.length;
  26841. while (++index < length) {
  26842. var data = transforms[index],
  26843. size = data.size;
  26844. switch (data.type) {
  26845. case 'drop': start += size; break;
  26846. case 'dropRight': end -= size; break;
  26847. case 'take': end = nativeMin(end, start + size); break;
  26848. case 'takeRight': start = nativeMax(start, end - size); break;
  26849. }
  26850. }
  26851. return { 'start': start, 'end': end };
  26852. }
  26853. /**
  26854. * Extracts wrapper details from the `source` body comment.
  26855. *
  26856. * @private
  26857. * @param {string} source The source to inspect.
  26858. * @returns {Array} Returns the wrapper details.
  26859. */
  26860. function getWrapDetails(source) {
  26861. var match = source.match(reWrapDetails);
  26862. return match ? match[1].split(reSplitDetails) : [];
  26863. }
  26864. /**
  26865. * Checks if `path` exists on `object`.
  26866. *
  26867. * @private
  26868. * @param {Object} object The object to query.
  26869. * @param {Array|string} path The path to check.
  26870. * @param {Function} hasFunc The function to check properties.
  26871. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26872. */
  26873. function hasPath(object, path, hasFunc) {
  26874. path = castPath(path, object);
  26875. var index = -1,
  26876. length = path.length,
  26877. result = false;
  26878. while (++index < length) {
  26879. var key = toKey(path[index]);
  26880. if (!(result = object != null && hasFunc(object, key))) {
  26881. break;
  26882. }
  26883. object = object[key];
  26884. }
  26885. if (result || ++index != length) {
  26886. return result;
  26887. }
  26888. length = object == null ? 0 : object.length;
  26889. return !!length && isLength(length) && isIndex(key, length) &&
  26890. (isArray(object) || isArguments(object));
  26891. }
  26892. /**
  26893. * Initializes an array clone.
  26894. *
  26895. * @private
  26896. * @param {Array} array The array to clone.
  26897. * @returns {Array} Returns the initialized clone.
  26898. */
  26899. function initCloneArray(array) {
  26900. var length = array.length,
  26901. result = new array.constructor(length);
  26902. // Add properties assigned by `RegExp#exec`.
  26903. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  26904. result.index = array.index;
  26905. result.input = array.input;
  26906. }
  26907. return result;
  26908. }
  26909. /**
  26910. * Initializes an object clone.
  26911. *
  26912. * @private
  26913. * @param {Object} object The object to clone.
  26914. * @returns {Object} Returns the initialized clone.
  26915. */
  26916. function initCloneObject(object) {
  26917. return (typeof object.constructor == 'function' && !isPrototype(object))
  26918. ? baseCreate(getPrototype(object))
  26919. : {};
  26920. }
  26921. /**
  26922. * Initializes an object clone based on its `toStringTag`.
  26923. *
  26924. * **Note:** This function only supports cloning values with tags of
  26925. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  26926. *
  26927. * @private
  26928. * @param {Object} object The object to clone.
  26929. * @param {string} tag The `toStringTag` of the object to clone.
  26930. * @param {boolean} [isDeep] Specify a deep clone.
  26931. * @returns {Object} Returns the initialized clone.
  26932. */
  26933. function initCloneByTag(object, tag, isDeep) {
  26934. var Ctor = object.constructor;
  26935. switch (tag) {
  26936. case arrayBufferTag:
  26937. return cloneArrayBuffer(object);
  26938. case boolTag:
  26939. case dateTag:
  26940. return new Ctor(+object);
  26941. case dataViewTag:
  26942. return cloneDataView(object, isDeep);
  26943. case float32Tag: case float64Tag:
  26944. case int8Tag: case int16Tag: case int32Tag:
  26945. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  26946. return cloneTypedArray(object, isDeep);
  26947. case mapTag:
  26948. return new Ctor;
  26949. case numberTag:
  26950. case stringTag:
  26951. return new Ctor(object);
  26952. case regexpTag:
  26953. return cloneRegExp(object);
  26954. case setTag:
  26955. return new Ctor;
  26956. case symbolTag:
  26957. return cloneSymbol(object);
  26958. }
  26959. }
  26960. /**
  26961. * Inserts wrapper `details` in a comment at the top of the `source` body.
  26962. *
  26963. * @private
  26964. * @param {string} source The source to modify.
  26965. * @returns {Array} details The details to insert.
  26966. * @returns {string} Returns the modified source.
  26967. */
  26968. function insertWrapDetails(source, details) {
  26969. var length = details.length;
  26970. if (!length) {
  26971. return source;
  26972. }
  26973. var lastIndex = length - 1;
  26974. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  26975. details = details.join(length > 2 ? ', ' : ' ');
  26976. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  26977. }
  26978. /**
  26979. * Checks if `value` is a flattenable `arguments` object or array.
  26980. *
  26981. * @private
  26982. * @param {*} value The value to check.
  26983. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  26984. */
  26985. function isFlattenable(value) {
  26986. return isArray(value) || isArguments(value) ||
  26987. !!(spreadableSymbol && value && value[spreadableSymbol]);
  26988. }
  26989. /**
  26990. * Checks if `value` is a valid array-like index.
  26991. *
  26992. * @private
  26993. * @param {*} value The value to check.
  26994. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  26995. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  26996. */
  26997. function isIndex(value, length) {
  26998. var type = typeof value;
  26999. length = length == null ? MAX_SAFE_INTEGER : length;
  27000. return !!length &&
  27001. (type == 'number' ||
  27002. (type != 'symbol' && reIsUint.test(value))) &&
  27003. (value > -1 && value % 1 == 0 && value < length);
  27004. }
  27005. /**
  27006. * Checks if the given arguments are from an iteratee call.
  27007. *
  27008. * @private
  27009. * @param {*} value The potential iteratee value argument.
  27010. * @param {*} index The potential iteratee index or key argument.
  27011. * @param {*} object The potential iteratee object argument.
  27012. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  27013. * else `false`.
  27014. */
  27015. function isIterateeCall(value, index, object) {
  27016. if (!isObject(object)) {
  27017. return false;
  27018. }
  27019. var type = typeof index;
  27020. if (type == 'number'
  27021. ? (isArrayLike(object) && isIndex(index, object.length))
  27022. : (type == 'string' && index in object)
  27023. ) {
  27024. return eq(object[index], value);
  27025. }
  27026. return false;
  27027. }
  27028. /**
  27029. * Checks if `value` is a property name and not a property path.
  27030. *
  27031. * @private
  27032. * @param {*} value The value to check.
  27033. * @param {Object} [object] The object to query keys on.
  27034. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  27035. */
  27036. function isKey(value, object) {
  27037. if (isArray(value)) {
  27038. return false;
  27039. }
  27040. var type = typeof value;
  27041. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  27042. value == null || isSymbol(value)) {
  27043. return true;
  27044. }
  27045. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  27046. (object != null && value in Object(object));
  27047. }
  27048. /**
  27049. * Checks if `value` is suitable for use as unique object key.
  27050. *
  27051. * @private
  27052. * @param {*} value The value to check.
  27053. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  27054. */
  27055. function isKeyable(value) {
  27056. var type = typeof value;
  27057. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  27058. ? (value !== '__proto__')
  27059. : (value === null);
  27060. }
  27061. /**
  27062. * Checks if `func` has a lazy counterpart.
  27063. *
  27064. * @private
  27065. * @param {Function} func The function to check.
  27066. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  27067. * else `false`.
  27068. */
  27069. function isLaziable(func) {
  27070. var funcName = getFuncName(func),
  27071. other = lodash[funcName];
  27072. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  27073. return false;
  27074. }
  27075. if (func === other) {
  27076. return true;
  27077. }
  27078. var data = getData(other);
  27079. return !!data && func === data[0];
  27080. }
  27081. /**
  27082. * Checks if `func` has its source masked.
  27083. *
  27084. * @private
  27085. * @param {Function} func The function to check.
  27086. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  27087. */
  27088. function isMasked(func) {
  27089. return !!maskSrcKey && (maskSrcKey in func);
  27090. }
  27091. /**
  27092. * Checks if `func` is capable of being masked.
  27093. *
  27094. * @private
  27095. * @param {*} value The value to check.
  27096. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  27097. */
  27098. var isMaskable = coreJsData ? isFunction : stubFalse;
  27099. /**
  27100. * Checks if `value` is likely a prototype object.
  27101. *
  27102. * @private
  27103. * @param {*} value The value to check.
  27104. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  27105. */
  27106. function isPrototype(value) {
  27107. var Ctor = value && value.constructor,
  27108. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  27109. return value === proto;
  27110. }
  27111. /**
  27112. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  27113. *
  27114. * @private
  27115. * @param {*} value The value to check.
  27116. * @returns {boolean} Returns `true` if `value` if suitable for strict
  27117. * equality comparisons, else `false`.
  27118. */
  27119. function isStrictComparable(value) {
  27120. return value === value && !isObject(value);
  27121. }
  27122. /**
  27123. * A specialized version of `matchesProperty` for source values suitable
  27124. * for strict equality comparisons, i.e. `===`.
  27125. *
  27126. * @private
  27127. * @param {string} key The key of the property to get.
  27128. * @param {*} srcValue The value to match.
  27129. * @returns {Function} Returns the new spec function.
  27130. */
  27131. function matchesStrictComparable(key, srcValue) {
  27132. return function(object) {
  27133. if (object == null) {
  27134. return false;
  27135. }
  27136. return object[key] === srcValue &&
  27137. (srcValue !== undefined || (key in Object(object)));
  27138. };
  27139. }
  27140. /**
  27141. * A specialized version of `_.memoize` which clears the memoized function's
  27142. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  27143. *
  27144. * @private
  27145. * @param {Function} func The function to have its output memoized.
  27146. * @returns {Function} Returns the new memoized function.
  27147. */
  27148. function memoizeCapped(func) {
  27149. var result = memoize(func, function(key) {
  27150. if (cache.size === MAX_MEMOIZE_SIZE) {
  27151. cache.clear();
  27152. }
  27153. return key;
  27154. });
  27155. var cache = result.cache;
  27156. return result;
  27157. }
  27158. /**
  27159. * Merges the function metadata of `source` into `data`.
  27160. *
  27161. * Merging metadata reduces the number of wrappers used to invoke a function.
  27162. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  27163. * may be applied regardless of execution order. Methods like `_.ary` and
  27164. * `_.rearg` modify function arguments, making the order in which they are
  27165. * executed important, preventing the merging of metadata. However, we make
  27166. * an exception for a safe combined case where curried functions have `_.ary`
  27167. * and or `_.rearg` applied.
  27168. *
  27169. * @private
  27170. * @param {Array} data The destination metadata.
  27171. * @param {Array} source The source metadata.
  27172. * @returns {Array} Returns `data`.
  27173. */
  27174. function mergeData(data, source) {
  27175. var bitmask = data[1],
  27176. srcBitmask = source[1],
  27177. newBitmask = bitmask | srcBitmask,
  27178. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  27179. var isCombo =
  27180. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  27181. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  27182. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  27183. // Exit early if metadata can't be merged.
  27184. if (!(isCommon || isCombo)) {
  27185. return data;
  27186. }
  27187. // Use source `thisArg` if available.
  27188. if (srcBitmask & WRAP_BIND_FLAG) {
  27189. data[2] = source[2];
  27190. // Set when currying a bound function.
  27191. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  27192. }
  27193. // Compose partial arguments.
  27194. var value = source[3];
  27195. if (value) {
  27196. var partials = data[3];
  27197. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  27198. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  27199. }
  27200. // Compose partial right arguments.
  27201. value = source[5];
  27202. if (value) {
  27203. partials = data[5];
  27204. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  27205. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  27206. }
  27207. // Use source `argPos` if available.
  27208. value = source[7];
  27209. if (value) {
  27210. data[7] = value;
  27211. }
  27212. // Use source `ary` if it's smaller.
  27213. if (srcBitmask & WRAP_ARY_FLAG) {
  27214. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  27215. }
  27216. // Use source `arity` if one is not provided.
  27217. if (data[9] == null) {
  27218. data[9] = source[9];
  27219. }
  27220. // Use source `func` and merge bitmasks.
  27221. data[0] = source[0];
  27222. data[1] = newBitmask;
  27223. return data;
  27224. }
  27225. /**
  27226. * This function is like
  27227. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  27228. * except that it includes inherited enumerable properties.
  27229. *
  27230. * @private
  27231. * @param {Object} object The object to query.
  27232. * @returns {Array} Returns the array of property names.
  27233. */
  27234. function nativeKeysIn(object) {
  27235. var result = [];
  27236. if (object != null) {
  27237. for (var key in Object(object)) {
  27238. result.push(key);
  27239. }
  27240. }
  27241. return result;
  27242. }
  27243. /**
  27244. * Converts `value` to a string using `Object.prototype.toString`.
  27245. *
  27246. * @private
  27247. * @param {*} value The value to convert.
  27248. * @returns {string} Returns the converted string.
  27249. */
  27250. function objectToString(value) {
  27251. return nativeObjectToString.call(value);
  27252. }
  27253. /**
  27254. * A specialized version of `baseRest` which transforms the rest array.
  27255. *
  27256. * @private
  27257. * @param {Function} func The function to apply a rest parameter to.
  27258. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27259. * @param {Function} transform The rest array transform.
  27260. * @returns {Function} Returns the new function.
  27261. */
  27262. function overRest(func, start, transform) {
  27263. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  27264. return function() {
  27265. var args = arguments,
  27266. index = -1,
  27267. length = nativeMax(args.length - start, 0),
  27268. array = Array(length);
  27269. while (++index < length) {
  27270. array[index] = args[start + index];
  27271. }
  27272. index = -1;
  27273. var otherArgs = Array(start + 1);
  27274. while (++index < start) {
  27275. otherArgs[index] = args[index];
  27276. }
  27277. otherArgs[start] = transform(array);
  27278. return apply(func, this, otherArgs);
  27279. };
  27280. }
  27281. /**
  27282. * Gets the parent value at `path` of `object`.
  27283. *
  27284. * @private
  27285. * @param {Object} object The object to query.
  27286. * @param {Array} path The path to get the parent value of.
  27287. * @returns {*} Returns the parent value.
  27288. */
  27289. function parent(object, path) {
  27290. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  27291. }
  27292. /**
  27293. * Reorder `array` according to the specified indexes where the element at
  27294. * the first index is assigned as the first element, the element at
  27295. * the second index is assigned as the second element, and so on.
  27296. *
  27297. * @private
  27298. * @param {Array} array The array to reorder.
  27299. * @param {Array} indexes The arranged array indexes.
  27300. * @returns {Array} Returns `array`.
  27301. */
  27302. function reorder(array, indexes) {
  27303. var arrLength = array.length,
  27304. length = nativeMin(indexes.length, arrLength),
  27305. oldArray = copyArray(array);
  27306. while (length--) {
  27307. var index = indexes[length];
  27308. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  27309. }
  27310. return array;
  27311. }
  27312. /**
  27313. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  27314. *
  27315. * @private
  27316. * @param {Object} object The object to query.
  27317. * @param {string} key The key of the property to get.
  27318. * @returns {*} Returns the property value.
  27319. */
  27320. function safeGet(object, key) {
  27321. if (key === 'constructor' && typeof object[key] === 'function') {
  27322. return;
  27323. }
  27324. if (key == '__proto__') {
  27325. return;
  27326. }
  27327. return object[key];
  27328. }
  27329. /**
  27330. * Sets metadata for `func`.
  27331. *
  27332. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  27333. * period of time, it will trip its breaker and transition to an identity
  27334. * function to avoid garbage collection pauses in V8. See
  27335. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  27336. * for more details.
  27337. *
  27338. * @private
  27339. * @param {Function} func The function to associate metadata with.
  27340. * @param {*} data The metadata.
  27341. * @returns {Function} Returns `func`.
  27342. */
  27343. var setData = shortOut(baseSetData);
  27344. /**
  27345. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  27346. *
  27347. * @private
  27348. * @param {Function} func The function to delay.
  27349. * @param {number} wait The number of milliseconds to delay invocation.
  27350. * @returns {number|Object} Returns the timer id or timeout object.
  27351. */
  27352. var setTimeout = ctxSetTimeout || function(func, wait) {
  27353. return root.setTimeout(func, wait);
  27354. };
  27355. /**
  27356. * Sets the `toString` method of `func` to return `string`.
  27357. *
  27358. * @private
  27359. * @param {Function} func The function to modify.
  27360. * @param {Function} string The `toString` result.
  27361. * @returns {Function} Returns `func`.
  27362. */
  27363. var setToString = shortOut(baseSetToString);
  27364. /**
  27365. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  27366. * with wrapper details in a comment at the top of the source body.
  27367. *
  27368. * @private
  27369. * @param {Function} wrapper The function to modify.
  27370. * @param {Function} reference The reference function.
  27371. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  27372. * @returns {Function} Returns `wrapper`.
  27373. */
  27374. function setWrapToString(wrapper, reference, bitmask) {
  27375. var source = (reference + '');
  27376. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  27377. }
  27378. /**
  27379. * Creates a function that'll short out and invoke `identity` instead
  27380. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  27381. * milliseconds.
  27382. *
  27383. * @private
  27384. * @param {Function} func The function to restrict.
  27385. * @returns {Function} Returns the new shortable function.
  27386. */
  27387. function shortOut(func) {
  27388. var count = 0,
  27389. lastCalled = 0;
  27390. return function() {
  27391. var stamp = nativeNow(),
  27392. remaining = HOT_SPAN - (stamp - lastCalled);
  27393. lastCalled = stamp;
  27394. if (remaining > 0) {
  27395. if (++count >= HOT_COUNT) {
  27396. return arguments[0];
  27397. }
  27398. } else {
  27399. count = 0;
  27400. }
  27401. return func.apply(undefined, arguments);
  27402. };
  27403. }
  27404. /**
  27405. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  27406. *
  27407. * @private
  27408. * @param {Array} array The array to shuffle.
  27409. * @param {number} [size=array.length] The size of `array`.
  27410. * @returns {Array} Returns `array`.
  27411. */
  27412. function shuffleSelf(array, size) {
  27413. var index = -1,
  27414. length = array.length,
  27415. lastIndex = length - 1;
  27416. size = size === undefined ? length : size;
  27417. while (++index < size) {
  27418. var rand = baseRandom(index, lastIndex),
  27419. value = array[rand];
  27420. array[rand] = array[index];
  27421. array[index] = value;
  27422. }
  27423. array.length = size;
  27424. return array;
  27425. }
  27426. /**
  27427. * Converts `string` to a property path array.
  27428. *
  27429. * @private
  27430. * @param {string} string The string to convert.
  27431. * @returns {Array} Returns the property path array.
  27432. */
  27433. var stringToPath = memoizeCapped(function(string) {
  27434. var result = [];
  27435. if (string.charCodeAt(0) === 46 /* . */) {
  27436. result.push('');
  27437. }
  27438. string.replace(rePropName, function(match, number, quote, subString) {
  27439. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  27440. });
  27441. return result;
  27442. });
  27443. /**
  27444. * Converts `value` to a string key if it's not a string or symbol.
  27445. *
  27446. * @private
  27447. * @param {*} value The value to inspect.
  27448. * @returns {string|symbol} Returns the key.
  27449. */
  27450. function toKey(value) {
  27451. if (typeof value == 'string' || isSymbol(value)) {
  27452. return value;
  27453. }
  27454. var result = (value + '');
  27455. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  27456. }
  27457. /**
  27458. * Converts `func` to its source code.
  27459. *
  27460. * @private
  27461. * @param {Function} func The function to convert.
  27462. * @returns {string} Returns the source code.
  27463. */
  27464. function toSource(func) {
  27465. if (func != null) {
  27466. try {
  27467. return funcToString.call(func);
  27468. } catch (e) {}
  27469. try {
  27470. return (func + '');
  27471. } catch (e) {}
  27472. }
  27473. return '';
  27474. }
  27475. /**
  27476. * Updates wrapper `details` based on `bitmask` flags.
  27477. *
  27478. * @private
  27479. * @returns {Array} details The details to modify.
  27480. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  27481. * @returns {Array} Returns `details`.
  27482. */
  27483. function updateWrapDetails(details, bitmask) {
  27484. arrayEach(wrapFlags, function(pair) {
  27485. var value = '_.' + pair[0];
  27486. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  27487. details.push(value);
  27488. }
  27489. });
  27490. return details.sort();
  27491. }
  27492. /**
  27493. * Creates a clone of `wrapper`.
  27494. *
  27495. * @private
  27496. * @param {Object} wrapper The wrapper to clone.
  27497. * @returns {Object} Returns the cloned wrapper.
  27498. */
  27499. function wrapperClone(wrapper) {
  27500. if (wrapper instanceof LazyWrapper) {
  27501. return wrapper.clone();
  27502. }
  27503. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  27504. result.__actions__ = copyArray(wrapper.__actions__);
  27505. result.__index__ = wrapper.__index__;
  27506. result.__values__ = wrapper.__values__;
  27507. return result;
  27508. }
  27509. /*------------------------------------------------------------------------*/
  27510. /**
  27511. * Creates an array of elements split into groups the length of `size`.
  27512. * If `array` can't be split evenly, the final chunk will be the remaining
  27513. * elements.
  27514. *
  27515. * @static
  27516. * @memberOf _
  27517. * @since 3.0.0
  27518. * @category Array
  27519. * @param {Array} array The array to process.
  27520. * @param {number} [size=1] The length of each chunk
  27521. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27522. * @returns {Array} Returns the new array of chunks.
  27523. * @example
  27524. *
  27525. * _.chunk(['a', 'b', 'c', 'd'], 2);
  27526. * // => [['a', 'b'], ['c', 'd']]
  27527. *
  27528. * _.chunk(['a', 'b', 'c', 'd'], 3);
  27529. * // => [['a', 'b', 'c'], ['d']]
  27530. */
  27531. function chunk(array, size, guard) {
  27532. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  27533. size = 1;
  27534. } else {
  27535. size = nativeMax(toInteger(size), 0);
  27536. }
  27537. var length = array == null ? 0 : array.length;
  27538. if (!length || size < 1) {
  27539. return [];
  27540. }
  27541. var index = 0,
  27542. resIndex = 0,
  27543. result = Array(nativeCeil(length / size));
  27544. while (index < length) {
  27545. result[resIndex++] = baseSlice(array, index, (index += size));
  27546. }
  27547. return result;
  27548. }
  27549. /**
  27550. * Creates an array with all falsey values removed. The values `false`, `null`,
  27551. * `0`, `""`, `undefined`, and `NaN` are falsey.
  27552. *
  27553. * @static
  27554. * @memberOf _
  27555. * @since 0.1.0
  27556. * @category Array
  27557. * @param {Array} array The array to compact.
  27558. * @returns {Array} Returns the new array of filtered values.
  27559. * @example
  27560. *
  27561. * _.compact([0, 1, false, 2, '', 3]);
  27562. * // => [1, 2, 3]
  27563. */
  27564. function compact(array) {
  27565. var index = -1,
  27566. length = array == null ? 0 : array.length,
  27567. resIndex = 0,
  27568. result = [];
  27569. while (++index < length) {
  27570. var value = array[index];
  27571. if (value) {
  27572. result[resIndex++] = value;
  27573. }
  27574. }
  27575. return result;
  27576. }
  27577. /**
  27578. * Creates a new array concatenating `array` with any additional arrays
  27579. * and/or values.
  27580. *
  27581. * @static
  27582. * @memberOf _
  27583. * @since 4.0.0
  27584. * @category Array
  27585. * @param {Array} array The array to concatenate.
  27586. * @param {...*} [values] The values to concatenate.
  27587. * @returns {Array} Returns the new concatenated array.
  27588. * @example
  27589. *
  27590. * var array = [1];
  27591. * var other = _.concat(array, 2, [3], [[4]]);
  27592. *
  27593. * console.log(other);
  27594. * // => [1, 2, 3, [4]]
  27595. *
  27596. * console.log(array);
  27597. * // => [1]
  27598. */
  27599. function concat() {
  27600. var length = arguments.length;
  27601. if (!length) {
  27602. return [];
  27603. }
  27604. var args = Array(length - 1),
  27605. array = arguments[0],
  27606. index = length;
  27607. while (index--) {
  27608. args[index - 1] = arguments[index];
  27609. }
  27610. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  27611. }
  27612. /**
  27613. * Creates an array of `array` values not included in the other given arrays
  27614. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27615. * for equality comparisons. The order and references of result values are
  27616. * determined by the first array.
  27617. *
  27618. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  27619. *
  27620. * @static
  27621. * @memberOf _
  27622. * @since 0.1.0
  27623. * @category Array
  27624. * @param {Array} array The array to inspect.
  27625. * @param {...Array} [values] The values to exclude.
  27626. * @returns {Array} Returns the new array of filtered values.
  27627. * @see _.without, _.xor
  27628. * @example
  27629. *
  27630. * _.difference([2, 1], [2, 3]);
  27631. * // => [1]
  27632. */
  27633. var difference = baseRest(function(array, values) {
  27634. return isArrayLikeObject(array)
  27635. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  27636. : [];
  27637. });
  27638. /**
  27639. * This method is like `_.difference` except that it accepts `iteratee` which
  27640. * is invoked for each element of `array` and `values` to generate the criterion
  27641. * by which they're compared. The order and references of result values are
  27642. * determined by the first array. The iteratee is invoked with one argument:
  27643. * (value).
  27644. *
  27645. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  27646. *
  27647. * @static
  27648. * @memberOf _
  27649. * @since 4.0.0
  27650. * @category Array
  27651. * @param {Array} array The array to inspect.
  27652. * @param {...Array} [values] The values to exclude.
  27653. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  27654. * @returns {Array} Returns the new array of filtered values.
  27655. * @example
  27656. *
  27657. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  27658. * // => [1.2]
  27659. *
  27660. * // The `_.property` iteratee shorthand.
  27661. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  27662. * // => [{ 'x': 2 }]
  27663. */
  27664. var differenceBy = baseRest(function(array, values) {
  27665. var iteratee = last(values);
  27666. if (isArrayLikeObject(iteratee)) {
  27667. iteratee = undefined;
  27668. }
  27669. return isArrayLikeObject(array)
  27670. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  27671. : [];
  27672. });
  27673. /**
  27674. * This method is like `_.difference` except that it accepts `comparator`
  27675. * which is invoked to compare elements of `array` to `values`. The order and
  27676. * references of result values are determined by the first array. The comparator
  27677. * is invoked with two arguments: (arrVal, othVal).
  27678. *
  27679. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  27680. *
  27681. * @static
  27682. * @memberOf _
  27683. * @since 4.0.0
  27684. * @category Array
  27685. * @param {Array} array The array to inspect.
  27686. * @param {...Array} [values] The values to exclude.
  27687. * @param {Function} [comparator] The comparator invoked per element.
  27688. * @returns {Array} Returns the new array of filtered values.
  27689. * @example
  27690. *
  27691. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  27692. *
  27693. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  27694. * // => [{ 'x': 2, 'y': 1 }]
  27695. */
  27696. var differenceWith = baseRest(function(array, values) {
  27697. var comparator = last(values);
  27698. if (isArrayLikeObject(comparator)) {
  27699. comparator = undefined;
  27700. }
  27701. return isArrayLikeObject(array)
  27702. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  27703. : [];
  27704. });
  27705. /**
  27706. * Creates a slice of `array` with `n` elements dropped from the beginning.
  27707. *
  27708. * @static
  27709. * @memberOf _
  27710. * @since 0.5.0
  27711. * @category Array
  27712. * @param {Array} array The array to query.
  27713. * @param {number} [n=1] The number of elements to drop.
  27714. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27715. * @returns {Array} Returns the slice of `array`.
  27716. * @example
  27717. *
  27718. * _.drop([1, 2, 3]);
  27719. * // => [2, 3]
  27720. *
  27721. * _.drop([1, 2, 3], 2);
  27722. * // => [3]
  27723. *
  27724. * _.drop([1, 2, 3], 5);
  27725. * // => []
  27726. *
  27727. * _.drop([1, 2, 3], 0);
  27728. * // => [1, 2, 3]
  27729. */
  27730. function drop(array, n, guard) {
  27731. var length = array == null ? 0 : array.length;
  27732. if (!length) {
  27733. return [];
  27734. }
  27735. n = (guard || n === undefined) ? 1 : toInteger(n);
  27736. return baseSlice(array, n < 0 ? 0 : n, length);
  27737. }
  27738. /**
  27739. * Creates a slice of `array` with `n` elements dropped from the end.
  27740. *
  27741. * @static
  27742. * @memberOf _
  27743. * @since 3.0.0
  27744. * @category Array
  27745. * @param {Array} array The array to query.
  27746. * @param {number} [n=1] The number of elements to drop.
  27747. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27748. * @returns {Array} Returns the slice of `array`.
  27749. * @example
  27750. *
  27751. * _.dropRight([1, 2, 3]);
  27752. * // => [1, 2]
  27753. *
  27754. * _.dropRight([1, 2, 3], 2);
  27755. * // => [1]
  27756. *
  27757. * _.dropRight([1, 2, 3], 5);
  27758. * // => []
  27759. *
  27760. * _.dropRight([1, 2, 3], 0);
  27761. * // => [1, 2, 3]
  27762. */
  27763. function dropRight(array, n, guard) {
  27764. var length = array == null ? 0 : array.length;
  27765. if (!length) {
  27766. return [];
  27767. }
  27768. n = (guard || n === undefined) ? 1 : toInteger(n);
  27769. n = length - n;
  27770. return baseSlice(array, 0, n < 0 ? 0 : n);
  27771. }
  27772. /**
  27773. * Creates a slice of `array` excluding elements dropped from the end.
  27774. * Elements are dropped until `predicate` returns falsey. The predicate is
  27775. * invoked with three arguments: (value, index, array).
  27776. *
  27777. * @static
  27778. * @memberOf _
  27779. * @since 3.0.0
  27780. * @category Array
  27781. * @param {Array} array The array to query.
  27782. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27783. * @returns {Array} Returns the slice of `array`.
  27784. * @example
  27785. *
  27786. * var users = [
  27787. * { 'user': 'barney', 'active': true },
  27788. * { 'user': 'fred', 'active': false },
  27789. * { 'user': 'pebbles', 'active': false }
  27790. * ];
  27791. *
  27792. * _.dropRightWhile(users, function(o) { return !o.active; });
  27793. * // => objects for ['barney']
  27794. *
  27795. * // The `_.matches` iteratee shorthand.
  27796. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  27797. * // => objects for ['barney', 'fred']
  27798. *
  27799. * // The `_.matchesProperty` iteratee shorthand.
  27800. * _.dropRightWhile(users, ['active', false]);
  27801. * // => objects for ['barney']
  27802. *
  27803. * // The `_.property` iteratee shorthand.
  27804. * _.dropRightWhile(users, 'active');
  27805. * // => objects for ['barney', 'fred', 'pebbles']
  27806. */
  27807. function dropRightWhile(array, predicate) {
  27808. return (array && array.length)
  27809. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  27810. : [];
  27811. }
  27812. /**
  27813. * Creates a slice of `array` excluding elements dropped from the beginning.
  27814. * Elements are dropped until `predicate` returns falsey. The predicate is
  27815. * invoked with three arguments: (value, index, array).
  27816. *
  27817. * @static
  27818. * @memberOf _
  27819. * @since 3.0.0
  27820. * @category Array
  27821. * @param {Array} array The array to query.
  27822. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27823. * @returns {Array} Returns the slice of `array`.
  27824. * @example
  27825. *
  27826. * var users = [
  27827. * { 'user': 'barney', 'active': false },
  27828. * { 'user': 'fred', 'active': false },
  27829. * { 'user': 'pebbles', 'active': true }
  27830. * ];
  27831. *
  27832. * _.dropWhile(users, function(o) { return !o.active; });
  27833. * // => objects for ['pebbles']
  27834. *
  27835. * // The `_.matches` iteratee shorthand.
  27836. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  27837. * // => objects for ['fred', 'pebbles']
  27838. *
  27839. * // The `_.matchesProperty` iteratee shorthand.
  27840. * _.dropWhile(users, ['active', false]);
  27841. * // => objects for ['pebbles']
  27842. *
  27843. * // The `_.property` iteratee shorthand.
  27844. * _.dropWhile(users, 'active');
  27845. * // => objects for ['barney', 'fred', 'pebbles']
  27846. */
  27847. function dropWhile(array, predicate) {
  27848. return (array && array.length)
  27849. ? baseWhile(array, getIteratee(predicate, 3), true)
  27850. : [];
  27851. }
  27852. /**
  27853. * Fills elements of `array` with `value` from `start` up to, but not
  27854. * including, `end`.
  27855. *
  27856. * **Note:** This method mutates `array`.
  27857. *
  27858. * @static
  27859. * @memberOf _
  27860. * @since 3.2.0
  27861. * @category Array
  27862. * @param {Array} array The array to fill.
  27863. * @param {*} value The value to fill `array` with.
  27864. * @param {number} [start=0] The start position.
  27865. * @param {number} [end=array.length] The end position.
  27866. * @returns {Array} Returns `array`.
  27867. * @example
  27868. *
  27869. * var array = [1, 2, 3];
  27870. *
  27871. * _.fill(array, 'a');
  27872. * console.log(array);
  27873. * // => ['a', 'a', 'a']
  27874. *
  27875. * _.fill(Array(3), 2);
  27876. * // => [2, 2, 2]
  27877. *
  27878. * _.fill([4, 6, 8, 10], '*', 1, 3);
  27879. * // => [4, '*', '*', 10]
  27880. */
  27881. function fill(array, value, start, end) {
  27882. var length = array == null ? 0 : array.length;
  27883. if (!length) {
  27884. return [];
  27885. }
  27886. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  27887. start = 0;
  27888. end = length;
  27889. }
  27890. return baseFill(array, value, start, end);
  27891. }
  27892. /**
  27893. * This method is like `_.find` except that it returns the index of the first
  27894. * element `predicate` returns truthy for instead of the element itself.
  27895. *
  27896. * @static
  27897. * @memberOf _
  27898. * @since 1.1.0
  27899. * @category Array
  27900. * @param {Array} array The array to inspect.
  27901. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27902. * @param {number} [fromIndex=0] The index to search from.
  27903. * @returns {number} Returns the index of the found element, else `-1`.
  27904. * @example
  27905. *
  27906. * var users = [
  27907. * { 'user': 'barney', 'active': false },
  27908. * { 'user': 'fred', 'active': false },
  27909. * { 'user': 'pebbles', 'active': true }
  27910. * ];
  27911. *
  27912. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  27913. * // => 0
  27914. *
  27915. * // The `_.matches` iteratee shorthand.
  27916. * _.findIndex(users, { 'user': 'fred', 'active': false });
  27917. * // => 1
  27918. *
  27919. * // The `_.matchesProperty` iteratee shorthand.
  27920. * _.findIndex(users, ['active', false]);
  27921. * // => 0
  27922. *
  27923. * // The `_.property` iteratee shorthand.
  27924. * _.findIndex(users, 'active');
  27925. * // => 2
  27926. */
  27927. function findIndex(array, predicate, fromIndex) {
  27928. var length = array == null ? 0 : array.length;
  27929. if (!length) {
  27930. return -1;
  27931. }
  27932. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  27933. if (index < 0) {
  27934. index = nativeMax(length + index, 0);
  27935. }
  27936. return baseFindIndex(array, getIteratee(predicate, 3), index);
  27937. }
  27938. /**
  27939. * This method is like `_.findIndex` except that it iterates over elements
  27940. * of `collection` from right to left.
  27941. *
  27942. * @static
  27943. * @memberOf _
  27944. * @since 2.0.0
  27945. * @category Array
  27946. * @param {Array} array The array to inspect.
  27947. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  27948. * @param {number} [fromIndex=array.length-1] The index to search from.
  27949. * @returns {number} Returns the index of the found element, else `-1`.
  27950. * @example
  27951. *
  27952. * var users = [
  27953. * { 'user': 'barney', 'active': true },
  27954. * { 'user': 'fred', 'active': false },
  27955. * { 'user': 'pebbles', 'active': false }
  27956. * ];
  27957. *
  27958. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  27959. * // => 2
  27960. *
  27961. * // The `_.matches` iteratee shorthand.
  27962. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  27963. * // => 0
  27964. *
  27965. * // The `_.matchesProperty` iteratee shorthand.
  27966. * _.findLastIndex(users, ['active', false]);
  27967. * // => 2
  27968. *
  27969. * // The `_.property` iteratee shorthand.
  27970. * _.findLastIndex(users, 'active');
  27971. * // => 0
  27972. */
  27973. function findLastIndex(array, predicate, fromIndex) {
  27974. var length = array == null ? 0 : array.length;
  27975. if (!length) {
  27976. return -1;
  27977. }
  27978. var index = length - 1;
  27979. if (fromIndex !== undefined) {
  27980. index = toInteger(fromIndex);
  27981. index = fromIndex < 0
  27982. ? nativeMax(length + index, 0)
  27983. : nativeMin(index, length - 1);
  27984. }
  27985. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  27986. }
  27987. /**
  27988. * Flattens `array` a single level deep.
  27989. *
  27990. * @static
  27991. * @memberOf _
  27992. * @since 0.1.0
  27993. * @category Array
  27994. * @param {Array} array The array to flatten.
  27995. * @returns {Array} Returns the new flattened array.
  27996. * @example
  27997. *
  27998. * _.flatten([1, [2, [3, [4]], 5]]);
  27999. * // => [1, 2, [3, [4]], 5]
  28000. */
  28001. function flatten(array) {
  28002. var length = array == null ? 0 : array.length;
  28003. return length ? baseFlatten(array, 1) : [];
  28004. }
  28005. /**
  28006. * Recursively flattens `array`.
  28007. *
  28008. * @static
  28009. * @memberOf _
  28010. * @since 3.0.0
  28011. * @category Array
  28012. * @param {Array} array The array to flatten.
  28013. * @returns {Array} Returns the new flattened array.
  28014. * @example
  28015. *
  28016. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  28017. * // => [1, 2, 3, 4, 5]
  28018. */
  28019. function flattenDeep(array) {
  28020. var length = array == null ? 0 : array.length;
  28021. return length ? baseFlatten(array, INFINITY) : [];
  28022. }
  28023. /**
  28024. * Recursively flatten `array` up to `depth` times.
  28025. *
  28026. * @static
  28027. * @memberOf _
  28028. * @since 4.4.0
  28029. * @category Array
  28030. * @param {Array} array The array to flatten.
  28031. * @param {number} [depth=1] The maximum recursion depth.
  28032. * @returns {Array} Returns the new flattened array.
  28033. * @example
  28034. *
  28035. * var array = [1, [2, [3, [4]], 5]];
  28036. *
  28037. * _.flattenDepth(array, 1);
  28038. * // => [1, 2, [3, [4]], 5]
  28039. *
  28040. * _.flattenDepth(array, 2);
  28041. * // => [1, 2, 3, [4], 5]
  28042. */
  28043. function flattenDepth(array, depth) {
  28044. var length = array == null ? 0 : array.length;
  28045. if (!length) {
  28046. return [];
  28047. }
  28048. depth = depth === undefined ? 1 : toInteger(depth);
  28049. return baseFlatten(array, depth);
  28050. }
  28051. /**
  28052. * The inverse of `_.toPairs`; this method returns an object composed
  28053. * from key-value `pairs`.
  28054. *
  28055. * @static
  28056. * @memberOf _
  28057. * @since 4.0.0
  28058. * @category Array
  28059. * @param {Array} pairs The key-value pairs.
  28060. * @returns {Object} Returns the new object.
  28061. * @example
  28062. *
  28063. * _.fromPairs([['a', 1], ['b', 2]]);
  28064. * // => { 'a': 1, 'b': 2 }
  28065. */
  28066. function fromPairs(pairs) {
  28067. var index = -1,
  28068. length = pairs == null ? 0 : pairs.length,
  28069. result = {};
  28070. while (++index < length) {
  28071. var pair = pairs[index];
  28072. result[pair[0]] = pair[1];
  28073. }
  28074. return result;
  28075. }
  28076. /**
  28077. * Gets the first element of `array`.
  28078. *
  28079. * @static
  28080. * @memberOf _
  28081. * @since 0.1.0
  28082. * @alias first
  28083. * @category Array
  28084. * @param {Array} array The array to query.
  28085. * @returns {*} Returns the first element of `array`.
  28086. * @example
  28087. *
  28088. * _.head([1, 2, 3]);
  28089. * // => 1
  28090. *
  28091. * _.head([]);
  28092. * // => undefined
  28093. */
  28094. function head(array) {
  28095. return (array && array.length) ? array[0] : undefined;
  28096. }
  28097. /**
  28098. * Gets the index at which the first occurrence of `value` is found in `array`
  28099. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28100. * for equality comparisons. If `fromIndex` is negative, it's used as the
  28101. * offset from the end of `array`.
  28102. *
  28103. * @static
  28104. * @memberOf _
  28105. * @since 0.1.0
  28106. * @category Array
  28107. * @param {Array} array The array to inspect.
  28108. * @param {*} value The value to search for.
  28109. * @param {number} [fromIndex=0] The index to search from.
  28110. * @returns {number} Returns the index of the matched value, else `-1`.
  28111. * @example
  28112. *
  28113. * _.indexOf([1, 2, 1, 2], 2);
  28114. * // => 1
  28115. *
  28116. * // Search from the `fromIndex`.
  28117. * _.indexOf([1, 2, 1, 2], 2, 2);
  28118. * // => 3
  28119. */
  28120. function indexOf(array, value, fromIndex) {
  28121. var length = array == null ? 0 : array.length;
  28122. if (!length) {
  28123. return -1;
  28124. }
  28125. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  28126. if (index < 0) {
  28127. index = nativeMax(length + index, 0);
  28128. }
  28129. return baseIndexOf(array, value, index);
  28130. }
  28131. /**
  28132. * Gets all but the last element of `array`.
  28133. *
  28134. * @static
  28135. * @memberOf _
  28136. * @since 0.1.0
  28137. * @category Array
  28138. * @param {Array} array The array to query.
  28139. * @returns {Array} Returns the slice of `array`.
  28140. * @example
  28141. *
  28142. * _.initial([1, 2, 3]);
  28143. * // => [1, 2]
  28144. */
  28145. function initial(array) {
  28146. var length = array == null ? 0 : array.length;
  28147. return length ? baseSlice(array, 0, -1) : [];
  28148. }
  28149. /**
  28150. * Creates an array of unique values that are included in all given arrays
  28151. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28152. * for equality comparisons. The order and references of result values are
  28153. * determined by the first array.
  28154. *
  28155. * @static
  28156. * @memberOf _
  28157. * @since 0.1.0
  28158. * @category Array
  28159. * @param {...Array} [arrays] The arrays to inspect.
  28160. * @returns {Array} Returns the new array of intersecting values.
  28161. * @example
  28162. *
  28163. * _.intersection([2, 1], [2, 3]);
  28164. * // => [2]
  28165. */
  28166. var intersection = baseRest(function(arrays) {
  28167. var mapped = arrayMap(arrays, castArrayLikeObject);
  28168. return (mapped.length && mapped[0] === arrays[0])
  28169. ? baseIntersection(mapped)
  28170. : [];
  28171. });
  28172. /**
  28173. * This method is like `_.intersection` except that it accepts `iteratee`
  28174. * which is invoked for each element of each `arrays` to generate the criterion
  28175. * by which they're compared. The order and references of result values are
  28176. * determined by the first array. The iteratee is invoked with one argument:
  28177. * (value).
  28178. *
  28179. * @static
  28180. * @memberOf _
  28181. * @since 4.0.0
  28182. * @category Array
  28183. * @param {...Array} [arrays] The arrays to inspect.
  28184. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  28185. * @returns {Array} Returns the new array of intersecting values.
  28186. * @example
  28187. *
  28188. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  28189. * // => [2.1]
  28190. *
  28191. * // The `_.property` iteratee shorthand.
  28192. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  28193. * // => [{ 'x': 1 }]
  28194. */
  28195. var intersectionBy = baseRest(function(arrays) {
  28196. var iteratee = last(arrays),
  28197. mapped = arrayMap(arrays, castArrayLikeObject);
  28198. if (iteratee === last(mapped)) {
  28199. iteratee = undefined;
  28200. } else {
  28201. mapped.pop();
  28202. }
  28203. return (mapped.length && mapped[0] === arrays[0])
  28204. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  28205. : [];
  28206. });
  28207. /**
  28208. * This method is like `_.intersection` except that it accepts `comparator`
  28209. * which is invoked to compare elements of `arrays`. The order and references
  28210. * of result values are determined by the first array. The comparator is
  28211. * invoked with two arguments: (arrVal, othVal).
  28212. *
  28213. * @static
  28214. * @memberOf _
  28215. * @since 4.0.0
  28216. * @category Array
  28217. * @param {...Array} [arrays] The arrays to inspect.
  28218. * @param {Function} [comparator] The comparator invoked per element.
  28219. * @returns {Array} Returns the new array of intersecting values.
  28220. * @example
  28221. *
  28222. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  28223. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  28224. *
  28225. * _.intersectionWith(objects, others, _.isEqual);
  28226. * // => [{ 'x': 1, 'y': 2 }]
  28227. */
  28228. var intersectionWith = baseRest(function(arrays) {
  28229. var comparator = last(arrays),
  28230. mapped = arrayMap(arrays, castArrayLikeObject);
  28231. comparator = typeof comparator == 'function' ? comparator : undefined;
  28232. if (comparator) {
  28233. mapped.pop();
  28234. }
  28235. return (mapped.length && mapped[0] === arrays[0])
  28236. ? baseIntersection(mapped, undefined, comparator)
  28237. : [];
  28238. });
  28239. /**
  28240. * Converts all elements in `array` into a string separated by `separator`.
  28241. *
  28242. * @static
  28243. * @memberOf _
  28244. * @since 4.0.0
  28245. * @category Array
  28246. * @param {Array} array The array to convert.
  28247. * @param {string} [separator=','] The element separator.
  28248. * @returns {string} Returns the joined string.
  28249. * @example
  28250. *
  28251. * _.join(['a', 'b', 'c'], '~');
  28252. * // => 'a~b~c'
  28253. */
  28254. function join(array, separator) {
  28255. return array == null ? '' : nativeJoin.call(array, separator);
  28256. }
  28257. /**
  28258. * Gets the last element of `array`.
  28259. *
  28260. * @static
  28261. * @memberOf _
  28262. * @since 0.1.0
  28263. * @category Array
  28264. * @param {Array} array The array to query.
  28265. * @returns {*} Returns the last element of `array`.
  28266. * @example
  28267. *
  28268. * _.last([1, 2, 3]);
  28269. * // => 3
  28270. */
  28271. function last(array) {
  28272. var length = array == null ? 0 : array.length;
  28273. return length ? array[length - 1] : undefined;
  28274. }
  28275. /**
  28276. * This method is like `_.indexOf` except that it iterates over elements of
  28277. * `array` from right to left.
  28278. *
  28279. * @static
  28280. * @memberOf _
  28281. * @since 0.1.0
  28282. * @category Array
  28283. * @param {Array} array The array to inspect.
  28284. * @param {*} value The value to search for.
  28285. * @param {number} [fromIndex=array.length-1] The index to search from.
  28286. * @returns {number} Returns the index of the matched value, else `-1`.
  28287. * @example
  28288. *
  28289. * _.lastIndexOf([1, 2, 1, 2], 2);
  28290. * // => 3
  28291. *
  28292. * // Search from the `fromIndex`.
  28293. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  28294. * // => 1
  28295. */
  28296. function lastIndexOf(array, value, fromIndex) {
  28297. var length = array == null ? 0 : array.length;
  28298. if (!length) {
  28299. return -1;
  28300. }
  28301. var index = length;
  28302. if (fromIndex !== undefined) {
  28303. index = toInteger(fromIndex);
  28304. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  28305. }
  28306. return value === value
  28307. ? strictLastIndexOf(array, value, index)
  28308. : baseFindIndex(array, baseIsNaN, index, true);
  28309. }
  28310. /**
  28311. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  28312. * element from the end is returned.
  28313. *
  28314. * @static
  28315. * @memberOf _
  28316. * @since 4.11.0
  28317. * @category Array
  28318. * @param {Array} array The array to query.
  28319. * @param {number} [n=0] The index of the element to return.
  28320. * @returns {*} Returns the nth element of `array`.
  28321. * @example
  28322. *
  28323. * var array = ['a', 'b', 'c', 'd'];
  28324. *
  28325. * _.nth(array, 1);
  28326. * // => 'b'
  28327. *
  28328. * _.nth(array, -2);
  28329. * // => 'c';
  28330. */
  28331. function nth(array, n) {
  28332. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  28333. }
  28334. /**
  28335. * Removes all given values from `array` using
  28336. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28337. * for equality comparisons.
  28338. *
  28339. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  28340. * to remove elements from an array by predicate.
  28341. *
  28342. * @static
  28343. * @memberOf _
  28344. * @since 2.0.0
  28345. * @category Array
  28346. * @param {Array} array The array to modify.
  28347. * @param {...*} [values] The values to remove.
  28348. * @returns {Array} Returns `array`.
  28349. * @example
  28350. *
  28351. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  28352. *
  28353. * _.pull(array, 'a', 'c');
  28354. * console.log(array);
  28355. * // => ['b', 'b']
  28356. */
  28357. var pull = baseRest(pullAll);
  28358. /**
  28359. * This method is like `_.pull` except that it accepts an array of values to remove.
  28360. *
  28361. * **Note:** Unlike `_.difference`, this method mutates `array`.
  28362. *
  28363. * @static
  28364. * @memberOf _
  28365. * @since 4.0.0
  28366. * @category Array
  28367. * @param {Array} array The array to modify.
  28368. * @param {Array} values The values to remove.
  28369. * @returns {Array} Returns `array`.
  28370. * @example
  28371. *
  28372. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  28373. *
  28374. * _.pullAll(array, ['a', 'c']);
  28375. * console.log(array);
  28376. * // => ['b', 'b']
  28377. */
  28378. function pullAll(array, values) {
  28379. return (array && array.length && values && values.length)
  28380. ? basePullAll(array, values)
  28381. : array;
  28382. }
  28383. /**
  28384. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  28385. * invoked for each element of `array` and `values` to generate the criterion
  28386. * by which they're compared. The iteratee is invoked with one argument: (value).
  28387. *
  28388. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  28389. *
  28390. * @static
  28391. * @memberOf _
  28392. * @since 4.0.0
  28393. * @category Array
  28394. * @param {Array} array The array to modify.
  28395. * @param {Array} values The values to remove.
  28396. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  28397. * @returns {Array} Returns `array`.
  28398. * @example
  28399. *
  28400. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  28401. *
  28402. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  28403. * console.log(array);
  28404. * // => [{ 'x': 2 }]
  28405. */
  28406. function pullAllBy(array, values, iteratee) {
  28407. return (array && array.length && values && values.length)
  28408. ? basePullAll(array, values, getIteratee(iteratee, 2))
  28409. : array;
  28410. }
  28411. /**
  28412. * This method is like `_.pullAll` except that it accepts `comparator` which
  28413. * is invoked to compare elements of `array` to `values`. The comparator is
  28414. * invoked with two arguments: (arrVal, othVal).
  28415. *
  28416. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  28417. *
  28418. * @static
  28419. * @memberOf _
  28420. * @since 4.6.0
  28421. * @category Array
  28422. * @param {Array} array The array to modify.
  28423. * @param {Array} values The values to remove.
  28424. * @param {Function} [comparator] The comparator invoked per element.
  28425. * @returns {Array} Returns `array`.
  28426. * @example
  28427. *
  28428. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  28429. *
  28430. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  28431. * console.log(array);
  28432. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  28433. */
  28434. function pullAllWith(array, values, comparator) {
  28435. return (array && array.length && values && values.length)
  28436. ? basePullAll(array, values, undefined, comparator)
  28437. : array;
  28438. }
  28439. /**
  28440. * Removes elements from `array` corresponding to `indexes` and returns an
  28441. * array of removed elements.
  28442. *
  28443. * **Note:** Unlike `_.at`, this method mutates `array`.
  28444. *
  28445. * @static
  28446. * @memberOf _
  28447. * @since 3.0.0
  28448. * @category Array
  28449. * @param {Array} array The array to modify.
  28450. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  28451. * @returns {Array} Returns the new array of removed elements.
  28452. * @example
  28453. *
  28454. * var array = ['a', 'b', 'c', 'd'];
  28455. * var pulled = _.pullAt(array, [1, 3]);
  28456. *
  28457. * console.log(array);
  28458. * // => ['a', 'c']
  28459. *
  28460. * console.log(pulled);
  28461. * // => ['b', 'd']
  28462. */
  28463. var pullAt = flatRest(function(array, indexes) {
  28464. var length = array == null ? 0 : array.length,
  28465. result = baseAt(array, indexes);
  28466. basePullAt(array, arrayMap(indexes, function(index) {
  28467. return isIndex(index, length) ? +index : index;
  28468. }).sort(compareAscending));
  28469. return result;
  28470. });
  28471. /**
  28472. * Removes all elements from `array` that `predicate` returns truthy for
  28473. * and returns an array of the removed elements. The predicate is invoked
  28474. * with three arguments: (value, index, array).
  28475. *
  28476. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  28477. * to pull elements from an array by value.
  28478. *
  28479. * @static
  28480. * @memberOf _
  28481. * @since 2.0.0
  28482. * @category Array
  28483. * @param {Array} array The array to modify.
  28484. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28485. * @returns {Array} Returns the new array of removed elements.
  28486. * @example
  28487. *
  28488. * var array = [1, 2, 3, 4];
  28489. * var evens = _.remove(array, function(n) {
  28490. * return n % 2 == 0;
  28491. * });
  28492. *
  28493. * console.log(array);
  28494. * // => [1, 3]
  28495. *
  28496. * console.log(evens);
  28497. * // => [2, 4]
  28498. */
  28499. function remove(array, predicate) {
  28500. var result = [];
  28501. if (!(array && array.length)) {
  28502. return result;
  28503. }
  28504. var index = -1,
  28505. indexes = [],
  28506. length = array.length;
  28507. predicate = getIteratee(predicate, 3);
  28508. while (++index < length) {
  28509. var value = array[index];
  28510. if (predicate(value, index, array)) {
  28511. result.push(value);
  28512. indexes.push(index);
  28513. }
  28514. }
  28515. basePullAt(array, indexes);
  28516. return result;
  28517. }
  28518. /**
  28519. * Reverses `array` so that the first element becomes the last, the second
  28520. * element becomes the second to last, and so on.
  28521. *
  28522. * **Note:** This method mutates `array` and is based on
  28523. * [`Array#reverse`](https://mdn.io/Array/reverse).
  28524. *
  28525. * @static
  28526. * @memberOf _
  28527. * @since 4.0.0
  28528. * @category Array
  28529. * @param {Array} array The array to modify.
  28530. * @returns {Array} Returns `array`.
  28531. * @example
  28532. *
  28533. * var array = [1, 2, 3];
  28534. *
  28535. * _.reverse(array);
  28536. * // => [3, 2, 1]
  28537. *
  28538. * console.log(array);
  28539. * // => [3, 2, 1]
  28540. */
  28541. function reverse(array) {
  28542. return array == null ? array : nativeReverse.call(array);
  28543. }
  28544. /**
  28545. * Creates a slice of `array` from `start` up to, but not including, `end`.
  28546. *
  28547. * **Note:** This method is used instead of
  28548. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  28549. * returned.
  28550. *
  28551. * @static
  28552. * @memberOf _
  28553. * @since 3.0.0
  28554. * @category Array
  28555. * @param {Array} array The array to slice.
  28556. * @param {number} [start=0] The start position.
  28557. * @param {number} [end=array.length] The end position.
  28558. * @returns {Array} Returns the slice of `array`.
  28559. */
  28560. function slice(array, start, end) {
  28561. var length = array == null ? 0 : array.length;
  28562. if (!length) {
  28563. return [];
  28564. }
  28565. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  28566. start = 0;
  28567. end = length;
  28568. }
  28569. else {
  28570. start = start == null ? 0 : toInteger(start);
  28571. end = end === undefined ? length : toInteger(end);
  28572. }
  28573. return baseSlice(array, start, end);
  28574. }
  28575. /**
  28576. * Uses a binary search to determine the lowest index at which `value`
  28577. * should be inserted into `array` in order to maintain its sort order.
  28578. *
  28579. * @static
  28580. * @memberOf _
  28581. * @since 0.1.0
  28582. * @category Array
  28583. * @param {Array} array The sorted array to inspect.
  28584. * @param {*} value The value to evaluate.
  28585. * @returns {number} Returns the index at which `value` should be inserted
  28586. * into `array`.
  28587. * @example
  28588. *
  28589. * _.sortedIndex([30, 50], 40);
  28590. * // => 1
  28591. */
  28592. function sortedIndex(array, value) {
  28593. return baseSortedIndex(array, value);
  28594. }
  28595. /**
  28596. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  28597. * which is invoked for `value` and each element of `array` to compute their
  28598. * sort ranking. The iteratee is invoked with one argument: (value).
  28599. *
  28600. * @static
  28601. * @memberOf _
  28602. * @since 4.0.0
  28603. * @category Array
  28604. * @param {Array} array The sorted array to inspect.
  28605. * @param {*} value The value to evaluate.
  28606. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  28607. * @returns {number} Returns the index at which `value` should be inserted
  28608. * into `array`.
  28609. * @example
  28610. *
  28611. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  28612. *
  28613. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  28614. * // => 0
  28615. *
  28616. * // The `_.property` iteratee shorthand.
  28617. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  28618. * // => 0
  28619. */
  28620. function sortedIndexBy(array, value, iteratee) {
  28621. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  28622. }
  28623. /**
  28624. * This method is like `_.indexOf` except that it performs a binary
  28625. * search on a sorted `array`.
  28626. *
  28627. * @static
  28628. * @memberOf _
  28629. * @since 4.0.0
  28630. * @category Array
  28631. * @param {Array} array The array to inspect.
  28632. * @param {*} value The value to search for.
  28633. * @returns {number} Returns the index of the matched value, else `-1`.
  28634. * @example
  28635. *
  28636. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  28637. * // => 1
  28638. */
  28639. function sortedIndexOf(array, value) {
  28640. var length = array == null ? 0 : array.length;
  28641. if (length) {
  28642. var index = baseSortedIndex(array, value);
  28643. if (index < length && eq(array[index], value)) {
  28644. return index;
  28645. }
  28646. }
  28647. return -1;
  28648. }
  28649. /**
  28650. * This method is like `_.sortedIndex` except that it returns the highest
  28651. * index at which `value` should be inserted into `array` in order to
  28652. * maintain its sort order.
  28653. *
  28654. * @static
  28655. * @memberOf _
  28656. * @since 3.0.0
  28657. * @category Array
  28658. * @param {Array} array The sorted array to inspect.
  28659. * @param {*} value The value to evaluate.
  28660. * @returns {number} Returns the index at which `value` should be inserted
  28661. * into `array`.
  28662. * @example
  28663. *
  28664. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  28665. * // => 4
  28666. */
  28667. function sortedLastIndex(array, value) {
  28668. return baseSortedIndex(array, value, true);
  28669. }
  28670. /**
  28671. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  28672. * which is invoked for `value` and each element of `array` to compute their
  28673. * sort ranking. The iteratee is invoked with one argument: (value).
  28674. *
  28675. * @static
  28676. * @memberOf _
  28677. * @since 4.0.0
  28678. * @category Array
  28679. * @param {Array} array The sorted array to inspect.
  28680. * @param {*} value The value to evaluate.
  28681. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  28682. * @returns {number} Returns the index at which `value` should be inserted
  28683. * into `array`.
  28684. * @example
  28685. *
  28686. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  28687. *
  28688. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  28689. * // => 1
  28690. *
  28691. * // The `_.property` iteratee shorthand.
  28692. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  28693. * // => 1
  28694. */
  28695. function sortedLastIndexBy(array, value, iteratee) {
  28696. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  28697. }
  28698. /**
  28699. * This method is like `_.lastIndexOf` except that it performs a binary
  28700. * search on a sorted `array`.
  28701. *
  28702. * @static
  28703. * @memberOf _
  28704. * @since 4.0.0
  28705. * @category Array
  28706. * @param {Array} array The array to inspect.
  28707. * @param {*} value The value to search for.
  28708. * @returns {number} Returns the index of the matched value, else `-1`.
  28709. * @example
  28710. *
  28711. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  28712. * // => 3
  28713. */
  28714. function sortedLastIndexOf(array, value) {
  28715. var length = array == null ? 0 : array.length;
  28716. if (length) {
  28717. var index = baseSortedIndex(array, value, true) - 1;
  28718. if (eq(array[index], value)) {
  28719. return index;
  28720. }
  28721. }
  28722. return -1;
  28723. }
  28724. /**
  28725. * This method is like `_.uniq` except that it's designed and optimized
  28726. * for sorted arrays.
  28727. *
  28728. * @static
  28729. * @memberOf _
  28730. * @since 4.0.0
  28731. * @category Array
  28732. * @param {Array} array The array to inspect.
  28733. * @returns {Array} Returns the new duplicate free array.
  28734. * @example
  28735. *
  28736. * _.sortedUniq([1, 1, 2]);
  28737. * // => [1, 2]
  28738. */
  28739. function sortedUniq(array) {
  28740. return (array && array.length)
  28741. ? baseSortedUniq(array)
  28742. : [];
  28743. }
  28744. /**
  28745. * This method is like `_.uniqBy` except that it's designed and optimized
  28746. * for sorted arrays.
  28747. *
  28748. * @static
  28749. * @memberOf _
  28750. * @since 4.0.0
  28751. * @category Array
  28752. * @param {Array} array The array to inspect.
  28753. * @param {Function} [iteratee] The iteratee invoked per element.
  28754. * @returns {Array} Returns the new duplicate free array.
  28755. * @example
  28756. *
  28757. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  28758. * // => [1.1, 2.3]
  28759. */
  28760. function sortedUniqBy(array, iteratee) {
  28761. return (array && array.length)
  28762. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  28763. : [];
  28764. }
  28765. /**
  28766. * Gets all but the first element of `array`.
  28767. *
  28768. * @static
  28769. * @memberOf _
  28770. * @since 4.0.0
  28771. * @category Array
  28772. * @param {Array} array The array to query.
  28773. * @returns {Array} Returns the slice of `array`.
  28774. * @example
  28775. *
  28776. * _.tail([1, 2, 3]);
  28777. * // => [2, 3]
  28778. */
  28779. function tail(array) {
  28780. var length = array == null ? 0 : array.length;
  28781. return length ? baseSlice(array, 1, length) : [];
  28782. }
  28783. /**
  28784. * Creates a slice of `array` with `n` elements taken from the beginning.
  28785. *
  28786. * @static
  28787. * @memberOf _
  28788. * @since 0.1.0
  28789. * @category Array
  28790. * @param {Array} array The array to query.
  28791. * @param {number} [n=1] The number of elements to take.
  28792. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28793. * @returns {Array} Returns the slice of `array`.
  28794. * @example
  28795. *
  28796. * _.take([1, 2, 3]);
  28797. * // => [1]
  28798. *
  28799. * _.take([1, 2, 3], 2);
  28800. * // => [1, 2]
  28801. *
  28802. * _.take([1, 2, 3], 5);
  28803. * // => [1, 2, 3]
  28804. *
  28805. * _.take([1, 2, 3], 0);
  28806. * // => []
  28807. */
  28808. function take(array, n, guard) {
  28809. if (!(array && array.length)) {
  28810. return [];
  28811. }
  28812. n = (guard || n === undefined) ? 1 : toInteger(n);
  28813. return baseSlice(array, 0, n < 0 ? 0 : n);
  28814. }
  28815. /**
  28816. * Creates a slice of `array` with `n` elements taken from the end.
  28817. *
  28818. * @static
  28819. * @memberOf _
  28820. * @since 3.0.0
  28821. * @category Array
  28822. * @param {Array} array The array to query.
  28823. * @param {number} [n=1] The number of elements to take.
  28824. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28825. * @returns {Array} Returns the slice of `array`.
  28826. * @example
  28827. *
  28828. * _.takeRight([1, 2, 3]);
  28829. * // => [3]
  28830. *
  28831. * _.takeRight([1, 2, 3], 2);
  28832. * // => [2, 3]
  28833. *
  28834. * _.takeRight([1, 2, 3], 5);
  28835. * // => [1, 2, 3]
  28836. *
  28837. * _.takeRight([1, 2, 3], 0);
  28838. * // => []
  28839. */
  28840. function takeRight(array, n, guard) {
  28841. var length = array == null ? 0 : array.length;
  28842. if (!length) {
  28843. return [];
  28844. }
  28845. n = (guard || n === undefined) ? 1 : toInteger(n);
  28846. n = length - n;
  28847. return baseSlice(array, n < 0 ? 0 : n, length);
  28848. }
  28849. /**
  28850. * Creates a slice of `array` with elements taken from the end. Elements are
  28851. * taken until `predicate` returns falsey. The predicate is invoked with
  28852. * three arguments: (value, index, array).
  28853. *
  28854. * @static
  28855. * @memberOf _
  28856. * @since 3.0.0
  28857. * @category Array
  28858. * @param {Array} array The array to query.
  28859. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28860. * @returns {Array} Returns the slice of `array`.
  28861. * @example
  28862. *
  28863. * var users = [
  28864. * { 'user': 'barney', 'active': true },
  28865. * { 'user': 'fred', 'active': false },
  28866. * { 'user': 'pebbles', 'active': false }
  28867. * ];
  28868. *
  28869. * _.takeRightWhile(users, function(o) { return !o.active; });
  28870. * // => objects for ['fred', 'pebbles']
  28871. *
  28872. * // The `_.matches` iteratee shorthand.
  28873. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  28874. * // => objects for ['pebbles']
  28875. *
  28876. * // The `_.matchesProperty` iteratee shorthand.
  28877. * _.takeRightWhile(users, ['active', false]);
  28878. * // => objects for ['fred', 'pebbles']
  28879. *
  28880. * // The `_.property` iteratee shorthand.
  28881. * _.takeRightWhile(users, 'active');
  28882. * // => []
  28883. */
  28884. function takeRightWhile(array, predicate) {
  28885. return (array && array.length)
  28886. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  28887. : [];
  28888. }
  28889. /**
  28890. * Creates a slice of `array` with elements taken from the beginning. Elements
  28891. * are taken until `predicate` returns falsey. The predicate is invoked with
  28892. * three arguments: (value, index, array).
  28893. *
  28894. * @static
  28895. * @memberOf _
  28896. * @since 3.0.0
  28897. * @category Array
  28898. * @param {Array} array The array to query.
  28899. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28900. * @returns {Array} Returns the slice of `array`.
  28901. * @example
  28902. *
  28903. * var users = [
  28904. * { 'user': 'barney', 'active': false },
  28905. * { 'user': 'fred', 'active': false },
  28906. * { 'user': 'pebbles', 'active': true }
  28907. * ];
  28908. *
  28909. * _.takeWhile(users, function(o) { return !o.active; });
  28910. * // => objects for ['barney', 'fred']
  28911. *
  28912. * // The `_.matches` iteratee shorthand.
  28913. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  28914. * // => objects for ['barney']
  28915. *
  28916. * // The `_.matchesProperty` iteratee shorthand.
  28917. * _.takeWhile(users, ['active', false]);
  28918. * // => objects for ['barney', 'fred']
  28919. *
  28920. * // The `_.property` iteratee shorthand.
  28921. * _.takeWhile(users, 'active');
  28922. * // => []
  28923. */
  28924. function takeWhile(array, predicate) {
  28925. return (array && array.length)
  28926. ? baseWhile(array, getIteratee(predicate, 3))
  28927. : [];
  28928. }
  28929. /**
  28930. * Creates an array of unique values, in order, from all given arrays using
  28931. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28932. * for equality comparisons.
  28933. *
  28934. * @static
  28935. * @memberOf _
  28936. * @since 0.1.0
  28937. * @category Array
  28938. * @param {...Array} [arrays] The arrays to inspect.
  28939. * @returns {Array} Returns the new array of combined values.
  28940. * @example
  28941. *
  28942. * _.union([2], [1, 2]);
  28943. * // => [2, 1]
  28944. */
  28945. var union = baseRest(function(arrays) {
  28946. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  28947. });
  28948. /**
  28949. * This method is like `_.union` except that it accepts `iteratee` which is
  28950. * invoked for each element of each `arrays` to generate the criterion by
  28951. * which uniqueness is computed. Result values are chosen from the first
  28952. * array in which the value occurs. The iteratee is invoked with one argument:
  28953. * (value).
  28954. *
  28955. * @static
  28956. * @memberOf _
  28957. * @since 4.0.0
  28958. * @category Array
  28959. * @param {...Array} [arrays] The arrays to inspect.
  28960. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  28961. * @returns {Array} Returns the new array of combined values.
  28962. * @example
  28963. *
  28964. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  28965. * // => [2.1, 1.2]
  28966. *
  28967. * // The `_.property` iteratee shorthand.
  28968. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  28969. * // => [{ 'x': 1 }, { 'x': 2 }]
  28970. */
  28971. var unionBy = baseRest(function(arrays) {
  28972. var iteratee = last(arrays);
  28973. if (isArrayLikeObject(iteratee)) {
  28974. iteratee = undefined;
  28975. }
  28976. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  28977. });
  28978. /**
  28979. * This method is like `_.union` except that it accepts `comparator` which
  28980. * is invoked to compare elements of `arrays`. Result values are chosen from
  28981. * the first array in which the value occurs. The comparator is invoked
  28982. * with two arguments: (arrVal, othVal).
  28983. *
  28984. * @static
  28985. * @memberOf _
  28986. * @since 4.0.0
  28987. * @category Array
  28988. * @param {...Array} [arrays] The arrays to inspect.
  28989. * @param {Function} [comparator] The comparator invoked per element.
  28990. * @returns {Array} Returns the new array of combined values.
  28991. * @example
  28992. *
  28993. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  28994. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  28995. *
  28996. * _.unionWith(objects, others, _.isEqual);
  28997. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  28998. */
  28999. var unionWith = baseRest(function(arrays) {
  29000. var comparator = last(arrays);
  29001. comparator = typeof comparator == 'function' ? comparator : undefined;
  29002. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  29003. });
  29004. /**
  29005. * Creates a duplicate-free version of an array, using
  29006. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  29007. * for equality comparisons, in which only the first occurrence of each element
  29008. * is kept. The order of result values is determined by the order they occur
  29009. * in the array.
  29010. *
  29011. * @static
  29012. * @memberOf _
  29013. * @since 0.1.0
  29014. * @category Array
  29015. * @param {Array} array The array to inspect.
  29016. * @returns {Array} Returns the new duplicate free array.
  29017. * @example
  29018. *
  29019. * _.uniq([2, 1, 2]);
  29020. * // => [2, 1]
  29021. */
  29022. function uniq(array) {
  29023. return (array && array.length) ? baseUniq(array) : [];
  29024. }
  29025. /**
  29026. * This method is like `_.uniq` except that it accepts `iteratee` which is
  29027. * invoked for each element in `array` to generate the criterion by which
  29028. * uniqueness is computed. The order of result values is determined by the
  29029. * order they occur in the array. The iteratee is invoked with one argument:
  29030. * (value).
  29031. *
  29032. * @static
  29033. * @memberOf _
  29034. * @since 4.0.0
  29035. * @category Array
  29036. * @param {Array} array The array to inspect.
  29037. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29038. * @returns {Array} Returns the new duplicate free array.
  29039. * @example
  29040. *
  29041. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  29042. * // => [2.1, 1.2]
  29043. *
  29044. * // The `_.property` iteratee shorthand.
  29045. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  29046. * // => [{ 'x': 1 }, { 'x': 2 }]
  29047. */
  29048. function uniqBy(array, iteratee) {
  29049. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  29050. }
  29051. /**
  29052. * This method is like `_.uniq` except that it accepts `comparator` which
  29053. * is invoked to compare elements of `array`. The order of result values is
  29054. * determined by the order they occur in the array.The comparator is invoked
  29055. * with two arguments: (arrVal, othVal).
  29056. *
  29057. * @static
  29058. * @memberOf _
  29059. * @since 4.0.0
  29060. * @category Array
  29061. * @param {Array} array The array to inspect.
  29062. * @param {Function} [comparator] The comparator invoked per element.
  29063. * @returns {Array} Returns the new duplicate free array.
  29064. * @example
  29065. *
  29066. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  29067. *
  29068. * _.uniqWith(objects, _.isEqual);
  29069. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  29070. */
  29071. function uniqWith(array, comparator) {
  29072. comparator = typeof comparator == 'function' ? comparator : undefined;
  29073. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  29074. }
  29075. /**
  29076. * This method is like `_.zip` except that it accepts an array of grouped
  29077. * elements and creates an array regrouping the elements to their pre-zip
  29078. * configuration.
  29079. *
  29080. * @static
  29081. * @memberOf _
  29082. * @since 1.2.0
  29083. * @category Array
  29084. * @param {Array} array The array of grouped elements to process.
  29085. * @returns {Array} Returns the new array of regrouped elements.
  29086. * @example
  29087. *
  29088. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  29089. * // => [['a', 1, true], ['b', 2, false]]
  29090. *
  29091. * _.unzip(zipped);
  29092. * // => [['a', 'b'], [1, 2], [true, false]]
  29093. */
  29094. function unzip(array) {
  29095. if (!(array && array.length)) {
  29096. return [];
  29097. }
  29098. var length = 0;
  29099. array = arrayFilter(array, function(group) {
  29100. if (isArrayLikeObject(group)) {
  29101. length = nativeMax(group.length, length);
  29102. return true;
  29103. }
  29104. });
  29105. return baseTimes(length, function(index) {
  29106. return arrayMap(array, baseProperty(index));
  29107. });
  29108. }
  29109. /**
  29110. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  29111. * how regrouped values should be combined. The iteratee is invoked with the
  29112. * elements of each group: (...group).
  29113. *
  29114. * @static
  29115. * @memberOf _
  29116. * @since 3.8.0
  29117. * @category Array
  29118. * @param {Array} array The array of grouped elements to process.
  29119. * @param {Function} [iteratee=_.identity] The function to combine
  29120. * regrouped values.
  29121. * @returns {Array} Returns the new array of regrouped elements.
  29122. * @example
  29123. *
  29124. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  29125. * // => [[1, 10, 100], [2, 20, 200]]
  29126. *
  29127. * _.unzipWith(zipped, _.add);
  29128. * // => [3, 30, 300]
  29129. */
  29130. function unzipWith(array, iteratee) {
  29131. if (!(array && array.length)) {
  29132. return [];
  29133. }
  29134. var result = unzip(array);
  29135. if (iteratee == null) {
  29136. return result;
  29137. }
  29138. return arrayMap(result, function(group) {
  29139. return apply(iteratee, undefined, group);
  29140. });
  29141. }
  29142. /**
  29143. * Creates an array excluding all given values using
  29144. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  29145. * for equality comparisons.
  29146. *
  29147. * **Note:** Unlike `_.pull`, this method returns a new array.
  29148. *
  29149. * @static
  29150. * @memberOf _
  29151. * @since 0.1.0
  29152. * @category Array
  29153. * @param {Array} array The array to inspect.
  29154. * @param {...*} [values] The values to exclude.
  29155. * @returns {Array} Returns the new array of filtered values.
  29156. * @see _.difference, _.xor
  29157. * @example
  29158. *
  29159. * _.without([2, 1, 2, 3], 1, 2);
  29160. * // => [3]
  29161. */
  29162. var without = baseRest(function(array, values) {
  29163. return isArrayLikeObject(array)
  29164. ? baseDifference(array, values)
  29165. : [];
  29166. });
  29167. /**
  29168. * Creates an array of unique values that is the
  29169. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  29170. * of the given arrays. The order of result values is determined by the order
  29171. * they occur in the arrays.
  29172. *
  29173. * @static
  29174. * @memberOf _
  29175. * @since 2.4.0
  29176. * @category Array
  29177. * @param {...Array} [arrays] The arrays to inspect.
  29178. * @returns {Array} Returns the new array of filtered values.
  29179. * @see _.difference, _.without
  29180. * @example
  29181. *
  29182. * _.xor([2, 1], [2, 3]);
  29183. * // => [1, 3]
  29184. */
  29185. var xor = baseRest(function(arrays) {
  29186. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  29187. });
  29188. /**
  29189. * This method is like `_.xor` except that it accepts `iteratee` which is
  29190. * invoked for each element of each `arrays` to generate the criterion by
  29191. * which by which they're compared. The order of result values is determined
  29192. * by the order they occur in the arrays. The iteratee is invoked with one
  29193. * argument: (value).
  29194. *
  29195. * @static
  29196. * @memberOf _
  29197. * @since 4.0.0
  29198. * @category Array
  29199. * @param {...Array} [arrays] The arrays to inspect.
  29200. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29201. * @returns {Array} Returns the new array of filtered values.
  29202. * @example
  29203. *
  29204. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  29205. * // => [1.2, 3.4]
  29206. *
  29207. * // The `_.property` iteratee shorthand.
  29208. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  29209. * // => [{ 'x': 2 }]
  29210. */
  29211. var xorBy = baseRest(function(arrays) {
  29212. var iteratee = last(arrays);
  29213. if (isArrayLikeObject(iteratee)) {
  29214. iteratee = undefined;
  29215. }
  29216. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  29217. });
  29218. /**
  29219. * This method is like `_.xor` except that it accepts `comparator` which is
  29220. * invoked to compare elements of `arrays`. The order of result values is
  29221. * determined by the order they occur in the arrays. The comparator is invoked
  29222. * with two arguments: (arrVal, othVal).
  29223. *
  29224. * @static
  29225. * @memberOf _
  29226. * @since 4.0.0
  29227. * @category Array
  29228. * @param {...Array} [arrays] The arrays to inspect.
  29229. * @param {Function} [comparator] The comparator invoked per element.
  29230. * @returns {Array} Returns the new array of filtered values.
  29231. * @example
  29232. *
  29233. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  29234. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  29235. *
  29236. * _.xorWith(objects, others, _.isEqual);
  29237. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  29238. */
  29239. var xorWith = baseRest(function(arrays) {
  29240. var comparator = last(arrays);
  29241. comparator = typeof comparator == 'function' ? comparator : undefined;
  29242. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  29243. });
  29244. /**
  29245. * Creates an array of grouped elements, the first of which contains the
  29246. * first elements of the given arrays, the second of which contains the
  29247. * second elements of the given arrays, and so on.
  29248. *
  29249. * @static
  29250. * @memberOf _
  29251. * @since 0.1.0
  29252. * @category Array
  29253. * @param {...Array} [arrays] The arrays to process.
  29254. * @returns {Array} Returns the new array of grouped elements.
  29255. * @example
  29256. *
  29257. * _.zip(['a', 'b'], [1, 2], [true, false]);
  29258. * // => [['a', 1, true], ['b', 2, false]]
  29259. */
  29260. var zip = baseRest(unzip);
  29261. /**
  29262. * This method is like `_.fromPairs` except that it accepts two arrays,
  29263. * one of property identifiers and one of corresponding values.
  29264. *
  29265. * @static
  29266. * @memberOf _
  29267. * @since 0.4.0
  29268. * @category Array
  29269. * @param {Array} [props=[]] The property identifiers.
  29270. * @param {Array} [values=[]] The property values.
  29271. * @returns {Object} Returns the new object.
  29272. * @example
  29273. *
  29274. * _.zipObject(['a', 'b'], [1, 2]);
  29275. * // => { 'a': 1, 'b': 2 }
  29276. */
  29277. function zipObject(props, values) {
  29278. return baseZipObject(props || [], values || [], assignValue);
  29279. }
  29280. /**
  29281. * This method is like `_.zipObject` except that it supports property paths.
  29282. *
  29283. * @static
  29284. * @memberOf _
  29285. * @since 4.1.0
  29286. * @category Array
  29287. * @param {Array} [props=[]] The property identifiers.
  29288. * @param {Array} [values=[]] The property values.
  29289. * @returns {Object} Returns the new object.
  29290. * @example
  29291. *
  29292. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  29293. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  29294. */
  29295. function zipObjectDeep(props, values) {
  29296. return baseZipObject(props || [], values || [], baseSet);
  29297. }
  29298. /**
  29299. * This method is like `_.zip` except that it accepts `iteratee` to specify
  29300. * how grouped values should be combined. The iteratee is invoked with the
  29301. * elements of each group: (...group).
  29302. *
  29303. * @static
  29304. * @memberOf _
  29305. * @since 3.8.0
  29306. * @category Array
  29307. * @param {...Array} [arrays] The arrays to process.
  29308. * @param {Function} [iteratee=_.identity] The function to combine
  29309. * grouped values.
  29310. * @returns {Array} Returns the new array of grouped elements.
  29311. * @example
  29312. *
  29313. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  29314. * return a + b + c;
  29315. * });
  29316. * // => [111, 222]
  29317. */
  29318. var zipWith = baseRest(function(arrays) {
  29319. var length = arrays.length,
  29320. iteratee = length > 1 ? arrays[length - 1] : undefined;
  29321. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  29322. return unzipWith(arrays, iteratee);
  29323. });
  29324. /*------------------------------------------------------------------------*/
  29325. /**
  29326. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  29327. * chain sequences enabled. The result of such sequences must be unwrapped
  29328. * with `_#value`.
  29329. *
  29330. * @static
  29331. * @memberOf _
  29332. * @since 1.3.0
  29333. * @category Seq
  29334. * @param {*} value The value to wrap.
  29335. * @returns {Object} Returns the new `lodash` wrapper instance.
  29336. * @example
  29337. *
  29338. * var users = [
  29339. * { 'user': 'barney', 'age': 36 },
  29340. * { 'user': 'fred', 'age': 40 },
  29341. * { 'user': 'pebbles', 'age': 1 }
  29342. * ];
  29343. *
  29344. * var youngest = _
  29345. * .chain(users)
  29346. * .sortBy('age')
  29347. * .map(function(o) {
  29348. * return o.user + ' is ' + o.age;
  29349. * })
  29350. * .head()
  29351. * .value();
  29352. * // => 'pebbles is 1'
  29353. */
  29354. function chain(value) {
  29355. var result = lodash(value);
  29356. result.__chain__ = true;
  29357. return result;
  29358. }
  29359. /**
  29360. * This method invokes `interceptor` and returns `value`. The interceptor
  29361. * is invoked with one argument; (value). The purpose of this method is to
  29362. * "tap into" a method chain sequence in order to modify intermediate results.
  29363. *
  29364. * @static
  29365. * @memberOf _
  29366. * @since 0.1.0
  29367. * @category Seq
  29368. * @param {*} value The value to provide to `interceptor`.
  29369. * @param {Function} interceptor The function to invoke.
  29370. * @returns {*} Returns `value`.
  29371. * @example
  29372. *
  29373. * _([1, 2, 3])
  29374. * .tap(function(array) {
  29375. * // Mutate input array.
  29376. * array.pop();
  29377. * })
  29378. * .reverse()
  29379. * .value();
  29380. * // => [2, 1]
  29381. */
  29382. function tap(value, interceptor) {
  29383. interceptor(value);
  29384. return value;
  29385. }
  29386. /**
  29387. * This method is like `_.tap` except that it returns the result of `interceptor`.
  29388. * The purpose of this method is to "pass thru" values replacing intermediate
  29389. * results in a method chain sequence.
  29390. *
  29391. * @static
  29392. * @memberOf _
  29393. * @since 3.0.0
  29394. * @category Seq
  29395. * @param {*} value The value to provide to `interceptor`.
  29396. * @param {Function} interceptor The function to invoke.
  29397. * @returns {*} Returns the result of `interceptor`.
  29398. * @example
  29399. *
  29400. * _(' abc ')
  29401. * .chain()
  29402. * .trim()
  29403. * .thru(function(value) {
  29404. * return [value];
  29405. * })
  29406. * .value();
  29407. * // => ['abc']
  29408. */
  29409. function thru(value, interceptor) {
  29410. return interceptor(value);
  29411. }
  29412. /**
  29413. * This method is the wrapper version of `_.at`.
  29414. *
  29415. * @name at
  29416. * @memberOf _
  29417. * @since 1.0.0
  29418. * @category Seq
  29419. * @param {...(string|string[])} [paths] The property paths to pick.
  29420. * @returns {Object} Returns the new `lodash` wrapper instance.
  29421. * @example
  29422. *
  29423. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29424. *
  29425. * _(object).at(['a[0].b.c', 'a[1]']).value();
  29426. * // => [3, 4]
  29427. */
  29428. var wrapperAt = flatRest(function(paths) {
  29429. var length = paths.length,
  29430. start = length ? paths[0] : 0,
  29431. value = this.__wrapped__,
  29432. interceptor = function(object) { return baseAt(object, paths); };
  29433. if (length > 1 || this.__actions__.length ||
  29434. !(value instanceof LazyWrapper) || !isIndex(start)) {
  29435. return this.thru(interceptor);
  29436. }
  29437. value = value.slice(start, +start + (length ? 1 : 0));
  29438. value.__actions__.push({
  29439. 'func': thru,
  29440. 'args': [interceptor],
  29441. 'thisArg': undefined
  29442. });
  29443. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  29444. if (length && !array.length) {
  29445. array.push(undefined);
  29446. }
  29447. return array;
  29448. });
  29449. });
  29450. /**
  29451. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  29452. *
  29453. * @name chain
  29454. * @memberOf _
  29455. * @since 0.1.0
  29456. * @category Seq
  29457. * @returns {Object} Returns the new `lodash` wrapper instance.
  29458. * @example
  29459. *
  29460. * var users = [
  29461. * { 'user': 'barney', 'age': 36 },
  29462. * { 'user': 'fred', 'age': 40 }
  29463. * ];
  29464. *
  29465. * // A sequence without explicit chaining.
  29466. * _(users).head();
  29467. * // => { 'user': 'barney', 'age': 36 }
  29468. *
  29469. * // A sequence with explicit chaining.
  29470. * _(users)
  29471. * .chain()
  29472. * .head()
  29473. * .pick('user')
  29474. * .value();
  29475. * // => { 'user': 'barney' }
  29476. */
  29477. function wrapperChain() {
  29478. return chain(this);
  29479. }
  29480. /**
  29481. * Executes the chain sequence and returns the wrapped result.
  29482. *
  29483. * @name commit
  29484. * @memberOf _
  29485. * @since 3.2.0
  29486. * @category Seq
  29487. * @returns {Object} Returns the new `lodash` wrapper instance.
  29488. * @example
  29489. *
  29490. * var array = [1, 2];
  29491. * var wrapped = _(array).push(3);
  29492. *
  29493. * console.log(array);
  29494. * // => [1, 2]
  29495. *
  29496. * wrapped = wrapped.commit();
  29497. * console.log(array);
  29498. * // => [1, 2, 3]
  29499. *
  29500. * wrapped.last();
  29501. * // => 3
  29502. *
  29503. * console.log(array);
  29504. * // => [1, 2, 3]
  29505. */
  29506. function wrapperCommit() {
  29507. return new LodashWrapper(this.value(), this.__chain__);
  29508. }
  29509. /**
  29510. * Gets the next value on a wrapped object following the
  29511. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  29512. *
  29513. * @name next
  29514. * @memberOf _
  29515. * @since 4.0.0
  29516. * @category Seq
  29517. * @returns {Object} Returns the next iterator value.
  29518. * @example
  29519. *
  29520. * var wrapped = _([1, 2]);
  29521. *
  29522. * wrapped.next();
  29523. * // => { 'done': false, 'value': 1 }
  29524. *
  29525. * wrapped.next();
  29526. * // => { 'done': false, 'value': 2 }
  29527. *
  29528. * wrapped.next();
  29529. * // => { 'done': true, 'value': undefined }
  29530. */
  29531. function wrapperNext() {
  29532. if (this.__values__ === undefined) {
  29533. this.__values__ = toArray(this.value());
  29534. }
  29535. var done = this.__index__ >= this.__values__.length,
  29536. value = done ? undefined : this.__values__[this.__index__++];
  29537. return { 'done': done, 'value': value };
  29538. }
  29539. /**
  29540. * Enables the wrapper to be iterable.
  29541. *
  29542. * @name Symbol.iterator
  29543. * @memberOf _
  29544. * @since 4.0.0
  29545. * @category Seq
  29546. * @returns {Object} Returns the wrapper object.
  29547. * @example
  29548. *
  29549. * var wrapped = _([1, 2]);
  29550. *
  29551. * wrapped[Symbol.iterator]() === wrapped;
  29552. * // => true
  29553. *
  29554. * Array.from(wrapped);
  29555. * // => [1, 2]
  29556. */
  29557. function wrapperToIterator() {
  29558. return this;
  29559. }
  29560. /**
  29561. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  29562. *
  29563. * @name plant
  29564. * @memberOf _
  29565. * @since 3.2.0
  29566. * @category Seq
  29567. * @param {*} value The value to plant.
  29568. * @returns {Object} Returns the new `lodash` wrapper instance.
  29569. * @example
  29570. *
  29571. * function square(n) {
  29572. * return n * n;
  29573. * }
  29574. *
  29575. * var wrapped = _([1, 2]).map(square);
  29576. * var other = wrapped.plant([3, 4]);
  29577. *
  29578. * other.value();
  29579. * // => [9, 16]
  29580. *
  29581. * wrapped.value();
  29582. * // => [1, 4]
  29583. */
  29584. function wrapperPlant(value) {
  29585. var result,
  29586. parent = this;
  29587. while (parent instanceof baseLodash) {
  29588. var clone = wrapperClone(parent);
  29589. clone.__index__ = 0;
  29590. clone.__values__ = undefined;
  29591. if (result) {
  29592. previous.__wrapped__ = clone;
  29593. } else {
  29594. result = clone;
  29595. }
  29596. var previous = clone;
  29597. parent = parent.__wrapped__;
  29598. }
  29599. previous.__wrapped__ = value;
  29600. return result;
  29601. }
  29602. /**
  29603. * This method is the wrapper version of `_.reverse`.
  29604. *
  29605. * **Note:** This method mutates the wrapped array.
  29606. *
  29607. * @name reverse
  29608. * @memberOf _
  29609. * @since 0.1.0
  29610. * @category Seq
  29611. * @returns {Object} Returns the new `lodash` wrapper instance.
  29612. * @example
  29613. *
  29614. * var array = [1, 2, 3];
  29615. *
  29616. * _(array).reverse().value()
  29617. * // => [3, 2, 1]
  29618. *
  29619. * console.log(array);
  29620. * // => [3, 2, 1]
  29621. */
  29622. function wrapperReverse() {
  29623. var value = this.__wrapped__;
  29624. if (value instanceof LazyWrapper) {
  29625. var wrapped = value;
  29626. if (this.__actions__.length) {
  29627. wrapped = new LazyWrapper(this);
  29628. }
  29629. wrapped = wrapped.reverse();
  29630. wrapped.__actions__.push({
  29631. 'func': thru,
  29632. 'args': [reverse],
  29633. 'thisArg': undefined
  29634. });
  29635. return new LodashWrapper(wrapped, this.__chain__);
  29636. }
  29637. return this.thru(reverse);
  29638. }
  29639. /**
  29640. * Executes the chain sequence to resolve the unwrapped value.
  29641. *
  29642. * @name value
  29643. * @memberOf _
  29644. * @since 0.1.0
  29645. * @alias toJSON, valueOf
  29646. * @category Seq
  29647. * @returns {*} Returns the resolved unwrapped value.
  29648. * @example
  29649. *
  29650. * _([1, 2, 3]).value();
  29651. * // => [1, 2, 3]
  29652. */
  29653. function wrapperValue() {
  29654. return baseWrapperValue(this.__wrapped__, this.__actions__);
  29655. }
  29656. /*------------------------------------------------------------------------*/
  29657. /**
  29658. * Creates an object composed of keys generated from the results of running
  29659. * each element of `collection` thru `iteratee`. The corresponding value of
  29660. * each key is the number of times the key was returned by `iteratee`. The
  29661. * iteratee is invoked with one argument: (value).
  29662. *
  29663. * @static
  29664. * @memberOf _
  29665. * @since 0.5.0
  29666. * @category Collection
  29667. * @param {Array|Object} collection The collection to iterate over.
  29668. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  29669. * @returns {Object} Returns the composed aggregate object.
  29670. * @example
  29671. *
  29672. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  29673. * // => { '4': 1, '6': 2 }
  29674. *
  29675. * // The `_.property` iteratee shorthand.
  29676. * _.countBy(['one', 'two', 'three'], 'length');
  29677. * // => { '3': 2, '5': 1 }
  29678. */
  29679. var countBy = createAggregator(function(result, value, key) {
  29680. if (hasOwnProperty.call(result, key)) {
  29681. ++result[key];
  29682. } else {
  29683. baseAssignValue(result, key, 1);
  29684. }
  29685. });
  29686. /**
  29687. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  29688. * Iteration is stopped once `predicate` returns falsey. The predicate is
  29689. * invoked with three arguments: (value, index|key, collection).
  29690. *
  29691. * **Note:** This method returns `true` for
  29692. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  29693. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  29694. * elements of empty collections.
  29695. *
  29696. * @static
  29697. * @memberOf _
  29698. * @since 0.1.0
  29699. * @category Collection
  29700. * @param {Array|Object} collection The collection to iterate over.
  29701. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29702. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  29703. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  29704. * else `false`.
  29705. * @example
  29706. *
  29707. * _.every([true, 1, null, 'yes'], Boolean);
  29708. * // => false
  29709. *
  29710. * var users = [
  29711. * { 'user': 'barney', 'age': 36, 'active': false },
  29712. * { 'user': 'fred', 'age': 40, 'active': false }
  29713. * ];
  29714. *
  29715. * // The `_.matches` iteratee shorthand.
  29716. * _.every(users, { 'user': 'barney', 'active': false });
  29717. * // => false
  29718. *
  29719. * // The `_.matchesProperty` iteratee shorthand.
  29720. * _.every(users, ['active', false]);
  29721. * // => true
  29722. *
  29723. * // The `_.property` iteratee shorthand.
  29724. * _.every(users, 'active');
  29725. * // => false
  29726. */
  29727. function every(collection, predicate, guard) {
  29728. var func = isArray(collection) ? arrayEvery : baseEvery;
  29729. if (guard && isIterateeCall(collection, predicate, guard)) {
  29730. predicate = undefined;
  29731. }
  29732. return func(collection, getIteratee(predicate, 3));
  29733. }
  29734. /**
  29735. * Iterates over elements of `collection`, returning an array of all elements
  29736. * `predicate` returns truthy for. The predicate is invoked with three
  29737. * arguments: (value, index|key, collection).
  29738. *
  29739. * **Note:** Unlike `_.remove`, this method returns a new array.
  29740. *
  29741. * @static
  29742. * @memberOf _
  29743. * @since 0.1.0
  29744. * @category Collection
  29745. * @param {Array|Object} collection The collection to iterate over.
  29746. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29747. * @returns {Array} Returns the new filtered array.
  29748. * @see _.reject
  29749. * @example
  29750. *
  29751. * var users = [
  29752. * { 'user': 'barney', 'age': 36, 'active': true },
  29753. * { 'user': 'fred', 'age': 40, 'active': false }
  29754. * ];
  29755. *
  29756. * _.filter(users, function(o) { return !o.active; });
  29757. * // => objects for ['fred']
  29758. *
  29759. * // The `_.matches` iteratee shorthand.
  29760. * _.filter(users, { 'age': 36, 'active': true });
  29761. * // => objects for ['barney']
  29762. *
  29763. * // The `_.matchesProperty` iteratee shorthand.
  29764. * _.filter(users, ['active', false]);
  29765. * // => objects for ['fred']
  29766. *
  29767. * // The `_.property` iteratee shorthand.
  29768. * _.filter(users, 'active');
  29769. * // => objects for ['barney']
  29770. */
  29771. function filter(collection, predicate) {
  29772. var func = isArray(collection) ? arrayFilter : baseFilter;
  29773. return func(collection, getIteratee(predicate, 3));
  29774. }
  29775. /**
  29776. * Iterates over elements of `collection`, returning the first element
  29777. * `predicate` returns truthy for. The predicate is invoked with three
  29778. * arguments: (value, index|key, collection).
  29779. *
  29780. * @static
  29781. * @memberOf _
  29782. * @since 0.1.0
  29783. * @category Collection
  29784. * @param {Array|Object} collection The collection to inspect.
  29785. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29786. * @param {number} [fromIndex=0] The index to search from.
  29787. * @returns {*} Returns the matched element, else `undefined`.
  29788. * @example
  29789. *
  29790. * var users = [
  29791. * { 'user': 'barney', 'age': 36, 'active': true },
  29792. * { 'user': 'fred', 'age': 40, 'active': false },
  29793. * { 'user': 'pebbles', 'age': 1, 'active': true }
  29794. * ];
  29795. *
  29796. * _.find(users, function(o) { return o.age < 40; });
  29797. * // => object for 'barney'
  29798. *
  29799. * // The `_.matches` iteratee shorthand.
  29800. * _.find(users, { 'age': 1, 'active': true });
  29801. * // => object for 'pebbles'
  29802. *
  29803. * // The `_.matchesProperty` iteratee shorthand.
  29804. * _.find(users, ['active', false]);
  29805. * // => object for 'fred'
  29806. *
  29807. * // The `_.property` iteratee shorthand.
  29808. * _.find(users, 'active');
  29809. * // => object for 'barney'
  29810. */
  29811. var find = createFind(findIndex);
  29812. /**
  29813. * This method is like `_.find` except that it iterates over elements of
  29814. * `collection` from right to left.
  29815. *
  29816. * @static
  29817. * @memberOf _
  29818. * @since 2.0.0
  29819. * @category Collection
  29820. * @param {Array|Object} collection The collection to inspect.
  29821. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29822. * @param {number} [fromIndex=collection.length-1] The index to search from.
  29823. * @returns {*} Returns the matched element, else `undefined`.
  29824. * @example
  29825. *
  29826. * _.findLast([1, 2, 3, 4], function(n) {
  29827. * return n % 2 == 1;
  29828. * });
  29829. * // => 3
  29830. */
  29831. var findLast = createFind(findLastIndex);
  29832. /**
  29833. * Creates a flattened array of values by running each element in `collection`
  29834. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  29835. * with three arguments: (value, index|key, collection).
  29836. *
  29837. * @static
  29838. * @memberOf _
  29839. * @since 4.0.0
  29840. * @category Collection
  29841. * @param {Array|Object} collection The collection to iterate over.
  29842. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29843. * @returns {Array} Returns the new flattened array.
  29844. * @example
  29845. *
  29846. * function duplicate(n) {
  29847. * return [n, n];
  29848. * }
  29849. *
  29850. * _.flatMap([1, 2], duplicate);
  29851. * // => [1, 1, 2, 2]
  29852. */
  29853. function flatMap(collection, iteratee) {
  29854. return baseFlatten(map(collection, iteratee), 1);
  29855. }
  29856. /**
  29857. * This method is like `_.flatMap` except that it recursively flattens the
  29858. * mapped results.
  29859. *
  29860. * @static
  29861. * @memberOf _
  29862. * @since 4.7.0
  29863. * @category Collection
  29864. * @param {Array|Object} collection The collection to iterate over.
  29865. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29866. * @returns {Array} Returns the new flattened array.
  29867. * @example
  29868. *
  29869. * function duplicate(n) {
  29870. * return [[[n, n]]];
  29871. * }
  29872. *
  29873. * _.flatMapDeep([1, 2], duplicate);
  29874. * // => [1, 1, 2, 2]
  29875. */
  29876. function flatMapDeep(collection, iteratee) {
  29877. return baseFlatten(map(collection, iteratee), INFINITY);
  29878. }
  29879. /**
  29880. * This method is like `_.flatMap` except that it recursively flattens the
  29881. * mapped results up to `depth` times.
  29882. *
  29883. * @static
  29884. * @memberOf _
  29885. * @since 4.7.0
  29886. * @category Collection
  29887. * @param {Array|Object} collection The collection to iterate over.
  29888. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29889. * @param {number} [depth=1] The maximum recursion depth.
  29890. * @returns {Array} Returns the new flattened array.
  29891. * @example
  29892. *
  29893. * function duplicate(n) {
  29894. * return [[[n, n]]];
  29895. * }
  29896. *
  29897. * _.flatMapDepth([1, 2], duplicate, 2);
  29898. * // => [[1, 1], [2, 2]]
  29899. */
  29900. function flatMapDepth(collection, iteratee, depth) {
  29901. depth = depth === undefined ? 1 : toInteger(depth);
  29902. return baseFlatten(map(collection, iteratee), depth);
  29903. }
  29904. /**
  29905. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  29906. * The iteratee is invoked with three arguments: (value, index|key, collection).
  29907. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29908. *
  29909. * **Note:** As with other "Collections" methods, objects with a "length"
  29910. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  29911. * or `_.forOwn` for object iteration.
  29912. *
  29913. * @static
  29914. * @memberOf _
  29915. * @since 0.1.0
  29916. * @alias each
  29917. * @category Collection
  29918. * @param {Array|Object} collection The collection to iterate over.
  29919. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29920. * @returns {Array|Object} Returns `collection`.
  29921. * @see _.forEachRight
  29922. * @example
  29923. *
  29924. * _.forEach([1, 2], function(value) {
  29925. * console.log(value);
  29926. * });
  29927. * // => Logs `1` then `2`.
  29928. *
  29929. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  29930. * console.log(key);
  29931. * });
  29932. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29933. */
  29934. function forEach(collection, iteratee) {
  29935. var func = isArray(collection) ? arrayEach : baseEach;
  29936. return func(collection, getIteratee(iteratee, 3));
  29937. }
  29938. /**
  29939. * This method is like `_.forEach` except that it iterates over elements of
  29940. * `collection` from right to left.
  29941. *
  29942. * @static
  29943. * @memberOf _
  29944. * @since 2.0.0
  29945. * @alias eachRight
  29946. * @category Collection
  29947. * @param {Array|Object} collection The collection to iterate over.
  29948. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29949. * @returns {Array|Object} Returns `collection`.
  29950. * @see _.forEach
  29951. * @example
  29952. *
  29953. * _.forEachRight([1, 2], function(value) {
  29954. * console.log(value);
  29955. * });
  29956. * // => Logs `2` then `1`.
  29957. */
  29958. function forEachRight(collection, iteratee) {
  29959. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  29960. return func(collection, getIteratee(iteratee, 3));
  29961. }
  29962. /**
  29963. * Creates an object composed of keys generated from the results of running
  29964. * each element of `collection` thru `iteratee`. The order of grouped values
  29965. * is determined by the order they occur in `collection`. The corresponding
  29966. * value of each key is an array of elements responsible for generating the
  29967. * key. The iteratee is invoked with one argument: (value).
  29968. *
  29969. * @static
  29970. * @memberOf _
  29971. * @since 0.1.0
  29972. * @category Collection
  29973. * @param {Array|Object} collection The collection to iterate over.
  29974. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  29975. * @returns {Object} Returns the composed aggregate object.
  29976. * @example
  29977. *
  29978. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  29979. * // => { '4': [4.2], '6': [6.1, 6.3] }
  29980. *
  29981. * // The `_.property` iteratee shorthand.
  29982. * _.groupBy(['one', 'two', 'three'], 'length');
  29983. * // => { '3': ['one', 'two'], '5': ['three'] }
  29984. */
  29985. var groupBy = createAggregator(function(result, value, key) {
  29986. if (hasOwnProperty.call(result, key)) {
  29987. result[key].push(value);
  29988. } else {
  29989. baseAssignValue(result, key, [value]);
  29990. }
  29991. });
  29992. /**
  29993. * Checks if `value` is in `collection`. If `collection` is a string, it's
  29994. * checked for a substring of `value`, otherwise
  29995. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  29996. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  29997. * the offset from the end of `collection`.
  29998. *
  29999. * @static
  30000. * @memberOf _
  30001. * @since 0.1.0
  30002. * @category Collection
  30003. * @param {Array|Object|string} collection The collection to inspect.
  30004. * @param {*} value The value to search for.
  30005. * @param {number} [fromIndex=0] The index to search from.
  30006. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  30007. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  30008. * @example
  30009. *
  30010. * _.includes([1, 2, 3], 1);
  30011. * // => true
  30012. *
  30013. * _.includes([1, 2, 3], 1, 2);
  30014. * // => false
  30015. *
  30016. * _.includes({ 'a': 1, 'b': 2 }, 1);
  30017. * // => true
  30018. *
  30019. * _.includes('abcd', 'bc');
  30020. * // => true
  30021. */
  30022. function includes(collection, value, fromIndex, guard) {
  30023. collection = isArrayLike(collection) ? collection : values(collection);
  30024. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  30025. var length = collection.length;
  30026. if (fromIndex < 0) {
  30027. fromIndex = nativeMax(length + fromIndex, 0);
  30028. }
  30029. return isString(collection)
  30030. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  30031. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  30032. }
  30033. /**
  30034. * Invokes the method at `path` of each element in `collection`, returning
  30035. * an array of the results of each invoked method. Any additional arguments
  30036. * are provided to each invoked method. If `path` is a function, it's invoked
  30037. * for, and `this` bound to, each element in `collection`.
  30038. *
  30039. * @static
  30040. * @memberOf _
  30041. * @since 4.0.0
  30042. * @category Collection
  30043. * @param {Array|Object} collection The collection to iterate over.
  30044. * @param {Array|Function|string} path The path of the method to invoke or
  30045. * the function invoked per iteration.
  30046. * @param {...*} [args] The arguments to invoke each method with.
  30047. * @returns {Array} Returns the array of results.
  30048. * @example
  30049. *
  30050. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  30051. * // => [[1, 5, 7], [1, 2, 3]]
  30052. *
  30053. * _.invokeMap([123, 456], String.prototype.split, '');
  30054. * // => [['1', '2', '3'], ['4', '5', '6']]
  30055. */
  30056. var invokeMap = baseRest(function(collection, path, args) {
  30057. var index = -1,
  30058. isFunc = typeof path == 'function',
  30059. result = isArrayLike(collection) ? Array(collection.length) : [];
  30060. baseEach(collection, function(value) {
  30061. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  30062. });
  30063. return result;
  30064. });
  30065. /**
  30066. * Creates an object composed of keys generated from the results of running
  30067. * each element of `collection` thru `iteratee`. The corresponding value of
  30068. * each key is the last element responsible for generating the key. The
  30069. * iteratee is invoked with one argument: (value).
  30070. *
  30071. * @static
  30072. * @memberOf _
  30073. * @since 4.0.0
  30074. * @category Collection
  30075. * @param {Array|Object} collection The collection to iterate over.
  30076. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  30077. * @returns {Object} Returns the composed aggregate object.
  30078. * @example
  30079. *
  30080. * var array = [
  30081. * { 'dir': 'left', 'code': 97 },
  30082. * { 'dir': 'right', 'code': 100 }
  30083. * ];
  30084. *
  30085. * _.keyBy(array, function(o) {
  30086. * return String.fromCharCode(o.code);
  30087. * });
  30088. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  30089. *
  30090. * _.keyBy(array, 'dir');
  30091. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  30092. */
  30093. var keyBy = createAggregator(function(result, value, key) {
  30094. baseAssignValue(result, key, value);
  30095. });
  30096. /**
  30097. * Creates an array of values by running each element in `collection` thru
  30098. * `iteratee`. The iteratee is invoked with three arguments:
  30099. * (value, index|key, collection).
  30100. *
  30101. * Many lodash methods are guarded to work as iteratees for methods like
  30102. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  30103. *
  30104. * The guarded methods are:
  30105. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  30106. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  30107. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  30108. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  30109. *
  30110. * @static
  30111. * @memberOf _
  30112. * @since 0.1.0
  30113. * @category Collection
  30114. * @param {Array|Object} collection The collection to iterate over.
  30115. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30116. * @returns {Array} Returns the new mapped array.
  30117. * @example
  30118. *
  30119. * function square(n) {
  30120. * return n * n;
  30121. * }
  30122. *
  30123. * _.map([4, 8], square);
  30124. * // => [16, 64]
  30125. *
  30126. * _.map({ 'a': 4, 'b': 8 }, square);
  30127. * // => [16, 64] (iteration order is not guaranteed)
  30128. *
  30129. * var users = [
  30130. * { 'user': 'barney' },
  30131. * { 'user': 'fred' }
  30132. * ];
  30133. *
  30134. * // The `_.property` iteratee shorthand.
  30135. * _.map(users, 'user');
  30136. * // => ['barney', 'fred']
  30137. */
  30138. function map(collection, iteratee) {
  30139. var func = isArray(collection) ? arrayMap : baseMap;
  30140. return func(collection, getIteratee(iteratee, 3));
  30141. }
  30142. /**
  30143. * This method is like `_.sortBy` except that it allows specifying the sort
  30144. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  30145. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  30146. * descending or "asc" for ascending sort order of corresponding values.
  30147. *
  30148. * @static
  30149. * @memberOf _
  30150. * @since 4.0.0
  30151. * @category Collection
  30152. * @param {Array|Object} collection The collection to iterate over.
  30153. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  30154. * The iteratees to sort by.
  30155. * @param {string[]} [orders] The sort orders of `iteratees`.
  30156. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  30157. * @returns {Array} Returns the new sorted array.
  30158. * @example
  30159. *
  30160. * var users = [
  30161. * { 'user': 'fred', 'age': 48 },
  30162. * { 'user': 'barney', 'age': 34 },
  30163. * { 'user': 'fred', 'age': 40 },
  30164. * { 'user': 'barney', 'age': 36 }
  30165. * ];
  30166. *
  30167. * // Sort by `user` in ascending order and by `age` in descending order.
  30168. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  30169. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  30170. */
  30171. function orderBy(collection, iteratees, orders, guard) {
  30172. if (collection == null) {
  30173. return [];
  30174. }
  30175. if (!isArray(iteratees)) {
  30176. iteratees = iteratees == null ? [] : [iteratees];
  30177. }
  30178. orders = guard ? undefined : orders;
  30179. if (!isArray(orders)) {
  30180. orders = orders == null ? [] : [orders];
  30181. }
  30182. return baseOrderBy(collection, iteratees, orders);
  30183. }
  30184. /**
  30185. * Creates an array of elements split into two groups, the first of which
  30186. * contains elements `predicate` returns truthy for, the second of which
  30187. * contains elements `predicate` returns falsey for. The predicate is
  30188. * invoked with one argument: (value).
  30189. *
  30190. * @static
  30191. * @memberOf _
  30192. * @since 3.0.0
  30193. * @category Collection
  30194. * @param {Array|Object} collection The collection to iterate over.
  30195. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  30196. * @returns {Array} Returns the array of grouped elements.
  30197. * @example
  30198. *
  30199. * var users = [
  30200. * { 'user': 'barney', 'age': 36, 'active': false },
  30201. * { 'user': 'fred', 'age': 40, 'active': true },
  30202. * { 'user': 'pebbles', 'age': 1, 'active': false }
  30203. * ];
  30204. *
  30205. * _.partition(users, function(o) { return o.active; });
  30206. * // => objects for [['fred'], ['barney', 'pebbles']]
  30207. *
  30208. * // The `_.matches` iteratee shorthand.
  30209. * _.partition(users, { 'age': 1, 'active': false });
  30210. * // => objects for [['pebbles'], ['barney', 'fred']]
  30211. *
  30212. * // The `_.matchesProperty` iteratee shorthand.
  30213. * _.partition(users, ['active', false]);
  30214. * // => objects for [['barney', 'pebbles'], ['fred']]
  30215. *
  30216. * // The `_.property` iteratee shorthand.
  30217. * _.partition(users, 'active');
  30218. * // => objects for [['fred'], ['barney', 'pebbles']]
  30219. */
  30220. var partition = createAggregator(function(result, value, key) {
  30221. result[key ? 0 : 1].push(value);
  30222. }, function() { return [[], []]; });
  30223. /**
  30224. * Reduces `collection` to a value which is the accumulated result of running
  30225. * each element in `collection` thru `iteratee`, where each successive
  30226. * invocation is supplied the return value of the previous. If `accumulator`
  30227. * is not given, the first element of `collection` is used as the initial
  30228. * value. The iteratee is invoked with four arguments:
  30229. * (accumulator, value, index|key, collection).
  30230. *
  30231. * Many lodash methods are guarded to work as iteratees for methods like
  30232. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  30233. *
  30234. * The guarded methods are:
  30235. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  30236. * and `sortBy`
  30237. *
  30238. * @static
  30239. * @memberOf _
  30240. * @since 0.1.0
  30241. * @category Collection
  30242. * @param {Array|Object} collection The collection to iterate over.
  30243. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30244. * @param {*} [accumulator] The initial value.
  30245. * @returns {*} Returns the accumulated value.
  30246. * @see _.reduceRight
  30247. * @example
  30248. *
  30249. * _.reduce([1, 2], function(sum, n) {
  30250. * return sum + n;
  30251. * }, 0);
  30252. * // => 3
  30253. *
  30254. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30255. * (result[value] || (result[value] = [])).push(key);
  30256. * return result;
  30257. * }, {});
  30258. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  30259. */
  30260. function reduce(collection, iteratee, accumulator) {
  30261. var func = isArray(collection) ? arrayReduce : baseReduce,
  30262. initAccum = arguments.length < 3;
  30263. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  30264. }
  30265. /**
  30266. * This method is like `_.reduce` except that it iterates over elements of
  30267. * `collection` from right to left.
  30268. *
  30269. * @static
  30270. * @memberOf _
  30271. * @since 0.1.0
  30272. * @category Collection
  30273. * @param {Array|Object} collection The collection to iterate over.
  30274. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30275. * @param {*} [accumulator] The initial value.
  30276. * @returns {*} Returns the accumulated value.
  30277. * @see _.reduce
  30278. * @example
  30279. *
  30280. * var array = [[0, 1], [2, 3], [4, 5]];
  30281. *
  30282. * _.reduceRight(array, function(flattened, other) {
  30283. * return flattened.concat(other);
  30284. * }, []);
  30285. * // => [4, 5, 2, 3, 0, 1]
  30286. */
  30287. function reduceRight(collection, iteratee, accumulator) {
  30288. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  30289. initAccum = arguments.length < 3;
  30290. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  30291. }
  30292. /**
  30293. * The opposite of `_.filter`; this method returns the elements of `collection`
  30294. * that `predicate` does **not** return truthy for.
  30295. *
  30296. * @static
  30297. * @memberOf _
  30298. * @since 0.1.0
  30299. * @category Collection
  30300. * @param {Array|Object} collection The collection to iterate over.
  30301. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  30302. * @returns {Array} Returns the new filtered array.
  30303. * @see _.filter
  30304. * @example
  30305. *
  30306. * var users = [
  30307. * { 'user': 'barney', 'age': 36, 'active': false },
  30308. * { 'user': 'fred', 'age': 40, 'active': true }
  30309. * ];
  30310. *
  30311. * _.reject(users, function(o) { return !o.active; });
  30312. * // => objects for ['fred']
  30313. *
  30314. * // The `_.matches` iteratee shorthand.
  30315. * _.reject(users, { 'age': 40, 'active': true });
  30316. * // => objects for ['barney']
  30317. *
  30318. * // The `_.matchesProperty` iteratee shorthand.
  30319. * _.reject(users, ['active', false]);
  30320. * // => objects for ['fred']
  30321. *
  30322. * // The `_.property` iteratee shorthand.
  30323. * _.reject(users, 'active');
  30324. * // => objects for ['barney']
  30325. */
  30326. function reject(collection, predicate) {
  30327. var func = isArray(collection) ? arrayFilter : baseFilter;
  30328. return func(collection, negate(getIteratee(predicate, 3)));
  30329. }
  30330. /**
  30331. * Gets a random element from `collection`.
  30332. *
  30333. * @static
  30334. * @memberOf _
  30335. * @since 2.0.0
  30336. * @category Collection
  30337. * @param {Array|Object} collection The collection to sample.
  30338. * @returns {*} Returns the random element.
  30339. * @example
  30340. *
  30341. * _.sample([1, 2, 3, 4]);
  30342. * // => 2
  30343. */
  30344. function sample(collection) {
  30345. var func = isArray(collection) ? arraySample : baseSample;
  30346. return func(collection);
  30347. }
  30348. /**
  30349. * Gets `n` random elements at unique keys from `collection` up to the
  30350. * size of `collection`.
  30351. *
  30352. * @static
  30353. * @memberOf _
  30354. * @since 4.0.0
  30355. * @category Collection
  30356. * @param {Array|Object} collection The collection to sample.
  30357. * @param {number} [n=1] The number of elements to sample.
  30358. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30359. * @returns {Array} Returns the random elements.
  30360. * @example
  30361. *
  30362. * _.sampleSize([1, 2, 3], 2);
  30363. * // => [3, 1]
  30364. *
  30365. * _.sampleSize([1, 2, 3], 4);
  30366. * // => [2, 3, 1]
  30367. */
  30368. function sampleSize(collection, n, guard) {
  30369. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  30370. n = 1;
  30371. } else {
  30372. n = toInteger(n);
  30373. }
  30374. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  30375. return func(collection, n);
  30376. }
  30377. /**
  30378. * Creates an array of shuffled values, using a version of the
  30379. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  30380. *
  30381. * @static
  30382. * @memberOf _
  30383. * @since 0.1.0
  30384. * @category Collection
  30385. * @param {Array|Object} collection The collection to shuffle.
  30386. * @returns {Array} Returns the new shuffled array.
  30387. * @example
  30388. *
  30389. * _.shuffle([1, 2, 3, 4]);
  30390. * // => [4, 1, 3, 2]
  30391. */
  30392. function shuffle(collection) {
  30393. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  30394. return func(collection);
  30395. }
  30396. /**
  30397. * Gets the size of `collection` by returning its length for array-like
  30398. * values or the number of own enumerable string keyed properties for objects.
  30399. *
  30400. * @static
  30401. * @memberOf _
  30402. * @since 0.1.0
  30403. * @category Collection
  30404. * @param {Array|Object|string} collection The collection to inspect.
  30405. * @returns {number} Returns the collection size.
  30406. * @example
  30407. *
  30408. * _.size([1, 2, 3]);
  30409. * // => 3
  30410. *
  30411. * _.size({ 'a': 1, 'b': 2 });
  30412. * // => 2
  30413. *
  30414. * _.size('pebbles');
  30415. * // => 7
  30416. */
  30417. function size(collection) {
  30418. if (collection == null) {
  30419. return 0;
  30420. }
  30421. if (isArrayLike(collection)) {
  30422. return isString(collection) ? stringSize(collection) : collection.length;
  30423. }
  30424. var tag = getTag(collection);
  30425. if (tag == mapTag || tag == setTag) {
  30426. return collection.size;
  30427. }
  30428. return baseKeys(collection).length;
  30429. }
  30430. /**
  30431. * Checks if `predicate` returns truthy for **any** element of `collection`.
  30432. * Iteration is stopped once `predicate` returns truthy. The predicate is
  30433. * invoked with three arguments: (value, index|key, collection).
  30434. *
  30435. * @static
  30436. * @memberOf _
  30437. * @since 0.1.0
  30438. * @category Collection
  30439. * @param {Array|Object} collection The collection to iterate over.
  30440. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  30441. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30442. * @returns {boolean} Returns `true` if any element passes the predicate check,
  30443. * else `false`.
  30444. * @example
  30445. *
  30446. * _.some([null, 0, 'yes', false], Boolean);
  30447. * // => true
  30448. *
  30449. * var users = [
  30450. * { 'user': 'barney', 'active': true },
  30451. * { 'user': 'fred', 'active': false }
  30452. * ];
  30453. *
  30454. * // The `_.matches` iteratee shorthand.
  30455. * _.some(users, { 'user': 'barney', 'active': false });
  30456. * // => false
  30457. *
  30458. * // The `_.matchesProperty` iteratee shorthand.
  30459. * _.some(users, ['active', false]);
  30460. * // => true
  30461. *
  30462. * // The `_.property` iteratee shorthand.
  30463. * _.some(users, 'active');
  30464. * // => true
  30465. */
  30466. function some(collection, predicate, guard) {
  30467. var func = isArray(collection) ? arraySome : baseSome;
  30468. if (guard && isIterateeCall(collection, predicate, guard)) {
  30469. predicate = undefined;
  30470. }
  30471. return func(collection, getIteratee(predicate, 3));
  30472. }
  30473. /**
  30474. * Creates an array of elements, sorted in ascending order by the results of
  30475. * running each element in a collection thru each iteratee. This method
  30476. * performs a stable sort, that is, it preserves the original sort order of
  30477. * equal elements. The iteratees are invoked with one argument: (value).
  30478. *
  30479. * @static
  30480. * @memberOf _
  30481. * @since 0.1.0
  30482. * @category Collection
  30483. * @param {Array|Object} collection The collection to iterate over.
  30484. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  30485. * The iteratees to sort by.
  30486. * @returns {Array} Returns the new sorted array.
  30487. * @example
  30488. *
  30489. * var users = [
  30490. * { 'user': 'fred', 'age': 48 },
  30491. * { 'user': 'barney', 'age': 36 },
  30492. * { 'user': 'fred', 'age': 40 },
  30493. * { 'user': 'barney', 'age': 34 }
  30494. * ];
  30495. *
  30496. * _.sortBy(users, [function(o) { return o.user; }]);
  30497. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  30498. *
  30499. * _.sortBy(users, ['user', 'age']);
  30500. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  30501. */
  30502. var sortBy = baseRest(function(collection, iteratees) {
  30503. if (collection == null) {
  30504. return [];
  30505. }
  30506. var length = iteratees.length;
  30507. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  30508. iteratees = [];
  30509. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  30510. iteratees = [iteratees[0]];
  30511. }
  30512. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  30513. });
  30514. /*------------------------------------------------------------------------*/
  30515. /**
  30516. * Gets the timestamp of the number of milliseconds that have elapsed since
  30517. * the Unix epoch (1 January 1970 00:00:00 UTC).
  30518. *
  30519. * @static
  30520. * @memberOf _
  30521. * @since 2.4.0
  30522. * @category Date
  30523. * @returns {number} Returns the timestamp.
  30524. * @example
  30525. *
  30526. * _.defer(function(stamp) {
  30527. * console.log(_.now() - stamp);
  30528. * }, _.now());
  30529. * // => Logs the number of milliseconds it took for the deferred invocation.
  30530. */
  30531. var now = ctxNow || function() {
  30532. return root.Date.now();
  30533. };
  30534. /*------------------------------------------------------------------------*/
  30535. /**
  30536. * The opposite of `_.before`; this method creates a function that invokes
  30537. * `func` once it's called `n` or more times.
  30538. *
  30539. * @static
  30540. * @memberOf _
  30541. * @since 0.1.0
  30542. * @category Function
  30543. * @param {number} n The number of calls before `func` is invoked.
  30544. * @param {Function} func The function to restrict.
  30545. * @returns {Function} Returns the new restricted function.
  30546. * @example
  30547. *
  30548. * var saves = ['profile', 'settings'];
  30549. *
  30550. * var done = _.after(saves.length, function() {
  30551. * console.log('done saving!');
  30552. * });
  30553. *
  30554. * _.forEach(saves, function(type) {
  30555. * asyncSave({ 'type': type, 'complete': done });
  30556. * });
  30557. * // => Logs 'done saving!' after the two async saves have completed.
  30558. */
  30559. function after(n, func) {
  30560. if (typeof func != 'function') {
  30561. throw new TypeError(FUNC_ERROR_TEXT);
  30562. }
  30563. n = toInteger(n);
  30564. return function() {
  30565. if (--n < 1) {
  30566. return func.apply(this, arguments);
  30567. }
  30568. };
  30569. }
  30570. /**
  30571. * Creates a function that invokes `func`, with up to `n` arguments,
  30572. * ignoring any additional arguments.
  30573. *
  30574. * @static
  30575. * @memberOf _
  30576. * @since 3.0.0
  30577. * @category Function
  30578. * @param {Function} func The function to cap arguments for.
  30579. * @param {number} [n=func.length] The arity cap.
  30580. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30581. * @returns {Function} Returns the new capped function.
  30582. * @example
  30583. *
  30584. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  30585. * // => [6, 8, 10]
  30586. */
  30587. function ary(func, n, guard) {
  30588. n = guard ? undefined : n;
  30589. n = (func && n == null) ? func.length : n;
  30590. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  30591. }
  30592. /**
  30593. * Creates a function that invokes `func`, with the `this` binding and arguments
  30594. * of the created function, while it's called less than `n` times. Subsequent
  30595. * calls to the created function return the result of the last `func` invocation.
  30596. *
  30597. * @static
  30598. * @memberOf _
  30599. * @since 3.0.0
  30600. * @category Function
  30601. * @param {number} n The number of calls at which `func` is no longer invoked.
  30602. * @param {Function} func The function to restrict.
  30603. * @returns {Function} Returns the new restricted function.
  30604. * @example
  30605. *
  30606. * jQuery(element).on('click', _.before(5, addContactToList));
  30607. * // => Allows adding up to 4 contacts to the list.
  30608. */
  30609. function before(n, func) {
  30610. var result;
  30611. if (typeof func != 'function') {
  30612. throw new TypeError(FUNC_ERROR_TEXT);
  30613. }
  30614. n = toInteger(n);
  30615. return function() {
  30616. if (--n > 0) {
  30617. result = func.apply(this, arguments);
  30618. }
  30619. if (n <= 1) {
  30620. func = undefined;
  30621. }
  30622. return result;
  30623. };
  30624. }
  30625. /**
  30626. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  30627. * and `partials` prepended to the arguments it receives.
  30628. *
  30629. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  30630. * may be used as a placeholder for partially applied arguments.
  30631. *
  30632. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  30633. * property of bound functions.
  30634. *
  30635. * @static
  30636. * @memberOf _
  30637. * @since 0.1.0
  30638. * @category Function
  30639. * @param {Function} func The function to bind.
  30640. * @param {*} thisArg The `this` binding of `func`.
  30641. * @param {...*} [partials] The arguments to be partially applied.
  30642. * @returns {Function} Returns the new bound function.
  30643. * @example
  30644. *
  30645. * function greet(greeting, punctuation) {
  30646. * return greeting + ' ' + this.user + punctuation;
  30647. * }
  30648. *
  30649. * var object = { 'user': 'fred' };
  30650. *
  30651. * var bound = _.bind(greet, object, 'hi');
  30652. * bound('!');
  30653. * // => 'hi fred!'
  30654. *
  30655. * // Bound with placeholders.
  30656. * var bound = _.bind(greet, object, _, '!');
  30657. * bound('hi');
  30658. * // => 'hi fred!'
  30659. */
  30660. var bind = baseRest(function(func, thisArg, partials) {
  30661. var bitmask = WRAP_BIND_FLAG;
  30662. if (partials.length) {
  30663. var holders = replaceHolders(partials, getHolder(bind));
  30664. bitmask |= WRAP_PARTIAL_FLAG;
  30665. }
  30666. return createWrap(func, bitmask, thisArg, partials, holders);
  30667. });
  30668. /**
  30669. * Creates a function that invokes the method at `object[key]` with `partials`
  30670. * prepended to the arguments it receives.
  30671. *
  30672. * This method differs from `_.bind` by allowing bound functions to reference
  30673. * methods that may be redefined or don't yet exist. See
  30674. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  30675. * for more details.
  30676. *
  30677. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  30678. * builds, may be used as a placeholder for partially applied arguments.
  30679. *
  30680. * @static
  30681. * @memberOf _
  30682. * @since 0.10.0
  30683. * @category Function
  30684. * @param {Object} object The object to invoke the method on.
  30685. * @param {string} key The key of the method.
  30686. * @param {...*} [partials] The arguments to be partially applied.
  30687. * @returns {Function} Returns the new bound function.
  30688. * @example
  30689. *
  30690. * var object = {
  30691. * 'user': 'fred',
  30692. * 'greet': function(greeting, punctuation) {
  30693. * return greeting + ' ' + this.user + punctuation;
  30694. * }
  30695. * };
  30696. *
  30697. * var bound = _.bindKey(object, 'greet', 'hi');
  30698. * bound('!');
  30699. * // => 'hi fred!'
  30700. *
  30701. * object.greet = function(greeting, punctuation) {
  30702. * return greeting + 'ya ' + this.user + punctuation;
  30703. * };
  30704. *
  30705. * bound('!');
  30706. * // => 'hiya fred!'
  30707. *
  30708. * // Bound with placeholders.
  30709. * var bound = _.bindKey(object, 'greet', _, '!');
  30710. * bound('hi');
  30711. * // => 'hiya fred!'
  30712. */
  30713. var bindKey = baseRest(function(object, key, partials) {
  30714. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  30715. if (partials.length) {
  30716. var holders = replaceHolders(partials, getHolder(bindKey));
  30717. bitmask |= WRAP_PARTIAL_FLAG;
  30718. }
  30719. return createWrap(key, bitmask, object, partials, holders);
  30720. });
  30721. /**
  30722. * Creates a function that accepts arguments of `func` and either invokes
  30723. * `func` returning its result, if at least `arity` number of arguments have
  30724. * been provided, or returns a function that accepts the remaining `func`
  30725. * arguments, and so on. The arity of `func` may be specified if `func.length`
  30726. * is not sufficient.
  30727. *
  30728. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  30729. * may be used as a placeholder for provided arguments.
  30730. *
  30731. * **Note:** This method doesn't set the "length" property of curried functions.
  30732. *
  30733. * @static
  30734. * @memberOf _
  30735. * @since 2.0.0
  30736. * @category Function
  30737. * @param {Function} func The function to curry.
  30738. * @param {number} [arity=func.length] The arity of `func`.
  30739. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30740. * @returns {Function} Returns the new curried function.
  30741. * @example
  30742. *
  30743. * var abc = function(a, b, c) {
  30744. * return [a, b, c];
  30745. * };
  30746. *
  30747. * var curried = _.curry(abc);
  30748. *
  30749. * curried(1)(2)(3);
  30750. * // => [1, 2, 3]
  30751. *
  30752. * curried(1, 2)(3);
  30753. * // => [1, 2, 3]
  30754. *
  30755. * curried(1, 2, 3);
  30756. * // => [1, 2, 3]
  30757. *
  30758. * // Curried with placeholders.
  30759. * curried(1)(_, 3)(2);
  30760. * // => [1, 2, 3]
  30761. */
  30762. function curry(func, arity, guard) {
  30763. arity = guard ? undefined : arity;
  30764. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  30765. result.placeholder = curry.placeholder;
  30766. return result;
  30767. }
  30768. /**
  30769. * This method is like `_.curry` except that arguments are applied to `func`
  30770. * in the manner of `_.partialRight` instead of `_.partial`.
  30771. *
  30772. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  30773. * builds, may be used as a placeholder for provided arguments.
  30774. *
  30775. * **Note:** This method doesn't set the "length" property of curried functions.
  30776. *
  30777. * @static
  30778. * @memberOf _
  30779. * @since 3.0.0
  30780. * @category Function
  30781. * @param {Function} func The function to curry.
  30782. * @param {number} [arity=func.length] The arity of `func`.
  30783. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30784. * @returns {Function} Returns the new curried function.
  30785. * @example
  30786. *
  30787. * var abc = function(a, b, c) {
  30788. * return [a, b, c];
  30789. * };
  30790. *
  30791. * var curried = _.curryRight(abc);
  30792. *
  30793. * curried(3)(2)(1);
  30794. * // => [1, 2, 3]
  30795. *
  30796. * curried(2, 3)(1);
  30797. * // => [1, 2, 3]
  30798. *
  30799. * curried(1, 2, 3);
  30800. * // => [1, 2, 3]
  30801. *
  30802. * // Curried with placeholders.
  30803. * curried(3)(1, _)(2);
  30804. * // => [1, 2, 3]
  30805. */
  30806. function curryRight(func, arity, guard) {
  30807. arity = guard ? undefined : arity;
  30808. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  30809. result.placeholder = curryRight.placeholder;
  30810. return result;
  30811. }
  30812. /**
  30813. * Creates a debounced function that delays invoking `func` until after `wait`
  30814. * milliseconds have elapsed since the last time the debounced function was
  30815. * invoked. The debounced function comes with a `cancel` method to cancel
  30816. * delayed `func` invocations and a `flush` method to immediately invoke them.
  30817. * Provide `options` to indicate whether `func` should be invoked on the
  30818. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  30819. * with the last arguments provided to the debounced function. Subsequent
  30820. * calls to the debounced function return the result of the last `func`
  30821. * invocation.
  30822. *
  30823. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  30824. * invoked on the trailing edge of the timeout only if the debounced function
  30825. * is invoked more than once during the `wait` timeout.
  30826. *
  30827. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  30828. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  30829. *
  30830. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  30831. * for details over the differences between `_.debounce` and `_.throttle`.
  30832. *
  30833. * @static
  30834. * @memberOf _
  30835. * @since 0.1.0
  30836. * @category Function
  30837. * @param {Function} func The function to debounce.
  30838. * @param {number} [wait=0] The number of milliseconds to delay.
  30839. * @param {Object} [options={}] The options object.
  30840. * @param {boolean} [options.leading=false]
  30841. * Specify invoking on the leading edge of the timeout.
  30842. * @param {number} [options.maxWait]
  30843. * The maximum time `func` is allowed to be delayed before it's invoked.
  30844. * @param {boolean} [options.trailing=true]
  30845. * Specify invoking on the trailing edge of the timeout.
  30846. * @returns {Function} Returns the new debounced function.
  30847. * @example
  30848. *
  30849. * // Avoid costly calculations while the window size is in flux.
  30850. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  30851. *
  30852. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  30853. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  30854. * 'leading': true,
  30855. * 'trailing': false
  30856. * }));
  30857. *
  30858. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  30859. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  30860. * var source = new EventSource('/stream');
  30861. * jQuery(source).on('message', debounced);
  30862. *
  30863. * // Cancel the trailing debounced invocation.
  30864. * jQuery(window).on('popstate', debounced.cancel);
  30865. */
  30866. function debounce(func, wait, options) {
  30867. var lastArgs,
  30868. lastThis,
  30869. maxWait,
  30870. result,
  30871. timerId,
  30872. lastCallTime,
  30873. lastInvokeTime = 0,
  30874. leading = false,
  30875. maxing = false,
  30876. trailing = true;
  30877. if (typeof func != 'function') {
  30878. throw new TypeError(FUNC_ERROR_TEXT);
  30879. }
  30880. wait = toNumber(wait) || 0;
  30881. if (isObject(options)) {
  30882. leading = !!options.leading;
  30883. maxing = 'maxWait' in options;
  30884. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  30885. trailing = 'trailing' in options ? !!options.trailing : trailing;
  30886. }
  30887. function invokeFunc(time) {
  30888. var args = lastArgs,
  30889. thisArg = lastThis;
  30890. lastArgs = lastThis = undefined;
  30891. lastInvokeTime = time;
  30892. result = func.apply(thisArg, args);
  30893. return result;
  30894. }
  30895. function leadingEdge(time) {
  30896. // Reset any `maxWait` timer.
  30897. lastInvokeTime = time;
  30898. // Start the timer for the trailing edge.
  30899. timerId = setTimeout(timerExpired, wait);
  30900. // Invoke the leading edge.
  30901. return leading ? invokeFunc(time) : result;
  30902. }
  30903. function remainingWait(time) {
  30904. var timeSinceLastCall = time - lastCallTime,
  30905. timeSinceLastInvoke = time - lastInvokeTime,
  30906. timeWaiting = wait - timeSinceLastCall;
  30907. return maxing
  30908. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  30909. : timeWaiting;
  30910. }
  30911. function shouldInvoke(time) {
  30912. var timeSinceLastCall = time - lastCallTime,
  30913. timeSinceLastInvoke = time - lastInvokeTime;
  30914. // Either this is the first call, activity has stopped and we're at the
  30915. // trailing edge, the system time has gone backwards and we're treating
  30916. // it as the trailing edge, or we've hit the `maxWait` limit.
  30917. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  30918. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  30919. }
  30920. function timerExpired() {
  30921. var time = now();
  30922. if (shouldInvoke(time)) {
  30923. return trailingEdge(time);
  30924. }
  30925. // Restart the timer.
  30926. timerId = setTimeout(timerExpired, remainingWait(time));
  30927. }
  30928. function trailingEdge(time) {
  30929. timerId = undefined;
  30930. // Only invoke if we have `lastArgs` which means `func` has been
  30931. // debounced at least once.
  30932. if (trailing && lastArgs) {
  30933. return invokeFunc(time);
  30934. }
  30935. lastArgs = lastThis = undefined;
  30936. return result;
  30937. }
  30938. function cancel() {
  30939. if (timerId !== undefined) {
  30940. clearTimeout(timerId);
  30941. }
  30942. lastInvokeTime = 0;
  30943. lastArgs = lastCallTime = lastThis = timerId = undefined;
  30944. }
  30945. function flush() {
  30946. return timerId === undefined ? result : trailingEdge(now());
  30947. }
  30948. function debounced() {
  30949. var time = now(),
  30950. isInvoking = shouldInvoke(time);
  30951. lastArgs = arguments;
  30952. lastThis = this;
  30953. lastCallTime = time;
  30954. if (isInvoking) {
  30955. if (timerId === undefined) {
  30956. return leadingEdge(lastCallTime);
  30957. }
  30958. if (maxing) {
  30959. // Handle invocations in a tight loop.
  30960. clearTimeout(timerId);
  30961. timerId = setTimeout(timerExpired, wait);
  30962. return invokeFunc(lastCallTime);
  30963. }
  30964. }
  30965. if (timerId === undefined) {
  30966. timerId = setTimeout(timerExpired, wait);
  30967. }
  30968. return result;
  30969. }
  30970. debounced.cancel = cancel;
  30971. debounced.flush = flush;
  30972. return debounced;
  30973. }
  30974. /**
  30975. * Defers invoking the `func` until the current call stack has cleared. Any
  30976. * additional arguments are provided to `func` when it's invoked.
  30977. *
  30978. * @static
  30979. * @memberOf _
  30980. * @since 0.1.0
  30981. * @category Function
  30982. * @param {Function} func The function to defer.
  30983. * @param {...*} [args] The arguments to invoke `func` with.
  30984. * @returns {number} Returns the timer id.
  30985. * @example
  30986. *
  30987. * _.defer(function(text) {
  30988. * console.log(text);
  30989. * }, 'deferred');
  30990. * // => Logs 'deferred' after one millisecond.
  30991. */
  30992. var defer = baseRest(function(func, args) {
  30993. return baseDelay(func, 1, args);
  30994. });
  30995. /**
  30996. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  30997. * provided to `func` when it's invoked.
  30998. *
  30999. * @static
  31000. * @memberOf _
  31001. * @since 0.1.0
  31002. * @category Function
  31003. * @param {Function} func The function to delay.
  31004. * @param {number} wait The number of milliseconds to delay invocation.
  31005. * @param {...*} [args] The arguments to invoke `func` with.
  31006. * @returns {number} Returns the timer id.
  31007. * @example
  31008. *
  31009. * _.delay(function(text) {
  31010. * console.log(text);
  31011. * }, 1000, 'later');
  31012. * // => Logs 'later' after one second.
  31013. */
  31014. var delay = baseRest(function(func, wait, args) {
  31015. return baseDelay(func, toNumber(wait) || 0, args);
  31016. });
  31017. /**
  31018. * Creates a function that invokes `func` with arguments reversed.
  31019. *
  31020. * @static
  31021. * @memberOf _
  31022. * @since 4.0.0
  31023. * @category Function
  31024. * @param {Function} func The function to flip arguments for.
  31025. * @returns {Function} Returns the new flipped function.
  31026. * @example
  31027. *
  31028. * var flipped = _.flip(function() {
  31029. * return _.toArray(arguments);
  31030. * });
  31031. *
  31032. * flipped('a', 'b', 'c', 'd');
  31033. * // => ['d', 'c', 'b', 'a']
  31034. */
  31035. function flip(func) {
  31036. return createWrap(func, WRAP_FLIP_FLAG);
  31037. }
  31038. /**
  31039. * Creates a function that memoizes the result of `func`. If `resolver` is
  31040. * provided, it determines the cache key for storing the result based on the
  31041. * arguments provided to the memoized function. By default, the first argument
  31042. * provided to the memoized function is used as the map cache key. The `func`
  31043. * is invoked with the `this` binding of the memoized function.
  31044. *
  31045. * **Note:** The cache is exposed as the `cache` property on the memoized
  31046. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  31047. * constructor with one whose instances implement the
  31048. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  31049. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  31050. *
  31051. * @static
  31052. * @memberOf _
  31053. * @since 0.1.0
  31054. * @category Function
  31055. * @param {Function} func The function to have its output memoized.
  31056. * @param {Function} [resolver] The function to resolve the cache key.
  31057. * @returns {Function} Returns the new memoized function.
  31058. * @example
  31059. *
  31060. * var object = { 'a': 1, 'b': 2 };
  31061. * var other = { 'c': 3, 'd': 4 };
  31062. *
  31063. * var values = _.memoize(_.values);
  31064. * values(object);
  31065. * // => [1, 2]
  31066. *
  31067. * values(other);
  31068. * // => [3, 4]
  31069. *
  31070. * object.a = 2;
  31071. * values(object);
  31072. * // => [1, 2]
  31073. *
  31074. * // Modify the result cache.
  31075. * values.cache.set(object, ['a', 'b']);
  31076. * values(object);
  31077. * // => ['a', 'b']
  31078. *
  31079. * // Replace `_.memoize.Cache`.
  31080. * _.memoize.Cache = WeakMap;
  31081. */
  31082. function memoize(func, resolver) {
  31083. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  31084. throw new TypeError(FUNC_ERROR_TEXT);
  31085. }
  31086. var memoized = function() {
  31087. var args = arguments,
  31088. key = resolver ? resolver.apply(this, args) : args[0],
  31089. cache = memoized.cache;
  31090. if (cache.has(key)) {
  31091. return cache.get(key);
  31092. }
  31093. var result = func.apply(this, args);
  31094. memoized.cache = cache.set(key, result) || cache;
  31095. return result;
  31096. };
  31097. memoized.cache = new (memoize.Cache || MapCache);
  31098. return memoized;
  31099. }
  31100. // Expose `MapCache`.
  31101. memoize.Cache = MapCache;
  31102. /**
  31103. * Creates a function that negates the result of the predicate `func`. The
  31104. * `func` predicate is invoked with the `this` binding and arguments of the
  31105. * created function.
  31106. *
  31107. * @static
  31108. * @memberOf _
  31109. * @since 3.0.0
  31110. * @category Function
  31111. * @param {Function} predicate The predicate to negate.
  31112. * @returns {Function} Returns the new negated function.
  31113. * @example
  31114. *
  31115. * function isEven(n) {
  31116. * return n % 2 == 0;
  31117. * }
  31118. *
  31119. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  31120. * // => [1, 3, 5]
  31121. */
  31122. function negate(predicate) {
  31123. if (typeof predicate != 'function') {
  31124. throw new TypeError(FUNC_ERROR_TEXT);
  31125. }
  31126. return function() {
  31127. var args = arguments;
  31128. switch (args.length) {
  31129. case 0: return !predicate.call(this);
  31130. case 1: return !predicate.call(this, args[0]);
  31131. case 2: return !predicate.call(this, args[0], args[1]);
  31132. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  31133. }
  31134. return !predicate.apply(this, args);
  31135. };
  31136. }
  31137. /**
  31138. * Creates a function that is restricted to invoking `func` once. Repeat calls
  31139. * to the function return the value of the first invocation. The `func` is
  31140. * invoked with the `this` binding and arguments of the created function.
  31141. *
  31142. * @static
  31143. * @memberOf _
  31144. * @since 0.1.0
  31145. * @category Function
  31146. * @param {Function} func The function to restrict.
  31147. * @returns {Function} Returns the new restricted function.
  31148. * @example
  31149. *
  31150. * var initialize = _.once(createApplication);
  31151. * initialize();
  31152. * initialize();
  31153. * // => `createApplication` is invoked once
  31154. */
  31155. function once(func) {
  31156. return before(2, func);
  31157. }
  31158. /**
  31159. * Creates a function that invokes `func` with its arguments transformed.
  31160. *
  31161. * @static
  31162. * @since 4.0.0
  31163. * @memberOf _
  31164. * @category Function
  31165. * @param {Function} func The function to wrap.
  31166. * @param {...(Function|Function[])} [transforms=[_.identity]]
  31167. * The argument transforms.
  31168. * @returns {Function} Returns the new function.
  31169. * @example
  31170. *
  31171. * function doubled(n) {
  31172. * return n * 2;
  31173. * }
  31174. *
  31175. * function square(n) {
  31176. * return n * n;
  31177. * }
  31178. *
  31179. * var func = _.overArgs(function(x, y) {
  31180. * return [x, y];
  31181. * }, [square, doubled]);
  31182. *
  31183. * func(9, 3);
  31184. * // => [81, 6]
  31185. *
  31186. * func(10, 5);
  31187. * // => [100, 10]
  31188. */
  31189. var overArgs = castRest(function(func, transforms) {
  31190. transforms = (transforms.length == 1 && isArray(transforms[0]))
  31191. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  31192. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  31193. var funcsLength = transforms.length;
  31194. return baseRest(function(args) {
  31195. var index = -1,
  31196. length = nativeMin(args.length, funcsLength);
  31197. while (++index < length) {
  31198. args[index] = transforms[index].call(this, args[index]);
  31199. }
  31200. return apply(func, this, args);
  31201. });
  31202. });
  31203. /**
  31204. * Creates a function that invokes `func` with `partials` prepended to the
  31205. * arguments it receives. This method is like `_.bind` except it does **not**
  31206. * alter the `this` binding.
  31207. *
  31208. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  31209. * builds, may be used as a placeholder for partially applied arguments.
  31210. *
  31211. * **Note:** This method doesn't set the "length" property of partially
  31212. * applied functions.
  31213. *
  31214. * @static
  31215. * @memberOf _
  31216. * @since 0.2.0
  31217. * @category Function
  31218. * @param {Function} func The function to partially apply arguments to.
  31219. * @param {...*} [partials] The arguments to be partially applied.
  31220. * @returns {Function} Returns the new partially applied function.
  31221. * @example
  31222. *
  31223. * function greet(greeting, name) {
  31224. * return greeting + ' ' + name;
  31225. * }
  31226. *
  31227. * var sayHelloTo = _.partial(greet, 'hello');
  31228. * sayHelloTo('fred');
  31229. * // => 'hello fred'
  31230. *
  31231. * // Partially applied with placeholders.
  31232. * var greetFred = _.partial(greet, _, 'fred');
  31233. * greetFred('hi');
  31234. * // => 'hi fred'
  31235. */
  31236. var partial = baseRest(function(func, partials) {
  31237. var holders = replaceHolders(partials, getHolder(partial));
  31238. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  31239. });
  31240. /**
  31241. * This method is like `_.partial` except that partially applied arguments
  31242. * are appended to the arguments it receives.
  31243. *
  31244. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  31245. * builds, may be used as a placeholder for partially applied arguments.
  31246. *
  31247. * **Note:** This method doesn't set the "length" property of partially
  31248. * applied functions.
  31249. *
  31250. * @static
  31251. * @memberOf _
  31252. * @since 1.0.0
  31253. * @category Function
  31254. * @param {Function} func The function to partially apply arguments to.
  31255. * @param {...*} [partials] The arguments to be partially applied.
  31256. * @returns {Function} Returns the new partially applied function.
  31257. * @example
  31258. *
  31259. * function greet(greeting, name) {
  31260. * return greeting + ' ' + name;
  31261. * }
  31262. *
  31263. * var greetFred = _.partialRight(greet, 'fred');
  31264. * greetFred('hi');
  31265. * // => 'hi fred'
  31266. *
  31267. * // Partially applied with placeholders.
  31268. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  31269. * sayHelloTo('fred');
  31270. * // => 'hello fred'
  31271. */
  31272. var partialRight = baseRest(function(func, partials) {
  31273. var holders = replaceHolders(partials, getHolder(partialRight));
  31274. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  31275. });
  31276. /**
  31277. * Creates a function that invokes `func` with arguments arranged according
  31278. * to the specified `indexes` where the argument value at the first index is
  31279. * provided as the first argument, the argument value at the second index is
  31280. * provided as the second argument, and so on.
  31281. *
  31282. * @static
  31283. * @memberOf _
  31284. * @since 3.0.0
  31285. * @category Function
  31286. * @param {Function} func The function to rearrange arguments for.
  31287. * @param {...(number|number[])} indexes The arranged argument indexes.
  31288. * @returns {Function} Returns the new function.
  31289. * @example
  31290. *
  31291. * var rearged = _.rearg(function(a, b, c) {
  31292. * return [a, b, c];
  31293. * }, [2, 0, 1]);
  31294. *
  31295. * rearged('b', 'c', 'a')
  31296. * // => ['a', 'b', 'c']
  31297. */
  31298. var rearg = flatRest(function(func, indexes) {
  31299. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  31300. });
  31301. /**
  31302. * Creates a function that invokes `func` with the `this` binding of the
  31303. * created function and arguments from `start` and beyond provided as
  31304. * an array.
  31305. *
  31306. * **Note:** This method is based on the
  31307. * [rest parameter](https://mdn.io/rest_parameters).
  31308. *
  31309. * @static
  31310. * @memberOf _
  31311. * @since 4.0.0
  31312. * @category Function
  31313. * @param {Function} func The function to apply a rest parameter to.
  31314. * @param {number} [start=func.length-1] The start position of the rest parameter.
  31315. * @returns {Function} Returns the new function.
  31316. * @example
  31317. *
  31318. * var say = _.rest(function(what, names) {
  31319. * return what + ' ' + _.initial(names).join(', ') +
  31320. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  31321. * });
  31322. *
  31323. * say('hello', 'fred', 'barney', 'pebbles');
  31324. * // => 'hello fred, barney, & pebbles'
  31325. */
  31326. function rest(func, start) {
  31327. if (typeof func != 'function') {
  31328. throw new TypeError(FUNC_ERROR_TEXT);
  31329. }
  31330. start = start === undefined ? start : toInteger(start);
  31331. return baseRest(func, start);
  31332. }
  31333. /**
  31334. * Creates a function that invokes `func` with the `this` binding of the
  31335. * create function and an array of arguments much like
  31336. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  31337. *
  31338. * **Note:** This method is based on the
  31339. * [spread operator](https://mdn.io/spread_operator).
  31340. *
  31341. * @static
  31342. * @memberOf _
  31343. * @since 3.2.0
  31344. * @category Function
  31345. * @param {Function} func The function to spread arguments over.
  31346. * @param {number} [start=0] The start position of the spread.
  31347. * @returns {Function} Returns the new function.
  31348. * @example
  31349. *
  31350. * var say = _.spread(function(who, what) {
  31351. * return who + ' says ' + what;
  31352. * });
  31353. *
  31354. * say(['fred', 'hello']);
  31355. * // => 'fred says hello'
  31356. *
  31357. * var numbers = Promise.all([
  31358. * Promise.resolve(40),
  31359. * Promise.resolve(36)
  31360. * ]);
  31361. *
  31362. * numbers.then(_.spread(function(x, y) {
  31363. * return x + y;
  31364. * }));
  31365. * // => a Promise of 76
  31366. */
  31367. function spread(func, start) {
  31368. if (typeof func != 'function') {
  31369. throw new TypeError(FUNC_ERROR_TEXT);
  31370. }
  31371. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  31372. return baseRest(function(args) {
  31373. var array = args[start],
  31374. otherArgs = castSlice(args, 0, start);
  31375. if (array) {
  31376. arrayPush(otherArgs, array);
  31377. }
  31378. return apply(func, this, otherArgs);
  31379. });
  31380. }
  31381. /**
  31382. * Creates a throttled function that only invokes `func` at most once per
  31383. * every `wait` milliseconds. The throttled function comes with a `cancel`
  31384. * method to cancel delayed `func` invocations and a `flush` method to
  31385. * immediately invoke them. Provide `options` to indicate whether `func`
  31386. * should be invoked on the leading and/or trailing edge of the `wait`
  31387. * timeout. The `func` is invoked with the last arguments provided to the
  31388. * throttled function. Subsequent calls to the throttled function return the
  31389. * result of the last `func` invocation.
  31390. *
  31391. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  31392. * invoked on the trailing edge of the timeout only if the throttled function
  31393. * is invoked more than once during the `wait` timeout.
  31394. *
  31395. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  31396. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  31397. *
  31398. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  31399. * for details over the differences between `_.throttle` and `_.debounce`.
  31400. *
  31401. * @static
  31402. * @memberOf _
  31403. * @since 0.1.0
  31404. * @category Function
  31405. * @param {Function} func The function to throttle.
  31406. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  31407. * @param {Object} [options={}] The options object.
  31408. * @param {boolean} [options.leading=true]
  31409. * Specify invoking on the leading edge of the timeout.
  31410. * @param {boolean} [options.trailing=true]
  31411. * Specify invoking on the trailing edge of the timeout.
  31412. * @returns {Function} Returns the new throttled function.
  31413. * @example
  31414. *
  31415. * // Avoid excessively updating the position while scrolling.
  31416. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  31417. *
  31418. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  31419. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  31420. * jQuery(element).on('click', throttled);
  31421. *
  31422. * // Cancel the trailing throttled invocation.
  31423. * jQuery(window).on('popstate', throttled.cancel);
  31424. */
  31425. function throttle(func, wait, options) {
  31426. var leading = true,
  31427. trailing = true;
  31428. if (typeof func != 'function') {
  31429. throw new TypeError(FUNC_ERROR_TEXT);
  31430. }
  31431. if (isObject(options)) {
  31432. leading = 'leading' in options ? !!options.leading : leading;
  31433. trailing = 'trailing' in options ? !!options.trailing : trailing;
  31434. }
  31435. return debounce(func, wait, {
  31436. 'leading': leading,
  31437. 'maxWait': wait,
  31438. 'trailing': trailing
  31439. });
  31440. }
  31441. /**
  31442. * Creates a function that accepts up to one argument, ignoring any
  31443. * additional arguments.
  31444. *
  31445. * @static
  31446. * @memberOf _
  31447. * @since 4.0.0
  31448. * @category Function
  31449. * @param {Function} func The function to cap arguments for.
  31450. * @returns {Function} Returns the new capped function.
  31451. * @example
  31452. *
  31453. * _.map(['6', '8', '10'], _.unary(parseInt));
  31454. * // => [6, 8, 10]
  31455. */
  31456. function unary(func) {
  31457. return ary(func, 1);
  31458. }
  31459. /**
  31460. * Creates a function that provides `value` to `wrapper` as its first
  31461. * argument. Any additional arguments provided to the function are appended
  31462. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  31463. * binding of the created function.
  31464. *
  31465. * @static
  31466. * @memberOf _
  31467. * @since 0.1.0
  31468. * @category Function
  31469. * @param {*} value The value to wrap.
  31470. * @param {Function} [wrapper=identity] The wrapper function.
  31471. * @returns {Function} Returns the new function.
  31472. * @example
  31473. *
  31474. * var p = _.wrap(_.escape, function(func, text) {
  31475. * return '<p>' + func(text) + '</p>';
  31476. * });
  31477. *
  31478. * p('fred, barney, & pebbles');
  31479. * // => '<p>fred, barney, &amp; pebbles</p>'
  31480. */
  31481. function wrap(value, wrapper) {
  31482. return partial(castFunction(wrapper), value);
  31483. }
  31484. /*------------------------------------------------------------------------*/
  31485. /**
  31486. * Casts `value` as an array if it's not one.
  31487. *
  31488. * @static
  31489. * @memberOf _
  31490. * @since 4.4.0
  31491. * @category Lang
  31492. * @param {*} value The value to inspect.
  31493. * @returns {Array} Returns the cast array.
  31494. * @example
  31495. *
  31496. * _.castArray(1);
  31497. * // => [1]
  31498. *
  31499. * _.castArray({ 'a': 1 });
  31500. * // => [{ 'a': 1 }]
  31501. *
  31502. * _.castArray('abc');
  31503. * // => ['abc']
  31504. *
  31505. * _.castArray(null);
  31506. * // => [null]
  31507. *
  31508. * _.castArray(undefined);
  31509. * // => [undefined]
  31510. *
  31511. * _.castArray();
  31512. * // => []
  31513. *
  31514. * var array = [1, 2, 3];
  31515. * console.log(_.castArray(array) === array);
  31516. * // => true
  31517. */
  31518. function castArray() {
  31519. if (!arguments.length) {
  31520. return [];
  31521. }
  31522. var value = arguments[0];
  31523. return isArray(value) ? value : [value];
  31524. }
  31525. /**
  31526. * Creates a shallow clone of `value`.
  31527. *
  31528. * **Note:** This method is loosely based on the
  31529. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  31530. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  31531. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  31532. * arrays. The own enumerable properties of `arguments` objects are cloned
  31533. * as plain objects. An empty object is returned for uncloneable values such
  31534. * as error objects, functions, DOM nodes, and WeakMaps.
  31535. *
  31536. * @static
  31537. * @memberOf _
  31538. * @since 0.1.0
  31539. * @category Lang
  31540. * @param {*} value The value to clone.
  31541. * @returns {*} Returns the cloned value.
  31542. * @see _.cloneDeep
  31543. * @example
  31544. *
  31545. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  31546. *
  31547. * var shallow = _.clone(objects);
  31548. * console.log(shallow[0] === objects[0]);
  31549. * // => true
  31550. */
  31551. function clone(value) {
  31552. return baseClone(value, CLONE_SYMBOLS_FLAG);
  31553. }
  31554. /**
  31555. * This method is like `_.clone` except that it accepts `customizer` which
  31556. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  31557. * cloning is handled by the method instead. The `customizer` is invoked with
  31558. * up to four arguments; (value [, index|key, object, stack]).
  31559. *
  31560. * @static
  31561. * @memberOf _
  31562. * @since 4.0.0
  31563. * @category Lang
  31564. * @param {*} value The value to clone.
  31565. * @param {Function} [customizer] The function to customize cloning.
  31566. * @returns {*} Returns the cloned value.
  31567. * @see _.cloneDeepWith
  31568. * @example
  31569. *
  31570. * function customizer(value) {
  31571. * if (_.isElement(value)) {
  31572. * return value.cloneNode(false);
  31573. * }
  31574. * }
  31575. *
  31576. * var el = _.cloneWith(document.body, customizer);
  31577. *
  31578. * console.log(el === document.body);
  31579. * // => false
  31580. * console.log(el.nodeName);
  31581. * // => 'BODY'
  31582. * console.log(el.childNodes.length);
  31583. * // => 0
  31584. */
  31585. function cloneWith(value, customizer) {
  31586. customizer = typeof customizer == 'function' ? customizer : undefined;
  31587. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  31588. }
  31589. /**
  31590. * This method is like `_.clone` except that it recursively clones `value`.
  31591. *
  31592. * @static
  31593. * @memberOf _
  31594. * @since 1.0.0
  31595. * @category Lang
  31596. * @param {*} value The value to recursively clone.
  31597. * @returns {*} Returns the deep cloned value.
  31598. * @see _.clone
  31599. * @example
  31600. *
  31601. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  31602. *
  31603. * var deep = _.cloneDeep(objects);
  31604. * console.log(deep[0] === objects[0]);
  31605. * // => false
  31606. */
  31607. function cloneDeep(value) {
  31608. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  31609. }
  31610. /**
  31611. * This method is like `_.cloneWith` except that it recursively clones `value`.
  31612. *
  31613. * @static
  31614. * @memberOf _
  31615. * @since 4.0.0
  31616. * @category Lang
  31617. * @param {*} value The value to recursively clone.
  31618. * @param {Function} [customizer] The function to customize cloning.
  31619. * @returns {*} Returns the deep cloned value.
  31620. * @see _.cloneWith
  31621. * @example
  31622. *
  31623. * function customizer(value) {
  31624. * if (_.isElement(value)) {
  31625. * return value.cloneNode(true);
  31626. * }
  31627. * }
  31628. *
  31629. * var el = _.cloneDeepWith(document.body, customizer);
  31630. *
  31631. * console.log(el === document.body);
  31632. * // => false
  31633. * console.log(el.nodeName);
  31634. * // => 'BODY'
  31635. * console.log(el.childNodes.length);
  31636. * // => 20
  31637. */
  31638. function cloneDeepWith(value, customizer) {
  31639. customizer = typeof customizer == 'function' ? customizer : undefined;
  31640. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  31641. }
  31642. /**
  31643. * Checks if `object` conforms to `source` by invoking the predicate
  31644. * properties of `source` with the corresponding property values of `object`.
  31645. *
  31646. * **Note:** This method is equivalent to `_.conforms` when `source` is
  31647. * partially applied.
  31648. *
  31649. * @static
  31650. * @memberOf _
  31651. * @since 4.14.0
  31652. * @category Lang
  31653. * @param {Object} object The object to inspect.
  31654. * @param {Object} source The object of property predicates to conform to.
  31655. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  31656. * @example
  31657. *
  31658. * var object = { 'a': 1, 'b': 2 };
  31659. *
  31660. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  31661. * // => true
  31662. *
  31663. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  31664. * // => false
  31665. */
  31666. function conformsTo(object, source) {
  31667. return source == null || baseConformsTo(object, source, keys(source));
  31668. }
  31669. /**
  31670. * Performs a
  31671. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  31672. * comparison between two values to determine if they are equivalent.
  31673. *
  31674. * @static
  31675. * @memberOf _
  31676. * @since 4.0.0
  31677. * @category Lang
  31678. * @param {*} value The value to compare.
  31679. * @param {*} other The other value to compare.
  31680. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  31681. * @example
  31682. *
  31683. * var object = { 'a': 1 };
  31684. * var other = { 'a': 1 };
  31685. *
  31686. * _.eq(object, object);
  31687. * // => true
  31688. *
  31689. * _.eq(object, other);
  31690. * // => false
  31691. *
  31692. * _.eq('a', 'a');
  31693. * // => true
  31694. *
  31695. * _.eq('a', Object('a'));
  31696. * // => false
  31697. *
  31698. * _.eq(NaN, NaN);
  31699. * // => true
  31700. */
  31701. function eq(value, other) {
  31702. return value === other || (value !== value && other !== other);
  31703. }
  31704. /**
  31705. * Checks if `value` is greater than `other`.
  31706. *
  31707. * @static
  31708. * @memberOf _
  31709. * @since 3.9.0
  31710. * @category Lang
  31711. * @param {*} value The value to compare.
  31712. * @param {*} other The other value to compare.
  31713. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  31714. * else `false`.
  31715. * @see _.lt
  31716. * @example
  31717. *
  31718. * _.gt(3, 1);
  31719. * // => true
  31720. *
  31721. * _.gt(3, 3);
  31722. * // => false
  31723. *
  31724. * _.gt(1, 3);
  31725. * // => false
  31726. */
  31727. var gt = createRelationalOperation(baseGt);
  31728. /**
  31729. * Checks if `value` is greater than or equal to `other`.
  31730. *
  31731. * @static
  31732. * @memberOf _
  31733. * @since 3.9.0
  31734. * @category Lang
  31735. * @param {*} value The value to compare.
  31736. * @param {*} other The other value to compare.
  31737. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  31738. * `other`, else `false`.
  31739. * @see _.lte
  31740. * @example
  31741. *
  31742. * _.gte(3, 1);
  31743. * // => true
  31744. *
  31745. * _.gte(3, 3);
  31746. * // => true
  31747. *
  31748. * _.gte(1, 3);
  31749. * // => false
  31750. */
  31751. var gte = createRelationalOperation(function(value, other) {
  31752. return value >= other;
  31753. });
  31754. /**
  31755. * Checks if `value` is likely an `arguments` object.
  31756. *
  31757. * @static
  31758. * @memberOf _
  31759. * @since 0.1.0
  31760. * @category Lang
  31761. * @param {*} value The value to check.
  31762. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  31763. * else `false`.
  31764. * @example
  31765. *
  31766. * _.isArguments(function() { return arguments; }());
  31767. * // => true
  31768. *
  31769. * _.isArguments([1, 2, 3]);
  31770. * // => false
  31771. */
  31772. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  31773. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  31774. !propertyIsEnumerable.call(value, 'callee');
  31775. };
  31776. /**
  31777. * Checks if `value` is classified as an `Array` object.
  31778. *
  31779. * @static
  31780. * @memberOf _
  31781. * @since 0.1.0
  31782. * @category Lang
  31783. * @param {*} value The value to check.
  31784. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  31785. * @example
  31786. *
  31787. * _.isArray([1, 2, 3]);
  31788. * // => true
  31789. *
  31790. * _.isArray(document.body.children);
  31791. * // => false
  31792. *
  31793. * _.isArray('abc');
  31794. * // => false
  31795. *
  31796. * _.isArray(_.noop);
  31797. * // => false
  31798. */
  31799. var isArray = Array.isArray;
  31800. /**
  31801. * Checks if `value` is classified as an `ArrayBuffer` object.
  31802. *
  31803. * @static
  31804. * @memberOf _
  31805. * @since 4.3.0
  31806. * @category Lang
  31807. * @param {*} value The value to check.
  31808. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  31809. * @example
  31810. *
  31811. * _.isArrayBuffer(new ArrayBuffer(2));
  31812. * // => true
  31813. *
  31814. * _.isArrayBuffer(new Array(2));
  31815. * // => false
  31816. */
  31817. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  31818. /**
  31819. * Checks if `value` is array-like. A value is considered array-like if it's
  31820. * not a function and has a `value.length` that's an integer greater than or
  31821. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  31822. *
  31823. * @static
  31824. * @memberOf _
  31825. * @since 4.0.0
  31826. * @category Lang
  31827. * @param {*} value The value to check.
  31828. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  31829. * @example
  31830. *
  31831. * _.isArrayLike([1, 2, 3]);
  31832. * // => true
  31833. *
  31834. * _.isArrayLike(document.body.children);
  31835. * // => true
  31836. *
  31837. * _.isArrayLike('abc');
  31838. * // => true
  31839. *
  31840. * _.isArrayLike(_.noop);
  31841. * // => false
  31842. */
  31843. function isArrayLike(value) {
  31844. return value != null && isLength(value.length) && !isFunction(value);
  31845. }
  31846. /**
  31847. * This method is like `_.isArrayLike` except that it also checks if `value`
  31848. * is an object.
  31849. *
  31850. * @static
  31851. * @memberOf _
  31852. * @since 4.0.0
  31853. * @category Lang
  31854. * @param {*} value The value to check.
  31855. * @returns {boolean} Returns `true` if `value` is an array-like object,
  31856. * else `false`.
  31857. * @example
  31858. *
  31859. * _.isArrayLikeObject([1, 2, 3]);
  31860. * // => true
  31861. *
  31862. * _.isArrayLikeObject(document.body.children);
  31863. * // => true
  31864. *
  31865. * _.isArrayLikeObject('abc');
  31866. * // => false
  31867. *
  31868. * _.isArrayLikeObject(_.noop);
  31869. * // => false
  31870. */
  31871. function isArrayLikeObject(value) {
  31872. return isObjectLike(value) && isArrayLike(value);
  31873. }
  31874. /**
  31875. * Checks if `value` is classified as a boolean primitive or object.
  31876. *
  31877. * @static
  31878. * @memberOf _
  31879. * @since 0.1.0
  31880. * @category Lang
  31881. * @param {*} value The value to check.
  31882. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  31883. * @example
  31884. *
  31885. * _.isBoolean(false);
  31886. * // => true
  31887. *
  31888. * _.isBoolean(null);
  31889. * // => false
  31890. */
  31891. function isBoolean(value) {
  31892. return value === true || value === false ||
  31893. (isObjectLike(value) && baseGetTag(value) == boolTag);
  31894. }
  31895. /**
  31896. * Checks if `value` is a buffer.
  31897. *
  31898. * @static
  31899. * @memberOf _
  31900. * @since 4.3.0
  31901. * @category Lang
  31902. * @param {*} value The value to check.
  31903. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  31904. * @example
  31905. *
  31906. * _.isBuffer(new Buffer(2));
  31907. * // => true
  31908. *
  31909. * _.isBuffer(new Uint8Array(2));
  31910. * // => false
  31911. */
  31912. var isBuffer = nativeIsBuffer || stubFalse;
  31913. /**
  31914. * Checks if `value` is classified as a `Date` object.
  31915. *
  31916. * @static
  31917. * @memberOf _
  31918. * @since 0.1.0
  31919. * @category Lang
  31920. * @param {*} value The value to check.
  31921. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  31922. * @example
  31923. *
  31924. * _.isDate(new Date);
  31925. * // => true
  31926. *
  31927. * _.isDate('Mon April 23 2012');
  31928. * // => false
  31929. */
  31930. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  31931. /**
  31932. * Checks if `value` is likely a DOM element.
  31933. *
  31934. * @static
  31935. * @memberOf _
  31936. * @since 0.1.0
  31937. * @category Lang
  31938. * @param {*} value The value to check.
  31939. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  31940. * @example
  31941. *
  31942. * _.isElement(document.body);
  31943. * // => true
  31944. *
  31945. * _.isElement('<body>');
  31946. * // => false
  31947. */
  31948. function isElement(value) {
  31949. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  31950. }
  31951. /**
  31952. * Checks if `value` is an empty object, collection, map, or set.
  31953. *
  31954. * Objects are considered empty if they have no own enumerable string keyed
  31955. * properties.
  31956. *
  31957. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  31958. * jQuery-like collections are considered empty if they have a `length` of `0`.
  31959. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  31960. *
  31961. * @static
  31962. * @memberOf _
  31963. * @since 0.1.0
  31964. * @category Lang
  31965. * @param {*} value The value to check.
  31966. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  31967. * @example
  31968. *
  31969. * _.isEmpty(null);
  31970. * // => true
  31971. *
  31972. * _.isEmpty(true);
  31973. * // => true
  31974. *
  31975. * _.isEmpty(1);
  31976. * // => true
  31977. *
  31978. * _.isEmpty([1, 2, 3]);
  31979. * // => false
  31980. *
  31981. * _.isEmpty({ 'a': 1 });
  31982. * // => false
  31983. */
  31984. function isEmpty(value) {
  31985. if (value == null) {
  31986. return true;
  31987. }
  31988. if (isArrayLike(value) &&
  31989. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  31990. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  31991. return !value.length;
  31992. }
  31993. var tag = getTag(value);
  31994. if (tag == mapTag || tag == setTag) {
  31995. return !value.size;
  31996. }
  31997. if (isPrototype(value)) {
  31998. return !baseKeys(value).length;
  31999. }
  32000. for (var key in value) {
  32001. if (hasOwnProperty.call(value, key)) {
  32002. return false;
  32003. }
  32004. }
  32005. return true;
  32006. }
  32007. /**
  32008. * Performs a deep comparison between two values to determine if they are
  32009. * equivalent.
  32010. *
  32011. * **Note:** This method supports comparing arrays, array buffers, booleans,
  32012. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  32013. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  32014. * by their own, not inherited, enumerable properties. Functions and DOM
  32015. * nodes are compared by strict equality, i.e. `===`.
  32016. *
  32017. * @static
  32018. * @memberOf _
  32019. * @since 0.1.0
  32020. * @category Lang
  32021. * @param {*} value The value to compare.
  32022. * @param {*} other The other value to compare.
  32023. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  32024. * @example
  32025. *
  32026. * var object = { 'a': 1 };
  32027. * var other = { 'a': 1 };
  32028. *
  32029. * _.isEqual(object, other);
  32030. * // => true
  32031. *
  32032. * object === other;
  32033. * // => false
  32034. */
  32035. function isEqual(value, other) {
  32036. return baseIsEqual(value, other);
  32037. }
  32038. /**
  32039. * This method is like `_.isEqual` except that it accepts `customizer` which
  32040. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  32041. * are handled by the method instead. The `customizer` is invoked with up to
  32042. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  32043. *
  32044. * @static
  32045. * @memberOf _
  32046. * @since 4.0.0
  32047. * @category Lang
  32048. * @param {*} value The value to compare.
  32049. * @param {*} other The other value to compare.
  32050. * @param {Function} [customizer] The function to customize comparisons.
  32051. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  32052. * @example
  32053. *
  32054. * function isGreeting(value) {
  32055. * return /^h(?:i|ello)$/.test(value);
  32056. * }
  32057. *
  32058. * function customizer(objValue, othValue) {
  32059. * if (isGreeting(objValue) && isGreeting(othValue)) {
  32060. * return true;
  32061. * }
  32062. * }
  32063. *
  32064. * var array = ['hello', 'goodbye'];
  32065. * var other = ['hi', 'goodbye'];
  32066. *
  32067. * _.isEqualWith(array, other, customizer);
  32068. * // => true
  32069. */
  32070. function isEqualWith(value, other, customizer) {
  32071. customizer = typeof customizer == 'function' ? customizer : undefined;
  32072. var result = customizer ? customizer(value, other) : undefined;
  32073. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  32074. }
  32075. /**
  32076. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  32077. * `SyntaxError`, `TypeError`, or `URIError` object.
  32078. *
  32079. * @static
  32080. * @memberOf _
  32081. * @since 3.0.0
  32082. * @category Lang
  32083. * @param {*} value The value to check.
  32084. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  32085. * @example
  32086. *
  32087. * _.isError(new Error);
  32088. * // => true
  32089. *
  32090. * _.isError(Error);
  32091. * // => false
  32092. */
  32093. function isError(value) {
  32094. if (!isObjectLike(value)) {
  32095. return false;
  32096. }
  32097. var tag = baseGetTag(value);
  32098. return tag == errorTag || tag == domExcTag ||
  32099. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  32100. }
  32101. /**
  32102. * Checks if `value` is a finite primitive number.
  32103. *
  32104. * **Note:** This method is based on
  32105. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  32106. *
  32107. * @static
  32108. * @memberOf _
  32109. * @since 0.1.0
  32110. * @category Lang
  32111. * @param {*} value The value to check.
  32112. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  32113. * @example
  32114. *
  32115. * _.isFinite(3);
  32116. * // => true
  32117. *
  32118. * _.isFinite(Number.MIN_VALUE);
  32119. * // => true
  32120. *
  32121. * _.isFinite(Infinity);
  32122. * // => false
  32123. *
  32124. * _.isFinite('3');
  32125. * // => false
  32126. */
  32127. function isFinite(value) {
  32128. return typeof value == 'number' && nativeIsFinite(value);
  32129. }
  32130. /**
  32131. * Checks if `value` is classified as a `Function` object.
  32132. *
  32133. * @static
  32134. * @memberOf _
  32135. * @since 0.1.0
  32136. * @category Lang
  32137. * @param {*} value The value to check.
  32138. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  32139. * @example
  32140. *
  32141. * _.isFunction(_);
  32142. * // => true
  32143. *
  32144. * _.isFunction(/abc/);
  32145. * // => false
  32146. */
  32147. function isFunction(value) {
  32148. if (!isObject(value)) {
  32149. return false;
  32150. }
  32151. // The use of `Object#toString` avoids issues with the `typeof` operator
  32152. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  32153. var tag = baseGetTag(value);
  32154. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  32155. }
  32156. /**
  32157. * Checks if `value` is an integer.
  32158. *
  32159. * **Note:** This method is based on
  32160. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  32161. *
  32162. * @static
  32163. * @memberOf _
  32164. * @since 4.0.0
  32165. * @category Lang
  32166. * @param {*} value The value to check.
  32167. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  32168. * @example
  32169. *
  32170. * _.isInteger(3);
  32171. * // => true
  32172. *
  32173. * _.isInteger(Number.MIN_VALUE);
  32174. * // => false
  32175. *
  32176. * _.isInteger(Infinity);
  32177. * // => false
  32178. *
  32179. * _.isInteger('3');
  32180. * // => false
  32181. */
  32182. function isInteger(value) {
  32183. return typeof value == 'number' && value == toInteger(value);
  32184. }
  32185. /**
  32186. * Checks if `value` is a valid array-like length.
  32187. *
  32188. * **Note:** This method is loosely based on
  32189. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  32190. *
  32191. * @static
  32192. * @memberOf _
  32193. * @since 4.0.0
  32194. * @category Lang
  32195. * @param {*} value The value to check.
  32196. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  32197. * @example
  32198. *
  32199. * _.isLength(3);
  32200. * // => true
  32201. *
  32202. * _.isLength(Number.MIN_VALUE);
  32203. * // => false
  32204. *
  32205. * _.isLength(Infinity);
  32206. * // => false
  32207. *
  32208. * _.isLength('3');
  32209. * // => false
  32210. */
  32211. function isLength(value) {
  32212. return typeof value == 'number' &&
  32213. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  32214. }
  32215. /**
  32216. * Checks if `value` is the
  32217. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  32218. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  32219. *
  32220. * @static
  32221. * @memberOf _
  32222. * @since 0.1.0
  32223. * @category Lang
  32224. * @param {*} value The value to check.
  32225. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  32226. * @example
  32227. *
  32228. * _.isObject({});
  32229. * // => true
  32230. *
  32231. * _.isObject([1, 2, 3]);
  32232. * // => true
  32233. *
  32234. * _.isObject(_.noop);
  32235. * // => true
  32236. *
  32237. * _.isObject(null);
  32238. * // => false
  32239. */
  32240. function isObject(value) {
  32241. var type = typeof value;
  32242. return value != null && (type == 'object' || type == 'function');
  32243. }
  32244. /**
  32245. * Checks if `value` is object-like. A value is object-like if it's not `null`
  32246. * and has a `typeof` result of "object".
  32247. *
  32248. * @static
  32249. * @memberOf _
  32250. * @since 4.0.0
  32251. * @category Lang
  32252. * @param {*} value The value to check.
  32253. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  32254. * @example
  32255. *
  32256. * _.isObjectLike({});
  32257. * // => true
  32258. *
  32259. * _.isObjectLike([1, 2, 3]);
  32260. * // => true
  32261. *
  32262. * _.isObjectLike(_.noop);
  32263. * // => false
  32264. *
  32265. * _.isObjectLike(null);
  32266. * // => false
  32267. */
  32268. function isObjectLike(value) {
  32269. return value != null && typeof value == 'object';
  32270. }
  32271. /**
  32272. * Checks if `value` is classified as a `Map` object.
  32273. *
  32274. * @static
  32275. * @memberOf _
  32276. * @since 4.3.0
  32277. * @category Lang
  32278. * @param {*} value The value to check.
  32279. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  32280. * @example
  32281. *
  32282. * _.isMap(new Map);
  32283. * // => true
  32284. *
  32285. * _.isMap(new WeakMap);
  32286. * // => false
  32287. */
  32288. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  32289. /**
  32290. * Performs a partial deep comparison between `object` and `source` to
  32291. * determine if `object` contains equivalent property values.
  32292. *
  32293. * **Note:** This method is equivalent to `_.matches` when `source` is
  32294. * partially applied.
  32295. *
  32296. * Partial comparisons will match empty array and empty object `source`
  32297. * values against any array or object value, respectively. See `_.isEqual`
  32298. * for a list of supported value comparisons.
  32299. *
  32300. * @static
  32301. * @memberOf _
  32302. * @since 3.0.0
  32303. * @category Lang
  32304. * @param {Object} object The object to inspect.
  32305. * @param {Object} source The object of property values to match.
  32306. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  32307. * @example
  32308. *
  32309. * var object = { 'a': 1, 'b': 2 };
  32310. *
  32311. * _.isMatch(object, { 'b': 2 });
  32312. * // => true
  32313. *
  32314. * _.isMatch(object, { 'b': 1 });
  32315. * // => false
  32316. */
  32317. function isMatch(object, source) {
  32318. return object === source || baseIsMatch(object, source, getMatchData(source));
  32319. }
  32320. /**
  32321. * This method is like `_.isMatch` except that it accepts `customizer` which
  32322. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  32323. * are handled by the method instead. The `customizer` is invoked with five
  32324. * arguments: (objValue, srcValue, index|key, object, source).
  32325. *
  32326. * @static
  32327. * @memberOf _
  32328. * @since 4.0.0
  32329. * @category Lang
  32330. * @param {Object} object The object to inspect.
  32331. * @param {Object} source The object of property values to match.
  32332. * @param {Function} [customizer] The function to customize comparisons.
  32333. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  32334. * @example
  32335. *
  32336. * function isGreeting(value) {
  32337. * return /^h(?:i|ello)$/.test(value);
  32338. * }
  32339. *
  32340. * function customizer(objValue, srcValue) {
  32341. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  32342. * return true;
  32343. * }
  32344. * }
  32345. *
  32346. * var object = { 'greeting': 'hello' };
  32347. * var source = { 'greeting': 'hi' };
  32348. *
  32349. * _.isMatchWith(object, source, customizer);
  32350. * // => true
  32351. */
  32352. function isMatchWith(object, source, customizer) {
  32353. customizer = typeof customizer == 'function' ? customizer : undefined;
  32354. return baseIsMatch(object, source, getMatchData(source), customizer);
  32355. }
  32356. /**
  32357. * Checks if `value` is `NaN`.
  32358. *
  32359. * **Note:** This method is based on
  32360. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  32361. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  32362. * `undefined` and other non-number values.
  32363. *
  32364. * @static
  32365. * @memberOf _
  32366. * @since 0.1.0
  32367. * @category Lang
  32368. * @param {*} value The value to check.
  32369. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  32370. * @example
  32371. *
  32372. * _.isNaN(NaN);
  32373. * // => true
  32374. *
  32375. * _.isNaN(new Number(NaN));
  32376. * // => true
  32377. *
  32378. * isNaN(undefined);
  32379. * // => true
  32380. *
  32381. * _.isNaN(undefined);
  32382. * // => false
  32383. */
  32384. function isNaN(value) {
  32385. // An `NaN` primitive is the only value that is not equal to itself.
  32386. // Perform the `toStringTag` check first to avoid errors with some
  32387. // ActiveX objects in IE.
  32388. return isNumber(value) && value != +value;
  32389. }
  32390. /**
  32391. * Checks if `value` is a pristine native function.
  32392. *
  32393. * **Note:** This method can't reliably detect native functions in the presence
  32394. * of the core-js package because core-js circumvents this kind of detection.
  32395. * Despite multiple requests, the core-js maintainer has made it clear: any
  32396. * attempt to fix the detection will be obstructed. As a result, we're left
  32397. * with little choice but to throw an error. Unfortunately, this also affects
  32398. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  32399. * which rely on core-js.
  32400. *
  32401. * @static
  32402. * @memberOf _
  32403. * @since 3.0.0
  32404. * @category Lang
  32405. * @param {*} value The value to check.
  32406. * @returns {boolean} Returns `true` if `value` is a native function,
  32407. * else `false`.
  32408. * @example
  32409. *
  32410. * _.isNative(Array.prototype.push);
  32411. * // => true
  32412. *
  32413. * _.isNative(_);
  32414. * // => false
  32415. */
  32416. function isNative(value) {
  32417. if (isMaskable(value)) {
  32418. throw new Error(CORE_ERROR_TEXT);
  32419. }
  32420. return baseIsNative(value);
  32421. }
  32422. /**
  32423. * Checks if `value` is `null`.
  32424. *
  32425. * @static
  32426. * @memberOf _
  32427. * @since 0.1.0
  32428. * @category Lang
  32429. * @param {*} value The value to check.
  32430. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  32431. * @example
  32432. *
  32433. * _.isNull(null);
  32434. * // => true
  32435. *
  32436. * _.isNull(void 0);
  32437. * // => false
  32438. */
  32439. function isNull(value) {
  32440. return value === null;
  32441. }
  32442. /**
  32443. * Checks if `value` is `null` or `undefined`.
  32444. *
  32445. * @static
  32446. * @memberOf _
  32447. * @since 4.0.0
  32448. * @category Lang
  32449. * @param {*} value The value to check.
  32450. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  32451. * @example
  32452. *
  32453. * _.isNil(null);
  32454. * // => true
  32455. *
  32456. * _.isNil(void 0);
  32457. * // => true
  32458. *
  32459. * _.isNil(NaN);
  32460. * // => false
  32461. */
  32462. function isNil(value) {
  32463. return value == null;
  32464. }
  32465. /**
  32466. * Checks if `value` is classified as a `Number` primitive or object.
  32467. *
  32468. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  32469. * classified as numbers, use the `_.isFinite` method.
  32470. *
  32471. * @static
  32472. * @memberOf _
  32473. * @since 0.1.0
  32474. * @category Lang
  32475. * @param {*} value The value to check.
  32476. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  32477. * @example
  32478. *
  32479. * _.isNumber(3);
  32480. * // => true
  32481. *
  32482. * _.isNumber(Number.MIN_VALUE);
  32483. * // => true
  32484. *
  32485. * _.isNumber(Infinity);
  32486. * // => true
  32487. *
  32488. * _.isNumber('3');
  32489. * // => false
  32490. */
  32491. function isNumber(value) {
  32492. return typeof value == 'number' ||
  32493. (isObjectLike(value) && baseGetTag(value) == numberTag);
  32494. }
  32495. /**
  32496. * Checks if `value` is a plain object, that is, an object created by the
  32497. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  32498. *
  32499. * @static
  32500. * @memberOf _
  32501. * @since 0.8.0
  32502. * @category Lang
  32503. * @param {*} value The value to check.
  32504. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  32505. * @example
  32506. *
  32507. * function Foo() {
  32508. * this.a = 1;
  32509. * }
  32510. *
  32511. * _.isPlainObject(new Foo);
  32512. * // => false
  32513. *
  32514. * _.isPlainObject([1, 2, 3]);
  32515. * // => false
  32516. *
  32517. * _.isPlainObject({ 'x': 0, 'y': 0 });
  32518. * // => true
  32519. *
  32520. * _.isPlainObject(Object.create(null));
  32521. * // => true
  32522. */
  32523. function isPlainObject(value) {
  32524. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  32525. return false;
  32526. }
  32527. var proto = getPrototype(value);
  32528. if (proto === null) {
  32529. return true;
  32530. }
  32531. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  32532. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  32533. funcToString.call(Ctor) == objectCtorString;
  32534. }
  32535. /**
  32536. * Checks if `value` is classified as a `RegExp` object.
  32537. *
  32538. * @static
  32539. * @memberOf _
  32540. * @since 0.1.0
  32541. * @category Lang
  32542. * @param {*} value The value to check.
  32543. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  32544. * @example
  32545. *
  32546. * _.isRegExp(/abc/);
  32547. * // => true
  32548. *
  32549. * _.isRegExp('/abc/');
  32550. * // => false
  32551. */
  32552. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  32553. /**
  32554. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  32555. * double precision number which isn't the result of a rounded unsafe integer.
  32556. *
  32557. * **Note:** This method is based on
  32558. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  32559. *
  32560. * @static
  32561. * @memberOf _
  32562. * @since 4.0.0
  32563. * @category Lang
  32564. * @param {*} value The value to check.
  32565. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  32566. * @example
  32567. *
  32568. * _.isSafeInteger(3);
  32569. * // => true
  32570. *
  32571. * _.isSafeInteger(Number.MIN_VALUE);
  32572. * // => false
  32573. *
  32574. * _.isSafeInteger(Infinity);
  32575. * // => false
  32576. *
  32577. * _.isSafeInteger('3');
  32578. * // => false
  32579. */
  32580. function isSafeInteger(value) {
  32581. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  32582. }
  32583. /**
  32584. * Checks if `value` is classified as a `Set` object.
  32585. *
  32586. * @static
  32587. * @memberOf _
  32588. * @since 4.3.0
  32589. * @category Lang
  32590. * @param {*} value The value to check.
  32591. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  32592. * @example
  32593. *
  32594. * _.isSet(new Set);
  32595. * // => true
  32596. *
  32597. * _.isSet(new WeakSet);
  32598. * // => false
  32599. */
  32600. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  32601. /**
  32602. * Checks if `value` is classified as a `String` primitive or object.
  32603. *
  32604. * @static
  32605. * @since 0.1.0
  32606. * @memberOf _
  32607. * @category Lang
  32608. * @param {*} value The value to check.
  32609. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  32610. * @example
  32611. *
  32612. * _.isString('abc');
  32613. * // => true
  32614. *
  32615. * _.isString(1);
  32616. * // => false
  32617. */
  32618. function isString(value) {
  32619. return typeof value == 'string' ||
  32620. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  32621. }
  32622. /**
  32623. * Checks if `value` is classified as a `Symbol` primitive or object.
  32624. *
  32625. * @static
  32626. * @memberOf _
  32627. * @since 4.0.0
  32628. * @category Lang
  32629. * @param {*} value The value to check.
  32630. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  32631. * @example
  32632. *
  32633. * _.isSymbol(Symbol.iterator);
  32634. * // => true
  32635. *
  32636. * _.isSymbol('abc');
  32637. * // => false
  32638. */
  32639. function isSymbol(value) {
  32640. return typeof value == 'symbol' ||
  32641. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  32642. }
  32643. /**
  32644. * Checks if `value` is classified as a typed array.
  32645. *
  32646. * @static
  32647. * @memberOf _
  32648. * @since 3.0.0
  32649. * @category Lang
  32650. * @param {*} value The value to check.
  32651. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  32652. * @example
  32653. *
  32654. * _.isTypedArray(new Uint8Array);
  32655. * // => true
  32656. *
  32657. * _.isTypedArray([]);
  32658. * // => false
  32659. */
  32660. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  32661. /**
  32662. * Checks if `value` is `undefined`.
  32663. *
  32664. * @static
  32665. * @since 0.1.0
  32666. * @memberOf _
  32667. * @category Lang
  32668. * @param {*} value The value to check.
  32669. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  32670. * @example
  32671. *
  32672. * _.isUndefined(void 0);
  32673. * // => true
  32674. *
  32675. * _.isUndefined(null);
  32676. * // => false
  32677. */
  32678. function isUndefined(value) {
  32679. return value === undefined;
  32680. }
  32681. /**
  32682. * Checks if `value` is classified as a `WeakMap` object.
  32683. *
  32684. * @static
  32685. * @memberOf _
  32686. * @since 4.3.0
  32687. * @category Lang
  32688. * @param {*} value The value to check.
  32689. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  32690. * @example
  32691. *
  32692. * _.isWeakMap(new WeakMap);
  32693. * // => true
  32694. *
  32695. * _.isWeakMap(new Map);
  32696. * // => false
  32697. */
  32698. function isWeakMap(value) {
  32699. return isObjectLike(value) && getTag(value) == weakMapTag;
  32700. }
  32701. /**
  32702. * Checks if `value` is classified as a `WeakSet` object.
  32703. *
  32704. * @static
  32705. * @memberOf _
  32706. * @since 4.3.0
  32707. * @category Lang
  32708. * @param {*} value The value to check.
  32709. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  32710. * @example
  32711. *
  32712. * _.isWeakSet(new WeakSet);
  32713. * // => true
  32714. *
  32715. * _.isWeakSet(new Set);
  32716. * // => false
  32717. */
  32718. function isWeakSet(value) {
  32719. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  32720. }
  32721. /**
  32722. * Checks if `value` is less than `other`.
  32723. *
  32724. * @static
  32725. * @memberOf _
  32726. * @since 3.9.0
  32727. * @category Lang
  32728. * @param {*} value The value to compare.
  32729. * @param {*} other The other value to compare.
  32730. * @returns {boolean} Returns `true` if `value` is less than `other`,
  32731. * else `false`.
  32732. * @see _.gt
  32733. * @example
  32734. *
  32735. * _.lt(1, 3);
  32736. * // => true
  32737. *
  32738. * _.lt(3, 3);
  32739. * // => false
  32740. *
  32741. * _.lt(3, 1);
  32742. * // => false
  32743. */
  32744. var lt = createRelationalOperation(baseLt);
  32745. /**
  32746. * Checks if `value` is less than or equal to `other`.
  32747. *
  32748. * @static
  32749. * @memberOf _
  32750. * @since 3.9.0
  32751. * @category Lang
  32752. * @param {*} value The value to compare.
  32753. * @param {*} other The other value to compare.
  32754. * @returns {boolean} Returns `true` if `value` is less than or equal to
  32755. * `other`, else `false`.
  32756. * @see _.gte
  32757. * @example
  32758. *
  32759. * _.lte(1, 3);
  32760. * // => true
  32761. *
  32762. * _.lte(3, 3);
  32763. * // => true
  32764. *
  32765. * _.lte(3, 1);
  32766. * // => false
  32767. */
  32768. var lte = createRelationalOperation(function(value, other) {
  32769. return value <= other;
  32770. });
  32771. /**
  32772. * Converts `value` to an array.
  32773. *
  32774. * @static
  32775. * @since 0.1.0
  32776. * @memberOf _
  32777. * @category Lang
  32778. * @param {*} value The value to convert.
  32779. * @returns {Array} Returns the converted array.
  32780. * @example
  32781. *
  32782. * _.toArray({ 'a': 1, 'b': 2 });
  32783. * // => [1, 2]
  32784. *
  32785. * _.toArray('abc');
  32786. * // => ['a', 'b', 'c']
  32787. *
  32788. * _.toArray(1);
  32789. * // => []
  32790. *
  32791. * _.toArray(null);
  32792. * // => []
  32793. */
  32794. function toArray(value) {
  32795. if (!value) {
  32796. return [];
  32797. }
  32798. if (isArrayLike(value)) {
  32799. return isString(value) ? stringToArray(value) : copyArray(value);
  32800. }
  32801. if (symIterator && value[symIterator]) {
  32802. return iteratorToArray(value[symIterator]());
  32803. }
  32804. var tag = getTag(value),
  32805. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  32806. return func(value);
  32807. }
  32808. /**
  32809. * Converts `value` to a finite number.
  32810. *
  32811. * @static
  32812. * @memberOf _
  32813. * @since 4.12.0
  32814. * @category Lang
  32815. * @param {*} value The value to convert.
  32816. * @returns {number} Returns the converted number.
  32817. * @example
  32818. *
  32819. * _.toFinite(3.2);
  32820. * // => 3.2
  32821. *
  32822. * _.toFinite(Number.MIN_VALUE);
  32823. * // => 5e-324
  32824. *
  32825. * _.toFinite(Infinity);
  32826. * // => 1.7976931348623157e+308
  32827. *
  32828. * _.toFinite('3.2');
  32829. * // => 3.2
  32830. */
  32831. function toFinite(value) {
  32832. if (!value) {
  32833. return value === 0 ? value : 0;
  32834. }
  32835. value = toNumber(value);
  32836. if (value === INFINITY || value === -INFINITY) {
  32837. var sign = (value < 0 ? -1 : 1);
  32838. return sign * MAX_INTEGER;
  32839. }
  32840. return value === value ? value : 0;
  32841. }
  32842. /**
  32843. * Converts `value` to an integer.
  32844. *
  32845. * **Note:** This method is loosely based on
  32846. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  32847. *
  32848. * @static
  32849. * @memberOf _
  32850. * @since 4.0.0
  32851. * @category Lang
  32852. * @param {*} value The value to convert.
  32853. * @returns {number} Returns the converted integer.
  32854. * @example
  32855. *
  32856. * _.toInteger(3.2);
  32857. * // => 3
  32858. *
  32859. * _.toInteger(Number.MIN_VALUE);
  32860. * // => 0
  32861. *
  32862. * _.toInteger(Infinity);
  32863. * // => 1.7976931348623157e+308
  32864. *
  32865. * _.toInteger('3.2');
  32866. * // => 3
  32867. */
  32868. function toInteger(value) {
  32869. var result = toFinite(value),
  32870. remainder = result % 1;
  32871. return result === result ? (remainder ? result - remainder : result) : 0;
  32872. }
  32873. /**
  32874. * Converts `value` to an integer suitable for use as the length of an
  32875. * array-like object.
  32876. *
  32877. * **Note:** This method is based on
  32878. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  32879. *
  32880. * @static
  32881. * @memberOf _
  32882. * @since 4.0.0
  32883. * @category Lang
  32884. * @param {*} value The value to convert.
  32885. * @returns {number} Returns the converted integer.
  32886. * @example
  32887. *
  32888. * _.toLength(3.2);
  32889. * // => 3
  32890. *
  32891. * _.toLength(Number.MIN_VALUE);
  32892. * // => 0
  32893. *
  32894. * _.toLength(Infinity);
  32895. * // => 4294967295
  32896. *
  32897. * _.toLength('3.2');
  32898. * // => 3
  32899. */
  32900. function toLength(value) {
  32901. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  32902. }
  32903. /**
  32904. * Converts `value` to a number.
  32905. *
  32906. * @static
  32907. * @memberOf _
  32908. * @since 4.0.0
  32909. * @category Lang
  32910. * @param {*} value The value to process.
  32911. * @returns {number} Returns the number.
  32912. * @example
  32913. *
  32914. * _.toNumber(3.2);
  32915. * // => 3.2
  32916. *
  32917. * _.toNumber(Number.MIN_VALUE);
  32918. * // => 5e-324
  32919. *
  32920. * _.toNumber(Infinity);
  32921. * // => Infinity
  32922. *
  32923. * _.toNumber('3.2');
  32924. * // => 3.2
  32925. */
  32926. function toNumber(value) {
  32927. if (typeof value == 'number') {
  32928. return value;
  32929. }
  32930. if (isSymbol(value)) {
  32931. return NAN;
  32932. }
  32933. if (isObject(value)) {
  32934. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  32935. value = isObject(other) ? (other + '') : other;
  32936. }
  32937. if (typeof value != 'string') {
  32938. return value === 0 ? value : +value;
  32939. }
  32940. value = value.replace(reTrim, '');
  32941. var isBinary = reIsBinary.test(value);
  32942. return (isBinary || reIsOctal.test(value))
  32943. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  32944. : (reIsBadHex.test(value) ? NAN : +value);
  32945. }
  32946. /**
  32947. * Converts `value` to a plain object flattening inherited enumerable string
  32948. * keyed properties of `value` to own properties of the plain object.
  32949. *
  32950. * @static
  32951. * @memberOf _
  32952. * @since 3.0.0
  32953. * @category Lang
  32954. * @param {*} value The value to convert.
  32955. * @returns {Object} Returns the converted plain object.
  32956. * @example
  32957. *
  32958. * function Foo() {
  32959. * this.b = 2;
  32960. * }
  32961. *
  32962. * Foo.prototype.c = 3;
  32963. *
  32964. * _.assign({ 'a': 1 }, new Foo);
  32965. * // => { 'a': 1, 'b': 2 }
  32966. *
  32967. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  32968. * // => { 'a': 1, 'b': 2, 'c': 3 }
  32969. */
  32970. function toPlainObject(value) {
  32971. return copyObject(value, keysIn(value));
  32972. }
  32973. /**
  32974. * Converts `value` to a safe integer. A safe integer can be compared and
  32975. * represented correctly.
  32976. *
  32977. * @static
  32978. * @memberOf _
  32979. * @since 4.0.0
  32980. * @category Lang
  32981. * @param {*} value The value to convert.
  32982. * @returns {number} Returns the converted integer.
  32983. * @example
  32984. *
  32985. * _.toSafeInteger(3.2);
  32986. * // => 3
  32987. *
  32988. * _.toSafeInteger(Number.MIN_VALUE);
  32989. * // => 0
  32990. *
  32991. * _.toSafeInteger(Infinity);
  32992. * // => 9007199254740991
  32993. *
  32994. * _.toSafeInteger('3.2');
  32995. * // => 3
  32996. */
  32997. function toSafeInteger(value) {
  32998. return value
  32999. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  33000. : (value === 0 ? value : 0);
  33001. }
  33002. /**
  33003. * Converts `value` to a string. An empty string is returned for `null`
  33004. * and `undefined` values. The sign of `-0` is preserved.
  33005. *
  33006. * @static
  33007. * @memberOf _
  33008. * @since 4.0.0
  33009. * @category Lang
  33010. * @param {*} value The value to convert.
  33011. * @returns {string} Returns the converted string.
  33012. * @example
  33013. *
  33014. * _.toString(null);
  33015. * // => ''
  33016. *
  33017. * _.toString(-0);
  33018. * // => '-0'
  33019. *
  33020. * _.toString([1, 2, 3]);
  33021. * // => '1,2,3'
  33022. */
  33023. function toString(value) {
  33024. return value == null ? '' : baseToString(value);
  33025. }
  33026. /*------------------------------------------------------------------------*/
  33027. /**
  33028. * Assigns own enumerable string keyed properties of source objects to the
  33029. * destination object. Source objects are applied from left to right.
  33030. * Subsequent sources overwrite property assignments of previous sources.
  33031. *
  33032. * **Note:** This method mutates `object` and is loosely based on
  33033. * [`Object.assign`](https://mdn.io/Object/assign).
  33034. *
  33035. * @static
  33036. * @memberOf _
  33037. * @since 0.10.0
  33038. * @category Object
  33039. * @param {Object} object The destination object.
  33040. * @param {...Object} [sources] The source objects.
  33041. * @returns {Object} Returns `object`.
  33042. * @see _.assignIn
  33043. * @example
  33044. *
  33045. * function Foo() {
  33046. * this.a = 1;
  33047. * }
  33048. *
  33049. * function Bar() {
  33050. * this.c = 3;
  33051. * }
  33052. *
  33053. * Foo.prototype.b = 2;
  33054. * Bar.prototype.d = 4;
  33055. *
  33056. * _.assign({ 'a': 0 }, new Foo, new Bar);
  33057. * // => { 'a': 1, 'c': 3 }
  33058. */
  33059. var assign = createAssigner(function(object, source) {
  33060. if (isPrototype(source) || isArrayLike(source)) {
  33061. copyObject(source, keys(source), object);
  33062. return;
  33063. }
  33064. for (var key in source) {
  33065. if (hasOwnProperty.call(source, key)) {
  33066. assignValue(object, key, source[key]);
  33067. }
  33068. }
  33069. });
  33070. /**
  33071. * This method is like `_.assign` except that it iterates over own and
  33072. * inherited source properties.
  33073. *
  33074. * **Note:** This method mutates `object`.
  33075. *
  33076. * @static
  33077. * @memberOf _
  33078. * @since 4.0.0
  33079. * @alias extend
  33080. * @category Object
  33081. * @param {Object} object The destination object.
  33082. * @param {...Object} [sources] The source objects.
  33083. * @returns {Object} Returns `object`.
  33084. * @see _.assign
  33085. * @example
  33086. *
  33087. * function Foo() {
  33088. * this.a = 1;
  33089. * }
  33090. *
  33091. * function Bar() {
  33092. * this.c = 3;
  33093. * }
  33094. *
  33095. * Foo.prototype.b = 2;
  33096. * Bar.prototype.d = 4;
  33097. *
  33098. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  33099. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  33100. */
  33101. var assignIn = createAssigner(function(object, source) {
  33102. copyObject(source, keysIn(source), object);
  33103. });
  33104. /**
  33105. * This method is like `_.assignIn` except that it accepts `customizer`
  33106. * which is invoked to produce the assigned values. If `customizer` returns
  33107. * `undefined`, assignment is handled by the method instead. The `customizer`
  33108. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  33109. *
  33110. * **Note:** This method mutates `object`.
  33111. *
  33112. * @static
  33113. * @memberOf _
  33114. * @since 4.0.0
  33115. * @alias extendWith
  33116. * @category Object
  33117. * @param {Object} object The destination object.
  33118. * @param {...Object} sources The source objects.
  33119. * @param {Function} [customizer] The function to customize assigned values.
  33120. * @returns {Object} Returns `object`.
  33121. * @see _.assignWith
  33122. * @example
  33123. *
  33124. * function customizer(objValue, srcValue) {
  33125. * return _.isUndefined(objValue) ? srcValue : objValue;
  33126. * }
  33127. *
  33128. * var defaults = _.partialRight(_.assignInWith, customizer);
  33129. *
  33130. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  33131. * // => { 'a': 1, 'b': 2 }
  33132. */
  33133. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  33134. copyObject(source, keysIn(source), object, customizer);
  33135. });
  33136. /**
  33137. * This method is like `_.assign` except that it accepts `customizer`
  33138. * which is invoked to produce the assigned values. If `customizer` returns
  33139. * `undefined`, assignment is handled by the method instead. The `customizer`
  33140. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  33141. *
  33142. * **Note:** This method mutates `object`.
  33143. *
  33144. * @static
  33145. * @memberOf _
  33146. * @since 4.0.0
  33147. * @category Object
  33148. * @param {Object} object The destination object.
  33149. * @param {...Object} sources The source objects.
  33150. * @param {Function} [customizer] The function to customize assigned values.
  33151. * @returns {Object} Returns `object`.
  33152. * @see _.assignInWith
  33153. * @example
  33154. *
  33155. * function customizer(objValue, srcValue) {
  33156. * return _.isUndefined(objValue) ? srcValue : objValue;
  33157. * }
  33158. *
  33159. * var defaults = _.partialRight(_.assignWith, customizer);
  33160. *
  33161. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  33162. * // => { 'a': 1, 'b': 2 }
  33163. */
  33164. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  33165. copyObject(source, keys(source), object, customizer);
  33166. });
  33167. /**
  33168. * Creates an array of values corresponding to `paths` of `object`.
  33169. *
  33170. * @static
  33171. * @memberOf _
  33172. * @since 1.0.0
  33173. * @category Object
  33174. * @param {Object} object The object to iterate over.
  33175. * @param {...(string|string[])} [paths] The property paths to pick.
  33176. * @returns {Array} Returns the picked values.
  33177. * @example
  33178. *
  33179. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  33180. *
  33181. * _.at(object, ['a[0].b.c', 'a[1]']);
  33182. * // => [3, 4]
  33183. */
  33184. var at = flatRest(baseAt);
  33185. /**
  33186. * Creates an object that inherits from the `prototype` object. If a
  33187. * `properties` object is given, its own enumerable string keyed properties
  33188. * are assigned to the created object.
  33189. *
  33190. * @static
  33191. * @memberOf _
  33192. * @since 2.3.0
  33193. * @category Object
  33194. * @param {Object} prototype The object to inherit from.
  33195. * @param {Object} [properties] The properties to assign to the object.
  33196. * @returns {Object} Returns the new object.
  33197. * @example
  33198. *
  33199. * function Shape() {
  33200. * this.x = 0;
  33201. * this.y = 0;
  33202. * }
  33203. *
  33204. * function Circle() {
  33205. * Shape.call(this);
  33206. * }
  33207. *
  33208. * Circle.prototype = _.create(Shape.prototype, {
  33209. * 'constructor': Circle
  33210. * });
  33211. *
  33212. * var circle = new Circle;
  33213. * circle instanceof Circle;
  33214. * // => true
  33215. *
  33216. * circle instanceof Shape;
  33217. * // => true
  33218. */
  33219. function create(prototype, properties) {
  33220. var result = baseCreate(prototype);
  33221. return properties == null ? result : baseAssign(result, properties);
  33222. }
  33223. /**
  33224. * Assigns own and inherited enumerable string keyed properties of source
  33225. * objects to the destination object for all destination properties that
  33226. * resolve to `undefined`. Source objects are applied from left to right.
  33227. * Once a property is set, additional values of the same property are ignored.
  33228. *
  33229. * **Note:** This method mutates `object`.
  33230. *
  33231. * @static
  33232. * @since 0.1.0
  33233. * @memberOf _
  33234. * @category Object
  33235. * @param {Object} object The destination object.
  33236. * @param {...Object} [sources] The source objects.
  33237. * @returns {Object} Returns `object`.
  33238. * @see _.defaultsDeep
  33239. * @example
  33240. *
  33241. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  33242. * // => { 'a': 1, 'b': 2 }
  33243. */
  33244. var defaults = baseRest(function(object, sources) {
  33245. object = Object(object);
  33246. var index = -1;
  33247. var length = sources.length;
  33248. var guard = length > 2 ? sources[2] : undefined;
  33249. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  33250. length = 1;
  33251. }
  33252. while (++index < length) {
  33253. var source = sources[index];
  33254. var props = keysIn(source);
  33255. var propsIndex = -1;
  33256. var propsLength = props.length;
  33257. while (++propsIndex < propsLength) {
  33258. var key = props[propsIndex];
  33259. var value = object[key];
  33260. if (value === undefined ||
  33261. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  33262. object[key] = source[key];
  33263. }
  33264. }
  33265. }
  33266. return object;
  33267. });
  33268. /**
  33269. * This method is like `_.defaults` except that it recursively assigns
  33270. * default properties.
  33271. *
  33272. * **Note:** This method mutates `object`.
  33273. *
  33274. * @static
  33275. * @memberOf _
  33276. * @since 3.10.0
  33277. * @category Object
  33278. * @param {Object} object The destination object.
  33279. * @param {...Object} [sources] The source objects.
  33280. * @returns {Object} Returns `object`.
  33281. * @see _.defaults
  33282. * @example
  33283. *
  33284. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  33285. * // => { 'a': { 'b': 2, 'c': 3 } }
  33286. */
  33287. var defaultsDeep = baseRest(function(args) {
  33288. args.push(undefined, customDefaultsMerge);
  33289. return apply(mergeWith, undefined, args);
  33290. });
  33291. /**
  33292. * This method is like `_.find` except that it returns the key of the first
  33293. * element `predicate` returns truthy for instead of the element itself.
  33294. *
  33295. * @static
  33296. * @memberOf _
  33297. * @since 1.1.0
  33298. * @category Object
  33299. * @param {Object} object The object to inspect.
  33300. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  33301. * @returns {string|undefined} Returns the key of the matched element,
  33302. * else `undefined`.
  33303. * @example
  33304. *
  33305. * var users = {
  33306. * 'barney': { 'age': 36, 'active': true },
  33307. * 'fred': { 'age': 40, 'active': false },
  33308. * 'pebbles': { 'age': 1, 'active': true }
  33309. * };
  33310. *
  33311. * _.findKey(users, function(o) { return o.age < 40; });
  33312. * // => 'barney' (iteration order is not guaranteed)
  33313. *
  33314. * // The `_.matches` iteratee shorthand.
  33315. * _.findKey(users, { 'age': 1, 'active': true });
  33316. * // => 'pebbles'
  33317. *
  33318. * // The `_.matchesProperty` iteratee shorthand.
  33319. * _.findKey(users, ['active', false]);
  33320. * // => 'fred'
  33321. *
  33322. * // The `_.property` iteratee shorthand.
  33323. * _.findKey(users, 'active');
  33324. * // => 'barney'
  33325. */
  33326. function findKey(object, predicate) {
  33327. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  33328. }
  33329. /**
  33330. * This method is like `_.findKey` except that it iterates over elements of
  33331. * a collection in the opposite order.
  33332. *
  33333. * @static
  33334. * @memberOf _
  33335. * @since 2.0.0
  33336. * @category Object
  33337. * @param {Object} object The object to inspect.
  33338. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  33339. * @returns {string|undefined} Returns the key of the matched element,
  33340. * else `undefined`.
  33341. * @example
  33342. *
  33343. * var users = {
  33344. * 'barney': { 'age': 36, 'active': true },
  33345. * 'fred': { 'age': 40, 'active': false },
  33346. * 'pebbles': { 'age': 1, 'active': true }
  33347. * };
  33348. *
  33349. * _.findLastKey(users, function(o) { return o.age < 40; });
  33350. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  33351. *
  33352. * // The `_.matches` iteratee shorthand.
  33353. * _.findLastKey(users, { 'age': 36, 'active': true });
  33354. * // => 'barney'
  33355. *
  33356. * // The `_.matchesProperty` iteratee shorthand.
  33357. * _.findLastKey(users, ['active', false]);
  33358. * // => 'fred'
  33359. *
  33360. * // The `_.property` iteratee shorthand.
  33361. * _.findLastKey(users, 'active');
  33362. * // => 'pebbles'
  33363. */
  33364. function findLastKey(object, predicate) {
  33365. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  33366. }
  33367. /**
  33368. * Iterates over own and inherited enumerable string keyed properties of an
  33369. * object and invokes `iteratee` for each property. The iteratee is invoked
  33370. * with three arguments: (value, key, object). Iteratee functions may exit
  33371. * iteration early by explicitly returning `false`.
  33372. *
  33373. * @static
  33374. * @memberOf _
  33375. * @since 0.3.0
  33376. * @category Object
  33377. * @param {Object} object The object to iterate over.
  33378. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33379. * @returns {Object} Returns `object`.
  33380. * @see _.forInRight
  33381. * @example
  33382. *
  33383. * function Foo() {
  33384. * this.a = 1;
  33385. * this.b = 2;
  33386. * }
  33387. *
  33388. * Foo.prototype.c = 3;
  33389. *
  33390. * _.forIn(new Foo, function(value, key) {
  33391. * console.log(key);
  33392. * });
  33393. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  33394. */
  33395. function forIn(object, iteratee) {
  33396. return object == null
  33397. ? object
  33398. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  33399. }
  33400. /**
  33401. * This method is like `_.forIn` except that it iterates over properties of
  33402. * `object` in the opposite order.
  33403. *
  33404. * @static
  33405. * @memberOf _
  33406. * @since 2.0.0
  33407. * @category Object
  33408. * @param {Object} object The object to iterate over.
  33409. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33410. * @returns {Object} Returns `object`.
  33411. * @see _.forIn
  33412. * @example
  33413. *
  33414. * function Foo() {
  33415. * this.a = 1;
  33416. * this.b = 2;
  33417. * }
  33418. *
  33419. * Foo.prototype.c = 3;
  33420. *
  33421. * _.forInRight(new Foo, function(value, key) {
  33422. * console.log(key);
  33423. * });
  33424. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  33425. */
  33426. function forInRight(object, iteratee) {
  33427. return object == null
  33428. ? object
  33429. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  33430. }
  33431. /**
  33432. * Iterates over own enumerable string keyed properties of an object and
  33433. * invokes `iteratee` for each property. The iteratee is invoked with three
  33434. * arguments: (value, key, object). Iteratee functions may exit iteration
  33435. * early by explicitly returning `false`.
  33436. *
  33437. * @static
  33438. * @memberOf _
  33439. * @since 0.3.0
  33440. * @category Object
  33441. * @param {Object} object The object to iterate over.
  33442. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33443. * @returns {Object} Returns `object`.
  33444. * @see _.forOwnRight
  33445. * @example
  33446. *
  33447. * function Foo() {
  33448. * this.a = 1;
  33449. * this.b = 2;
  33450. * }
  33451. *
  33452. * Foo.prototype.c = 3;
  33453. *
  33454. * _.forOwn(new Foo, function(value, key) {
  33455. * console.log(key);
  33456. * });
  33457. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  33458. */
  33459. function forOwn(object, iteratee) {
  33460. return object && baseForOwn(object, getIteratee(iteratee, 3));
  33461. }
  33462. /**
  33463. * This method is like `_.forOwn` except that it iterates over properties of
  33464. * `object` in the opposite order.
  33465. *
  33466. * @static
  33467. * @memberOf _
  33468. * @since 2.0.0
  33469. * @category Object
  33470. * @param {Object} object The object to iterate over.
  33471. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33472. * @returns {Object} Returns `object`.
  33473. * @see _.forOwn
  33474. * @example
  33475. *
  33476. * function Foo() {
  33477. * this.a = 1;
  33478. * this.b = 2;
  33479. * }
  33480. *
  33481. * Foo.prototype.c = 3;
  33482. *
  33483. * _.forOwnRight(new Foo, function(value, key) {
  33484. * console.log(key);
  33485. * });
  33486. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  33487. */
  33488. function forOwnRight(object, iteratee) {
  33489. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  33490. }
  33491. /**
  33492. * Creates an array of function property names from own enumerable properties
  33493. * of `object`.
  33494. *
  33495. * @static
  33496. * @since 0.1.0
  33497. * @memberOf _
  33498. * @category Object
  33499. * @param {Object} object The object to inspect.
  33500. * @returns {Array} Returns the function names.
  33501. * @see _.functionsIn
  33502. * @example
  33503. *
  33504. * function Foo() {
  33505. * this.a = _.constant('a');
  33506. * this.b = _.constant('b');
  33507. * }
  33508. *
  33509. * Foo.prototype.c = _.constant('c');
  33510. *
  33511. * _.functions(new Foo);
  33512. * // => ['a', 'b']
  33513. */
  33514. function functions(object) {
  33515. return object == null ? [] : baseFunctions(object, keys(object));
  33516. }
  33517. /**
  33518. * Creates an array of function property names from own and inherited
  33519. * enumerable properties of `object`.
  33520. *
  33521. * @static
  33522. * @memberOf _
  33523. * @since 4.0.0
  33524. * @category Object
  33525. * @param {Object} object The object to inspect.
  33526. * @returns {Array} Returns the function names.
  33527. * @see _.functions
  33528. * @example
  33529. *
  33530. * function Foo() {
  33531. * this.a = _.constant('a');
  33532. * this.b = _.constant('b');
  33533. * }
  33534. *
  33535. * Foo.prototype.c = _.constant('c');
  33536. *
  33537. * _.functionsIn(new Foo);
  33538. * // => ['a', 'b', 'c']
  33539. */
  33540. function functionsIn(object) {
  33541. return object == null ? [] : baseFunctions(object, keysIn(object));
  33542. }
  33543. /**
  33544. * Gets the value at `path` of `object`. If the resolved value is
  33545. * `undefined`, the `defaultValue` is returned in its place.
  33546. *
  33547. * @static
  33548. * @memberOf _
  33549. * @since 3.7.0
  33550. * @category Object
  33551. * @param {Object} object The object to query.
  33552. * @param {Array|string} path The path of the property to get.
  33553. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  33554. * @returns {*} Returns the resolved value.
  33555. * @example
  33556. *
  33557. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  33558. *
  33559. * _.get(object, 'a[0].b.c');
  33560. * // => 3
  33561. *
  33562. * _.get(object, ['a', '0', 'b', 'c']);
  33563. * // => 3
  33564. *
  33565. * _.get(object, 'a.b.c', 'default');
  33566. * // => 'default'
  33567. */
  33568. function get(object, path, defaultValue) {
  33569. var result = object == null ? undefined : baseGet(object, path);
  33570. return result === undefined ? defaultValue : result;
  33571. }
  33572. /**
  33573. * Checks if `path` is a direct property of `object`.
  33574. *
  33575. * @static
  33576. * @since 0.1.0
  33577. * @memberOf _
  33578. * @category Object
  33579. * @param {Object} object The object to query.
  33580. * @param {Array|string} path The path to check.
  33581. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  33582. * @example
  33583. *
  33584. * var object = { 'a': { 'b': 2 } };
  33585. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  33586. *
  33587. * _.has(object, 'a');
  33588. * // => true
  33589. *
  33590. * _.has(object, 'a.b');
  33591. * // => true
  33592. *
  33593. * _.has(object, ['a', 'b']);
  33594. * // => true
  33595. *
  33596. * _.has(other, 'a');
  33597. * // => false
  33598. */
  33599. function has(object, path) {
  33600. return object != null && hasPath(object, path, baseHas);
  33601. }
  33602. /**
  33603. * Checks if `path` is a direct or inherited property of `object`.
  33604. *
  33605. * @static
  33606. * @memberOf _
  33607. * @since 4.0.0
  33608. * @category Object
  33609. * @param {Object} object The object to query.
  33610. * @param {Array|string} path The path to check.
  33611. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  33612. * @example
  33613. *
  33614. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  33615. *
  33616. * _.hasIn(object, 'a');
  33617. * // => true
  33618. *
  33619. * _.hasIn(object, 'a.b');
  33620. * // => true
  33621. *
  33622. * _.hasIn(object, ['a', 'b']);
  33623. * // => true
  33624. *
  33625. * _.hasIn(object, 'b');
  33626. * // => false
  33627. */
  33628. function hasIn(object, path) {
  33629. return object != null && hasPath(object, path, baseHasIn);
  33630. }
  33631. /**
  33632. * Creates an object composed of the inverted keys and values of `object`.
  33633. * If `object` contains duplicate values, subsequent values overwrite
  33634. * property assignments of previous values.
  33635. *
  33636. * @static
  33637. * @memberOf _
  33638. * @since 0.7.0
  33639. * @category Object
  33640. * @param {Object} object The object to invert.
  33641. * @returns {Object} Returns the new inverted object.
  33642. * @example
  33643. *
  33644. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  33645. *
  33646. * _.invert(object);
  33647. * // => { '1': 'c', '2': 'b' }
  33648. */
  33649. var invert = createInverter(function(result, value, key) {
  33650. if (value != null &&
  33651. typeof value.toString != 'function') {
  33652. value = nativeObjectToString.call(value);
  33653. }
  33654. result[value] = key;
  33655. }, constant(identity));
  33656. /**
  33657. * This method is like `_.invert` except that the inverted object is generated
  33658. * from the results of running each element of `object` thru `iteratee`. The
  33659. * corresponding inverted value of each inverted key is an array of keys
  33660. * responsible for generating the inverted value. The iteratee is invoked
  33661. * with one argument: (value).
  33662. *
  33663. * @static
  33664. * @memberOf _
  33665. * @since 4.1.0
  33666. * @category Object
  33667. * @param {Object} object The object to invert.
  33668. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33669. * @returns {Object} Returns the new inverted object.
  33670. * @example
  33671. *
  33672. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  33673. *
  33674. * _.invertBy(object);
  33675. * // => { '1': ['a', 'c'], '2': ['b'] }
  33676. *
  33677. * _.invertBy(object, function(value) {
  33678. * return 'group' + value;
  33679. * });
  33680. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  33681. */
  33682. var invertBy = createInverter(function(result, value, key) {
  33683. if (value != null &&
  33684. typeof value.toString != 'function') {
  33685. value = nativeObjectToString.call(value);
  33686. }
  33687. if (hasOwnProperty.call(result, value)) {
  33688. result[value].push(key);
  33689. } else {
  33690. result[value] = [key];
  33691. }
  33692. }, getIteratee);
  33693. /**
  33694. * Invokes the method at `path` of `object`.
  33695. *
  33696. * @static
  33697. * @memberOf _
  33698. * @since 4.0.0
  33699. * @category Object
  33700. * @param {Object} object The object to query.
  33701. * @param {Array|string} path The path of the method to invoke.
  33702. * @param {...*} [args] The arguments to invoke the method with.
  33703. * @returns {*} Returns the result of the invoked method.
  33704. * @example
  33705. *
  33706. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  33707. *
  33708. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  33709. * // => [2, 3]
  33710. */
  33711. var invoke = baseRest(baseInvoke);
  33712. /**
  33713. * Creates an array of the own enumerable property names of `object`.
  33714. *
  33715. * **Note:** Non-object values are coerced to objects. See the
  33716. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  33717. * for more details.
  33718. *
  33719. * @static
  33720. * @since 0.1.0
  33721. * @memberOf _
  33722. * @category Object
  33723. * @param {Object} object The object to query.
  33724. * @returns {Array} Returns the array of property names.
  33725. * @example
  33726. *
  33727. * function Foo() {
  33728. * this.a = 1;
  33729. * this.b = 2;
  33730. * }
  33731. *
  33732. * Foo.prototype.c = 3;
  33733. *
  33734. * _.keys(new Foo);
  33735. * // => ['a', 'b'] (iteration order is not guaranteed)
  33736. *
  33737. * _.keys('hi');
  33738. * // => ['0', '1']
  33739. */
  33740. function keys(object) {
  33741. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  33742. }
  33743. /**
  33744. * Creates an array of the own and inherited enumerable property names of `object`.
  33745. *
  33746. * **Note:** Non-object values are coerced to objects.
  33747. *
  33748. * @static
  33749. * @memberOf _
  33750. * @since 3.0.0
  33751. * @category Object
  33752. * @param {Object} object The object to query.
  33753. * @returns {Array} Returns the array of property names.
  33754. * @example
  33755. *
  33756. * function Foo() {
  33757. * this.a = 1;
  33758. * this.b = 2;
  33759. * }
  33760. *
  33761. * Foo.prototype.c = 3;
  33762. *
  33763. * _.keysIn(new Foo);
  33764. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  33765. */
  33766. function keysIn(object) {
  33767. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  33768. }
  33769. /**
  33770. * The opposite of `_.mapValues`; this method creates an object with the
  33771. * same values as `object` and keys generated by running each own enumerable
  33772. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  33773. * with three arguments: (value, key, object).
  33774. *
  33775. * @static
  33776. * @memberOf _
  33777. * @since 3.8.0
  33778. * @category Object
  33779. * @param {Object} object The object to iterate over.
  33780. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33781. * @returns {Object} Returns the new mapped object.
  33782. * @see _.mapValues
  33783. * @example
  33784. *
  33785. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  33786. * return key + value;
  33787. * });
  33788. * // => { 'a1': 1, 'b2': 2 }
  33789. */
  33790. function mapKeys(object, iteratee) {
  33791. var result = {};
  33792. iteratee = getIteratee(iteratee, 3);
  33793. baseForOwn(object, function(value, key, object) {
  33794. baseAssignValue(result, iteratee(value, key, object), value);
  33795. });
  33796. return result;
  33797. }
  33798. /**
  33799. * Creates an object with the same keys as `object` and values generated
  33800. * by running each own enumerable string keyed property of `object` thru
  33801. * `iteratee`. The iteratee is invoked with three arguments:
  33802. * (value, key, object).
  33803. *
  33804. * @static
  33805. * @memberOf _
  33806. * @since 2.4.0
  33807. * @category Object
  33808. * @param {Object} object The object to iterate over.
  33809. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  33810. * @returns {Object} Returns the new mapped object.
  33811. * @see _.mapKeys
  33812. * @example
  33813. *
  33814. * var users = {
  33815. * 'fred': { 'user': 'fred', 'age': 40 },
  33816. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  33817. * };
  33818. *
  33819. * _.mapValues(users, function(o) { return o.age; });
  33820. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  33821. *
  33822. * // The `_.property` iteratee shorthand.
  33823. * _.mapValues(users, 'age');
  33824. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  33825. */
  33826. function mapValues(object, iteratee) {
  33827. var result = {};
  33828. iteratee = getIteratee(iteratee, 3);
  33829. baseForOwn(object, function(value, key, object) {
  33830. baseAssignValue(result, key, iteratee(value, key, object));
  33831. });
  33832. return result;
  33833. }
  33834. /**
  33835. * This method is like `_.assign` except that it recursively merges own and
  33836. * inherited enumerable string keyed properties of source objects into the
  33837. * destination object. Source properties that resolve to `undefined` are
  33838. * skipped if a destination value exists. Array and plain object properties
  33839. * are merged recursively. Other objects and value types are overridden by
  33840. * assignment. Source objects are applied from left to right. Subsequent
  33841. * sources overwrite property assignments of previous sources.
  33842. *
  33843. * **Note:** This method mutates `object`.
  33844. *
  33845. * @static
  33846. * @memberOf _
  33847. * @since 0.5.0
  33848. * @category Object
  33849. * @param {Object} object The destination object.
  33850. * @param {...Object} [sources] The source objects.
  33851. * @returns {Object} Returns `object`.
  33852. * @example
  33853. *
  33854. * var object = {
  33855. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  33856. * };
  33857. *
  33858. * var other = {
  33859. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  33860. * };
  33861. *
  33862. * _.merge(object, other);
  33863. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  33864. */
  33865. var merge = createAssigner(function(object, source, srcIndex) {
  33866. baseMerge(object, source, srcIndex);
  33867. });
  33868. /**
  33869. * This method is like `_.merge` except that it accepts `customizer` which
  33870. * is invoked to produce the merged values of the destination and source
  33871. * properties. If `customizer` returns `undefined`, merging is handled by the
  33872. * method instead. The `customizer` is invoked with six arguments:
  33873. * (objValue, srcValue, key, object, source, stack).
  33874. *
  33875. * **Note:** This method mutates `object`.
  33876. *
  33877. * @static
  33878. * @memberOf _
  33879. * @since 4.0.0
  33880. * @category Object
  33881. * @param {Object} object The destination object.
  33882. * @param {...Object} sources The source objects.
  33883. * @param {Function} customizer The function to customize assigned values.
  33884. * @returns {Object} Returns `object`.
  33885. * @example
  33886. *
  33887. * function customizer(objValue, srcValue) {
  33888. * if (_.isArray(objValue)) {
  33889. * return objValue.concat(srcValue);
  33890. * }
  33891. * }
  33892. *
  33893. * var object = { 'a': [1], 'b': [2] };
  33894. * var other = { 'a': [3], 'b': [4] };
  33895. *
  33896. * _.mergeWith(object, other, customizer);
  33897. * // => { 'a': [1, 3], 'b': [2, 4] }
  33898. */
  33899. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  33900. baseMerge(object, source, srcIndex, customizer);
  33901. });
  33902. /**
  33903. * The opposite of `_.pick`; this method creates an object composed of the
  33904. * own and inherited enumerable property paths of `object` that are not omitted.
  33905. *
  33906. * **Note:** This method is considerably slower than `_.pick`.
  33907. *
  33908. * @static
  33909. * @since 0.1.0
  33910. * @memberOf _
  33911. * @category Object
  33912. * @param {Object} object The source object.
  33913. * @param {...(string|string[])} [paths] The property paths to omit.
  33914. * @returns {Object} Returns the new object.
  33915. * @example
  33916. *
  33917. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  33918. *
  33919. * _.omit(object, ['a', 'c']);
  33920. * // => { 'b': '2' }
  33921. */
  33922. var omit = flatRest(function(object, paths) {
  33923. var result = {};
  33924. if (object == null) {
  33925. return result;
  33926. }
  33927. var isDeep = false;
  33928. paths = arrayMap(paths, function(path) {
  33929. path = castPath(path, object);
  33930. isDeep || (isDeep = path.length > 1);
  33931. return path;
  33932. });
  33933. copyObject(object, getAllKeysIn(object), result);
  33934. if (isDeep) {
  33935. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  33936. }
  33937. var length = paths.length;
  33938. while (length--) {
  33939. baseUnset(result, paths[length]);
  33940. }
  33941. return result;
  33942. });
  33943. /**
  33944. * The opposite of `_.pickBy`; this method creates an object composed of
  33945. * the own and inherited enumerable string keyed properties of `object` that
  33946. * `predicate` doesn't return truthy for. The predicate is invoked with two
  33947. * arguments: (value, key).
  33948. *
  33949. * @static
  33950. * @memberOf _
  33951. * @since 4.0.0
  33952. * @category Object
  33953. * @param {Object} object The source object.
  33954. * @param {Function} [predicate=_.identity] The function invoked per property.
  33955. * @returns {Object} Returns the new object.
  33956. * @example
  33957. *
  33958. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  33959. *
  33960. * _.omitBy(object, _.isNumber);
  33961. * // => { 'b': '2' }
  33962. */
  33963. function omitBy(object, predicate) {
  33964. return pickBy(object, negate(getIteratee(predicate)));
  33965. }
  33966. /**
  33967. * Creates an object composed of the picked `object` properties.
  33968. *
  33969. * @static
  33970. * @since 0.1.0
  33971. * @memberOf _
  33972. * @category Object
  33973. * @param {Object} object The source object.
  33974. * @param {...(string|string[])} [paths] The property paths to pick.
  33975. * @returns {Object} Returns the new object.
  33976. * @example
  33977. *
  33978. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  33979. *
  33980. * _.pick(object, ['a', 'c']);
  33981. * // => { 'a': 1, 'c': 3 }
  33982. */
  33983. var pick = flatRest(function(object, paths) {
  33984. return object == null ? {} : basePick(object, paths);
  33985. });
  33986. /**
  33987. * Creates an object composed of the `object` properties `predicate` returns
  33988. * truthy for. The predicate is invoked with two arguments: (value, key).
  33989. *
  33990. * @static
  33991. * @memberOf _
  33992. * @since 4.0.0
  33993. * @category Object
  33994. * @param {Object} object The source object.
  33995. * @param {Function} [predicate=_.identity] The function invoked per property.
  33996. * @returns {Object} Returns the new object.
  33997. * @example
  33998. *
  33999. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  34000. *
  34001. * _.pickBy(object, _.isNumber);
  34002. * // => { 'a': 1, 'c': 3 }
  34003. */
  34004. function pickBy(object, predicate) {
  34005. if (object == null) {
  34006. return {};
  34007. }
  34008. var props = arrayMap(getAllKeysIn(object), function(prop) {
  34009. return [prop];
  34010. });
  34011. predicate = getIteratee(predicate);
  34012. return basePickBy(object, props, function(value, path) {
  34013. return predicate(value, path[0]);
  34014. });
  34015. }
  34016. /**
  34017. * This method is like `_.get` except that if the resolved value is a
  34018. * function it's invoked with the `this` binding of its parent object and
  34019. * its result is returned.
  34020. *
  34021. * @static
  34022. * @since 0.1.0
  34023. * @memberOf _
  34024. * @category Object
  34025. * @param {Object} object The object to query.
  34026. * @param {Array|string} path The path of the property to resolve.
  34027. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  34028. * @returns {*} Returns the resolved value.
  34029. * @example
  34030. *
  34031. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  34032. *
  34033. * _.result(object, 'a[0].b.c1');
  34034. * // => 3
  34035. *
  34036. * _.result(object, 'a[0].b.c2');
  34037. * // => 4
  34038. *
  34039. * _.result(object, 'a[0].b.c3', 'default');
  34040. * // => 'default'
  34041. *
  34042. * _.result(object, 'a[0].b.c3', _.constant('default'));
  34043. * // => 'default'
  34044. */
  34045. function result(object, path, defaultValue) {
  34046. path = castPath(path, object);
  34047. var index = -1,
  34048. length = path.length;
  34049. // Ensure the loop is entered when path is empty.
  34050. if (!length) {
  34051. length = 1;
  34052. object = undefined;
  34053. }
  34054. while (++index < length) {
  34055. var value = object == null ? undefined : object[toKey(path[index])];
  34056. if (value === undefined) {
  34057. index = length;
  34058. value = defaultValue;
  34059. }
  34060. object = isFunction(value) ? value.call(object) : value;
  34061. }
  34062. return object;
  34063. }
  34064. /**
  34065. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  34066. * it's created. Arrays are created for missing index properties while objects
  34067. * are created for all other missing properties. Use `_.setWith` to customize
  34068. * `path` creation.
  34069. *
  34070. * **Note:** This method mutates `object`.
  34071. *
  34072. * @static
  34073. * @memberOf _
  34074. * @since 3.7.0
  34075. * @category Object
  34076. * @param {Object} object The object to modify.
  34077. * @param {Array|string} path The path of the property to set.
  34078. * @param {*} value The value to set.
  34079. * @returns {Object} Returns `object`.
  34080. * @example
  34081. *
  34082. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  34083. *
  34084. * _.set(object, 'a[0].b.c', 4);
  34085. * console.log(object.a[0].b.c);
  34086. * // => 4
  34087. *
  34088. * _.set(object, ['x', '0', 'y', 'z'], 5);
  34089. * console.log(object.x[0].y.z);
  34090. * // => 5
  34091. */
  34092. function set(object, path, value) {
  34093. return object == null ? object : baseSet(object, path, value);
  34094. }
  34095. /**
  34096. * This method is like `_.set` except that it accepts `customizer` which is
  34097. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  34098. * path creation is handled by the method instead. The `customizer` is invoked
  34099. * with three arguments: (nsValue, key, nsObject).
  34100. *
  34101. * **Note:** This method mutates `object`.
  34102. *
  34103. * @static
  34104. * @memberOf _
  34105. * @since 4.0.0
  34106. * @category Object
  34107. * @param {Object} object The object to modify.
  34108. * @param {Array|string} path The path of the property to set.
  34109. * @param {*} value The value to set.
  34110. * @param {Function} [customizer] The function to customize assigned values.
  34111. * @returns {Object} Returns `object`.
  34112. * @example
  34113. *
  34114. * var object = {};
  34115. *
  34116. * _.setWith(object, '[0][1]', 'a', Object);
  34117. * // => { '0': { '1': 'a' } }
  34118. */
  34119. function setWith(object, path, value, customizer) {
  34120. customizer = typeof customizer == 'function' ? customizer : undefined;
  34121. return object == null ? object : baseSet(object, path, value, customizer);
  34122. }
  34123. /**
  34124. * Creates an array of own enumerable string keyed-value pairs for `object`
  34125. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  34126. * entries are returned.
  34127. *
  34128. * @static
  34129. * @memberOf _
  34130. * @since 4.0.0
  34131. * @alias entries
  34132. * @category Object
  34133. * @param {Object} object The object to query.
  34134. * @returns {Array} Returns the key-value pairs.
  34135. * @example
  34136. *
  34137. * function Foo() {
  34138. * this.a = 1;
  34139. * this.b = 2;
  34140. * }
  34141. *
  34142. * Foo.prototype.c = 3;
  34143. *
  34144. * _.toPairs(new Foo);
  34145. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  34146. */
  34147. var toPairs = createToPairs(keys);
  34148. /**
  34149. * Creates an array of own and inherited enumerable string keyed-value pairs
  34150. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  34151. * or set, its entries are returned.
  34152. *
  34153. * @static
  34154. * @memberOf _
  34155. * @since 4.0.0
  34156. * @alias entriesIn
  34157. * @category Object
  34158. * @param {Object} object The object to query.
  34159. * @returns {Array} Returns the key-value pairs.
  34160. * @example
  34161. *
  34162. * function Foo() {
  34163. * this.a = 1;
  34164. * this.b = 2;
  34165. * }
  34166. *
  34167. * Foo.prototype.c = 3;
  34168. *
  34169. * _.toPairsIn(new Foo);
  34170. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  34171. */
  34172. var toPairsIn = createToPairs(keysIn);
  34173. /**
  34174. * An alternative to `_.reduce`; this method transforms `object` to a new
  34175. * `accumulator` object which is the result of running each of its own
  34176. * enumerable string keyed properties thru `iteratee`, with each invocation
  34177. * potentially mutating the `accumulator` object. If `accumulator` is not
  34178. * provided, a new object with the same `[[Prototype]]` will be used. The
  34179. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  34180. * Iteratee functions may exit iteration early by explicitly returning `false`.
  34181. *
  34182. * @static
  34183. * @memberOf _
  34184. * @since 1.3.0
  34185. * @category Object
  34186. * @param {Object} object The object to iterate over.
  34187. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  34188. * @param {*} [accumulator] The custom accumulator value.
  34189. * @returns {*} Returns the accumulated value.
  34190. * @example
  34191. *
  34192. * _.transform([2, 3, 4], function(result, n) {
  34193. * result.push(n *= n);
  34194. * return n % 2 == 0;
  34195. * }, []);
  34196. * // => [4, 9]
  34197. *
  34198. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  34199. * (result[value] || (result[value] = [])).push(key);
  34200. * }, {});
  34201. * // => { '1': ['a', 'c'], '2': ['b'] }
  34202. */
  34203. function transform(object, iteratee, accumulator) {
  34204. var isArr = isArray(object),
  34205. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  34206. iteratee = getIteratee(iteratee, 4);
  34207. if (accumulator == null) {
  34208. var Ctor = object && object.constructor;
  34209. if (isArrLike) {
  34210. accumulator = isArr ? new Ctor : [];
  34211. }
  34212. else if (isObject(object)) {
  34213. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  34214. }
  34215. else {
  34216. accumulator = {};
  34217. }
  34218. }
  34219. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  34220. return iteratee(accumulator, value, index, object);
  34221. });
  34222. return accumulator;
  34223. }
  34224. /**
  34225. * Removes the property at `path` of `object`.
  34226. *
  34227. * **Note:** This method mutates `object`.
  34228. *
  34229. * @static
  34230. * @memberOf _
  34231. * @since 4.0.0
  34232. * @category Object
  34233. * @param {Object} object The object to modify.
  34234. * @param {Array|string} path The path of the property to unset.
  34235. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  34236. * @example
  34237. *
  34238. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  34239. * _.unset(object, 'a[0].b.c');
  34240. * // => true
  34241. *
  34242. * console.log(object);
  34243. * // => { 'a': [{ 'b': {} }] };
  34244. *
  34245. * _.unset(object, ['a', '0', 'b', 'c']);
  34246. * // => true
  34247. *
  34248. * console.log(object);
  34249. * // => { 'a': [{ 'b': {} }] };
  34250. */
  34251. function unset(object, path) {
  34252. return object == null ? true : baseUnset(object, path);
  34253. }
  34254. /**
  34255. * This method is like `_.set` except that accepts `updater` to produce the
  34256. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  34257. * is invoked with one argument: (value).
  34258. *
  34259. * **Note:** This method mutates `object`.
  34260. *
  34261. * @static
  34262. * @memberOf _
  34263. * @since 4.6.0
  34264. * @category Object
  34265. * @param {Object} object The object to modify.
  34266. * @param {Array|string} path The path of the property to set.
  34267. * @param {Function} updater The function to produce the updated value.
  34268. * @returns {Object} Returns `object`.
  34269. * @example
  34270. *
  34271. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  34272. *
  34273. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  34274. * console.log(object.a[0].b.c);
  34275. * // => 9
  34276. *
  34277. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  34278. * console.log(object.x[0].y.z);
  34279. * // => 0
  34280. */
  34281. function update(object, path, updater) {
  34282. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  34283. }
  34284. /**
  34285. * This method is like `_.update` except that it accepts `customizer` which is
  34286. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  34287. * path creation is handled by the method instead. The `customizer` is invoked
  34288. * with three arguments: (nsValue, key, nsObject).
  34289. *
  34290. * **Note:** This method mutates `object`.
  34291. *
  34292. * @static
  34293. * @memberOf _
  34294. * @since 4.6.0
  34295. * @category Object
  34296. * @param {Object} object The object to modify.
  34297. * @param {Array|string} path The path of the property to set.
  34298. * @param {Function} updater The function to produce the updated value.
  34299. * @param {Function} [customizer] The function to customize assigned values.
  34300. * @returns {Object} Returns `object`.
  34301. * @example
  34302. *
  34303. * var object = {};
  34304. *
  34305. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  34306. * // => { '0': { '1': 'a' } }
  34307. */
  34308. function updateWith(object, path, updater, customizer) {
  34309. customizer = typeof customizer == 'function' ? customizer : undefined;
  34310. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  34311. }
  34312. /**
  34313. * Creates an array of the own enumerable string keyed property values of `object`.
  34314. *
  34315. * **Note:** Non-object values are coerced to objects.
  34316. *
  34317. * @static
  34318. * @since 0.1.0
  34319. * @memberOf _
  34320. * @category Object
  34321. * @param {Object} object The object to query.
  34322. * @returns {Array} Returns the array of property values.
  34323. * @example
  34324. *
  34325. * function Foo() {
  34326. * this.a = 1;
  34327. * this.b = 2;
  34328. * }
  34329. *
  34330. * Foo.prototype.c = 3;
  34331. *
  34332. * _.values(new Foo);
  34333. * // => [1, 2] (iteration order is not guaranteed)
  34334. *
  34335. * _.values('hi');
  34336. * // => ['h', 'i']
  34337. */
  34338. function values(object) {
  34339. return object == null ? [] : baseValues(object, keys(object));
  34340. }
  34341. /**
  34342. * Creates an array of the own and inherited enumerable string keyed property
  34343. * values of `object`.
  34344. *
  34345. * **Note:** Non-object values are coerced to objects.
  34346. *
  34347. * @static
  34348. * @memberOf _
  34349. * @since 3.0.0
  34350. * @category Object
  34351. * @param {Object} object The object to query.
  34352. * @returns {Array} Returns the array of property values.
  34353. * @example
  34354. *
  34355. * function Foo() {
  34356. * this.a = 1;
  34357. * this.b = 2;
  34358. * }
  34359. *
  34360. * Foo.prototype.c = 3;
  34361. *
  34362. * _.valuesIn(new Foo);
  34363. * // => [1, 2, 3] (iteration order is not guaranteed)
  34364. */
  34365. function valuesIn(object) {
  34366. return object == null ? [] : baseValues(object, keysIn(object));
  34367. }
  34368. /*------------------------------------------------------------------------*/
  34369. /**
  34370. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  34371. *
  34372. * @static
  34373. * @memberOf _
  34374. * @since 4.0.0
  34375. * @category Number
  34376. * @param {number} number The number to clamp.
  34377. * @param {number} [lower] The lower bound.
  34378. * @param {number} upper The upper bound.
  34379. * @returns {number} Returns the clamped number.
  34380. * @example
  34381. *
  34382. * _.clamp(-10, -5, 5);
  34383. * // => -5
  34384. *
  34385. * _.clamp(10, -5, 5);
  34386. * // => 5
  34387. */
  34388. function clamp(number, lower, upper) {
  34389. if (upper === undefined) {
  34390. upper = lower;
  34391. lower = undefined;
  34392. }
  34393. if (upper !== undefined) {
  34394. upper = toNumber(upper);
  34395. upper = upper === upper ? upper : 0;
  34396. }
  34397. if (lower !== undefined) {
  34398. lower = toNumber(lower);
  34399. lower = lower === lower ? lower : 0;
  34400. }
  34401. return baseClamp(toNumber(number), lower, upper);
  34402. }
  34403. /**
  34404. * Checks if `n` is between `start` and up to, but not including, `end`. If
  34405. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  34406. * If `start` is greater than `end` the params are swapped to support
  34407. * negative ranges.
  34408. *
  34409. * @static
  34410. * @memberOf _
  34411. * @since 3.3.0
  34412. * @category Number
  34413. * @param {number} number The number to check.
  34414. * @param {number} [start=0] The start of the range.
  34415. * @param {number} end The end of the range.
  34416. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  34417. * @see _.range, _.rangeRight
  34418. * @example
  34419. *
  34420. * _.inRange(3, 2, 4);
  34421. * // => true
  34422. *
  34423. * _.inRange(4, 8);
  34424. * // => true
  34425. *
  34426. * _.inRange(4, 2);
  34427. * // => false
  34428. *
  34429. * _.inRange(2, 2);
  34430. * // => false
  34431. *
  34432. * _.inRange(1.2, 2);
  34433. * // => true
  34434. *
  34435. * _.inRange(5.2, 4);
  34436. * // => false
  34437. *
  34438. * _.inRange(-3, -2, -6);
  34439. * // => true
  34440. */
  34441. function inRange(number, start, end) {
  34442. start = toFinite(start);
  34443. if (end === undefined) {
  34444. end = start;
  34445. start = 0;
  34446. } else {
  34447. end = toFinite(end);
  34448. }
  34449. number = toNumber(number);
  34450. return baseInRange(number, start, end);
  34451. }
  34452. /**
  34453. * Produces a random number between the inclusive `lower` and `upper` bounds.
  34454. * If only one argument is provided a number between `0` and the given number
  34455. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  34456. * floats, a floating-point number is returned instead of an integer.
  34457. *
  34458. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  34459. * floating-point values which can produce unexpected results.
  34460. *
  34461. * @static
  34462. * @memberOf _
  34463. * @since 0.7.0
  34464. * @category Number
  34465. * @param {number} [lower=0] The lower bound.
  34466. * @param {number} [upper=1] The upper bound.
  34467. * @param {boolean} [floating] Specify returning a floating-point number.
  34468. * @returns {number} Returns the random number.
  34469. * @example
  34470. *
  34471. * _.random(0, 5);
  34472. * // => an integer between 0 and 5
  34473. *
  34474. * _.random(5);
  34475. * // => also an integer between 0 and 5
  34476. *
  34477. * _.random(5, true);
  34478. * // => a floating-point number between 0 and 5
  34479. *
  34480. * _.random(1.2, 5.2);
  34481. * // => a floating-point number between 1.2 and 5.2
  34482. */
  34483. function random(lower, upper, floating) {
  34484. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  34485. upper = floating = undefined;
  34486. }
  34487. if (floating === undefined) {
  34488. if (typeof upper == 'boolean') {
  34489. floating = upper;
  34490. upper = undefined;
  34491. }
  34492. else if (typeof lower == 'boolean') {
  34493. floating = lower;
  34494. lower = undefined;
  34495. }
  34496. }
  34497. if (lower === undefined && upper === undefined) {
  34498. lower = 0;
  34499. upper = 1;
  34500. }
  34501. else {
  34502. lower = toFinite(lower);
  34503. if (upper === undefined) {
  34504. upper = lower;
  34505. lower = 0;
  34506. } else {
  34507. upper = toFinite(upper);
  34508. }
  34509. }
  34510. if (lower > upper) {
  34511. var temp = lower;
  34512. lower = upper;
  34513. upper = temp;
  34514. }
  34515. if (floating || lower % 1 || upper % 1) {
  34516. var rand = nativeRandom();
  34517. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  34518. }
  34519. return baseRandom(lower, upper);
  34520. }
  34521. /*------------------------------------------------------------------------*/
  34522. /**
  34523. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  34524. *
  34525. * @static
  34526. * @memberOf _
  34527. * @since 3.0.0
  34528. * @category String
  34529. * @param {string} [string=''] The string to convert.
  34530. * @returns {string} Returns the camel cased string.
  34531. * @example
  34532. *
  34533. * _.camelCase('Foo Bar');
  34534. * // => 'fooBar'
  34535. *
  34536. * _.camelCase('--foo-bar--');
  34537. * // => 'fooBar'
  34538. *
  34539. * _.camelCase('__FOO_BAR__');
  34540. * // => 'fooBar'
  34541. */
  34542. var camelCase = createCompounder(function(result, word, index) {
  34543. word = word.toLowerCase();
  34544. return result + (index ? capitalize(word) : word);
  34545. });
  34546. /**
  34547. * Converts the first character of `string` to upper case and the remaining
  34548. * to lower case.
  34549. *
  34550. * @static
  34551. * @memberOf _
  34552. * @since 3.0.0
  34553. * @category String
  34554. * @param {string} [string=''] The string to capitalize.
  34555. * @returns {string} Returns the capitalized string.
  34556. * @example
  34557. *
  34558. * _.capitalize('FRED');
  34559. * // => 'Fred'
  34560. */
  34561. function capitalize(string) {
  34562. return upperFirst(toString(string).toLowerCase());
  34563. }
  34564. /**
  34565. * Deburrs `string` by converting
  34566. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  34567. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  34568. * letters to basic Latin letters and removing
  34569. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  34570. *
  34571. * @static
  34572. * @memberOf _
  34573. * @since 3.0.0
  34574. * @category String
  34575. * @param {string} [string=''] The string to deburr.
  34576. * @returns {string} Returns the deburred string.
  34577. * @example
  34578. *
  34579. * _.deburr('déjà vu');
  34580. * // => 'deja vu'
  34581. */
  34582. function deburr(string) {
  34583. string = toString(string);
  34584. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  34585. }
  34586. /**
  34587. * Checks if `string` ends with the given target string.
  34588. *
  34589. * @static
  34590. * @memberOf _
  34591. * @since 3.0.0
  34592. * @category String
  34593. * @param {string} [string=''] The string to inspect.
  34594. * @param {string} [target] The string to search for.
  34595. * @param {number} [position=string.length] The position to search up to.
  34596. * @returns {boolean} Returns `true` if `string` ends with `target`,
  34597. * else `false`.
  34598. * @example
  34599. *
  34600. * _.endsWith('abc', 'c');
  34601. * // => true
  34602. *
  34603. * _.endsWith('abc', 'b');
  34604. * // => false
  34605. *
  34606. * _.endsWith('abc', 'b', 2);
  34607. * // => true
  34608. */
  34609. function endsWith(string, target, position) {
  34610. string = toString(string);
  34611. target = baseToString(target);
  34612. var length = string.length;
  34613. position = position === undefined
  34614. ? length
  34615. : baseClamp(toInteger(position), 0, length);
  34616. var end = position;
  34617. position -= target.length;
  34618. return position >= 0 && string.slice(position, end) == target;
  34619. }
  34620. /**
  34621. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  34622. * corresponding HTML entities.
  34623. *
  34624. * **Note:** No other characters are escaped. To escape additional
  34625. * characters use a third-party library like [_he_](https://mths.be/he).
  34626. *
  34627. * Though the ">" character is escaped for symmetry, characters like
  34628. * ">" and "/" don't need escaping in HTML and have no special meaning
  34629. * unless they're part of a tag or unquoted attribute value. See
  34630. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  34631. * (under "semi-related fun fact") for more details.
  34632. *
  34633. * When working with HTML you should always
  34634. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  34635. * XSS vectors.
  34636. *
  34637. * @static
  34638. * @since 0.1.0
  34639. * @memberOf _
  34640. * @category String
  34641. * @param {string} [string=''] The string to escape.
  34642. * @returns {string} Returns the escaped string.
  34643. * @example
  34644. *
  34645. * _.escape('fred, barney, & pebbles');
  34646. * // => 'fred, barney, &amp; pebbles'
  34647. */
  34648. function escape(string) {
  34649. string = toString(string);
  34650. return (string && reHasUnescapedHtml.test(string))
  34651. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  34652. : string;
  34653. }
  34654. /**
  34655. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  34656. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  34657. *
  34658. * @static
  34659. * @memberOf _
  34660. * @since 3.0.0
  34661. * @category String
  34662. * @param {string} [string=''] The string to escape.
  34663. * @returns {string} Returns the escaped string.
  34664. * @example
  34665. *
  34666. * _.escapeRegExp('[lodash](https://lodash.com/)');
  34667. * // => '\[lodash\]\(https://lodash\.com/\)'
  34668. */
  34669. function escapeRegExp(string) {
  34670. string = toString(string);
  34671. return (string && reHasRegExpChar.test(string))
  34672. ? string.replace(reRegExpChar, '\\$&')
  34673. : string;
  34674. }
  34675. /**
  34676. * Converts `string` to
  34677. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  34678. *
  34679. * @static
  34680. * @memberOf _
  34681. * @since 3.0.0
  34682. * @category String
  34683. * @param {string} [string=''] The string to convert.
  34684. * @returns {string} Returns the kebab cased string.
  34685. * @example
  34686. *
  34687. * _.kebabCase('Foo Bar');
  34688. * // => 'foo-bar'
  34689. *
  34690. * _.kebabCase('fooBar');
  34691. * // => 'foo-bar'
  34692. *
  34693. * _.kebabCase('__FOO_BAR__');
  34694. * // => 'foo-bar'
  34695. */
  34696. var kebabCase = createCompounder(function(result, word, index) {
  34697. return result + (index ? '-' : '') + word.toLowerCase();
  34698. });
  34699. /**
  34700. * Converts `string`, as space separated words, to lower case.
  34701. *
  34702. * @static
  34703. * @memberOf _
  34704. * @since 4.0.0
  34705. * @category String
  34706. * @param {string} [string=''] The string to convert.
  34707. * @returns {string} Returns the lower cased string.
  34708. * @example
  34709. *
  34710. * _.lowerCase('--Foo-Bar--');
  34711. * // => 'foo bar'
  34712. *
  34713. * _.lowerCase('fooBar');
  34714. * // => 'foo bar'
  34715. *
  34716. * _.lowerCase('__FOO_BAR__');
  34717. * // => 'foo bar'
  34718. */
  34719. var lowerCase = createCompounder(function(result, word, index) {
  34720. return result + (index ? ' ' : '') + word.toLowerCase();
  34721. });
  34722. /**
  34723. * Converts the first character of `string` to lower case.
  34724. *
  34725. * @static
  34726. * @memberOf _
  34727. * @since 4.0.0
  34728. * @category String
  34729. * @param {string} [string=''] The string to convert.
  34730. * @returns {string} Returns the converted string.
  34731. * @example
  34732. *
  34733. * _.lowerFirst('Fred');
  34734. * // => 'fred'
  34735. *
  34736. * _.lowerFirst('FRED');
  34737. * // => 'fRED'
  34738. */
  34739. var lowerFirst = createCaseFirst('toLowerCase');
  34740. /**
  34741. * Pads `string` on the left and right sides if it's shorter than `length`.
  34742. * Padding characters are truncated if they can't be evenly divided by `length`.
  34743. *
  34744. * @static
  34745. * @memberOf _
  34746. * @since 3.0.0
  34747. * @category String
  34748. * @param {string} [string=''] The string to pad.
  34749. * @param {number} [length=0] The padding length.
  34750. * @param {string} [chars=' '] The string used as padding.
  34751. * @returns {string} Returns the padded string.
  34752. * @example
  34753. *
  34754. * _.pad('abc', 8);
  34755. * // => ' abc '
  34756. *
  34757. * _.pad('abc', 8, '_-');
  34758. * // => '_-abc_-_'
  34759. *
  34760. * _.pad('abc', 3);
  34761. * // => 'abc'
  34762. */
  34763. function pad(string, length, chars) {
  34764. string = toString(string);
  34765. length = toInteger(length);
  34766. var strLength = length ? stringSize(string) : 0;
  34767. if (!length || strLength >= length) {
  34768. return string;
  34769. }
  34770. var mid = (length - strLength) / 2;
  34771. return (
  34772. createPadding(nativeFloor(mid), chars) +
  34773. string +
  34774. createPadding(nativeCeil(mid), chars)
  34775. );
  34776. }
  34777. /**
  34778. * Pads `string` on the right side if it's shorter than `length`. Padding
  34779. * characters are truncated if they exceed `length`.
  34780. *
  34781. * @static
  34782. * @memberOf _
  34783. * @since 4.0.0
  34784. * @category String
  34785. * @param {string} [string=''] The string to pad.
  34786. * @param {number} [length=0] The padding length.
  34787. * @param {string} [chars=' '] The string used as padding.
  34788. * @returns {string} Returns the padded string.
  34789. * @example
  34790. *
  34791. * _.padEnd('abc', 6);
  34792. * // => 'abc '
  34793. *
  34794. * _.padEnd('abc', 6, '_-');
  34795. * // => 'abc_-_'
  34796. *
  34797. * _.padEnd('abc', 3);
  34798. * // => 'abc'
  34799. */
  34800. function padEnd(string, length, chars) {
  34801. string = toString(string);
  34802. length = toInteger(length);
  34803. var strLength = length ? stringSize(string) : 0;
  34804. return (length && strLength < length)
  34805. ? (string + createPadding(length - strLength, chars))
  34806. : string;
  34807. }
  34808. /**
  34809. * Pads `string` on the left side if it's shorter than `length`. Padding
  34810. * characters are truncated if they exceed `length`.
  34811. *
  34812. * @static
  34813. * @memberOf _
  34814. * @since 4.0.0
  34815. * @category String
  34816. * @param {string} [string=''] The string to pad.
  34817. * @param {number} [length=0] The padding length.
  34818. * @param {string} [chars=' '] The string used as padding.
  34819. * @returns {string} Returns the padded string.
  34820. * @example
  34821. *
  34822. * _.padStart('abc', 6);
  34823. * // => ' abc'
  34824. *
  34825. * _.padStart('abc', 6, '_-');
  34826. * // => '_-_abc'
  34827. *
  34828. * _.padStart('abc', 3);
  34829. * // => 'abc'
  34830. */
  34831. function padStart(string, length, chars) {
  34832. string = toString(string);
  34833. length = toInteger(length);
  34834. var strLength = length ? stringSize(string) : 0;
  34835. return (length && strLength < length)
  34836. ? (createPadding(length - strLength, chars) + string)
  34837. : string;
  34838. }
  34839. /**
  34840. * Converts `string` to an integer of the specified radix. If `radix` is
  34841. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  34842. * hexadecimal, in which case a `radix` of `16` is used.
  34843. *
  34844. * **Note:** This method aligns with the
  34845. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  34846. *
  34847. * @static
  34848. * @memberOf _
  34849. * @since 1.1.0
  34850. * @category String
  34851. * @param {string} string The string to convert.
  34852. * @param {number} [radix=10] The radix to interpret `value` by.
  34853. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  34854. * @returns {number} Returns the converted integer.
  34855. * @example
  34856. *
  34857. * _.parseInt('08');
  34858. * // => 8
  34859. *
  34860. * _.map(['6', '08', '10'], _.parseInt);
  34861. * // => [6, 8, 10]
  34862. */
  34863. function parseInt(string, radix, guard) {
  34864. if (guard || radix == null) {
  34865. radix = 0;
  34866. } else if (radix) {
  34867. radix = +radix;
  34868. }
  34869. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  34870. }
  34871. /**
  34872. * Repeats the given string `n` times.
  34873. *
  34874. * @static
  34875. * @memberOf _
  34876. * @since 3.0.0
  34877. * @category String
  34878. * @param {string} [string=''] The string to repeat.
  34879. * @param {number} [n=1] The number of times to repeat the string.
  34880. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  34881. * @returns {string} Returns the repeated string.
  34882. * @example
  34883. *
  34884. * _.repeat('*', 3);
  34885. * // => '***'
  34886. *
  34887. * _.repeat('abc', 2);
  34888. * // => 'abcabc'
  34889. *
  34890. * _.repeat('abc', 0);
  34891. * // => ''
  34892. */
  34893. function repeat(string, n, guard) {
  34894. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  34895. n = 1;
  34896. } else {
  34897. n = toInteger(n);
  34898. }
  34899. return baseRepeat(toString(string), n);
  34900. }
  34901. /**
  34902. * Replaces matches for `pattern` in `string` with `replacement`.
  34903. *
  34904. * **Note:** This method is based on
  34905. * [`String#replace`](https://mdn.io/String/replace).
  34906. *
  34907. * @static
  34908. * @memberOf _
  34909. * @since 4.0.0
  34910. * @category String
  34911. * @param {string} [string=''] The string to modify.
  34912. * @param {RegExp|string} pattern The pattern to replace.
  34913. * @param {Function|string} replacement The match replacement.
  34914. * @returns {string} Returns the modified string.
  34915. * @example
  34916. *
  34917. * _.replace('Hi Fred', 'Fred', 'Barney');
  34918. * // => 'Hi Barney'
  34919. */
  34920. function replace() {
  34921. var args = arguments,
  34922. string = toString(args[0]);
  34923. return args.length < 3 ? string : string.replace(args[1], args[2]);
  34924. }
  34925. /**
  34926. * Converts `string` to
  34927. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  34928. *
  34929. * @static
  34930. * @memberOf _
  34931. * @since 3.0.0
  34932. * @category String
  34933. * @param {string} [string=''] The string to convert.
  34934. * @returns {string} Returns the snake cased string.
  34935. * @example
  34936. *
  34937. * _.snakeCase('Foo Bar');
  34938. * // => 'foo_bar'
  34939. *
  34940. * _.snakeCase('fooBar');
  34941. * // => 'foo_bar'
  34942. *
  34943. * _.snakeCase('--FOO-BAR--');
  34944. * // => 'foo_bar'
  34945. */
  34946. var snakeCase = createCompounder(function(result, word, index) {
  34947. return result + (index ? '_' : '') + word.toLowerCase();
  34948. });
  34949. /**
  34950. * Splits `string` by `separator`.
  34951. *
  34952. * **Note:** This method is based on
  34953. * [`String#split`](https://mdn.io/String/split).
  34954. *
  34955. * @static
  34956. * @memberOf _
  34957. * @since 4.0.0
  34958. * @category String
  34959. * @param {string} [string=''] The string to split.
  34960. * @param {RegExp|string} separator The separator pattern to split by.
  34961. * @param {number} [limit] The length to truncate results to.
  34962. * @returns {Array} Returns the string segments.
  34963. * @example
  34964. *
  34965. * _.split('a-b-c', '-', 2);
  34966. * // => ['a', 'b']
  34967. */
  34968. function split(string, separator, limit) {
  34969. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  34970. separator = limit = undefined;
  34971. }
  34972. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  34973. if (!limit) {
  34974. return [];
  34975. }
  34976. string = toString(string);
  34977. if (string && (
  34978. typeof separator == 'string' ||
  34979. (separator != null && !isRegExp(separator))
  34980. )) {
  34981. separator = baseToString(separator);
  34982. if (!separator && hasUnicode(string)) {
  34983. return castSlice(stringToArray(string), 0, limit);
  34984. }
  34985. }
  34986. return string.split(separator, limit);
  34987. }
  34988. /**
  34989. * Converts `string` to
  34990. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  34991. *
  34992. * @static
  34993. * @memberOf _
  34994. * @since 3.1.0
  34995. * @category String
  34996. * @param {string} [string=''] The string to convert.
  34997. * @returns {string} Returns the start cased string.
  34998. * @example
  34999. *
  35000. * _.startCase('--foo-bar--');
  35001. * // => 'Foo Bar'
  35002. *
  35003. * _.startCase('fooBar');
  35004. * // => 'Foo Bar'
  35005. *
  35006. * _.startCase('__FOO_BAR__');
  35007. * // => 'FOO BAR'
  35008. */
  35009. var startCase = createCompounder(function(result, word, index) {
  35010. return result + (index ? ' ' : '') + upperFirst(word);
  35011. });
  35012. /**
  35013. * Checks if `string` starts with the given target string.
  35014. *
  35015. * @static
  35016. * @memberOf _
  35017. * @since 3.0.0
  35018. * @category String
  35019. * @param {string} [string=''] The string to inspect.
  35020. * @param {string} [target] The string to search for.
  35021. * @param {number} [position=0] The position to search from.
  35022. * @returns {boolean} Returns `true` if `string` starts with `target`,
  35023. * else `false`.
  35024. * @example
  35025. *
  35026. * _.startsWith('abc', 'a');
  35027. * // => true
  35028. *
  35029. * _.startsWith('abc', 'b');
  35030. * // => false
  35031. *
  35032. * _.startsWith('abc', 'b', 1);
  35033. * // => true
  35034. */
  35035. function startsWith(string, target, position) {
  35036. string = toString(string);
  35037. position = position == null
  35038. ? 0
  35039. : baseClamp(toInteger(position), 0, string.length);
  35040. target = baseToString(target);
  35041. return string.slice(position, position + target.length) == target;
  35042. }
  35043. /**
  35044. * Creates a compiled template function that can interpolate data properties
  35045. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  35046. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  35047. * properties may be accessed as free variables in the template. If a setting
  35048. * object is given, it takes precedence over `_.templateSettings` values.
  35049. *
  35050. * **Note:** In the development build `_.template` utilizes
  35051. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  35052. * for easier debugging.
  35053. *
  35054. * For more information on precompiling templates see
  35055. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  35056. *
  35057. * For more information on Chrome extension sandboxes see
  35058. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  35059. *
  35060. * @static
  35061. * @since 0.1.0
  35062. * @memberOf _
  35063. * @category String
  35064. * @param {string} [string=''] The template string.
  35065. * @param {Object} [options={}] The options object.
  35066. * @param {RegExp} [options.escape=_.templateSettings.escape]
  35067. * The HTML "escape" delimiter.
  35068. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  35069. * The "evaluate" delimiter.
  35070. * @param {Object} [options.imports=_.templateSettings.imports]
  35071. * An object to import into the template as free variables.
  35072. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  35073. * The "interpolate" delimiter.
  35074. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  35075. * The sourceURL of the compiled template.
  35076. * @param {string} [options.variable='obj']
  35077. * The data object variable name.
  35078. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  35079. * @returns {Function} Returns the compiled template function.
  35080. * @example
  35081. *
  35082. * // Use the "interpolate" delimiter to create a compiled template.
  35083. * var compiled = _.template('hello <%= user %>!');
  35084. * compiled({ 'user': 'fred' });
  35085. * // => 'hello fred!'
  35086. *
  35087. * // Use the HTML "escape" delimiter to escape data property values.
  35088. * var compiled = _.template('<b><%- value %></b>');
  35089. * compiled({ 'value': '<script>' });
  35090. * // => '<b>&lt;script&gt;</b>'
  35091. *
  35092. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  35093. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  35094. * compiled({ 'users': ['fred', 'barney'] });
  35095. * // => '<li>fred</li><li>barney</li>'
  35096. *
  35097. * // Use the internal `print` function in "evaluate" delimiters.
  35098. * var compiled = _.template('<% print("hello " + user); %>!');
  35099. * compiled({ 'user': 'barney' });
  35100. * // => 'hello barney!'
  35101. *
  35102. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  35103. * // Disable support by replacing the "interpolate" delimiter.
  35104. * var compiled = _.template('hello ${ user }!');
  35105. * compiled({ 'user': 'pebbles' });
  35106. * // => 'hello pebbles!'
  35107. *
  35108. * // Use backslashes to treat delimiters as plain text.
  35109. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  35110. * compiled({ 'value': 'ignored' });
  35111. * // => '<%- value %>'
  35112. *
  35113. * // Use the `imports` option to import `jQuery` as `jq`.
  35114. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  35115. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  35116. * compiled({ 'users': ['fred', 'barney'] });
  35117. * // => '<li>fred</li><li>barney</li>'
  35118. *
  35119. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  35120. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  35121. * compiled(data);
  35122. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  35123. *
  35124. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  35125. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  35126. * compiled.source;
  35127. * // => function(data) {
  35128. * // var __t, __p = '';
  35129. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  35130. * // return __p;
  35131. * // }
  35132. *
  35133. * // Use custom template delimiters.
  35134. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  35135. * var compiled = _.template('hello {{ user }}!');
  35136. * compiled({ 'user': 'mustache' });
  35137. * // => 'hello mustache!'
  35138. *
  35139. * // Use the `source` property to inline compiled templates for meaningful
  35140. * // line numbers in error messages and stack traces.
  35141. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  35142. * var JST = {\
  35143. * "main": ' + _.template(mainText).source + '\
  35144. * };\
  35145. * ');
  35146. */
  35147. function template(string, options, guard) {
  35148. // Based on John Resig's `tmpl` implementation
  35149. // (http://ejohn.org/blog/javascript-micro-templating/)
  35150. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  35151. var settings = lodash.templateSettings;
  35152. if (guard && isIterateeCall(string, options, guard)) {
  35153. options = undefined;
  35154. }
  35155. string = toString(string);
  35156. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  35157. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  35158. importsKeys = keys(imports),
  35159. importsValues = baseValues(imports, importsKeys);
  35160. var isEscaping,
  35161. isEvaluating,
  35162. index = 0,
  35163. interpolate = options.interpolate || reNoMatch,
  35164. source = "__p += '";
  35165. // Compile the regexp to match each delimiter.
  35166. var reDelimiters = RegExp(
  35167. (options.escape || reNoMatch).source + '|' +
  35168. interpolate.source + '|' +
  35169. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  35170. (options.evaluate || reNoMatch).source + '|$'
  35171. , 'g');
  35172. // Use a sourceURL for easier debugging.
  35173. // The sourceURL gets injected into the source that's eval-ed, so be careful
  35174. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  35175. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  35176. var sourceURL = '//# sourceURL=' +
  35177. (hasOwnProperty.call(options, 'sourceURL')
  35178. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  35179. : ('lodash.templateSources[' + (++templateCounter) + ']')
  35180. ) + '\n';
  35181. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  35182. interpolateValue || (interpolateValue = esTemplateValue);
  35183. // Escape characters that can't be included in string literals.
  35184. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  35185. // Replace delimiters with snippets.
  35186. if (escapeValue) {
  35187. isEscaping = true;
  35188. source += "' +\n__e(" + escapeValue + ") +\n'";
  35189. }
  35190. if (evaluateValue) {
  35191. isEvaluating = true;
  35192. source += "';\n" + evaluateValue + ";\n__p += '";
  35193. }
  35194. if (interpolateValue) {
  35195. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  35196. }
  35197. index = offset + match.length;
  35198. // The JS engine embedded in Adobe products needs `match` returned in
  35199. // order to produce the correct `offset` value.
  35200. return match;
  35201. });
  35202. source += "';\n";
  35203. // If `variable` is not specified wrap a with-statement around the generated
  35204. // code to add the data object to the top of the scope chain.
  35205. // Like with sourceURL, we take care to not check the option's prototype,
  35206. // as this configuration is a code injection vector.
  35207. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  35208. if (!variable) {
  35209. source = 'with (obj) {\n' + source + '\n}\n';
  35210. }
  35211. // Cleanup code by stripping empty strings.
  35212. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  35213. .replace(reEmptyStringMiddle, '$1')
  35214. .replace(reEmptyStringTrailing, '$1;');
  35215. // Frame code as the function body.
  35216. source = 'function(' + (variable || 'obj') + ') {\n' +
  35217. (variable
  35218. ? ''
  35219. : 'obj || (obj = {});\n'
  35220. ) +
  35221. "var __t, __p = ''" +
  35222. (isEscaping
  35223. ? ', __e = _.escape'
  35224. : ''
  35225. ) +
  35226. (isEvaluating
  35227. ? ', __j = Array.prototype.join;\n' +
  35228. "function print() { __p += __j.call(arguments, '') }\n"
  35229. : ';\n'
  35230. ) +
  35231. source +
  35232. 'return __p\n}';
  35233. var result = attempt(function() {
  35234. return Function(importsKeys, sourceURL + 'return ' + source)
  35235. .apply(undefined, importsValues);
  35236. });
  35237. // Provide the compiled function's source by its `toString` method or
  35238. // the `source` property as a convenience for inlining compiled templates.
  35239. result.source = source;
  35240. if (isError(result)) {
  35241. throw result;
  35242. }
  35243. return result;
  35244. }
  35245. /**
  35246. * Converts `string`, as a whole, to lower case just like
  35247. * [String#toLowerCase](https://mdn.io/toLowerCase).
  35248. *
  35249. * @static
  35250. * @memberOf _
  35251. * @since 4.0.0
  35252. * @category String
  35253. * @param {string} [string=''] The string to convert.
  35254. * @returns {string} Returns the lower cased string.
  35255. * @example
  35256. *
  35257. * _.toLower('--Foo-Bar--');
  35258. * // => '--foo-bar--'
  35259. *
  35260. * _.toLower('fooBar');
  35261. * // => 'foobar'
  35262. *
  35263. * _.toLower('__FOO_BAR__');
  35264. * // => '__foo_bar__'
  35265. */
  35266. function toLower(value) {
  35267. return toString(value).toLowerCase();
  35268. }
  35269. /**
  35270. * Converts `string`, as a whole, to upper case just like
  35271. * [String#toUpperCase](https://mdn.io/toUpperCase).
  35272. *
  35273. * @static
  35274. * @memberOf _
  35275. * @since 4.0.0
  35276. * @category String
  35277. * @param {string} [string=''] The string to convert.
  35278. * @returns {string} Returns the upper cased string.
  35279. * @example
  35280. *
  35281. * _.toUpper('--foo-bar--');
  35282. * // => '--FOO-BAR--'
  35283. *
  35284. * _.toUpper('fooBar');
  35285. * // => 'FOOBAR'
  35286. *
  35287. * _.toUpper('__foo_bar__');
  35288. * // => '__FOO_BAR__'
  35289. */
  35290. function toUpper(value) {
  35291. return toString(value).toUpperCase();
  35292. }
  35293. /**
  35294. * Removes leading and trailing whitespace or specified characters from `string`.
  35295. *
  35296. * @static
  35297. * @memberOf _
  35298. * @since 3.0.0
  35299. * @category String
  35300. * @param {string} [string=''] The string to trim.
  35301. * @param {string} [chars=whitespace] The characters to trim.
  35302. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  35303. * @returns {string} Returns the trimmed string.
  35304. * @example
  35305. *
  35306. * _.trim(' abc ');
  35307. * // => 'abc'
  35308. *
  35309. * _.trim('-_-abc-_-', '_-');
  35310. * // => 'abc'
  35311. *
  35312. * _.map([' foo ', ' bar '], _.trim);
  35313. * // => ['foo', 'bar']
  35314. */
  35315. function trim(string, chars, guard) {
  35316. string = toString(string);
  35317. if (string && (guard || chars === undefined)) {
  35318. return string.replace(reTrim, '');
  35319. }
  35320. if (!string || !(chars = baseToString(chars))) {
  35321. return string;
  35322. }
  35323. var strSymbols = stringToArray(string),
  35324. chrSymbols = stringToArray(chars),
  35325. start = charsStartIndex(strSymbols, chrSymbols),
  35326. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  35327. return castSlice(strSymbols, start, end).join('');
  35328. }
  35329. /**
  35330. * Removes trailing whitespace or specified characters from `string`.
  35331. *
  35332. * @static
  35333. * @memberOf _
  35334. * @since 4.0.0
  35335. * @category String
  35336. * @param {string} [string=''] The string to trim.
  35337. * @param {string} [chars=whitespace] The characters to trim.
  35338. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  35339. * @returns {string} Returns the trimmed string.
  35340. * @example
  35341. *
  35342. * _.trimEnd(' abc ');
  35343. * // => ' abc'
  35344. *
  35345. * _.trimEnd('-_-abc-_-', '_-');
  35346. * // => '-_-abc'
  35347. */
  35348. function trimEnd(string, chars, guard) {
  35349. string = toString(string);
  35350. if (string && (guard || chars === undefined)) {
  35351. return string.replace(reTrimEnd, '');
  35352. }
  35353. if (!string || !(chars = baseToString(chars))) {
  35354. return string;
  35355. }
  35356. var strSymbols = stringToArray(string),
  35357. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  35358. return castSlice(strSymbols, 0, end).join('');
  35359. }
  35360. /**
  35361. * Removes leading whitespace or specified characters from `string`.
  35362. *
  35363. * @static
  35364. * @memberOf _
  35365. * @since 4.0.0
  35366. * @category String
  35367. * @param {string} [string=''] The string to trim.
  35368. * @param {string} [chars=whitespace] The characters to trim.
  35369. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  35370. * @returns {string} Returns the trimmed string.
  35371. * @example
  35372. *
  35373. * _.trimStart(' abc ');
  35374. * // => 'abc '
  35375. *
  35376. * _.trimStart('-_-abc-_-', '_-');
  35377. * // => 'abc-_-'
  35378. */
  35379. function trimStart(string, chars, guard) {
  35380. string = toString(string);
  35381. if (string && (guard || chars === undefined)) {
  35382. return string.replace(reTrimStart, '');
  35383. }
  35384. if (!string || !(chars = baseToString(chars))) {
  35385. return string;
  35386. }
  35387. var strSymbols = stringToArray(string),
  35388. start = charsStartIndex(strSymbols, stringToArray(chars));
  35389. return castSlice(strSymbols, start).join('');
  35390. }
  35391. /**
  35392. * Truncates `string` if it's longer than the given maximum string length.
  35393. * The last characters of the truncated string are replaced with the omission
  35394. * string which defaults to "...".
  35395. *
  35396. * @static
  35397. * @memberOf _
  35398. * @since 4.0.0
  35399. * @category String
  35400. * @param {string} [string=''] The string to truncate.
  35401. * @param {Object} [options={}] The options object.
  35402. * @param {number} [options.length=30] The maximum string length.
  35403. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  35404. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  35405. * @returns {string} Returns the truncated string.
  35406. * @example
  35407. *
  35408. * _.truncate('hi-diddly-ho there, neighborino');
  35409. * // => 'hi-diddly-ho there, neighbo...'
  35410. *
  35411. * _.truncate('hi-diddly-ho there, neighborino', {
  35412. * 'length': 24,
  35413. * 'separator': ' '
  35414. * });
  35415. * // => 'hi-diddly-ho there,...'
  35416. *
  35417. * _.truncate('hi-diddly-ho there, neighborino', {
  35418. * 'length': 24,
  35419. * 'separator': /,? +/
  35420. * });
  35421. * // => 'hi-diddly-ho there...'
  35422. *
  35423. * _.truncate('hi-diddly-ho there, neighborino', {
  35424. * 'omission': ' [...]'
  35425. * });
  35426. * // => 'hi-diddly-ho there, neig [...]'
  35427. */
  35428. function truncate(string, options) {
  35429. var length = DEFAULT_TRUNC_LENGTH,
  35430. omission = DEFAULT_TRUNC_OMISSION;
  35431. if (isObject(options)) {
  35432. var separator = 'separator' in options ? options.separator : separator;
  35433. length = 'length' in options ? toInteger(options.length) : length;
  35434. omission = 'omission' in options ? baseToString(options.omission) : omission;
  35435. }
  35436. string = toString(string);
  35437. var strLength = string.length;
  35438. if (hasUnicode(string)) {
  35439. var strSymbols = stringToArray(string);
  35440. strLength = strSymbols.length;
  35441. }
  35442. if (length >= strLength) {
  35443. return string;
  35444. }
  35445. var end = length - stringSize(omission);
  35446. if (end < 1) {
  35447. return omission;
  35448. }
  35449. var result = strSymbols
  35450. ? castSlice(strSymbols, 0, end).join('')
  35451. : string.slice(0, end);
  35452. if (separator === undefined) {
  35453. return result + omission;
  35454. }
  35455. if (strSymbols) {
  35456. end += (result.length - end);
  35457. }
  35458. if (isRegExp(separator)) {
  35459. if (string.slice(end).search(separator)) {
  35460. var match,
  35461. substring = result;
  35462. if (!separator.global) {
  35463. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  35464. }
  35465. separator.lastIndex = 0;
  35466. while ((match = separator.exec(substring))) {
  35467. var newEnd = match.index;
  35468. }
  35469. result = result.slice(0, newEnd === undefined ? end : newEnd);
  35470. }
  35471. } else if (string.indexOf(baseToString(separator), end) != end) {
  35472. var index = result.lastIndexOf(separator);
  35473. if (index > -1) {
  35474. result = result.slice(0, index);
  35475. }
  35476. }
  35477. return result + omission;
  35478. }
  35479. /**
  35480. * The inverse of `_.escape`; this method converts the HTML entities
  35481. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  35482. * their corresponding characters.
  35483. *
  35484. * **Note:** No other HTML entities are unescaped. To unescape additional
  35485. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  35486. *
  35487. * @static
  35488. * @memberOf _
  35489. * @since 0.6.0
  35490. * @category String
  35491. * @param {string} [string=''] The string to unescape.
  35492. * @returns {string} Returns the unescaped string.
  35493. * @example
  35494. *
  35495. * _.unescape('fred, barney, &amp; pebbles');
  35496. * // => 'fred, barney, & pebbles'
  35497. */
  35498. function unescape(string) {
  35499. string = toString(string);
  35500. return (string && reHasEscapedHtml.test(string))
  35501. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  35502. : string;
  35503. }
  35504. /**
  35505. * Converts `string`, as space separated words, to upper case.
  35506. *
  35507. * @static
  35508. * @memberOf _
  35509. * @since 4.0.0
  35510. * @category String
  35511. * @param {string} [string=''] The string to convert.
  35512. * @returns {string} Returns the upper cased string.
  35513. * @example
  35514. *
  35515. * _.upperCase('--foo-bar');
  35516. * // => 'FOO BAR'
  35517. *
  35518. * _.upperCase('fooBar');
  35519. * // => 'FOO BAR'
  35520. *
  35521. * _.upperCase('__foo_bar__');
  35522. * // => 'FOO BAR'
  35523. */
  35524. var upperCase = createCompounder(function(result, word, index) {
  35525. return result + (index ? ' ' : '') + word.toUpperCase();
  35526. });
  35527. /**
  35528. * Converts the first character of `string` to upper case.
  35529. *
  35530. * @static
  35531. * @memberOf _
  35532. * @since 4.0.0
  35533. * @category String
  35534. * @param {string} [string=''] The string to convert.
  35535. * @returns {string} Returns the converted string.
  35536. * @example
  35537. *
  35538. * _.upperFirst('fred');
  35539. * // => 'Fred'
  35540. *
  35541. * _.upperFirst('FRED');
  35542. * // => 'FRED'
  35543. */
  35544. var upperFirst = createCaseFirst('toUpperCase');
  35545. /**
  35546. * Splits `string` into an array of its words.
  35547. *
  35548. * @static
  35549. * @memberOf _
  35550. * @since 3.0.0
  35551. * @category String
  35552. * @param {string} [string=''] The string to inspect.
  35553. * @param {RegExp|string} [pattern] The pattern to match words.
  35554. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  35555. * @returns {Array} Returns the words of `string`.
  35556. * @example
  35557. *
  35558. * _.words('fred, barney, & pebbles');
  35559. * // => ['fred', 'barney', 'pebbles']
  35560. *
  35561. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  35562. * // => ['fred', 'barney', '&', 'pebbles']
  35563. */
  35564. function words(string, pattern, guard) {
  35565. string = toString(string);
  35566. pattern = guard ? undefined : pattern;
  35567. if (pattern === undefined) {
  35568. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  35569. }
  35570. return string.match(pattern) || [];
  35571. }
  35572. /*------------------------------------------------------------------------*/
  35573. /**
  35574. * Attempts to invoke `func`, returning either the result or the caught error
  35575. * object. Any additional arguments are provided to `func` when it's invoked.
  35576. *
  35577. * @static
  35578. * @memberOf _
  35579. * @since 3.0.0
  35580. * @category Util
  35581. * @param {Function} func The function to attempt.
  35582. * @param {...*} [args] The arguments to invoke `func` with.
  35583. * @returns {*} Returns the `func` result or error object.
  35584. * @example
  35585. *
  35586. * // Avoid throwing errors for invalid selectors.
  35587. * var elements = _.attempt(function(selector) {
  35588. * return document.querySelectorAll(selector);
  35589. * }, '>_>');
  35590. *
  35591. * if (_.isError(elements)) {
  35592. * elements = [];
  35593. * }
  35594. */
  35595. var attempt = baseRest(function(func, args) {
  35596. try {
  35597. return apply(func, undefined, args);
  35598. } catch (e) {
  35599. return isError(e) ? e : new Error(e);
  35600. }
  35601. });
  35602. /**
  35603. * Binds methods of an object to the object itself, overwriting the existing
  35604. * method.
  35605. *
  35606. * **Note:** This method doesn't set the "length" property of bound functions.
  35607. *
  35608. * @static
  35609. * @since 0.1.0
  35610. * @memberOf _
  35611. * @category Util
  35612. * @param {Object} object The object to bind and assign the bound methods to.
  35613. * @param {...(string|string[])} methodNames The object method names to bind.
  35614. * @returns {Object} Returns `object`.
  35615. * @example
  35616. *
  35617. * var view = {
  35618. * 'label': 'docs',
  35619. * 'click': function() {
  35620. * console.log('clicked ' + this.label);
  35621. * }
  35622. * };
  35623. *
  35624. * _.bindAll(view, ['click']);
  35625. * jQuery(element).on('click', view.click);
  35626. * // => Logs 'clicked docs' when clicked.
  35627. */
  35628. var bindAll = flatRest(function(object, methodNames) {
  35629. arrayEach(methodNames, function(key) {
  35630. key = toKey(key);
  35631. baseAssignValue(object, key, bind(object[key], object));
  35632. });
  35633. return object;
  35634. });
  35635. /**
  35636. * Creates a function that iterates over `pairs` and invokes the corresponding
  35637. * function of the first predicate to return truthy. The predicate-function
  35638. * pairs are invoked with the `this` binding and arguments of the created
  35639. * function.
  35640. *
  35641. * @static
  35642. * @memberOf _
  35643. * @since 4.0.0
  35644. * @category Util
  35645. * @param {Array} pairs The predicate-function pairs.
  35646. * @returns {Function} Returns the new composite function.
  35647. * @example
  35648. *
  35649. * var func = _.cond([
  35650. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  35651. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  35652. * [_.stubTrue, _.constant('no match')]
  35653. * ]);
  35654. *
  35655. * func({ 'a': 1, 'b': 2 });
  35656. * // => 'matches A'
  35657. *
  35658. * func({ 'a': 0, 'b': 1 });
  35659. * // => 'matches B'
  35660. *
  35661. * func({ 'a': '1', 'b': '2' });
  35662. * // => 'no match'
  35663. */
  35664. function cond(pairs) {
  35665. var length = pairs == null ? 0 : pairs.length,
  35666. toIteratee = getIteratee();
  35667. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  35668. if (typeof pair[1] != 'function') {
  35669. throw new TypeError(FUNC_ERROR_TEXT);
  35670. }
  35671. return [toIteratee(pair[0]), pair[1]];
  35672. });
  35673. return baseRest(function(args) {
  35674. var index = -1;
  35675. while (++index < length) {
  35676. var pair = pairs[index];
  35677. if (apply(pair[0], this, args)) {
  35678. return apply(pair[1], this, args);
  35679. }
  35680. }
  35681. });
  35682. }
  35683. /**
  35684. * Creates a function that invokes the predicate properties of `source` with
  35685. * the corresponding property values of a given object, returning `true` if
  35686. * all predicates return truthy, else `false`.
  35687. *
  35688. * **Note:** The created function is equivalent to `_.conformsTo` with
  35689. * `source` partially applied.
  35690. *
  35691. * @static
  35692. * @memberOf _
  35693. * @since 4.0.0
  35694. * @category Util
  35695. * @param {Object} source The object of property predicates to conform to.
  35696. * @returns {Function} Returns the new spec function.
  35697. * @example
  35698. *
  35699. * var objects = [
  35700. * { 'a': 2, 'b': 1 },
  35701. * { 'a': 1, 'b': 2 }
  35702. * ];
  35703. *
  35704. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  35705. * // => [{ 'a': 1, 'b': 2 }]
  35706. */
  35707. function conforms(source) {
  35708. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  35709. }
  35710. /**
  35711. * Creates a function that returns `value`.
  35712. *
  35713. * @static
  35714. * @memberOf _
  35715. * @since 2.4.0
  35716. * @category Util
  35717. * @param {*} value The value to return from the new function.
  35718. * @returns {Function} Returns the new constant function.
  35719. * @example
  35720. *
  35721. * var objects = _.times(2, _.constant({ 'a': 1 }));
  35722. *
  35723. * console.log(objects);
  35724. * // => [{ 'a': 1 }, { 'a': 1 }]
  35725. *
  35726. * console.log(objects[0] === objects[1]);
  35727. * // => true
  35728. */
  35729. function constant(value) {
  35730. return function() {
  35731. return value;
  35732. };
  35733. }
  35734. /**
  35735. * Checks `value` to determine whether a default value should be returned in
  35736. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  35737. * or `undefined`.
  35738. *
  35739. * @static
  35740. * @memberOf _
  35741. * @since 4.14.0
  35742. * @category Util
  35743. * @param {*} value The value to check.
  35744. * @param {*} defaultValue The default value.
  35745. * @returns {*} Returns the resolved value.
  35746. * @example
  35747. *
  35748. * _.defaultTo(1, 10);
  35749. * // => 1
  35750. *
  35751. * _.defaultTo(undefined, 10);
  35752. * // => 10
  35753. */
  35754. function defaultTo(value, defaultValue) {
  35755. return (value == null || value !== value) ? defaultValue : value;
  35756. }
  35757. /**
  35758. * Creates a function that returns the result of invoking the given functions
  35759. * with the `this` binding of the created function, where each successive
  35760. * invocation is supplied the return value of the previous.
  35761. *
  35762. * @static
  35763. * @memberOf _
  35764. * @since 3.0.0
  35765. * @category Util
  35766. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  35767. * @returns {Function} Returns the new composite function.
  35768. * @see _.flowRight
  35769. * @example
  35770. *
  35771. * function square(n) {
  35772. * return n * n;
  35773. * }
  35774. *
  35775. * var addSquare = _.flow([_.add, square]);
  35776. * addSquare(1, 2);
  35777. * // => 9
  35778. */
  35779. var flow = createFlow();
  35780. /**
  35781. * This method is like `_.flow` except that it creates a function that
  35782. * invokes the given functions from right to left.
  35783. *
  35784. * @static
  35785. * @since 3.0.0
  35786. * @memberOf _
  35787. * @category Util
  35788. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  35789. * @returns {Function} Returns the new composite function.
  35790. * @see _.flow
  35791. * @example
  35792. *
  35793. * function square(n) {
  35794. * return n * n;
  35795. * }
  35796. *
  35797. * var addSquare = _.flowRight([square, _.add]);
  35798. * addSquare(1, 2);
  35799. * // => 9
  35800. */
  35801. var flowRight = createFlow(true);
  35802. /**
  35803. * This method returns the first argument it receives.
  35804. *
  35805. * @static
  35806. * @since 0.1.0
  35807. * @memberOf _
  35808. * @category Util
  35809. * @param {*} value Any value.
  35810. * @returns {*} Returns `value`.
  35811. * @example
  35812. *
  35813. * var object = { 'a': 1 };
  35814. *
  35815. * console.log(_.identity(object) === object);
  35816. * // => true
  35817. */
  35818. function identity(value) {
  35819. return value;
  35820. }
  35821. /**
  35822. * Creates a function that invokes `func` with the arguments of the created
  35823. * function. If `func` is a property name, the created function returns the
  35824. * property value for a given element. If `func` is an array or object, the
  35825. * created function returns `true` for elements that contain the equivalent
  35826. * source properties, otherwise it returns `false`.
  35827. *
  35828. * @static
  35829. * @since 4.0.0
  35830. * @memberOf _
  35831. * @category Util
  35832. * @param {*} [func=_.identity] The value to convert to a callback.
  35833. * @returns {Function} Returns the callback.
  35834. * @example
  35835. *
  35836. * var users = [
  35837. * { 'user': 'barney', 'age': 36, 'active': true },
  35838. * { 'user': 'fred', 'age': 40, 'active': false }
  35839. * ];
  35840. *
  35841. * // The `_.matches` iteratee shorthand.
  35842. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  35843. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  35844. *
  35845. * // The `_.matchesProperty` iteratee shorthand.
  35846. * _.filter(users, _.iteratee(['user', 'fred']));
  35847. * // => [{ 'user': 'fred', 'age': 40 }]
  35848. *
  35849. * // The `_.property` iteratee shorthand.
  35850. * _.map(users, _.iteratee('user'));
  35851. * // => ['barney', 'fred']
  35852. *
  35853. * // Create custom iteratee shorthands.
  35854. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  35855. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  35856. * return func.test(string);
  35857. * };
  35858. * });
  35859. *
  35860. * _.filter(['abc', 'def'], /ef/);
  35861. * // => ['def']
  35862. */
  35863. function iteratee(func) {
  35864. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  35865. }
  35866. /**
  35867. * Creates a function that performs a partial deep comparison between a given
  35868. * object and `source`, returning `true` if the given object has equivalent
  35869. * property values, else `false`.
  35870. *
  35871. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  35872. * partially applied.
  35873. *
  35874. * Partial comparisons will match empty array and empty object `source`
  35875. * values against any array or object value, respectively. See `_.isEqual`
  35876. * for a list of supported value comparisons.
  35877. *
  35878. * @static
  35879. * @memberOf _
  35880. * @since 3.0.0
  35881. * @category Util
  35882. * @param {Object} source The object of property values to match.
  35883. * @returns {Function} Returns the new spec function.
  35884. * @example
  35885. *
  35886. * var objects = [
  35887. * { 'a': 1, 'b': 2, 'c': 3 },
  35888. * { 'a': 4, 'b': 5, 'c': 6 }
  35889. * ];
  35890. *
  35891. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  35892. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  35893. */
  35894. function matches(source) {
  35895. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  35896. }
  35897. /**
  35898. * Creates a function that performs a partial deep comparison between the
  35899. * value at `path` of a given object to `srcValue`, returning `true` if the
  35900. * object value is equivalent, else `false`.
  35901. *
  35902. * **Note:** Partial comparisons will match empty array and empty object
  35903. * `srcValue` values against any array or object value, respectively. See
  35904. * `_.isEqual` for a list of supported value comparisons.
  35905. *
  35906. * @static
  35907. * @memberOf _
  35908. * @since 3.2.0
  35909. * @category Util
  35910. * @param {Array|string} path The path of the property to get.
  35911. * @param {*} srcValue The value to match.
  35912. * @returns {Function} Returns the new spec function.
  35913. * @example
  35914. *
  35915. * var objects = [
  35916. * { 'a': 1, 'b': 2, 'c': 3 },
  35917. * { 'a': 4, 'b': 5, 'c': 6 }
  35918. * ];
  35919. *
  35920. * _.find(objects, _.matchesProperty('a', 4));
  35921. * // => { 'a': 4, 'b': 5, 'c': 6 }
  35922. */
  35923. function matchesProperty(path, srcValue) {
  35924. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  35925. }
  35926. /**
  35927. * Creates a function that invokes the method at `path` of a given object.
  35928. * Any additional arguments are provided to the invoked method.
  35929. *
  35930. * @static
  35931. * @memberOf _
  35932. * @since 3.7.0
  35933. * @category Util
  35934. * @param {Array|string} path The path of the method to invoke.
  35935. * @param {...*} [args] The arguments to invoke the method with.
  35936. * @returns {Function} Returns the new invoker function.
  35937. * @example
  35938. *
  35939. * var objects = [
  35940. * { 'a': { 'b': _.constant(2) } },
  35941. * { 'a': { 'b': _.constant(1) } }
  35942. * ];
  35943. *
  35944. * _.map(objects, _.method('a.b'));
  35945. * // => [2, 1]
  35946. *
  35947. * _.map(objects, _.method(['a', 'b']));
  35948. * // => [2, 1]
  35949. */
  35950. var method = baseRest(function(path, args) {
  35951. return function(object) {
  35952. return baseInvoke(object, path, args);
  35953. };
  35954. });
  35955. /**
  35956. * The opposite of `_.method`; this method creates a function that invokes
  35957. * the method at a given path of `object`. Any additional arguments are
  35958. * provided to the invoked method.
  35959. *
  35960. * @static
  35961. * @memberOf _
  35962. * @since 3.7.0
  35963. * @category Util
  35964. * @param {Object} object The object to query.
  35965. * @param {...*} [args] The arguments to invoke the method with.
  35966. * @returns {Function} Returns the new invoker function.
  35967. * @example
  35968. *
  35969. * var array = _.times(3, _.constant),
  35970. * object = { 'a': array, 'b': array, 'c': array };
  35971. *
  35972. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  35973. * // => [2, 0]
  35974. *
  35975. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  35976. * // => [2, 0]
  35977. */
  35978. var methodOf = baseRest(function(object, args) {
  35979. return function(path) {
  35980. return baseInvoke(object, path, args);
  35981. };
  35982. });
  35983. /**
  35984. * Adds all own enumerable string keyed function properties of a source
  35985. * object to the destination object. If `object` is a function, then methods
  35986. * are added to its prototype as well.
  35987. *
  35988. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  35989. * avoid conflicts caused by modifying the original.
  35990. *
  35991. * @static
  35992. * @since 0.1.0
  35993. * @memberOf _
  35994. * @category Util
  35995. * @param {Function|Object} [object=lodash] The destination object.
  35996. * @param {Object} source The object of functions to add.
  35997. * @param {Object} [options={}] The options object.
  35998. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  35999. * @returns {Function|Object} Returns `object`.
  36000. * @example
  36001. *
  36002. * function vowels(string) {
  36003. * return _.filter(string, function(v) {
  36004. * return /[aeiou]/i.test(v);
  36005. * });
  36006. * }
  36007. *
  36008. * _.mixin({ 'vowels': vowels });
  36009. * _.vowels('fred');
  36010. * // => ['e']
  36011. *
  36012. * _('fred').vowels().value();
  36013. * // => ['e']
  36014. *
  36015. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  36016. * _('fred').vowels();
  36017. * // => ['e']
  36018. */
  36019. function mixin(object, source, options) {
  36020. var props = keys(source),
  36021. methodNames = baseFunctions(source, props);
  36022. if (options == null &&
  36023. !(isObject(source) && (methodNames.length || !props.length))) {
  36024. options = source;
  36025. source = object;
  36026. object = this;
  36027. methodNames = baseFunctions(source, keys(source));
  36028. }
  36029. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  36030. isFunc = isFunction(object);
  36031. arrayEach(methodNames, function(methodName) {
  36032. var func = source[methodName];
  36033. object[methodName] = func;
  36034. if (isFunc) {
  36035. object.prototype[methodName] = function() {
  36036. var chainAll = this.__chain__;
  36037. if (chain || chainAll) {
  36038. var result = object(this.__wrapped__),
  36039. actions = result.__actions__ = copyArray(this.__actions__);
  36040. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  36041. result.__chain__ = chainAll;
  36042. return result;
  36043. }
  36044. return func.apply(object, arrayPush([this.value()], arguments));
  36045. };
  36046. }
  36047. });
  36048. return object;
  36049. }
  36050. /**
  36051. * Reverts the `_` variable to its previous value and returns a reference to
  36052. * the `lodash` function.
  36053. *
  36054. * @static
  36055. * @since 0.1.0
  36056. * @memberOf _
  36057. * @category Util
  36058. * @returns {Function} Returns the `lodash` function.
  36059. * @example
  36060. *
  36061. * var lodash = _.noConflict();
  36062. */
  36063. function noConflict() {
  36064. if (root._ === this) {
  36065. root._ = oldDash;
  36066. }
  36067. return this;
  36068. }
  36069. /**
  36070. * This method returns `undefined`.
  36071. *
  36072. * @static
  36073. * @memberOf _
  36074. * @since 2.3.0
  36075. * @category Util
  36076. * @example
  36077. *
  36078. * _.times(2, _.noop);
  36079. * // => [undefined, undefined]
  36080. */
  36081. function noop() {
  36082. // No operation performed.
  36083. }
  36084. /**
  36085. * Creates a function that gets the argument at index `n`. If `n` is negative,
  36086. * the nth argument from the end is returned.
  36087. *
  36088. * @static
  36089. * @memberOf _
  36090. * @since 4.0.0
  36091. * @category Util
  36092. * @param {number} [n=0] The index of the argument to return.
  36093. * @returns {Function} Returns the new pass-thru function.
  36094. * @example
  36095. *
  36096. * var func = _.nthArg(1);
  36097. * func('a', 'b', 'c', 'd');
  36098. * // => 'b'
  36099. *
  36100. * var func = _.nthArg(-2);
  36101. * func('a', 'b', 'c', 'd');
  36102. * // => 'c'
  36103. */
  36104. function nthArg(n) {
  36105. n = toInteger(n);
  36106. return baseRest(function(args) {
  36107. return baseNth(args, n);
  36108. });
  36109. }
  36110. /**
  36111. * Creates a function that invokes `iteratees` with the arguments it receives
  36112. * and returns their results.
  36113. *
  36114. * @static
  36115. * @memberOf _
  36116. * @since 4.0.0
  36117. * @category Util
  36118. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  36119. * The iteratees to invoke.
  36120. * @returns {Function} Returns the new function.
  36121. * @example
  36122. *
  36123. * var func = _.over([Math.max, Math.min]);
  36124. *
  36125. * func(1, 2, 3, 4);
  36126. * // => [4, 1]
  36127. */
  36128. var over = createOver(arrayMap);
  36129. /**
  36130. * Creates a function that checks if **all** of the `predicates` return
  36131. * truthy when invoked with the arguments it receives.
  36132. *
  36133. * @static
  36134. * @memberOf _
  36135. * @since 4.0.0
  36136. * @category Util
  36137. * @param {...(Function|Function[])} [predicates=[_.identity]]
  36138. * The predicates to check.
  36139. * @returns {Function} Returns the new function.
  36140. * @example
  36141. *
  36142. * var func = _.overEvery([Boolean, isFinite]);
  36143. *
  36144. * func('1');
  36145. * // => true
  36146. *
  36147. * func(null);
  36148. * // => false
  36149. *
  36150. * func(NaN);
  36151. * // => false
  36152. */
  36153. var overEvery = createOver(arrayEvery);
  36154. /**
  36155. * Creates a function that checks if **any** of the `predicates` return
  36156. * truthy when invoked with the arguments it receives.
  36157. *
  36158. * @static
  36159. * @memberOf _
  36160. * @since 4.0.0
  36161. * @category Util
  36162. * @param {...(Function|Function[])} [predicates=[_.identity]]
  36163. * The predicates to check.
  36164. * @returns {Function} Returns the new function.
  36165. * @example
  36166. *
  36167. * var func = _.overSome([Boolean, isFinite]);
  36168. *
  36169. * func('1');
  36170. * // => true
  36171. *
  36172. * func(null);
  36173. * // => true
  36174. *
  36175. * func(NaN);
  36176. * // => false
  36177. */
  36178. var overSome = createOver(arraySome);
  36179. /**
  36180. * Creates a function that returns the value at `path` of a given object.
  36181. *
  36182. * @static
  36183. * @memberOf _
  36184. * @since 2.4.0
  36185. * @category Util
  36186. * @param {Array|string} path The path of the property to get.
  36187. * @returns {Function} Returns the new accessor function.
  36188. * @example
  36189. *
  36190. * var objects = [
  36191. * { 'a': { 'b': 2 } },
  36192. * { 'a': { 'b': 1 } }
  36193. * ];
  36194. *
  36195. * _.map(objects, _.property('a.b'));
  36196. * // => [2, 1]
  36197. *
  36198. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  36199. * // => [1, 2]
  36200. */
  36201. function property(path) {
  36202. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  36203. }
  36204. /**
  36205. * The opposite of `_.property`; this method creates a function that returns
  36206. * the value at a given path of `object`.
  36207. *
  36208. * @static
  36209. * @memberOf _
  36210. * @since 3.0.0
  36211. * @category Util
  36212. * @param {Object} object The object to query.
  36213. * @returns {Function} Returns the new accessor function.
  36214. * @example
  36215. *
  36216. * var array = [0, 1, 2],
  36217. * object = { 'a': array, 'b': array, 'c': array };
  36218. *
  36219. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  36220. * // => [2, 0]
  36221. *
  36222. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  36223. * // => [2, 0]
  36224. */
  36225. function propertyOf(object) {
  36226. return function(path) {
  36227. return object == null ? undefined : baseGet(object, path);
  36228. };
  36229. }
  36230. /**
  36231. * Creates an array of numbers (positive and/or negative) progressing from
  36232. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  36233. * `start` is specified without an `end` or `step`. If `end` is not specified,
  36234. * it's set to `start` with `start` then set to `0`.
  36235. *
  36236. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  36237. * floating-point values which can produce unexpected results.
  36238. *
  36239. * @static
  36240. * @since 0.1.0
  36241. * @memberOf _
  36242. * @category Util
  36243. * @param {number} [start=0] The start of the range.
  36244. * @param {number} end The end of the range.
  36245. * @param {number} [step=1] The value to increment or decrement by.
  36246. * @returns {Array} Returns the range of numbers.
  36247. * @see _.inRange, _.rangeRight
  36248. * @example
  36249. *
  36250. * _.range(4);
  36251. * // => [0, 1, 2, 3]
  36252. *
  36253. * _.range(-4);
  36254. * // => [0, -1, -2, -3]
  36255. *
  36256. * _.range(1, 5);
  36257. * // => [1, 2, 3, 4]
  36258. *
  36259. * _.range(0, 20, 5);
  36260. * // => [0, 5, 10, 15]
  36261. *
  36262. * _.range(0, -4, -1);
  36263. * // => [0, -1, -2, -3]
  36264. *
  36265. * _.range(1, 4, 0);
  36266. * // => [1, 1, 1]
  36267. *
  36268. * _.range(0);
  36269. * // => []
  36270. */
  36271. var range = createRange();
  36272. /**
  36273. * This method is like `_.range` except that it populates values in
  36274. * descending order.
  36275. *
  36276. * @static
  36277. * @memberOf _
  36278. * @since 4.0.0
  36279. * @category Util
  36280. * @param {number} [start=0] The start of the range.
  36281. * @param {number} end The end of the range.
  36282. * @param {number} [step=1] The value to increment or decrement by.
  36283. * @returns {Array} Returns the range of numbers.
  36284. * @see _.inRange, _.range
  36285. * @example
  36286. *
  36287. * _.rangeRight(4);
  36288. * // => [3, 2, 1, 0]
  36289. *
  36290. * _.rangeRight(-4);
  36291. * // => [-3, -2, -1, 0]
  36292. *
  36293. * _.rangeRight(1, 5);
  36294. * // => [4, 3, 2, 1]
  36295. *
  36296. * _.rangeRight(0, 20, 5);
  36297. * // => [15, 10, 5, 0]
  36298. *
  36299. * _.rangeRight(0, -4, -1);
  36300. * // => [-3, -2, -1, 0]
  36301. *
  36302. * _.rangeRight(1, 4, 0);
  36303. * // => [1, 1, 1]
  36304. *
  36305. * _.rangeRight(0);
  36306. * // => []
  36307. */
  36308. var rangeRight = createRange(true);
  36309. /**
  36310. * This method returns a new empty array.
  36311. *
  36312. * @static
  36313. * @memberOf _
  36314. * @since 4.13.0
  36315. * @category Util
  36316. * @returns {Array} Returns the new empty array.
  36317. * @example
  36318. *
  36319. * var arrays = _.times(2, _.stubArray);
  36320. *
  36321. * console.log(arrays);
  36322. * // => [[], []]
  36323. *
  36324. * console.log(arrays[0] === arrays[1]);
  36325. * // => false
  36326. */
  36327. function stubArray() {
  36328. return [];
  36329. }
  36330. /**
  36331. * This method returns `false`.
  36332. *
  36333. * @static
  36334. * @memberOf _
  36335. * @since 4.13.0
  36336. * @category Util
  36337. * @returns {boolean} Returns `false`.
  36338. * @example
  36339. *
  36340. * _.times(2, _.stubFalse);
  36341. * // => [false, false]
  36342. */
  36343. function stubFalse() {
  36344. return false;
  36345. }
  36346. /**
  36347. * This method returns a new empty object.
  36348. *
  36349. * @static
  36350. * @memberOf _
  36351. * @since 4.13.0
  36352. * @category Util
  36353. * @returns {Object} Returns the new empty object.
  36354. * @example
  36355. *
  36356. * var objects = _.times(2, _.stubObject);
  36357. *
  36358. * console.log(objects);
  36359. * // => [{}, {}]
  36360. *
  36361. * console.log(objects[0] === objects[1]);
  36362. * // => false
  36363. */
  36364. function stubObject() {
  36365. return {};
  36366. }
  36367. /**
  36368. * This method returns an empty string.
  36369. *
  36370. * @static
  36371. * @memberOf _
  36372. * @since 4.13.0
  36373. * @category Util
  36374. * @returns {string} Returns the empty string.
  36375. * @example
  36376. *
  36377. * _.times(2, _.stubString);
  36378. * // => ['', '']
  36379. */
  36380. function stubString() {
  36381. return '';
  36382. }
  36383. /**
  36384. * This method returns `true`.
  36385. *
  36386. * @static
  36387. * @memberOf _
  36388. * @since 4.13.0
  36389. * @category Util
  36390. * @returns {boolean} Returns `true`.
  36391. * @example
  36392. *
  36393. * _.times(2, _.stubTrue);
  36394. * // => [true, true]
  36395. */
  36396. function stubTrue() {
  36397. return true;
  36398. }
  36399. /**
  36400. * Invokes the iteratee `n` times, returning an array of the results of
  36401. * each invocation. The iteratee is invoked with one argument; (index).
  36402. *
  36403. * @static
  36404. * @since 0.1.0
  36405. * @memberOf _
  36406. * @category Util
  36407. * @param {number} n The number of times to invoke `iteratee`.
  36408. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  36409. * @returns {Array} Returns the array of results.
  36410. * @example
  36411. *
  36412. * _.times(3, String);
  36413. * // => ['0', '1', '2']
  36414. *
  36415. * _.times(4, _.constant(0));
  36416. * // => [0, 0, 0, 0]
  36417. */
  36418. function times(n, iteratee) {
  36419. n = toInteger(n);
  36420. if (n < 1 || n > MAX_SAFE_INTEGER) {
  36421. return [];
  36422. }
  36423. var index = MAX_ARRAY_LENGTH,
  36424. length = nativeMin(n, MAX_ARRAY_LENGTH);
  36425. iteratee = getIteratee(iteratee);
  36426. n -= MAX_ARRAY_LENGTH;
  36427. var result = baseTimes(length, iteratee);
  36428. while (++index < n) {
  36429. iteratee(index);
  36430. }
  36431. return result;
  36432. }
  36433. /**
  36434. * Converts `value` to a property path array.
  36435. *
  36436. * @static
  36437. * @memberOf _
  36438. * @since 4.0.0
  36439. * @category Util
  36440. * @param {*} value The value to convert.
  36441. * @returns {Array} Returns the new property path array.
  36442. * @example
  36443. *
  36444. * _.toPath('a.b.c');
  36445. * // => ['a', 'b', 'c']
  36446. *
  36447. * _.toPath('a[0].b.c');
  36448. * // => ['a', '0', 'b', 'c']
  36449. */
  36450. function toPath(value) {
  36451. if (isArray(value)) {
  36452. return arrayMap(value, toKey);
  36453. }
  36454. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  36455. }
  36456. /**
  36457. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  36458. *
  36459. * @static
  36460. * @since 0.1.0
  36461. * @memberOf _
  36462. * @category Util
  36463. * @param {string} [prefix=''] The value to prefix the ID with.
  36464. * @returns {string} Returns the unique ID.
  36465. * @example
  36466. *
  36467. * _.uniqueId('contact_');
  36468. * // => 'contact_104'
  36469. *
  36470. * _.uniqueId();
  36471. * // => '105'
  36472. */
  36473. function uniqueId(prefix) {
  36474. var id = ++idCounter;
  36475. return toString(prefix) + id;
  36476. }
  36477. /*------------------------------------------------------------------------*/
  36478. /**
  36479. * Adds two numbers.
  36480. *
  36481. * @static
  36482. * @memberOf _
  36483. * @since 3.4.0
  36484. * @category Math
  36485. * @param {number} augend The first number in an addition.
  36486. * @param {number} addend The second number in an addition.
  36487. * @returns {number} Returns the total.
  36488. * @example
  36489. *
  36490. * _.add(6, 4);
  36491. * // => 10
  36492. */
  36493. var add = createMathOperation(function(augend, addend) {
  36494. return augend + addend;
  36495. }, 0);
  36496. /**
  36497. * Computes `number` rounded up to `precision`.
  36498. *
  36499. * @static
  36500. * @memberOf _
  36501. * @since 3.10.0
  36502. * @category Math
  36503. * @param {number} number The number to round up.
  36504. * @param {number} [precision=0] The precision to round up to.
  36505. * @returns {number} Returns the rounded up number.
  36506. * @example
  36507. *
  36508. * _.ceil(4.006);
  36509. * // => 5
  36510. *
  36511. * _.ceil(6.004, 2);
  36512. * // => 6.01
  36513. *
  36514. * _.ceil(6040, -2);
  36515. * // => 6100
  36516. */
  36517. var ceil = createRound('ceil');
  36518. /**
  36519. * Divide two numbers.
  36520. *
  36521. * @static
  36522. * @memberOf _
  36523. * @since 4.7.0
  36524. * @category Math
  36525. * @param {number} dividend The first number in a division.
  36526. * @param {number} divisor The second number in a division.
  36527. * @returns {number} Returns the quotient.
  36528. * @example
  36529. *
  36530. * _.divide(6, 4);
  36531. * // => 1.5
  36532. */
  36533. var divide = createMathOperation(function(dividend, divisor) {
  36534. return dividend / divisor;
  36535. }, 1);
  36536. /**
  36537. * Computes `number` rounded down to `precision`.
  36538. *
  36539. * @static
  36540. * @memberOf _
  36541. * @since 3.10.0
  36542. * @category Math
  36543. * @param {number} number The number to round down.
  36544. * @param {number} [precision=0] The precision to round down to.
  36545. * @returns {number} Returns the rounded down number.
  36546. * @example
  36547. *
  36548. * _.floor(4.006);
  36549. * // => 4
  36550. *
  36551. * _.floor(0.046, 2);
  36552. * // => 0.04
  36553. *
  36554. * _.floor(4060, -2);
  36555. * // => 4000
  36556. */
  36557. var floor = createRound('floor');
  36558. /**
  36559. * Computes the maximum value of `array`. If `array` is empty or falsey,
  36560. * `undefined` is returned.
  36561. *
  36562. * @static
  36563. * @since 0.1.0
  36564. * @memberOf _
  36565. * @category Math
  36566. * @param {Array} array The array to iterate over.
  36567. * @returns {*} Returns the maximum value.
  36568. * @example
  36569. *
  36570. * _.max([4, 2, 8, 6]);
  36571. * // => 8
  36572. *
  36573. * _.max([]);
  36574. * // => undefined
  36575. */
  36576. function max(array) {
  36577. return (array && array.length)
  36578. ? baseExtremum(array, identity, baseGt)
  36579. : undefined;
  36580. }
  36581. /**
  36582. * This method is like `_.max` except that it accepts `iteratee` which is
  36583. * invoked for each element in `array` to generate the criterion by which
  36584. * the value is ranked. The iteratee is invoked with one argument: (value).
  36585. *
  36586. * @static
  36587. * @memberOf _
  36588. * @since 4.0.0
  36589. * @category Math
  36590. * @param {Array} array The array to iterate over.
  36591. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  36592. * @returns {*} Returns the maximum value.
  36593. * @example
  36594. *
  36595. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  36596. *
  36597. * _.maxBy(objects, function(o) { return o.n; });
  36598. * // => { 'n': 2 }
  36599. *
  36600. * // The `_.property` iteratee shorthand.
  36601. * _.maxBy(objects, 'n');
  36602. * // => { 'n': 2 }
  36603. */
  36604. function maxBy(array, iteratee) {
  36605. return (array && array.length)
  36606. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  36607. : undefined;
  36608. }
  36609. /**
  36610. * Computes the mean of the values in `array`.
  36611. *
  36612. * @static
  36613. * @memberOf _
  36614. * @since 4.0.0
  36615. * @category Math
  36616. * @param {Array} array The array to iterate over.
  36617. * @returns {number} Returns the mean.
  36618. * @example
  36619. *
  36620. * _.mean([4, 2, 8, 6]);
  36621. * // => 5
  36622. */
  36623. function mean(array) {
  36624. return baseMean(array, identity);
  36625. }
  36626. /**
  36627. * This method is like `_.mean` except that it accepts `iteratee` which is
  36628. * invoked for each element in `array` to generate the value to be averaged.
  36629. * The iteratee is invoked with one argument: (value).
  36630. *
  36631. * @static
  36632. * @memberOf _
  36633. * @since 4.7.0
  36634. * @category Math
  36635. * @param {Array} array The array to iterate over.
  36636. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  36637. * @returns {number} Returns the mean.
  36638. * @example
  36639. *
  36640. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  36641. *
  36642. * _.meanBy(objects, function(o) { return o.n; });
  36643. * // => 5
  36644. *
  36645. * // The `_.property` iteratee shorthand.
  36646. * _.meanBy(objects, 'n');
  36647. * // => 5
  36648. */
  36649. function meanBy(array, iteratee) {
  36650. return baseMean(array, getIteratee(iteratee, 2));
  36651. }
  36652. /**
  36653. * Computes the minimum value of `array`. If `array` is empty or falsey,
  36654. * `undefined` is returned.
  36655. *
  36656. * @static
  36657. * @since 0.1.0
  36658. * @memberOf _
  36659. * @category Math
  36660. * @param {Array} array The array to iterate over.
  36661. * @returns {*} Returns the minimum value.
  36662. * @example
  36663. *
  36664. * _.min([4, 2, 8, 6]);
  36665. * // => 2
  36666. *
  36667. * _.min([]);
  36668. * // => undefined
  36669. */
  36670. function min(array) {
  36671. return (array && array.length)
  36672. ? baseExtremum(array, identity, baseLt)
  36673. : undefined;
  36674. }
  36675. /**
  36676. * This method is like `_.min` except that it accepts `iteratee` which is
  36677. * invoked for each element in `array` to generate the criterion by which
  36678. * the value is ranked. The iteratee is invoked with one argument: (value).
  36679. *
  36680. * @static
  36681. * @memberOf _
  36682. * @since 4.0.0
  36683. * @category Math
  36684. * @param {Array} array The array to iterate over.
  36685. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  36686. * @returns {*} Returns the minimum value.
  36687. * @example
  36688. *
  36689. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  36690. *
  36691. * _.minBy(objects, function(o) { return o.n; });
  36692. * // => { 'n': 1 }
  36693. *
  36694. * // The `_.property` iteratee shorthand.
  36695. * _.minBy(objects, 'n');
  36696. * // => { 'n': 1 }
  36697. */
  36698. function minBy(array, iteratee) {
  36699. return (array && array.length)
  36700. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  36701. : undefined;
  36702. }
  36703. /**
  36704. * Multiply two numbers.
  36705. *
  36706. * @static
  36707. * @memberOf _
  36708. * @since 4.7.0
  36709. * @category Math
  36710. * @param {number} multiplier The first number in a multiplication.
  36711. * @param {number} multiplicand The second number in a multiplication.
  36712. * @returns {number} Returns the product.
  36713. * @example
  36714. *
  36715. * _.multiply(6, 4);
  36716. * // => 24
  36717. */
  36718. var multiply = createMathOperation(function(multiplier, multiplicand) {
  36719. return multiplier * multiplicand;
  36720. }, 1);
  36721. /**
  36722. * Computes `number` rounded to `precision`.
  36723. *
  36724. * @static
  36725. * @memberOf _
  36726. * @since 3.10.0
  36727. * @category Math
  36728. * @param {number} number The number to round.
  36729. * @param {number} [precision=0] The precision to round to.
  36730. * @returns {number} Returns the rounded number.
  36731. * @example
  36732. *
  36733. * _.round(4.006);
  36734. * // => 4
  36735. *
  36736. * _.round(4.006, 2);
  36737. * // => 4.01
  36738. *
  36739. * _.round(4060, -2);
  36740. * // => 4100
  36741. */
  36742. var round = createRound('round');
  36743. /**
  36744. * Subtract two numbers.
  36745. *
  36746. * @static
  36747. * @memberOf _
  36748. * @since 4.0.0
  36749. * @category Math
  36750. * @param {number} minuend The first number in a subtraction.
  36751. * @param {number} subtrahend The second number in a subtraction.
  36752. * @returns {number} Returns the difference.
  36753. * @example
  36754. *
  36755. * _.subtract(6, 4);
  36756. * // => 2
  36757. */
  36758. var subtract = createMathOperation(function(minuend, subtrahend) {
  36759. return minuend - subtrahend;
  36760. }, 0);
  36761. /**
  36762. * Computes the sum of the values in `array`.
  36763. *
  36764. * @static
  36765. * @memberOf _
  36766. * @since 3.4.0
  36767. * @category Math
  36768. * @param {Array} array The array to iterate over.
  36769. * @returns {number} Returns the sum.
  36770. * @example
  36771. *
  36772. * _.sum([4, 2, 8, 6]);
  36773. * // => 20
  36774. */
  36775. function sum(array) {
  36776. return (array && array.length)
  36777. ? baseSum(array, identity)
  36778. : 0;
  36779. }
  36780. /**
  36781. * This method is like `_.sum` except that it accepts `iteratee` which is
  36782. * invoked for each element in `array` to generate the value to be summed.
  36783. * The iteratee is invoked with one argument: (value).
  36784. *
  36785. * @static
  36786. * @memberOf _
  36787. * @since 4.0.0
  36788. * @category Math
  36789. * @param {Array} array The array to iterate over.
  36790. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  36791. * @returns {number} Returns the sum.
  36792. * @example
  36793. *
  36794. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  36795. *
  36796. * _.sumBy(objects, function(o) { return o.n; });
  36797. * // => 20
  36798. *
  36799. * // The `_.property` iteratee shorthand.
  36800. * _.sumBy(objects, 'n');
  36801. * // => 20
  36802. */
  36803. function sumBy(array, iteratee) {
  36804. return (array && array.length)
  36805. ? baseSum(array, getIteratee(iteratee, 2))
  36806. : 0;
  36807. }
  36808. /*------------------------------------------------------------------------*/
  36809. // Add methods that return wrapped values in chain sequences.
  36810. lodash.after = after;
  36811. lodash.ary = ary;
  36812. lodash.assign = assign;
  36813. lodash.assignIn = assignIn;
  36814. lodash.assignInWith = assignInWith;
  36815. lodash.assignWith = assignWith;
  36816. lodash.at = at;
  36817. lodash.before = before;
  36818. lodash.bind = bind;
  36819. lodash.bindAll = bindAll;
  36820. lodash.bindKey = bindKey;
  36821. lodash.castArray = castArray;
  36822. lodash.chain = chain;
  36823. lodash.chunk = chunk;
  36824. lodash.compact = compact;
  36825. lodash.concat = concat;
  36826. lodash.cond = cond;
  36827. lodash.conforms = conforms;
  36828. lodash.constant = constant;
  36829. lodash.countBy = countBy;
  36830. lodash.create = create;
  36831. lodash.curry = curry;
  36832. lodash.curryRight = curryRight;
  36833. lodash.debounce = debounce;
  36834. lodash.defaults = defaults;
  36835. lodash.defaultsDeep = defaultsDeep;
  36836. lodash.defer = defer;
  36837. lodash.delay = delay;
  36838. lodash.difference = difference;
  36839. lodash.differenceBy = differenceBy;
  36840. lodash.differenceWith = differenceWith;
  36841. lodash.drop = drop;
  36842. lodash.dropRight = dropRight;
  36843. lodash.dropRightWhile = dropRightWhile;
  36844. lodash.dropWhile = dropWhile;
  36845. lodash.fill = fill;
  36846. lodash.filter = filter;
  36847. lodash.flatMap = flatMap;
  36848. lodash.flatMapDeep = flatMapDeep;
  36849. lodash.flatMapDepth = flatMapDepth;
  36850. lodash.flatten = flatten;
  36851. lodash.flattenDeep = flattenDeep;
  36852. lodash.flattenDepth = flattenDepth;
  36853. lodash.flip = flip;
  36854. lodash.flow = flow;
  36855. lodash.flowRight = flowRight;
  36856. lodash.fromPairs = fromPairs;
  36857. lodash.functions = functions;
  36858. lodash.functionsIn = functionsIn;
  36859. lodash.groupBy = groupBy;
  36860. lodash.initial = initial;
  36861. lodash.intersection = intersection;
  36862. lodash.intersectionBy = intersectionBy;
  36863. lodash.intersectionWith = intersectionWith;
  36864. lodash.invert = invert;
  36865. lodash.invertBy = invertBy;
  36866. lodash.invokeMap = invokeMap;
  36867. lodash.iteratee = iteratee;
  36868. lodash.keyBy = keyBy;
  36869. lodash.keys = keys;
  36870. lodash.keysIn = keysIn;
  36871. lodash.map = map;
  36872. lodash.mapKeys = mapKeys;
  36873. lodash.mapValues = mapValues;
  36874. lodash.matches = matches;
  36875. lodash.matchesProperty = matchesProperty;
  36876. lodash.memoize = memoize;
  36877. lodash.merge = merge;
  36878. lodash.mergeWith = mergeWith;
  36879. lodash.method = method;
  36880. lodash.methodOf = methodOf;
  36881. lodash.mixin = mixin;
  36882. lodash.negate = negate;
  36883. lodash.nthArg = nthArg;
  36884. lodash.omit = omit;
  36885. lodash.omitBy = omitBy;
  36886. lodash.once = once;
  36887. lodash.orderBy = orderBy;
  36888. lodash.over = over;
  36889. lodash.overArgs = overArgs;
  36890. lodash.overEvery = overEvery;
  36891. lodash.overSome = overSome;
  36892. lodash.partial = partial;
  36893. lodash.partialRight = partialRight;
  36894. lodash.partition = partition;
  36895. lodash.pick = pick;
  36896. lodash.pickBy = pickBy;
  36897. lodash.property = property;
  36898. lodash.propertyOf = propertyOf;
  36899. lodash.pull = pull;
  36900. lodash.pullAll = pullAll;
  36901. lodash.pullAllBy = pullAllBy;
  36902. lodash.pullAllWith = pullAllWith;
  36903. lodash.pullAt = pullAt;
  36904. lodash.range = range;
  36905. lodash.rangeRight = rangeRight;
  36906. lodash.rearg = rearg;
  36907. lodash.reject = reject;
  36908. lodash.remove = remove;
  36909. lodash.rest = rest;
  36910. lodash.reverse = reverse;
  36911. lodash.sampleSize = sampleSize;
  36912. lodash.set = set;
  36913. lodash.setWith = setWith;
  36914. lodash.shuffle = shuffle;
  36915. lodash.slice = slice;
  36916. lodash.sortBy = sortBy;
  36917. lodash.sortedUniq = sortedUniq;
  36918. lodash.sortedUniqBy = sortedUniqBy;
  36919. lodash.split = split;
  36920. lodash.spread = spread;
  36921. lodash.tail = tail;
  36922. lodash.take = take;
  36923. lodash.takeRight = takeRight;
  36924. lodash.takeRightWhile = takeRightWhile;
  36925. lodash.takeWhile = takeWhile;
  36926. lodash.tap = tap;
  36927. lodash.throttle = throttle;
  36928. lodash.thru = thru;
  36929. lodash.toArray = toArray;
  36930. lodash.toPairs = toPairs;
  36931. lodash.toPairsIn = toPairsIn;
  36932. lodash.toPath = toPath;
  36933. lodash.toPlainObject = toPlainObject;
  36934. lodash.transform = transform;
  36935. lodash.unary = unary;
  36936. lodash.union = union;
  36937. lodash.unionBy = unionBy;
  36938. lodash.unionWith = unionWith;
  36939. lodash.uniq = uniq;
  36940. lodash.uniqBy = uniqBy;
  36941. lodash.uniqWith = uniqWith;
  36942. lodash.unset = unset;
  36943. lodash.unzip = unzip;
  36944. lodash.unzipWith = unzipWith;
  36945. lodash.update = update;
  36946. lodash.updateWith = updateWith;
  36947. lodash.values = values;
  36948. lodash.valuesIn = valuesIn;
  36949. lodash.without = without;
  36950. lodash.words = words;
  36951. lodash.wrap = wrap;
  36952. lodash.xor = xor;
  36953. lodash.xorBy = xorBy;
  36954. lodash.xorWith = xorWith;
  36955. lodash.zip = zip;
  36956. lodash.zipObject = zipObject;
  36957. lodash.zipObjectDeep = zipObjectDeep;
  36958. lodash.zipWith = zipWith;
  36959. // Add aliases.
  36960. lodash.entries = toPairs;
  36961. lodash.entriesIn = toPairsIn;
  36962. lodash.extend = assignIn;
  36963. lodash.extendWith = assignInWith;
  36964. // Add methods to `lodash.prototype`.
  36965. mixin(lodash, lodash);
  36966. /*------------------------------------------------------------------------*/
  36967. // Add methods that return unwrapped values in chain sequences.
  36968. lodash.add = add;
  36969. lodash.attempt = attempt;
  36970. lodash.camelCase = camelCase;
  36971. lodash.capitalize = capitalize;
  36972. lodash.ceil = ceil;
  36973. lodash.clamp = clamp;
  36974. lodash.clone = clone;
  36975. lodash.cloneDeep = cloneDeep;
  36976. lodash.cloneDeepWith = cloneDeepWith;
  36977. lodash.cloneWith = cloneWith;
  36978. lodash.conformsTo = conformsTo;
  36979. lodash.deburr = deburr;
  36980. lodash.defaultTo = defaultTo;
  36981. lodash.divide = divide;
  36982. lodash.endsWith = endsWith;
  36983. lodash.eq = eq;
  36984. lodash.escape = escape;
  36985. lodash.escapeRegExp = escapeRegExp;
  36986. lodash.every = every;
  36987. lodash.find = find;
  36988. lodash.findIndex = findIndex;
  36989. lodash.findKey = findKey;
  36990. lodash.findLast = findLast;
  36991. lodash.findLastIndex = findLastIndex;
  36992. lodash.findLastKey = findLastKey;
  36993. lodash.floor = floor;
  36994. lodash.forEach = forEach;
  36995. lodash.forEachRight = forEachRight;
  36996. lodash.forIn = forIn;
  36997. lodash.forInRight = forInRight;
  36998. lodash.forOwn = forOwn;
  36999. lodash.forOwnRight = forOwnRight;
  37000. lodash.get = get;
  37001. lodash.gt = gt;
  37002. lodash.gte = gte;
  37003. lodash.has = has;
  37004. lodash.hasIn = hasIn;
  37005. lodash.head = head;
  37006. lodash.identity = identity;
  37007. lodash.includes = includes;
  37008. lodash.indexOf = indexOf;
  37009. lodash.inRange = inRange;
  37010. lodash.invoke = invoke;
  37011. lodash.isArguments = isArguments;
  37012. lodash.isArray = isArray;
  37013. lodash.isArrayBuffer = isArrayBuffer;
  37014. lodash.isArrayLike = isArrayLike;
  37015. lodash.isArrayLikeObject = isArrayLikeObject;
  37016. lodash.isBoolean = isBoolean;
  37017. lodash.isBuffer = isBuffer;
  37018. lodash.isDate = isDate;
  37019. lodash.isElement = isElement;
  37020. lodash.isEmpty = isEmpty;
  37021. lodash.isEqual = isEqual;
  37022. lodash.isEqualWith = isEqualWith;
  37023. lodash.isError = isError;
  37024. lodash.isFinite = isFinite;
  37025. lodash.isFunction = isFunction;
  37026. lodash.isInteger = isInteger;
  37027. lodash.isLength = isLength;
  37028. lodash.isMap = isMap;
  37029. lodash.isMatch = isMatch;
  37030. lodash.isMatchWith = isMatchWith;
  37031. lodash.isNaN = isNaN;
  37032. lodash.isNative = isNative;
  37033. lodash.isNil = isNil;
  37034. lodash.isNull = isNull;
  37035. lodash.isNumber = isNumber;
  37036. lodash.isObject = isObject;
  37037. lodash.isObjectLike = isObjectLike;
  37038. lodash.isPlainObject = isPlainObject;
  37039. lodash.isRegExp = isRegExp;
  37040. lodash.isSafeInteger = isSafeInteger;
  37041. lodash.isSet = isSet;
  37042. lodash.isString = isString;
  37043. lodash.isSymbol = isSymbol;
  37044. lodash.isTypedArray = isTypedArray;
  37045. lodash.isUndefined = isUndefined;
  37046. lodash.isWeakMap = isWeakMap;
  37047. lodash.isWeakSet = isWeakSet;
  37048. lodash.join = join;
  37049. lodash.kebabCase = kebabCase;
  37050. lodash.last = last;
  37051. lodash.lastIndexOf = lastIndexOf;
  37052. lodash.lowerCase = lowerCase;
  37053. lodash.lowerFirst = lowerFirst;
  37054. lodash.lt = lt;
  37055. lodash.lte = lte;
  37056. lodash.max = max;
  37057. lodash.maxBy = maxBy;
  37058. lodash.mean = mean;
  37059. lodash.meanBy = meanBy;
  37060. lodash.min = min;
  37061. lodash.minBy = minBy;
  37062. lodash.stubArray = stubArray;
  37063. lodash.stubFalse = stubFalse;
  37064. lodash.stubObject = stubObject;
  37065. lodash.stubString = stubString;
  37066. lodash.stubTrue = stubTrue;
  37067. lodash.multiply = multiply;
  37068. lodash.nth = nth;
  37069. lodash.noConflict = noConflict;
  37070. lodash.noop = noop;
  37071. lodash.now = now;
  37072. lodash.pad = pad;
  37073. lodash.padEnd = padEnd;
  37074. lodash.padStart = padStart;
  37075. lodash.parseInt = parseInt;
  37076. lodash.random = random;
  37077. lodash.reduce = reduce;
  37078. lodash.reduceRight = reduceRight;
  37079. lodash.repeat = repeat;
  37080. lodash.replace = replace;
  37081. lodash.result = result;
  37082. lodash.round = round;
  37083. lodash.runInContext = runInContext;
  37084. lodash.sample = sample;
  37085. lodash.size = size;
  37086. lodash.snakeCase = snakeCase;
  37087. lodash.some = some;
  37088. lodash.sortedIndex = sortedIndex;
  37089. lodash.sortedIndexBy = sortedIndexBy;
  37090. lodash.sortedIndexOf = sortedIndexOf;
  37091. lodash.sortedLastIndex = sortedLastIndex;
  37092. lodash.sortedLastIndexBy = sortedLastIndexBy;
  37093. lodash.sortedLastIndexOf = sortedLastIndexOf;
  37094. lodash.startCase = startCase;
  37095. lodash.startsWith = startsWith;
  37096. lodash.subtract = subtract;
  37097. lodash.sum = sum;
  37098. lodash.sumBy = sumBy;
  37099. lodash.template = template;
  37100. lodash.times = times;
  37101. lodash.toFinite = toFinite;
  37102. lodash.toInteger = toInteger;
  37103. lodash.toLength = toLength;
  37104. lodash.toLower = toLower;
  37105. lodash.toNumber = toNumber;
  37106. lodash.toSafeInteger = toSafeInteger;
  37107. lodash.toString = toString;
  37108. lodash.toUpper = toUpper;
  37109. lodash.trim = trim;
  37110. lodash.trimEnd = trimEnd;
  37111. lodash.trimStart = trimStart;
  37112. lodash.truncate = truncate;
  37113. lodash.unescape = unescape;
  37114. lodash.uniqueId = uniqueId;
  37115. lodash.upperCase = upperCase;
  37116. lodash.upperFirst = upperFirst;
  37117. // Add aliases.
  37118. lodash.each = forEach;
  37119. lodash.eachRight = forEachRight;
  37120. lodash.first = head;
  37121. mixin(lodash, (function() {
  37122. var source = {};
  37123. baseForOwn(lodash, function(func, methodName) {
  37124. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  37125. source[methodName] = func;
  37126. }
  37127. });
  37128. return source;
  37129. }()), { 'chain': false });
  37130. /*------------------------------------------------------------------------*/
  37131. /**
  37132. * The semantic version number.
  37133. *
  37134. * @static
  37135. * @memberOf _
  37136. * @type {string}
  37137. */
  37138. lodash.VERSION = VERSION;
  37139. // Assign default placeholders.
  37140. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  37141. lodash[methodName].placeholder = lodash;
  37142. });
  37143. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  37144. arrayEach(['drop', 'take'], function(methodName, index) {
  37145. LazyWrapper.prototype[methodName] = function(n) {
  37146. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  37147. var result = (this.__filtered__ && !index)
  37148. ? new LazyWrapper(this)
  37149. : this.clone();
  37150. if (result.__filtered__) {
  37151. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  37152. } else {
  37153. result.__views__.push({
  37154. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  37155. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  37156. });
  37157. }
  37158. return result;
  37159. };
  37160. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  37161. return this.reverse()[methodName](n).reverse();
  37162. };
  37163. });
  37164. // Add `LazyWrapper` methods that accept an `iteratee` value.
  37165. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  37166. var type = index + 1,
  37167. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  37168. LazyWrapper.prototype[methodName] = function(iteratee) {
  37169. var result = this.clone();
  37170. result.__iteratees__.push({
  37171. 'iteratee': getIteratee(iteratee, 3),
  37172. 'type': type
  37173. });
  37174. result.__filtered__ = result.__filtered__ || isFilter;
  37175. return result;
  37176. };
  37177. });
  37178. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  37179. arrayEach(['head', 'last'], function(methodName, index) {
  37180. var takeName = 'take' + (index ? 'Right' : '');
  37181. LazyWrapper.prototype[methodName] = function() {
  37182. return this[takeName](1).value()[0];
  37183. };
  37184. });
  37185. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  37186. arrayEach(['initial', 'tail'], function(methodName, index) {
  37187. var dropName = 'drop' + (index ? '' : 'Right');
  37188. LazyWrapper.prototype[methodName] = function() {
  37189. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  37190. };
  37191. });
  37192. LazyWrapper.prototype.compact = function() {
  37193. return this.filter(identity);
  37194. };
  37195. LazyWrapper.prototype.find = function(predicate) {
  37196. return this.filter(predicate).head();
  37197. };
  37198. LazyWrapper.prototype.findLast = function(predicate) {
  37199. return this.reverse().find(predicate);
  37200. };
  37201. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  37202. if (typeof path == 'function') {
  37203. return new LazyWrapper(this);
  37204. }
  37205. return this.map(function(value) {
  37206. return baseInvoke(value, path, args);
  37207. });
  37208. });
  37209. LazyWrapper.prototype.reject = function(predicate) {
  37210. return this.filter(negate(getIteratee(predicate)));
  37211. };
  37212. LazyWrapper.prototype.slice = function(start, end) {
  37213. start = toInteger(start);
  37214. var result = this;
  37215. if (result.__filtered__ && (start > 0 || end < 0)) {
  37216. return new LazyWrapper(result);
  37217. }
  37218. if (start < 0) {
  37219. result = result.takeRight(-start);
  37220. } else if (start) {
  37221. result = result.drop(start);
  37222. }
  37223. if (end !== undefined) {
  37224. end = toInteger(end);
  37225. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  37226. }
  37227. return result;
  37228. };
  37229. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  37230. return this.reverse().takeWhile(predicate).reverse();
  37231. };
  37232. LazyWrapper.prototype.toArray = function() {
  37233. return this.take(MAX_ARRAY_LENGTH);
  37234. };
  37235. // Add `LazyWrapper` methods to `lodash.prototype`.
  37236. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  37237. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  37238. isTaker = /^(?:head|last)$/.test(methodName),
  37239. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  37240. retUnwrapped = isTaker || /^find/.test(methodName);
  37241. if (!lodashFunc) {
  37242. return;
  37243. }
  37244. lodash.prototype[methodName] = function() {
  37245. var value = this.__wrapped__,
  37246. args = isTaker ? [1] : arguments,
  37247. isLazy = value instanceof LazyWrapper,
  37248. iteratee = args[0],
  37249. useLazy = isLazy || isArray(value);
  37250. var interceptor = function(value) {
  37251. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  37252. return (isTaker && chainAll) ? result[0] : result;
  37253. };
  37254. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  37255. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  37256. isLazy = useLazy = false;
  37257. }
  37258. var chainAll = this.__chain__,
  37259. isHybrid = !!this.__actions__.length,
  37260. isUnwrapped = retUnwrapped && !chainAll,
  37261. onlyLazy = isLazy && !isHybrid;
  37262. if (!retUnwrapped && useLazy) {
  37263. value = onlyLazy ? value : new LazyWrapper(this);
  37264. var result = func.apply(value, args);
  37265. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  37266. return new LodashWrapper(result, chainAll);
  37267. }
  37268. if (isUnwrapped && onlyLazy) {
  37269. return func.apply(this, args);
  37270. }
  37271. result = this.thru(interceptor);
  37272. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  37273. };
  37274. });
  37275. // Add `Array` methods to `lodash.prototype`.
  37276. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  37277. var func = arrayProto[methodName],
  37278. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  37279. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  37280. lodash.prototype[methodName] = function() {
  37281. var args = arguments;
  37282. if (retUnwrapped && !this.__chain__) {
  37283. var value = this.value();
  37284. return func.apply(isArray(value) ? value : [], args);
  37285. }
  37286. return this[chainName](function(value) {
  37287. return func.apply(isArray(value) ? value : [], args);
  37288. });
  37289. };
  37290. });
  37291. // Map minified method names to their real names.
  37292. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  37293. var lodashFunc = lodash[methodName];
  37294. if (lodashFunc) {
  37295. var key = lodashFunc.name + '';
  37296. if (!hasOwnProperty.call(realNames, key)) {
  37297. realNames[key] = [];
  37298. }
  37299. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  37300. }
  37301. });
  37302. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  37303. 'name': 'wrapper',
  37304. 'func': undefined
  37305. }];
  37306. // Add methods to `LazyWrapper`.
  37307. LazyWrapper.prototype.clone = lazyClone;
  37308. LazyWrapper.prototype.reverse = lazyReverse;
  37309. LazyWrapper.prototype.value = lazyValue;
  37310. // Add chain sequence methods to the `lodash` wrapper.
  37311. lodash.prototype.at = wrapperAt;
  37312. lodash.prototype.chain = wrapperChain;
  37313. lodash.prototype.commit = wrapperCommit;
  37314. lodash.prototype.next = wrapperNext;
  37315. lodash.prototype.plant = wrapperPlant;
  37316. lodash.prototype.reverse = wrapperReverse;
  37317. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  37318. // Add lazy aliases.
  37319. lodash.prototype.first = lodash.prototype.head;
  37320. if (symIterator) {
  37321. lodash.prototype[symIterator] = wrapperToIterator;
  37322. }
  37323. return lodash;
  37324. });
  37325. /*--------------------------------------------------------------------------*/
  37326. // Export lodash.
  37327. var _ = runInContext();
  37328. // Some AMD build optimizers, like r.js, check for condition patterns like:
  37329. if (true) {
  37330. // Expose Lodash on the global object to prevent errors when Lodash is
  37331. // loaded by a script tag in the presence of an AMD loader.
  37332. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  37333. // Use `_.noConflict` to remove Lodash from the global object.
  37334. root._ = _;
  37335. // Define as an anonymous module so, through path mapping, it can be
  37336. // referenced as the "underscore" module.
  37337. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  37338. return _;
  37339. }).call(exports, __webpack_require__, exports, module),
  37340. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  37341. }
  37342. // Check for `exports` after `define` in case a build optimizer adds it.
  37343. else {}
  37344. }.call(this));
  37345. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  37346. /***/ }),
  37347. /***/ "./node_modules/ms/index.js":
  37348. /*!**********************************!*\
  37349. !*** ./node_modules/ms/index.js ***!
  37350. \**********************************/
  37351. /*! no static exports found */
  37352. /***/ (function(module, exports) {
  37353. /**
  37354. * Helpers.
  37355. */
  37356. var s = 1000;
  37357. var m = s * 60;
  37358. var h = m * 60;
  37359. var d = h * 24;
  37360. var y = d * 365.25;
  37361. /**
  37362. * Parse or format the given `val`.
  37363. *
  37364. * Options:
  37365. *
  37366. * - `long` verbose formatting [false]
  37367. *
  37368. * @param {String|Number} val
  37369. * @param {Object} [options]
  37370. * @throws {Error} throw an error if val is not a non-empty string or a number
  37371. * @return {String|Number}
  37372. * @api public
  37373. */
  37374. module.exports = function(val, options) {
  37375. options = options || {};
  37376. var type = typeof val;
  37377. if (type === 'string' && val.length > 0) {
  37378. return parse(val);
  37379. } else if (type === 'number' && isNaN(val) === false) {
  37380. return options.long ? fmtLong(val) : fmtShort(val);
  37381. }
  37382. throw new Error(
  37383. 'val is not a non-empty string or a valid number. val=' +
  37384. JSON.stringify(val)
  37385. );
  37386. };
  37387. /**
  37388. * Parse the given `str` and return milliseconds.
  37389. *
  37390. * @param {String} str
  37391. * @return {Number}
  37392. * @api private
  37393. */
  37394. function parse(str) {
  37395. str = String(str);
  37396. if (str.length > 100) {
  37397. return;
  37398. }
  37399. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
  37400. str
  37401. );
  37402. if (!match) {
  37403. return;
  37404. }
  37405. var n = parseFloat(match[1]);
  37406. var type = (match[2] || 'ms').toLowerCase();
  37407. switch (type) {
  37408. case 'years':
  37409. case 'year':
  37410. case 'yrs':
  37411. case 'yr':
  37412. case 'y':
  37413. return n * y;
  37414. case 'days':
  37415. case 'day':
  37416. case 'd':
  37417. return n * d;
  37418. case 'hours':
  37419. case 'hour':
  37420. case 'hrs':
  37421. case 'hr':
  37422. case 'h':
  37423. return n * h;
  37424. case 'minutes':
  37425. case 'minute':
  37426. case 'mins':
  37427. case 'min':
  37428. case 'm':
  37429. return n * m;
  37430. case 'seconds':
  37431. case 'second':
  37432. case 'secs':
  37433. case 'sec':
  37434. case 's':
  37435. return n * s;
  37436. case 'milliseconds':
  37437. case 'millisecond':
  37438. case 'msecs':
  37439. case 'msec':
  37440. case 'ms':
  37441. return n;
  37442. default:
  37443. return undefined;
  37444. }
  37445. }
  37446. /**
  37447. * Short format for `ms`.
  37448. *
  37449. * @param {Number} ms
  37450. * @return {String}
  37451. * @api private
  37452. */
  37453. function fmtShort(ms) {
  37454. if (ms >= d) {
  37455. return Math.round(ms / d) + 'd';
  37456. }
  37457. if (ms >= h) {
  37458. return Math.round(ms / h) + 'h';
  37459. }
  37460. if (ms >= m) {
  37461. return Math.round(ms / m) + 'm';
  37462. }
  37463. if (ms >= s) {
  37464. return Math.round(ms / s) + 's';
  37465. }
  37466. return ms + 'ms';
  37467. }
  37468. /**
  37469. * Long format for `ms`.
  37470. *
  37471. * @param {Number} ms
  37472. * @return {String}
  37473. * @api private
  37474. */
  37475. function fmtLong(ms) {
  37476. return plural(ms, d, 'day') ||
  37477. plural(ms, h, 'hour') ||
  37478. plural(ms, m, 'minute') ||
  37479. plural(ms, s, 'second') ||
  37480. ms + ' ms';
  37481. }
  37482. /**
  37483. * Pluralization helper.
  37484. */
  37485. function plural(ms, n, name) {
  37486. if (ms < n) {
  37487. return;
  37488. }
  37489. if (ms < n * 1.5) {
  37490. return Math.floor(ms / n) + ' ' + name;
  37491. }
  37492. return Math.ceil(ms / n) + ' ' + name + 's';
  37493. }
  37494. /***/ }),
  37495. /***/ "./node_modules/parseqs/index.js":
  37496. /*!***************************************!*\
  37497. !*** ./node_modules/parseqs/index.js ***!
  37498. \***************************************/
  37499. /*! no static exports found */
  37500. /***/ (function(module, exports) {
  37501. /**
  37502. * Compiles a querystring
  37503. * Returns string representation of the object
  37504. *
  37505. * @param {Object}
  37506. * @api private
  37507. */
  37508. exports.encode = function (obj) {
  37509. var str = '';
  37510. for (var i in obj) {
  37511. if (obj.hasOwnProperty(i)) {
  37512. if (str.length) str += '&';
  37513. str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
  37514. }
  37515. }
  37516. return str;
  37517. };
  37518. /**
  37519. * Parses a simple querystring into an object
  37520. *
  37521. * @param {String} qs
  37522. * @api private
  37523. */
  37524. exports.decode = function(qs){
  37525. var qry = {};
  37526. var pairs = qs.split('&');
  37527. for (var i = 0, l = pairs.length; i < l; i++) {
  37528. var pair = pairs[i].split('=');
  37529. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  37530. }
  37531. return qry;
  37532. };
  37533. /***/ }),
  37534. /***/ "./node_modules/parseuri/index.js":
  37535. /*!****************************************!*\
  37536. !*** ./node_modules/parseuri/index.js ***!
  37537. \****************************************/
  37538. /*! no static exports found */
  37539. /***/ (function(module, exports) {
  37540. /**
  37541. * Parses an URI
  37542. *
  37543. * @author Steven Levithan <stevenlevithan.com> (MIT license)
  37544. * @api private
  37545. */
  37546. var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  37547. var parts = [
  37548. 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
  37549. ];
  37550. module.exports = function parseuri(str) {
  37551. var src = str,
  37552. b = str.indexOf('['),
  37553. e = str.indexOf(']');
  37554. if (b != -1 && e != -1) {
  37555. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);
  37556. }
  37557. var m = re.exec(str || ''),
  37558. uri = {},
  37559. i = 14;
  37560. while (i--) {
  37561. uri[parts[i]] = m[i] || '';
  37562. }
  37563. if (b != -1 && e != -1) {
  37564. uri.source = src;
  37565. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');
  37566. uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');
  37567. uri.ipv6uri = true;
  37568. }
  37569. return uri;
  37570. };
  37571. /***/ }),
  37572. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  37573. /*!***************************************************!*\
  37574. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  37575. \***************************************************/
  37576. /*! exports provided: default */
  37577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37578. "use strict";
  37579. __webpack_require__.r(__webpack_exports__);
  37580. /* WEBPACK VAR INJECTION */(function(global) {/**!
  37581. * @fileOverview Kickass library to create and place poppers near their reference elements.
  37582. * @version 1.16.1
  37583. * @license
  37584. * Copyright (c) 2016 Federico Zivolo and contributors
  37585. *
  37586. * Permission is hereby granted, free of charge, to any person obtaining a copy
  37587. * of this software and associated documentation files (the "Software"), to deal
  37588. * in the Software without restriction, including without limitation the rights
  37589. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  37590. * copies of the Software, and to permit persons to whom the Software is
  37591. * furnished to do so, subject to the following conditions:
  37592. *
  37593. * The above copyright notice and this permission notice shall be included in all
  37594. * copies or substantial portions of the Software.
  37595. *
  37596. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  37597. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  37598. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  37599. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  37600. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  37601. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  37602. * SOFTWARE.
  37603. */
  37604. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  37605. var timeoutDuration = function () {
  37606. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  37607. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  37608. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  37609. return 1;
  37610. }
  37611. }
  37612. return 0;
  37613. }();
  37614. function microtaskDebounce(fn) {
  37615. var called = false;
  37616. return function () {
  37617. if (called) {
  37618. return;
  37619. }
  37620. called = true;
  37621. window.Promise.resolve().then(function () {
  37622. called = false;
  37623. fn();
  37624. });
  37625. };
  37626. }
  37627. function taskDebounce(fn) {
  37628. var scheduled = false;
  37629. return function () {
  37630. if (!scheduled) {
  37631. scheduled = true;
  37632. setTimeout(function () {
  37633. scheduled = false;
  37634. fn();
  37635. }, timeoutDuration);
  37636. }
  37637. };
  37638. }
  37639. var supportsMicroTasks = isBrowser && window.Promise;
  37640. /**
  37641. * Create a debounced version of a method, that's asynchronously deferred
  37642. * but called in the minimum time possible.
  37643. *
  37644. * @method
  37645. * @memberof Popper.Utils
  37646. * @argument {Function} fn
  37647. * @returns {Function}
  37648. */
  37649. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  37650. /**
  37651. * Check if the given variable is a function
  37652. * @method
  37653. * @memberof Popper.Utils
  37654. * @argument {Any} functionToCheck - variable to check
  37655. * @returns {Boolean} answer to: is a function?
  37656. */
  37657. function isFunction(functionToCheck) {
  37658. var getType = {};
  37659. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  37660. }
  37661. /**
  37662. * Get CSS computed property of the given element
  37663. * @method
  37664. * @memberof Popper.Utils
  37665. * @argument {Eement} element
  37666. * @argument {String} property
  37667. */
  37668. function getStyleComputedProperty(element, property) {
  37669. if (element.nodeType !== 1) {
  37670. return [];
  37671. }
  37672. // NOTE: 1 DOM access here
  37673. var window = element.ownerDocument.defaultView;
  37674. var css = window.getComputedStyle(element, null);
  37675. return property ? css[property] : css;
  37676. }
  37677. /**
  37678. * Returns the parentNode or the host of the element
  37679. * @method
  37680. * @memberof Popper.Utils
  37681. * @argument {Element} element
  37682. * @returns {Element} parent
  37683. */
  37684. function getParentNode(element) {
  37685. if (element.nodeName === 'HTML') {
  37686. return element;
  37687. }
  37688. return element.parentNode || element.host;
  37689. }
  37690. /**
  37691. * Returns the scrolling parent of the given element
  37692. * @method
  37693. * @memberof Popper.Utils
  37694. * @argument {Element} element
  37695. * @returns {Element} scroll parent
  37696. */
  37697. function getScrollParent(element) {
  37698. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  37699. if (!element) {
  37700. return document.body;
  37701. }
  37702. switch (element.nodeName) {
  37703. case 'HTML':
  37704. case 'BODY':
  37705. return element.ownerDocument.body;
  37706. case '#document':
  37707. return element.body;
  37708. }
  37709. // Firefox want us to check `-x` and `-y` variations as well
  37710. var _getStyleComputedProp = getStyleComputedProperty(element),
  37711. overflow = _getStyleComputedProp.overflow,
  37712. overflowX = _getStyleComputedProp.overflowX,
  37713. overflowY = _getStyleComputedProp.overflowY;
  37714. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  37715. return element;
  37716. }
  37717. return getScrollParent(getParentNode(element));
  37718. }
  37719. /**
  37720. * Returns the reference node of the reference object, or the reference object itself.
  37721. * @method
  37722. * @memberof Popper.Utils
  37723. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  37724. * @returns {Element} parent
  37725. */
  37726. function getReferenceNode(reference) {
  37727. return reference && reference.referenceNode ? reference.referenceNode : reference;
  37728. }
  37729. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  37730. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  37731. /**
  37732. * Determines if the browser is Internet Explorer
  37733. * @method
  37734. * @memberof Popper.Utils
  37735. * @param {Number} version to check
  37736. * @returns {Boolean} isIE
  37737. */
  37738. function isIE(version) {
  37739. if (version === 11) {
  37740. return isIE11;
  37741. }
  37742. if (version === 10) {
  37743. return isIE10;
  37744. }
  37745. return isIE11 || isIE10;
  37746. }
  37747. /**
  37748. * Returns the offset parent of the given element
  37749. * @method
  37750. * @memberof Popper.Utils
  37751. * @argument {Element} element
  37752. * @returns {Element} offset parent
  37753. */
  37754. function getOffsetParent(element) {
  37755. if (!element) {
  37756. return document.documentElement;
  37757. }
  37758. var noOffsetParent = isIE(10) ? document.body : null;
  37759. // NOTE: 1 DOM access here
  37760. var offsetParent = element.offsetParent || null;
  37761. // Skip hidden elements which don't have an offsetParent
  37762. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  37763. offsetParent = (element = element.nextElementSibling).offsetParent;
  37764. }
  37765. var nodeName = offsetParent && offsetParent.nodeName;
  37766. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  37767. return element ? element.ownerDocument.documentElement : document.documentElement;
  37768. }
  37769. // .offsetParent will return the closest TH, TD or TABLE in case
  37770. // no offsetParent is present, I hate this job...
  37771. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  37772. return getOffsetParent(offsetParent);
  37773. }
  37774. return offsetParent;
  37775. }
  37776. function isOffsetContainer(element) {
  37777. var nodeName = element.nodeName;
  37778. if (nodeName === 'BODY') {
  37779. return false;
  37780. }
  37781. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  37782. }
  37783. /**
  37784. * Finds the root node (document, shadowDOM root) of the given element
  37785. * @method
  37786. * @memberof Popper.Utils
  37787. * @argument {Element} node
  37788. * @returns {Element} root node
  37789. */
  37790. function getRoot(node) {
  37791. if (node.parentNode !== null) {
  37792. return getRoot(node.parentNode);
  37793. }
  37794. return node;
  37795. }
  37796. /**
  37797. * Finds the offset parent common to the two provided nodes
  37798. * @method
  37799. * @memberof Popper.Utils
  37800. * @argument {Element} element1
  37801. * @argument {Element} element2
  37802. * @returns {Element} common offset parent
  37803. */
  37804. function findCommonOffsetParent(element1, element2) {
  37805. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  37806. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  37807. return document.documentElement;
  37808. }
  37809. // Here we make sure to give as "start" the element that comes first in the DOM
  37810. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  37811. var start = order ? element1 : element2;
  37812. var end = order ? element2 : element1;
  37813. // Get common ancestor container
  37814. var range = document.createRange();
  37815. range.setStart(start, 0);
  37816. range.setEnd(end, 0);
  37817. var commonAncestorContainer = range.commonAncestorContainer;
  37818. // Both nodes are inside #document
  37819. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  37820. if (isOffsetContainer(commonAncestorContainer)) {
  37821. return commonAncestorContainer;
  37822. }
  37823. return getOffsetParent(commonAncestorContainer);
  37824. }
  37825. // one of the nodes is inside shadowDOM, find which one
  37826. var element1root = getRoot(element1);
  37827. if (element1root.host) {
  37828. return findCommonOffsetParent(element1root.host, element2);
  37829. } else {
  37830. return findCommonOffsetParent(element1, getRoot(element2).host);
  37831. }
  37832. }
  37833. /**
  37834. * Gets the scroll value of the given element in the given side (top and left)
  37835. * @method
  37836. * @memberof Popper.Utils
  37837. * @argument {Element} element
  37838. * @argument {String} side `top` or `left`
  37839. * @returns {number} amount of scrolled pixels
  37840. */
  37841. function getScroll(element) {
  37842. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  37843. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  37844. var nodeName = element.nodeName;
  37845. if (nodeName === 'BODY' || nodeName === 'HTML') {
  37846. var html = element.ownerDocument.documentElement;
  37847. var scrollingElement = element.ownerDocument.scrollingElement || html;
  37848. return scrollingElement[upperSide];
  37849. }
  37850. return element[upperSide];
  37851. }
  37852. /*
  37853. * Sum or subtract the element scroll values (left and top) from a given rect object
  37854. * @method
  37855. * @memberof Popper.Utils
  37856. * @param {Object} rect - Rect object you want to change
  37857. * @param {HTMLElement} element - The element from the function reads the scroll values
  37858. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  37859. * @return {Object} rect - The modifier rect object
  37860. */
  37861. function includeScroll(rect, element) {
  37862. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  37863. var scrollTop = getScroll(element, 'top');
  37864. var scrollLeft = getScroll(element, 'left');
  37865. var modifier = subtract ? -1 : 1;
  37866. rect.top += scrollTop * modifier;
  37867. rect.bottom += scrollTop * modifier;
  37868. rect.left += scrollLeft * modifier;
  37869. rect.right += scrollLeft * modifier;
  37870. return rect;
  37871. }
  37872. /*
  37873. * Helper to detect borders of a given element
  37874. * @method
  37875. * @memberof Popper.Utils
  37876. * @param {CSSStyleDeclaration} styles
  37877. * Result of `getStyleComputedProperty` on the given element
  37878. * @param {String} axis - `x` or `y`
  37879. * @return {number} borders - The borders size of the given axis
  37880. */
  37881. function getBordersSize(styles, axis) {
  37882. var sideA = axis === 'x' ? 'Left' : 'Top';
  37883. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  37884. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  37885. }
  37886. function getSize(axis, body, html, computedStyle) {
  37887. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  37888. }
  37889. function getWindowSizes(document) {
  37890. var body = document.body;
  37891. var html = document.documentElement;
  37892. var computedStyle = isIE(10) && getComputedStyle(html);
  37893. return {
  37894. height: getSize('Height', body, html, computedStyle),
  37895. width: getSize('Width', body, html, computedStyle)
  37896. };
  37897. }
  37898. var classCallCheck = function (instance, Constructor) {
  37899. if (!(instance instanceof Constructor)) {
  37900. throw new TypeError("Cannot call a class as a function");
  37901. }
  37902. };
  37903. var createClass = function () {
  37904. function defineProperties(target, props) {
  37905. for (var i = 0; i < props.length; i++) {
  37906. var descriptor = props[i];
  37907. descriptor.enumerable = descriptor.enumerable || false;
  37908. descriptor.configurable = true;
  37909. if ("value" in descriptor) descriptor.writable = true;
  37910. Object.defineProperty(target, descriptor.key, descriptor);
  37911. }
  37912. }
  37913. return function (Constructor, protoProps, staticProps) {
  37914. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  37915. if (staticProps) defineProperties(Constructor, staticProps);
  37916. return Constructor;
  37917. };
  37918. }();
  37919. var defineProperty = function (obj, key, value) {
  37920. if (key in obj) {
  37921. Object.defineProperty(obj, key, {
  37922. value: value,
  37923. enumerable: true,
  37924. configurable: true,
  37925. writable: true
  37926. });
  37927. } else {
  37928. obj[key] = value;
  37929. }
  37930. return obj;
  37931. };
  37932. var _extends = Object.assign || function (target) {
  37933. for (var i = 1; i < arguments.length; i++) {
  37934. var source = arguments[i];
  37935. for (var key in source) {
  37936. if (Object.prototype.hasOwnProperty.call(source, key)) {
  37937. target[key] = source[key];
  37938. }
  37939. }
  37940. }
  37941. return target;
  37942. };
  37943. /**
  37944. * Given element offsets, generate an output similar to getBoundingClientRect
  37945. * @method
  37946. * @memberof Popper.Utils
  37947. * @argument {Object} offsets
  37948. * @returns {Object} ClientRect like output
  37949. */
  37950. function getClientRect(offsets) {
  37951. return _extends({}, offsets, {
  37952. right: offsets.left + offsets.width,
  37953. bottom: offsets.top + offsets.height
  37954. });
  37955. }
  37956. /**
  37957. * Get bounding client rect of given element
  37958. * @method
  37959. * @memberof Popper.Utils
  37960. * @param {HTMLElement} element
  37961. * @return {Object} client rect
  37962. */
  37963. function getBoundingClientRect(element) {
  37964. var rect = {};
  37965. // IE10 10 FIX: Please, don't ask, the element isn't
  37966. // considered in DOM in some circumstances...
  37967. // This isn't reproducible in IE10 compatibility mode of IE11
  37968. try {
  37969. if (isIE(10)) {
  37970. rect = element.getBoundingClientRect();
  37971. var scrollTop = getScroll(element, 'top');
  37972. var scrollLeft = getScroll(element, 'left');
  37973. rect.top += scrollTop;
  37974. rect.left += scrollLeft;
  37975. rect.bottom += scrollTop;
  37976. rect.right += scrollLeft;
  37977. } else {
  37978. rect = element.getBoundingClientRect();
  37979. }
  37980. } catch (e) {}
  37981. var result = {
  37982. left: rect.left,
  37983. top: rect.top,
  37984. width: rect.right - rect.left,
  37985. height: rect.bottom - rect.top
  37986. };
  37987. // subtract scrollbar size from sizes
  37988. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  37989. var width = sizes.width || element.clientWidth || result.width;
  37990. var height = sizes.height || element.clientHeight || result.height;
  37991. var horizScrollbar = element.offsetWidth - width;
  37992. var vertScrollbar = element.offsetHeight - height;
  37993. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  37994. // we make this check conditional for performance reasons
  37995. if (horizScrollbar || vertScrollbar) {
  37996. var styles = getStyleComputedProperty(element);
  37997. horizScrollbar -= getBordersSize(styles, 'x');
  37998. vertScrollbar -= getBordersSize(styles, 'y');
  37999. result.width -= horizScrollbar;
  38000. result.height -= vertScrollbar;
  38001. }
  38002. return getClientRect(result);
  38003. }
  38004. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  38005. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  38006. var isIE10 = isIE(10);
  38007. var isHTML = parent.nodeName === 'HTML';
  38008. var childrenRect = getBoundingClientRect(children);
  38009. var parentRect = getBoundingClientRect(parent);
  38010. var scrollParent = getScrollParent(children);
  38011. var styles = getStyleComputedProperty(parent);
  38012. var borderTopWidth = parseFloat(styles.borderTopWidth);
  38013. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  38014. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  38015. if (fixedPosition && isHTML) {
  38016. parentRect.top = Math.max(parentRect.top, 0);
  38017. parentRect.left = Math.max(parentRect.left, 0);
  38018. }
  38019. var offsets = getClientRect({
  38020. top: childrenRect.top - parentRect.top - borderTopWidth,
  38021. left: childrenRect.left - parentRect.left - borderLeftWidth,
  38022. width: childrenRect.width,
  38023. height: childrenRect.height
  38024. });
  38025. offsets.marginTop = 0;
  38026. offsets.marginLeft = 0;
  38027. // Subtract margins of documentElement in case it's being used as parent
  38028. // we do this only on HTML because it's the only element that behaves
  38029. // differently when margins are applied to it. The margins are included in
  38030. // the box of the documentElement, in the other cases not.
  38031. if (!isIE10 && isHTML) {
  38032. var marginTop = parseFloat(styles.marginTop);
  38033. var marginLeft = parseFloat(styles.marginLeft);
  38034. offsets.top -= borderTopWidth - marginTop;
  38035. offsets.bottom -= borderTopWidth - marginTop;
  38036. offsets.left -= borderLeftWidth - marginLeft;
  38037. offsets.right -= borderLeftWidth - marginLeft;
  38038. // Attach marginTop and marginLeft because in some circumstances we may need them
  38039. offsets.marginTop = marginTop;
  38040. offsets.marginLeft = marginLeft;
  38041. }
  38042. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  38043. offsets = includeScroll(offsets, parent);
  38044. }
  38045. return offsets;
  38046. }
  38047. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  38048. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  38049. var html = element.ownerDocument.documentElement;
  38050. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  38051. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  38052. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  38053. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  38054. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  38055. var offset = {
  38056. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  38057. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  38058. width: width,
  38059. height: height
  38060. };
  38061. return getClientRect(offset);
  38062. }
  38063. /**
  38064. * Check if the given element is fixed or is inside a fixed parent
  38065. * @method
  38066. * @memberof Popper.Utils
  38067. * @argument {Element} element
  38068. * @argument {Element} customContainer
  38069. * @returns {Boolean} answer to "isFixed?"
  38070. */
  38071. function isFixed(element) {
  38072. var nodeName = element.nodeName;
  38073. if (nodeName === 'BODY' || nodeName === 'HTML') {
  38074. return false;
  38075. }
  38076. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  38077. return true;
  38078. }
  38079. var parentNode = getParentNode(element);
  38080. if (!parentNode) {
  38081. return false;
  38082. }
  38083. return isFixed(parentNode);
  38084. }
  38085. /**
  38086. * Finds the first parent of an element that has a transformed property defined
  38087. * @method
  38088. * @memberof Popper.Utils
  38089. * @argument {Element} element
  38090. * @returns {Element} first transformed parent or documentElement
  38091. */
  38092. function getFixedPositionOffsetParent(element) {
  38093. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  38094. if (!element || !element.parentElement || isIE()) {
  38095. return document.documentElement;
  38096. }
  38097. var el = element.parentElement;
  38098. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  38099. el = el.parentElement;
  38100. }
  38101. return el || document.documentElement;
  38102. }
  38103. /**
  38104. * Computed the boundaries limits and return them
  38105. * @method
  38106. * @memberof Popper.Utils
  38107. * @param {HTMLElement} popper
  38108. * @param {HTMLElement} reference
  38109. * @param {number} padding
  38110. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  38111. * @param {Boolean} fixedPosition - Is in fixed position mode
  38112. * @returns {Object} Coordinates of the boundaries
  38113. */
  38114. function getBoundaries(popper, reference, padding, boundariesElement) {
  38115. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  38116. // NOTE: 1 DOM access here
  38117. var boundaries = { top: 0, left: 0 };
  38118. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  38119. // Handle viewport case
  38120. if (boundariesElement === 'viewport') {
  38121. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  38122. } else {
  38123. // Handle other cases based on DOM element used as boundaries
  38124. var boundariesNode = void 0;
  38125. if (boundariesElement === 'scrollParent') {
  38126. boundariesNode = getScrollParent(getParentNode(reference));
  38127. if (boundariesNode.nodeName === 'BODY') {
  38128. boundariesNode = popper.ownerDocument.documentElement;
  38129. }
  38130. } else if (boundariesElement === 'window') {
  38131. boundariesNode = popper.ownerDocument.documentElement;
  38132. } else {
  38133. boundariesNode = boundariesElement;
  38134. }
  38135. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  38136. // In case of HTML, we need a different computation
  38137. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  38138. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  38139. height = _getWindowSizes.height,
  38140. width = _getWindowSizes.width;
  38141. boundaries.top += offsets.top - offsets.marginTop;
  38142. boundaries.bottom = height + offsets.top;
  38143. boundaries.left += offsets.left - offsets.marginLeft;
  38144. boundaries.right = width + offsets.left;
  38145. } else {
  38146. // for all the other DOM elements, this one is good
  38147. boundaries = offsets;
  38148. }
  38149. }
  38150. // Add paddings
  38151. padding = padding || 0;
  38152. var isPaddingNumber = typeof padding === 'number';
  38153. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  38154. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  38155. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  38156. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  38157. return boundaries;
  38158. }
  38159. function getArea(_ref) {
  38160. var width = _ref.width,
  38161. height = _ref.height;
  38162. return width * height;
  38163. }
  38164. /**
  38165. * Utility used to transform the `auto` placement to the placement with more
  38166. * available space.
  38167. * @method
  38168. * @memberof Popper.Utils
  38169. * @argument {Object} data - The data object generated by update method
  38170. * @argument {Object} options - Modifiers configuration and options
  38171. * @returns {Object} The data object, properly modified
  38172. */
  38173. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  38174. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  38175. if (placement.indexOf('auto') === -1) {
  38176. return placement;
  38177. }
  38178. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  38179. var rects = {
  38180. top: {
  38181. width: boundaries.width,
  38182. height: refRect.top - boundaries.top
  38183. },
  38184. right: {
  38185. width: boundaries.right - refRect.right,
  38186. height: boundaries.height
  38187. },
  38188. bottom: {
  38189. width: boundaries.width,
  38190. height: boundaries.bottom - refRect.bottom
  38191. },
  38192. left: {
  38193. width: refRect.left - boundaries.left,
  38194. height: boundaries.height
  38195. }
  38196. };
  38197. var sortedAreas = Object.keys(rects).map(function (key) {
  38198. return _extends({
  38199. key: key
  38200. }, rects[key], {
  38201. area: getArea(rects[key])
  38202. });
  38203. }).sort(function (a, b) {
  38204. return b.area - a.area;
  38205. });
  38206. var filteredAreas = sortedAreas.filter(function (_ref2) {
  38207. var width = _ref2.width,
  38208. height = _ref2.height;
  38209. return width >= popper.clientWidth && height >= popper.clientHeight;
  38210. });
  38211. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  38212. var variation = placement.split('-')[1];
  38213. return computedPlacement + (variation ? '-' + variation : '');
  38214. }
  38215. /**
  38216. * Get offsets to the reference element
  38217. * @method
  38218. * @memberof Popper.Utils
  38219. * @param {Object} state
  38220. * @param {Element} popper - the popper element
  38221. * @param {Element} reference - the reference element (the popper will be relative to this)
  38222. * @param {Element} fixedPosition - is in fixed position mode
  38223. * @returns {Object} An object containing the offsets which will be applied to the popper
  38224. */
  38225. function getReferenceOffsets(state, popper, reference) {
  38226. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  38227. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  38228. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  38229. }
  38230. /**
  38231. * Get the outer sizes of the given element (offset size + margins)
  38232. * @method
  38233. * @memberof Popper.Utils
  38234. * @argument {Element} element
  38235. * @returns {Object} object containing width and height properties
  38236. */
  38237. function getOuterSizes(element) {
  38238. var window = element.ownerDocument.defaultView;
  38239. var styles = window.getComputedStyle(element);
  38240. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  38241. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  38242. var result = {
  38243. width: element.offsetWidth + y,
  38244. height: element.offsetHeight + x
  38245. };
  38246. return result;
  38247. }
  38248. /**
  38249. * Get the opposite placement of the given one
  38250. * @method
  38251. * @memberof Popper.Utils
  38252. * @argument {String} placement
  38253. * @returns {String} flipped placement
  38254. */
  38255. function getOppositePlacement(placement) {
  38256. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  38257. return placement.replace(/left|right|bottom|top/g, function (matched) {
  38258. return hash[matched];
  38259. });
  38260. }
  38261. /**
  38262. * Get offsets to the popper
  38263. * @method
  38264. * @memberof Popper.Utils
  38265. * @param {Object} position - CSS position the Popper will get applied
  38266. * @param {HTMLElement} popper - the popper element
  38267. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  38268. * @param {String} placement - one of the valid placement options
  38269. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  38270. */
  38271. function getPopperOffsets(popper, referenceOffsets, placement) {
  38272. placement = placement.split('-')[0];
  38273. // Get popper node sizes
  38274. var popperRect = getOuterSizes(popper);
  38275. // Add position, width and height to our offsets object
  38276. var popperOffsets = {
  38277. width: popperRect.width,
  38278. height: popperRect.height
  38279. };
  38280. // depending by the popper placement we have to compute its offsets slightly differently
  38281. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  38282. var mainSide = isHoriz ? 'top' : 'left';
  38283. var secondarySide = isHoriz ? 'left' : 'top';
  38284. var measurement = isHoriz ? 'height' : 'width';
  38285. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  38286. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  38287. if (placement === secondarySide) {
  38288. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  38289. } else {
  38290. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  38291. }
  38292. return popperOffsets;
  38293. }
  38294. /**
  38295. * Mimics the `find` method of Array
  38296. * @method
  38297. * @memberof Popper.Utils
  38298. * @argument {Array} arr
  38299. * @argument prop
  38300. * @argument value
  38301. * @returns index or -1
  38302. */
  38303. function find(arr, check) {
  38304. // use native find if supported
  38305. if (Array.prototype.find) {
  38306. return arr.find(check);
  38307. }
  38308. // use `filter` to obtain the same behavior of `find`
  38309. return arr.filter(check)[0];
  38310. }
  38311. /**
  38312. * Return the index of the matching object
  38313. * @method
  38314. * @memberof Popper.Utils
  38315. * @argument {Array} arr
  38316. * @argument prop
  38317. * @argument value
  38318. * @returns index or -1
  38319. */
  38320. function findIndex(arr, prop, value) {
  38321. // use native findIndex if supported
  38322. if (Array.prototype.findIndex) {
  38323. return arr.findIndex(function (cur) {
  38324. return cur[prop] === value;
  38325. });
  38326. }
  38327. // use `find` + `indexOf` if `findIndex` isn't supported
  38328. var match = find(arr, function (obj) {
  38329. return obj[prop] === value;
  38330. });
  38331. return arr.indexOf(match);
  38332. }
  38333. /**
  38334. * Loop trough the list of modifiers and run them in order,
  38335. * each of them will then edit the data object.
  38336. * @method
  38337. * @memberof Popper.Utils
  38338. * @param {dataObject} data
  38339. * @param {Array} modifiers
  38340. * @param {String} ends - Optional modifier name used as stopper
  38341. * @returns {dataObject}
  38342. */
  38343. function runModifiers(modifiers, data, ends) {
  38344. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  38345. modifiersToRun.forEach(function (modifier) {
  38346. if (modifier['function']) {
  38347. // eslint-disable-line dot-notation
  38348. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  38349. }
  38350. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  38351. if (modifier.enabled && isFunction(fn)) {
  38352. // Add properties to offsets to make them a complete clientRect object
  38353. // we do this before each modifier to make sure the previous one doesn't
  38354. // mess with these values
  38355. data.offsets.popper = getClientRect(data.offsets.popper);
  38356. data.offsets.reference = getClientRect(data.offsets.reference);
  38357. data = fn(data, modifier);
  38358. }
  38359. });
  38360. return data;
  38361. }
  38362. /**
  38363. * Updates the position of the popper, computing the new offsets and applying
  38364. * the new style.<br />
  38365. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  38366. * @method
  38367. * @memberof Popper
  38368. */
  38369. function update() {
  38370. // if popper is destroyed, don't perform any further update
  38371. if (this.state.isDestroyed) {
  38372. return;
  38373. }
  38374. var data = {
  38375. instance: this,
  38376. styles: {},
  38377. arrowStyles: {},
  38378. attributes: {},
  38379. flipped: false,
  38380. offsets: {}
  38381. };
  38382. // compute reference element offsets
  38383. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  38384. // compute auto placement, store placement inside the data object,
  38385. // modifiers will be able to edit `placement` if needed
  38386. // and refer to originalPlacement to know the original value
  38387. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  38388. // store the computed placement inside `originalPlacement`
  38389. data.originalPlacement = data.placement;
  38390. data.positionFixed = this.options.positionFixed;
  38391. // compute the popper offsets
  38392. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  38393. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  38394. // run the modifiers
  38395. data = runModifiers(this.modifiers, data);
  38396. // the first `update` will call `onCreate` callback
  38397. // the other ones will call `onUpdate` callback
  38398. if (!this.state.isCreated) {
  38399. this.state.isCreated = true;
  38400. this.options.onCreate(data);
  38401. } else {
  38402. this.options.onUpdate(data);
  38403. }
  38404. }
  38405. /**
  38406. * Helper used to know if the given modifier is enabled.
  38407. * @method
  38408. * @memberof Popper.Utils
  38409. * @returns {Boolean}
  38410. */
  38411. function isModifierEnabled(modifiers, modifierName) {
  38412. return modifiers.some(function (_ref) {
  38413. var name = _ref.name,
  38414. enabled = _ref.enabled;
  38415. return enabled && name === modifierName;
  38416. });
  38417. }
  38418. /**
  38419. * Get the prefixed supported property name
  38420. * @method
  38421. * @memberof Popper.Utils
  38422. * @argument {String} property (camelCase)
  38423. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  38424. */
  38425. function getSupportedPropertyName(property) {
  38426. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  38427. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  38428. for (var i = 0; i < prefixes.length; i++) {
  38429. var prefix = prefixes[i];
  38430. var toCheck = prefix ? '' + prefix + upperProp : property;
  38431. if (typeof document.body.style[toCheck] !== 'undefined') {
  38432. return toCheck;
  38433. }
  38434. }
  38435. return null;
  38436. }
  38437. /**
  38438. * Destroys the popper.
  38439. * @method
  38440. * @memberof Popper
  38441. */
  38442. function destroy() {
  38443. this.state.isDestroyed = true;
  38444. // touch DOM only if `applyStyle` modifier is enabled
  38445. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  38446. this.popper.removeAttribute('x-placement');
  38447. this.popper.style.position = '';
  38448. this.popper.style.top = '';
  38449. this.popper.style.left = '';
  38450. this.popper.style.right = '';
  38451. this.popper.style.bottom = '';
  38452. this.popper.style.willChange = '';
  38453. this.popper.style[getSupportedPropertyName('transform')] = '';
  38454. }
  38455. this.disableEventListeners();
  38456. // remove the popper if user explicitly asked for the deletion on destroy
  38457. // do not use `remove` because IE11 doesn't support it
  38458. if (this.options.removeOnDestroy) {
  38459. this.popper.parentNode.removeChild(this.popper);
  38460. }
  38461. return this;
  38462. }
  38463. /**
  38464. * Get the window associated with the element
  38465. * @argument {Element} element
  38466. * @returns {Window}
  38467. */
  38468. function getWindow(element) {
  38469. var ownerDocument = element.ownerDocument;
  38470. return ownerDocument ? ownerDocument.defaultView : window;
  38471. }
  38472. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  38473. var isBody = scrollParent.nodeName === 'BODY';
  38474. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  38475. target.addEventListener(event, callback, { passive: true });
  38476. if (!isBody) {
  38477. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  38478. }
  38479. scrollParents.push(target);
  38480. }
  38481. /**
  38482. * Setup needed event listeners used to update the popper position
  38483. * @method
  38484. * @memberof Popper.Utils
  38485. * @private
  38486. */
  38487. function setupEventListeners(reference, options, state, updateBound) {
  38488. // Resize event listener on window
  38489. state.updateBound = updateBound;
  38490. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  38491. // Scroll event listener on scroll parents
  38492. var scrollElement = getScrollParent(reference);
  38493. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  38494. state.scrollElement = scrollElement;
  38495. state.eventsEnabled = true;
  38496. return state;
  38497. }
  38498. /**
  38499. * It will add resize/scroll events and start recalculating
  38500. * position of the popper element when they are triggered.
  38501. * @method
  38502. * @memberof Popper
  38503. */
  38504. function enableEventListeners() {
  38505. if (!this.state.eventsEnabled) {
  38506. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  38507. }
  38508. }
  38509. /**
  38510. * Remove event listeners used to update the popper position
  38511. * @method
  38512. * @memberof Popper.Utils
  38513. * @private
  38514. */
  38515. function removeEventListeners(reference, state) {
  38516. // Remove resize event listener on window
  38517. getWindow(reference).removeEventListener('resize', state.updateBound);
  38518. // Remove scroll event listener on scroll parents
  38519. state.scrollParents.forEach(function (target) {
  38520. target.removeEventListener('scroll', state.updateBound);
  38521. });
  38522. // Reset state
  38523. state.updateBound = null;
  38524. state.scrollParents = [];
  38525. state.scrollElement = null;
  38526. state.eventsEnabled = false;
  38527. return state;
  38528. }
  38529. /**
  38530. * It will remove resize/scroll events and won't recalculate popper position
  38531. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  38532. * unless you call `update` method manually.
  38533. * @method
  38534. * @memberof Popper
  38535. */
  38536. function disableEventListeners() {
  38537. if (this.state.eventsEnabled) {
  38538. cancelAnimationFrame(this.scheduleUpdate);
  38539. this.state = removeEventListeners(this.reference, this.state);
  38540. }
  38541. }
  38542. /**
  38543. * Tells if a given input is a number
  38544. * @method
  38545. * @memberof Popper.Utils
  38546. * @param {*} input to check
  38547. * @return {Boolean}
  38548. */
  38549. function isNumeric(n) {
  38550. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  38551. }
  38552. /**
  38553. * Set the style to the given popper
  38554. * @method
  38555. * @memberof Popper.Utils
  38556. * @argument {Element} element - Element to apply the style to
  38557. * @argument {Object} styles
  38558. * Object with a list of properties and values which will be applied to the element
  38559. */
  38560. function setStyles(element, styles) {
  38561. Object.keys(styles).forEach(function (prop) {
  38562. var unit = '';
  38563. // add unit if the value is numeric and is one of the following
  38564. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  38565. unit = 'px';
  38566. }
  38567. element.style[prop] = styles[prop] + unit;
  38568. });
  38569. }
  38570. /**
  38571. * Set the attributes to the given popper
  38572. * @method
  38573. * @memberof Popper.Utils
  38574. * @argument {Element} element - Element to apply the attributes to
  38575. * @argument {Object} styles
  38576. * Object with a list of properties and values which will be applied to the element
  38577. */
  38578. function setAttributes(element, attributes) {
  38579. Object.keys(attributes).forEach(function (prop) {
  38580. var value = attributes[prop];
  38581. if (value !== false) {
  38582. element.setAttribute(prop, attributes[prop]);
  38583. } else {
  38584. element.removeAttribute(prop);
  38585. }
  38586. });
  38587. }
  38588. /**
  38589. * @function
  38590. * @memberof Modifiers
  38591. * @argument {Object} data - The data object generated by `update` method
  38592. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  38593. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  38594. * @argument {Object} options - Modifiers configuration and options
  38595. * @returns {Object} The same data object
  38596. */
  38597. function applyStyle(data) {
  38598. // any property present in `data.styles` will be applied to the popper,
  38599. // in this way we can make the 3rd party modifiers add custom styles to it
  38600. // Be aware, modifiers could override the properties defined in the previous
  38601. // lines of this modifier!
  38602. setStyles(data.instance.popper, data.styles);
  38603. // any property present in `data.attributes` will be applied to the popper,
  38604. // they will be set as HTML attributes of the element
  38605. setAttributes(data.instance.popper, data.attributes);
  38606. // if arrowElement is defined and arrowStyles has some properties
  38607. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  38608. setStyles(data.arrowElement, data.arrowStyles);
  38609. }
  38610. return data;
  38611. }
  38612. /**
  38613. * Set the x-placement attribute before everything else because it could be used
  38614. * to add margins to the popper margins needs to be calculated to get the
  38615. * correct popper offsets.
  38616. * @method
  38617. * @memberof Popper.modifiers
  38618. * @param {HTMLElement} reference - The reference element used to position the popper
  38619. * @param {HTMLElement} popper - The HTML element used as popper
  38620. * @param {Object} options - Popper.js options
  38621. */
  38622. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  38623. // compute reference element offsets
  38624. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  38625. // compute auto placement, store placement inside the data object,
  38626. // modifiers will be able to edit `placement` if needed
  38627. // and refer to originalPlacement to know the original value
  38628. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  38629. popper.setAttribute('x-placement', placement);
  38630. // Apply `position` to popper before anything else because
  38631. // without the position applied we can't guarantee correct computations
  38632. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  38633. return options;
  38634. }
  38635. /**
  38636. * @function
  38637. * @memberof Popper.Utils
  38638. * @argument {Object} data - The data object generated by `update` method
  38639. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  38640. * @returns {Object} The popper's position offsets rounded
  38641. *
  38642. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  38643. * good as it can be within reason.
  38644. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  38645. *
  38646. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  38647. * as well on High DPI screens).
  38648. *
  38649. * Firefox prefers no rounding for positioning and does not have blurriness on
  38650. * high DPI screens.
  38651. *
  38652. * Only horizontal placement and left/right values need to be considered.
  38653. */
  38654. function getRoundedOffsets(data, shouldRound) {
  38655. var _data$offsets = data.offsets,
  38656. popper = _data$offsets.popper,
  38657. reference = _data$offsets.reference;
  38658. var round = Math.round,
  38659. floor = Math.floor;
  38660. var noRound = function noRound(v) {
  38661. return v;
  38662. };
  38663. var referenceWidth = round(reference.width);
  38664. var popperWidth = round(popper.width);
  38665. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  38666. var isVariation = data.placement.indexOf('-') !== -1;
  38667. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  38668. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  38669. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  38670. var verticalToInteger = !shouldRound ? noRound : round;
  38671. return {
  38672. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  38673. top: verticalToInteger(popper.top),
  38674. bottom: verticalToInteger(popper.bottom),
  38675. right: horizontalToInteger(popper.right)
  38676. };
  38677. }
  38678. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  38679. /**
  38680. * @function
  38681. * @memberof Modifiers
  38682. * @argument {Object} data - The data object generated by `update` method
  38683. * @argument {Object} options - Modifiers configuration and options
  38684. * @returns {Object} The data object, properly modified
  38685. */
  38686. function computeStyle(data, options) {
  38687. var x = options.x,
  38688. y = options.y;
  38689. var popper = data.offsets.popper;
  38690. // Remove this legacy support in Popper.js v2
  38691. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  38692. return modifier.name === 'applyStyle';
  38693. }).gpuAcceleration;
  38694. if (legacyGpuAccelerationOption !== undefined) {
  38695. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  38696. }
  38697. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  38698. var offsetParent = getOffsetParent(data.instance.popper);
  38699. var offsetParentRect = getBoundingClientRect(offsetParent);
  38700. // Styles
  38701. var styles = {
  38702. position: popper.position
  38703. };
  38704. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  38705. var sideA = x === 'bottom' ? 'top' : 'bottom';
  38706. var sideB = y === 'right' ? 'left' : 'right';
  38707. // if gpuAcceleration is set to `true` and transform is supported,
  38708. // we use `translate3d` to apply the position to the popper we
  38709. // automatically use the supported prefixed version if needed
  38710. var prefixedProperty = getSupportedPropertyName('transform');
  38711. // now, let's make a step back and look at this code closely (wtf?)
  38712. // If the content of the popper grows once it's been positioned, it
  38713. // may happen that the popper gets misplaced because of the new content
  38714. // overflowing its reference element
  38715. // To avoid this problem, we provide two options (x and y), which allow
  38716. // the consumer to define the offset origin.
  38717. // If we position a popper on top of a reference element, we can set
  38718. // `x` to `top` to make the popper grow towards its top instead of
  38719. // its bottom.
  38720. var left = void 0,
  38721. top = void 0;
  38722. if (sideA === 'bottom') {
  38723. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  38724. // and not the bottom of the html element
  38725. if (offsetParent.nodeName === 'HTML') {
  38726. top = -offsetParent.clientHeight + offsets.bottom;
  38727. } else {
  38728. top = -offsetParentRect.height + offsets.bottom;
  38729. }
  38730. } else {
  38731. top = offsets.top;
  38732. }
  38733. if (sideB === 'right') {
  38734. if (offsetParent.nodeName === 'HTML') {
  38735. left = -offsetParent.clientWidth + offsets.right;
  38736. } else {
  38737. left = -offsetParentRect.width + offsets.right;
  38738. }
  38739. } else {
  38740. left = offsets.left;
  38741. }
  38742. if (gpuAcceleration && prefixedProperty) {
  38743. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  38744. styles[sideA] = 0;
  38745. styles[sideB] = 0;
  38746. styles.willChange = 'transform';
  38747. } else {
  38748. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  38749. var invertTop = sideA === 'bottom' ? -1 : 1;
  38750. var invertLeft = sideB === 'right' ? -1 : 1;
  38751. styles[sideA] = top * invertTop;
  38752. styles[sideB] = left * invertLeft;
  38753. styles.willChange = sideA + ', ' + sideB;
  38754. }
  38755. // Attributes
  38756. var attributes = {
  38757. 'x-placement': data.placement
  38758. };
  38759. // Update `data` attributes, styles and arrowStyles
  38760. data.attributes = _extends({}, attributes, data.attributes);
  38761. data.styles = _extends({}, styles, data.styles);
  38762. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  38763. return data;
  38764. }
  38765. /**
  38766. * Helper used to know if the given modifier depends from another one.<br />
  38767. * It checks if the needed modifier is listed and enabled.
  38768. * @method
  38769. * @memberof Popper.Utils
  38770. * @param {Array} modifiers - list of modifiers
  38771. * @param {String} requestingName - name of requesting modifier
  38772. * @param {String} requestedName - name of requested modifier
  38773. * @returns {Boolean}
  38774. */
  38775. function isModifierRequired(modifiers, requestingName, requestedName) {
  38776. var requesting = find(modifiers, function (_ref) {
  38777. var name = _ref.name;
  38778. return name === requestingName;
  38779. });
  38780. var isRequired = !!requesting && modifiers.some(function (modifier) {
  38781. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  38782. });
  38783. if (!isRequired) {
  38784. var _requesting = '`' + requestingName + '`';
  38785. var requested = '`' + requestedName + '`';
  38786. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  38787. }
  38788. return isRequired;
  38789. }
  38790. /**
  38791. * @function
  38792. * @memberof Modifiers
  38793. * @argument {Object} data - The data object generated by update method
  38794. * @argument {Object} options - Modifiers configuration and options
  38795. * @returns {Object} The data object, properly modified
  38796. */
  38797. function arrow(data, options) {
  38798. var _data$offsets$arrow;
  38799. // arrow depends on keepTogether in order to work
  38800. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  38801. return data;
  38802. }
  38803. var arrowElement = options.element;
  38804. // if arrowElement is a string, suppose it's a CSS selector
  38805. if (typeof arrowElement === 'string') {
  38806. arrowElement = data.instance.popper.querySelector(arrowElement);
  38807. // if arrowElement is not found, don't run the modifier
  38808. if (!arrowElement) {
  38809. return data;
  38810. }
  38811. } else {
  38812. // if the arrowElement isn't a query selector we must check that the
  38813. // provided DOM node is child of its popper node
  38814. if (!data.instance.popper.contains(arrowElement)) {
  38815. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  38816. return data;
  38817. }
  38818. }
  38819. var placement = data.placement.split('-')[0];
  38820. var _data$offsets = data.offsets,
  38821. popper = _data$offsets.popper,
  38822. reference = _data$offsets.reference;
  38823. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  38824. var len = isVertical ? 'height' : 'width';
  38825. var sideCapitalized = isVertical ? 'Top' : 'Left';
  38826. var side = sideCapitalized.toLowerCase();
  38827. var altSide = isVertical ? 'left' : 'top';
  38828. var opSide = isVertical ? 'bottom' : 'right';
  38829. var arrowElementSize = getOuterSizes(arrowElement)[len];
  38830. //
  38831. // extends keepTogether behavior making sure the popper and its
  38832. // reference have enough pixels in conjunction
  38833. //
  38834. // top/left side
  38835. if (reference[opSide] - arrowElementSize < popper[side]) {
  38836. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  38837. }
  38838. // bottom/right side
  38839. if (reference[side] + arrowElementSize > popper[opSide]) {
  38840. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  38841. }
  38842. data.offsets.popper = getClientRect(data.offsets.popper);
  38843. // compute center of the popper
  38844. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  38845. // Compute the sideValue using the updated popper offsets
  38846. // take popper margin in account because we don't have this info available
  38847. var css = getStyleComputedProperty(data.instance.popper);
  38848. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  38849. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  38850. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  38851. // prevent arrowElement from being placed not contiguously to its popper
  38852. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  38853. data.arrowElement = arrowElement;
  38854. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  38855. return data;
  38856. }
  38857. /**
  38858. * Get the opposite placement variation of the given one
  38859. * @method
  38860. * @memberof Popper.Utils
  38861. * @argument {String} placement variation
  38862. * @returns {String} flipped placement variation
  38863. */
  38864. function getOppositeVariation(variation) {
  38865. if (variation === 'end') {
  38866. return 'start';
  38867. } else if (variation === 'start') {
  38868. return 'end';
  38869. }
  38870. return variation;
  38871. }
  38872. /**
  38873. * List of accepted placements to use as values of the `placement` option.<br />
  38874. * Valid placements are:
  38875. * - `auto`
  38876. * - `top`
  38877. * - `right`
  38878. * - `bottom`
  38879. * - `left`
  38880. *
  38881. * Each placement can have a variation from this list:
  38882. * - `-start`
  38883. * - `-end`
  38884. *
  38885. * Variations are interpreted easily if you think of them as the left to right
  38886. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  38887. * is right.<br />
  38888. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  38889. *
  38890. * Some valid examples are:
  38891. * - `top-end` (on top of reference, right aligned)
  38892. * - `right-start` (on right of reference, top aligned)
  38893. * - `bottom` (on bottom, centered)
  38894. * - `auto-end` (on the side with more space available, alignment depends by placement)
  38895. *
  38896. * @static
  38897. * @type {Array}
  38898. * @enum {String}
  38899. * @readonly
  38900. * @method placements
  38901. * @memberof Popper
  38902. */
  38903. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
  38904. // Get rid of `auto` `auto-start` and `auto-end`
  38905. var validPlacements = placements.slice(3);
  38906. /**
  38907. * Given an initial placement, returns all the subsequent placements
  38908. * clockwise (or counter-clockwise).
  38909. *
  38910. * @method
  38911. * @memberof Popper.Utils
  38912. * @argument {String} placement - A valid placement (it accepts variations)
  38913. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  38914. * @returns {Array} placements including their variations
  38915. */
  38916. function clockwise(placement) {
  38917. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  38918. var index = validPlacements.indexOf(placement);
  38919. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  38920. return counter ? arr.reverse() : arr;
  38921. }
  38922. var BEHAVIORS = {
  38923. FLIP: 'flip',
  38924. CLOCKWISE: 'clockwise',
  38925. COUNTERCLOCKWISE: 'counterclockwise'
  38926. };
  38927. /**
  38928. * @function
  38929. * @memberof Modifiers
  38930. * @argument {Object} data - The data object generated by update method
  38931. * @argument {Object} options - Modifiers configuration and options
  38932. * @returns {Object} The data object, properly modified
  38933. */
  38934. function flip(data, options) {
  38935. // if `inner` modifier is enabled, we can't use the `flip` modifier
  38936. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  38937. return data;
  38938. }
  38939. if (data.flipped && data.placement === data.originalPlacement) {
  38940. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  38941. return data;
  38942. }
  38943. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  38944. var placement = data.placement.split('-')[0];
  38945. var placementOpposite = getOppositePlacement(placement);
  38946. var variation = data.placement.split('-')[1] || '';
  38947. var flipOrder = [];
  38948. switch (options.behavior) {
  38949. case BEHAVIORS.FLIP:
  38950. flipOrder = [placement, placementOpposite];
  38951. break;
  38952. case BEHAVIORS.CLOCKWISE:
  38953. flipOrder = clockwise(placement);
  38954. break;
  38955. case BEHAVIORS.COUNTERCLOCKWISE:
  38956. flipOrder = clockwise(placement, true);
  38957. break;
  38958. default:
  38959. flipOrder = options.behavior;
  38960. }
  38961. flipOrder.forEach(function (step, index) {
  38962. if (placement !== step || flipOrder.length === index + 1) {
  38963. return data;
  38964. }
  38965. placement = data.placement.split('-')[0];
  38966. placementOpposite = getOppositePlacement(placement);
  38967. var popperOffsets = data.offsets.popper;
  38968. var refOffsets = data.offsets.reference;
  38969. // using floor because the reference offsets may contain decimals we are not going to consider here
  38970. var floor = Math.floor;
  38971. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  38972. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  38973. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  38974. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  38975. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  38976. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  38977. // flip the variation if required
  38978. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  38979. // flips variation if reference element overflows boundaries
  38980. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  38981. // flips variation if popper content overflows boundaries
  38982. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  38983. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  38984. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  38985. // this boolean to detect any flip loop
  38986. data.flipped = true;
  38987. if (overlapsRef || overflowsBoundaries) {
  38988. placement = flipOrder[index + 1];
  38989. }
  38990. if (flippedVariation) {
  38991. variation = getOppositeVariation(variation);
  38992. }
  38993. data.placement = placement + (variation ? '-' + variation : '');
  38994. // this object contains `position`, we want to preserve it along with
  38995. // any additional property we may add in the future
  38996. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  38997. data = runModifiers(data.instance.modifiers, data, 'flip');
  38998. }
  38999. });
  39000. return data;
  39001. }
  39002. /**
  39003. * @function
  39004. * @memberof Modifiers
  39005. * @argument {Object} data - The data object generated by update method
  39006. * @argument {Object} options - Modifiers configuration and options
  39007. * @returns {Object} The data object, properly modified
  39008. */
  39009. function keepTogether(data) {
  39010. var _data$offsets = data.offsets,
  39011. popper = _data$offsets.popper,
  39012. reference = _data$offsets.reference;
  39013. var placement = data.placement.split('-')[0];
  39014. var floor = Math.floor;
  39015. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  39016. var side = isVertical ? 'right' : 'bottom';
  39017. var opSide = isVertical ? 'left' : 'top';
  39018. var measurement = isVertical ? 'width' : 'height';
  39019. if (popper[side] < floor(reference[opSide])) {
  39020. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  39021. }
  39022. if (popper[opSide] > floor(reference[side])) {
  39023. data.offsets.popper[opSide] = floor(reference[side]);
  39024. }
  39025. return data;
  39026. }
  39027. /**
  39028. * Converts a string containing value + unit into a px value number
  39029. * @function
  39030. * @memberof {modifiers~offset}
  39031. * @private
  39032. * @argument {String} str - Value + unit string
  39033. * @argument {String} measurement - `height` or `width`
  39034. * @argument {Object} popperOffsets
  39035. * @argument {Object} referenceOffsets
  39036. * @returns {Number|String}
  39037. * Value in pixels, or original string if no values were extracted
  39038. */
  39039. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  39040. // separate value from unit
  39041. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  39042. var value = +split[1];
  39043. var unit = split[2];
  39044. // If it's not a number it's an operator, I guess
  39045. if (!value) {
  39046. return str;
  39047. }
  39048. if (unit.indexOf('%') === 0) {
  39049. var element = void 0;
  39050. switch (unit) {
  39051. case '%p':
  39052. element = popperOffsets;
  39053. break;
  39054. case '%':
  39055. case '%r':
  39056. default:
  39057. element = referenceOffsets;
  39058. }
  39059. var rect = getClientRect(element);
  39060. return rect[measurement] / 100 * value;
  39061. } else if (unit === 'vh' || unit === 'vw') {
  39062. // if is a vh or vw, we calculate the size based on the viewport
  39063. var size = void 0;
  39064. if (unit === 'vh') {
  39065. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  39066. } else {
  39067. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  39068. }
  39069. return size / 100 * value;
  39070. } else {
  39071. // if is an explicit pixel unit, we get rid of the unit and keep the value
  39072. // if is an implicit unit, it's px, and we return just the value
  39073. return value;
  39074. }
  39075. }
  39076. /**
  39077. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  39078. * @function
  39079. * @memberof {modifiers~offset}
  39080. * @private
  39081. * @argument {String} offset
  39082. * @argument {Object} popperOffsets
  39083. * @argument {Object} referenceOffsets
  39084. * @argument {String} basePlacement
  39085. * @returns {Array} a two cells array with x and y offsets in numbers
  39086. */
  39087. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  39088. var offsets = [0, 0];
  39089. // Use height if placement is left or right and index is 0 otherwise use width
  39090. // in this way the first offset will use an axis and the second one
  39091. // will use the other one
  39092. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  39093. // Split the offset string to obtain a list of values and operands
  39094. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  39095. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  39096. return frag.trim();
  39097. });
  39098. // Detect if the offset string contains a pair of values or a single one
  39099. // they could be separated by comma or space
  39100. var divider = fragments.indexOf(find(fragments, function (frag) {
  39101. return frag.search(/,|\s/) !== -1;
  39102. }));
  39103. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  39104. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  39105. }
  39106. // If divider is found, we divide the list of values and operands to divide
  39107. // them by ofset X and Y.
  39108. var splitRegex = /\s*,\s*|\s+/;
  39109. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  39110. // Convert the values with units to absolute pixels to allow our computations
  39111. ops = ops.map(function (op, index) {
  39112. // Most of the units rely on the orientation of the popper
  39113. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  39114. var mergeWithPrevious = false;
  39115. return op
  39116. // This aggregates any `+` or `-` sign that aren't considered operators
  39117. // e.g.: 10 + +5 => [10, +, +5]
  39118. .reduce(function (a, b) {
  39119. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  39120. a[a.length - 1] = b;
  39121. mergeWithPrevious = true;
  39122. return a;
  39123. } else if (mergeWithPrevious) {
  39124. a[a.length - 1] += b;
  39125. mergeWithPrevious = false;
  39126. return a;
  39127. } else {
  39128. return a.concat(b);
  39129. }
  39130. }, [])
  39131. // Here we convert the string values into number values (in px)
  39132. .map(function (str) {
  39133. return toValue(str, measurement, popperOffsets, referenceOffsets);
  39134. });
  39135. });
  39136. // Loop trough the offsets arrays and execute the operations
  39137. ops.forEach(function (op, index) {
  39138. op.forEach(function (frag, index2) {
  39139. if (isNumeric(frag)) {
  39140. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  39141. }
  39142. });
  39143. });
  39144. return offsets;
  39145. }
  39146. /**
  39147. * @function
  39148. * @memberof Modifiers
  39149. * @argument {Object} data - The data object generated by update method
  39150. * @argument {Object} options - Modifiers configuration and options
  39151. * @argument {Number|String} options.offset=0
  39152. * The offset value as described in the modifier description
  39153. * @returns {Object} The data object, properly modified
  39154. */
  39155. function offset(data, _ref) {
  39156. var offset = _ref.offset;
  39157. var placement = data.placement,
  39158. _data$offsets = data.offsets,
  39159. popper = _data$offsets.popper,
  39160. reference = _data$offsets.reference;
  39161. var basePlacement = placement.split('-')[0];
  39162. var offsets = void 0;
  39163. if (isNumeric(+offset)) {
  39164. offsets = [+offset, 0];
  39165. } else {
  39166. offsets = parseOffset(offset, popper, reference, basePlacement);
  39167. }
  39168. if (basePlacement === 'left') {
  39169. popper.top += offsets[0];
  39170. popper.left -= offsets[1];
  39171. } else if (basePlacement === 'right') {
  39172. popper.top += offsets[0];
  39173. popper.left += offsets[1];
  39174. } else if (basePlacement === 'top') {
  39175. popper.left += offsets[0];
  39176. popper.top -= offsets[1];
  39177. } else if (basePlacement === 'bottom') {
  39178. popper.left += offsets[0];
  39179. popper.top += offsets[1];
  39180. }
  39181. data.popper = popper;
  39182. return data;
  39183. }
  39184. /**
  39185. * @function
  39186. * @memberof Modifiers
  39187. * @argument {Object} data - The data object generated by `update` method
  39188. * @argument {Object} options - Modifiers configuration and options
  39189. * @returns {Object} The data object, properly modified
  39190. */
  39191. function preventOverflow(data, options) {
  39192. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  39193. // If offsetParent is the reference element, we really want to
  39194. // go one step up and use the next offsetParent as reference to
  39195. // avoid to make this modifier completely useless and look like broken
  39196. if (data.instance.reference === boundariesElement) {
  39197. boundariesElement = getOffsetParent(boundariesElement);
  39198. }
  39199. // NOTE: DOM access here
  39200. // resets the popper's position so that the document size can be calculated excluding
  39201. // the size of the popper element itself
  39202. var transformProp = getSupportedPropertyName('transform');
  39203. var popperStyles = data.instance.popper.style; // assignment to help minification
  39204. var top = popperStyles.top,
  39205. left = popperStyles.left,
  39206. transform = popperStyles[transformProp];
  39207. popperStyles.top = '';
  39208. popperStyles.left = '';
  39209. popperStyles[transformProp] = '';
  39210. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  39211. // NOTE: DOM access here
  39212. // restores the original style properties after the offsets have been computed
  39213. popperStyles.top = top;
  39214. popperStyles.left = left;
  39215. popperStyles[transformProp] = transform;
  39216. options.boundaries = boundaries;
  39217. var order = options.priority;
  39218. var popper = data.offsets.popper;
  39219. var check = {
  39220. primary: function primary(placement) {
  39221. var value = popper[placement];
  39222. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  39223. value = Math.max(popper[placement], boundaries[placement]);
  39224. }
  39225. return defineProperty({}, placement, value);
  39226. },
  39227. secondary: function secondary(placement) {
  39228. var mainSide = placement === 'right' ? 'left' : 'top';
  39229. var value = popper[mainSide];
  39230. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  39231. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  39232. }
  39233. return defineProperty({}, mainSide, value);
  39234. }
  39235. };
  39236. order.forEach(function (placement) {
  39237. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  39238. popper = _extends({}, popper, check[side](placement));
  39239. });
  39240. data.offsets.popper = popper;
  39241. return data;
  39242. }
  39243. /**
  39244. * @function
  39245. * @memberof Modifiers
  39246. * @argument {Object} data - The data object generated by `update` method
  39247. * @argument {Object} options - Modifiers configuration and options
  39248. * @returns {Object} The data object, properly modified
  39249. */
  39250. function shift(data) {
  39251. var placement = data.placement;
  39252. var basePlacement = placement.split('-')[0];
  39253. var shiftvariation = placement.split('-')[1];
  39254. // if shift shiftvariation is specified, run the modifier
  39255. if (shiftvariation) {
  39256. var _data$offsets = data.offsets,
  39257. reference = _data$offsets.reference,
  39258. popper = _data$offsets.popper;
  39259. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  39260. var side = isVertical ? 'left' : 'top';
  39261. var measurement = isVertical ? 'width' : 'height';
  39262. var shiftOffsets = {
  39263. start: defineProperty({}, side, reference[side]),
  39264. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  39265. };
  39266. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  39267. }
  39268. return data;
  39269. }
  39270. /**
  39271. * @function
  39272. * @memberof Modifiers
  39273. * @argument {Object} data - The data object generated by update method
  39274. * @argument {Object} options - Modifiers configuration and options
  39275. * @returns {Object} The data object, properly modified
  39276. */
  39277. function hide(data) {
  39278. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  39279. return data;
  39280. }
  39281. var refRect = data.offsets.reference;
  39282. var bound = find(data.instance.modifiers, function (modifier) {
  39283. return modifier.name === 'preventOverflow';
  39284. }).boundaries;
  39285. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  39286. // Avoid unnecessary DOM access if visibility hasn't changed
  39287. if (data.hide === true) {
  39288. return data;
  39289. }
  39290. data.hide = true;
  39291. data.attributes['x-out-of-boundaries'] = '';
  39292. } else {
  39293. // Avoid unnecessary DOM access if visibility hasn't changed
  39294. if (data.hide === false) {
  39295. return data;
  39296. }
  39297. data.hide = false;
  39298. data.attributes['x-out-of-boundaries'] = false;
  39299. }
  39300. return data;
  39301. }
  39302. /**
  39303. * @function
  39304. * @memberof Modifiers
  39305. * @argument {Object} data - The data object generated by `update` method
  39306. * @argument {Object} options - Modifiers configuration and options
  39307. * @returns {Object} The data object, properly modified
  39308. */
  39309. function inner(data) {
  39310. var placement = data.placement;
  39311. var basePlacement = placement.split('-')[0];
  39312. var _data$offsets = data.offsets,
  39313. popper = _data$offsets.popper,
  39314. reference = _data$offsets.reference;
  39315. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  39316. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  39317. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  39318. data.placement = getOppositePlacement(placement);
  39319. data.offsets.popper = getClientRect(popper);
  39320. return data;
  39321. }
  39322. /**
  39323. * Modifier function, each modifier can have a function of this type assigned
  39324. * to its `fn` property.<br />
  39325. * These functions will be called on each update, this means that you must
  39326. * make sure they are performant enough to avoid performance bottlenecks.
  39327. *
  39328. * @function ModifierFn
  39329. * @argument {dataObject} data - The data object generated by `update` method
  39330. * @argument {Object} options - Modifiers configuration and options
  39331. * @returns {dataObject} The data object, properly modified
  39332. */
  39333. /**
  39334. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  39335. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  39336. * needed by the library.
  39337. *
  39338. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  39339. * All the other properties are configurations that could be tweaked.
  39340. * @namespace modifiers
  39341. */
  39342. var modifiers = {
  39343. /**
  39344. * Modifier used to shift the popper on the start or end of its reference
  39345. * element.<br />
  39346. * It will read the variation of the `placement` property.<br />
  39347. * It can be one either `-end` or `-start`.
  39348. * @memberof modifiers
  39349. * @inner
  39350. */
  39351. shift: {
  39352. /** @prop {number} order=100 - Index used to define the order of execution */
  39353. order: 100,
  39354. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39355. enabled: true,
  39356. /** @prop {ModifierFn} */
  39357. fn: shift
  39358. },
  39359. /**
  39360. * The `offset` modifier can shift your popper on both its axis.
  39361. *
  39362. * It accepts the following units:
  39363. * - `px` or unit-less, interpreted as pixels
  39364. * - `%` or `%r`, percentage relative to the length of the reference element
  39365. * - `%p`, percentage relative to the length of the popper element
  39366. * - `vw`, CSS viewport width unit
  39367. * - `vh`, CSS viewport height unit
  39368. *
  39369. * For length is intended the main axis relative to the placement of the popper.<br />
  39370. * This means that if the placement is `top` or `bottom`, the length will be the
  39371. * `width`. In case of `left` or `right`, it will be the `height`.
  39372. *
  39373. * You can provide a single value (as `Number` or `String`), or a pair of values
  39374. * as `String` divided by a comma or one (or more) white spaces.<br />
  39375. * The latter is a deprecated method because it leads to confusion and will be
  39376. * removed in v2.<br />
  39377. * Additionally, it accepts additions and subtractions between different units.
  39378. * Note that multiplications and divisions aren't supported.
  39379. *
  39380. * Valid examples are:
  39381. * ```
  39382. * 10
  39383. * '10%'
  39384. * '10, 10'
  39385. * '10%, 10'
  39386. * '10 + 10%'
  39387. * '10 - 5vh + 3%'
  39388. * '-10px + 5vh, 5px - 6%'
  39389. * ```
  39390. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  39391. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  39392. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  39393. *
  39394. * @memberof modifiers
  39395. * @inner
  39396. */
  39397. offset: {
  39398. /** @prop {number} order=200 - Index used to define the order of execution */
  39399. order: 200,
  39400. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39401. enabled: true,
  39402. /** @prop {ModifierFn} */
  39403. fn: offset,
  39404. /** @prop {Number|String} offset=0
  39405. * The offset value as described in the modifier description
  39406. */
  39407. offset: 0
  39408. },
  39409. /**
  39410. * Modifier used to prevent the popper from being positioned outside the boundary.
  39411. *
  39412. * A scenario exists where the reference itself is not within the boundaries.<br />
  39413. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  39414. * In this case we need to decide whether the popper should either:
  39415. *
  39416. * - detach from the reference and remain "trapped" in the boundaries, or
  39417. * - if it should ignore the boundary and "escape with its reference"
  39418. *
  39419. * When `escapeWithReference` is set to`true` and reference is completely
  39420. * outside its boundaries, the popper will overflow (or completely leave)
  39421. * the boundaries in order to remain attached to the edge of the reference.
  39422. *
  39423. * @memberof modifiers
  39424. * @inner
  39425. */
  39426. preventOverflow: {
  39427. /** @prop {number} order=300 - Index used to define the order of execution */
  39428. order: 300,
  39429. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39430. enabled: true,
  39431. /** @prop {ModifierFn} */
  39432. fn: preventOverflow,
  39433. /**
  39434. * @prop {Array} [priority=['left','right','top','bottom']]
  39435. * Popper will try to prevent overflow following these priorities by default,
  39436. * then, it could overflow on the left and on top of the `boundariesElement`
  39437. */
  39438. priority: ['left', 'right', 'top', 'bottom'],
  39439. /**
  39440. * @prop {number} padding=5
  39441. * Amount of pixel used to define a minimum distance between the boundaries
  39442. * and the popper. This makes sure the popper always has a little padding
  39443. * between the edges of its container
  39444. */
  39445. padding: 5,
  39446. /**
  39447. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  39448. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  39449. * `viewport` or any DOM element.
  39450. */
  39451. boundariesElement: 'scrollParent'
  39452. },
  39453. /**
  39454. * Modifier used to make sure the reference and its popper stay near each other
  39455. * without leaving any gap between the two. Especially useful when the arrow is
  39456. * enabled and you want to ensure that it points to its reference element.
  39457. * It cares only about the first axis. You can still have poppers with margin
  39458. * between the popper and its reference element.
  39459. * @memberof modifiers
  39460. * @inner
  39461. */
  39462. keepTogether: {
  39463. /** @prop {number} order=400 - Index used to define the order of execution */
  39464. order: 400,
  39465. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39466. enabled: true,
  39467. /** @prop {ModifierFn} */
  39468. fn: keepTogether
  39469. },
  39470. /**
  39471. * This modifier is used to move the `arrowElement` of the popper to make
  39472. * sure it is positioned between the reference element and its popper element.
  39473. * It will read the outer size of the `arrowElement` node to detect how many
  39474. * pixels of conjunction are needed.
  39475. *
  39476. * It has no effect if no `arrowElement` is provided.
  39477. * @memberof modifiers
  39478. * @inner
  39479. */
  39480. arrow: {
  39481. /** @prop {number} order=500 - Index used to define the order of execution */
  39482. order: 500,
  39483. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39484. enabled: true,
  39485. /** @prop {ModifierFn} */
  39486. fn: arrow,
  39487. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  39488. element: '[x-arrow]'
  39489. },
  39490. /**
  39491. * Modifier used to flip the popper's placement when it starts to overlap its
  39492. * reference element.
  39493. *
  39494. * Requires the `preventOverflow` modifier before it in order to work.
  39495. *
  39496. * **NOTE:** this modifier will interrupt the current update cycle and will
  39497. * restart it if it detects the need to flip the placement.
  39498. * @memberof modifiers
  39499. * @inner
  39500. */
  39501. flip: {
  39502. /** @prop {number} order=600 - Index used to define the order of execution */
  39503. order: 600,
  39504. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39505. enabled: true,
  39506. /** @prop {ModifierFn} */
  39507. fn: flip,
  39508. /**
  39509. * @prop {String|Array} behavior='flip'
  39510. * The behavior used to change the popper's placement. It can be one of
  39511. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  39512. * placements (with optional variations)
  39513. */
  39514. behavior: 'flip',
  39515. /**
  39516. * @prop {number} padding=5
  39517. * The popper will flip if it hits the edges of the `boundariesElement`
  39518. */
  39519. padding: 5,
  39520. /**
  39521. * @prop {String|HTMLElement} boundariesElement='viewport'
  39522. * The element which will define the boundaries of the popper position.
  39523. * The popper will never be placed outside of the defined boundaries
  39524. * (except if `keepTogether` is enabled)
  39525. */
  39526. boundariesElement: 'viewport',
  39527. /**
  39528. * @prop {Boolean} flipVariations=false
  39529. * The popper will switch placement variation between `-start` and `-end` when
  39530. * the reference element overlaps its boundaries.
  39531. *
  39532. * The original placement should have a set variation.
  39533. */
  39534. flipVariations: false,
  39535. /**
  39536. * @prop {Boolean} flipVariationsByContent=false
  39537. * The popper will switch placement variation between `-start` and `-end` when
  39538. * the popper element overlaps its reference boundaries.
  39539. *
  39540. * The original placement should have a set variation.
  39541. */
  39542. flipVariationsByContent: false
  39543. },
  39544. /**
  39545. * Modifier used to make the popper flow toward the inner of the reference element.
  39546. * By default, when this modifier is disabled, the popper will be placed outside
  39547. * the reference element.
  39548. * @memberof modifiers
  39549. * @inner
  39550. */
  39551. inner: {
  39552. /** @prop {number} order=700 - Index used to define the order of execution */
  39553. order: 700,
  39554. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  39555. enabled: false,
  39556. /** @prop {ModifierFn} */
  39557. fn: inner
  39558. },
  39559. /**
  39560. * Modifier used to hide the popper when its reference element is outside of the
  39561. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  39562. * be used to hide with a CSS selector the popper when its reference is
  39563. * out of boundaries.
  39564. *
  39565. * Requires the `preventOverflow` modifier before it in order to work.
  39566. * @memberof modifiers
  39567. * @inner
  39568. */
  39569. hide: {
  39570. /** @prop {number} order=800 - Index used to define the order of execution */
  39571. order: 800,
  39572. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39573. enabled: true,
  39574. /** @prop {ModifierFn} */
  39575. fn: hide
  39576. },
  39577. /**
  39578. * Computes the style that will be applied to the popper element to gets
  39579. * properly positioned.
  39580. *
  39581. * Note that this modifier will not touch the DOM, it just prepares the styles
  39582. * so that `applyStyle` modifier can apply it. This separation is useful
  39583. * in case you need to replace `applyStyle` with a custom implementation.
  39584. *
  39585. * This modifier has `850` as `order` value to maintain backward compatibility
  39586. * with previous versions of Popper.js. Expect the modifiers ordering method
  39587. * to change in future major versions of the library.
  39588. *
  39589. * @memberof modifiers
  39590. * @inner
  39591. */
  39592. computeStyle: {
  39593. /** @prop {number} order=850 - Index used to define the order of execution */
  39594. order: 850,
  39595. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39596. enabled: true,
  39597. /** @prop {ModifierFn} */
  39598. fn: computeStyle,
  39599. /**
  39600. * @prop {Boolean} gpuAcceleration=true
  39601. * If true, it uses the CSS 3D transformation to position the popper.
  39602. * Otherwise, it will use the `top` and `left` properties
  39603. */
  39604. gpuAcceleration: true,
  39605. /**
  39606. * @prop {string} [x='bottom']
  39607. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  39608. * Change this if your popper should grow in a direction different from `bottom`
  39609. */
  39610. x: 'bottom',
  39611. /**
  39612. * @prop {string} [x='left']
  39613. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  39614. * Change this if your popper should grow in a direction different from `right`
  39615. */
  39616. y: 'right'
  39617. },
  39618. /**
  39619. * Applies the computed styles to the popper element.
  39620. *
  39621. * All the DOM manipulations are limited to this modifier. This is useful in case
  39622. * you want to integrate Popper.js inside a framework or view library and you
  39623. * want to delegate all the DOM manipulations to it.
  39624. *
  39625. * Note that if you disable this modifier, you must make sure the popper element
  39626. * has its position set to `absolute` before Popper.js can do its work!
  39627. *
  39628. * Just disable this modifier and define your own to achieve the desired effect.
  39629. *
  39630. * @memberof modifiers
  39631. * @inner
  39632. */
  39633. applyStyle: {
  39634. /** @prop {number} order=900 - Index used to define the order of execution */
  39635. order: 900,
  39636. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  39637. enabled: true,
  39638. /** @prop {ModifierFn} */
  39639. fn: applyStyle,
  39640. /** @prop {Function} */
  39641. onLoad: applyStyleOnLoad,
  39642. /**
  39643. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  39644. * @prop {Boolean} gpuAcceleration=true
  39645. * If true, it uses the CSS 3D transformation to position the popper.
  39646. * Otherwise, it will use the `top` and `left` properties
  39647. */
  39648. gpuAcceleration: undefined
  39649. }
  39650. };
  39651. /**
  39652. * The `dataObject` is an object containing all the information used by Popper.js.
  39653. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  39654. * @name dataObject
  39655. * @property {Object} data.instance The Popper.js instance
  39656. * @property {String} data.placement Placement applied to popper
  39657. * @property {String} data.originalPlacement Placement originally defined on init
  39658. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  39659. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  39660. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  39661. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  39662. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  39663. * @property {Object} data.boundaries Offsets of the popper boundaries
  39664. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  39665. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  39666. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  39667. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  39668. */
  39669. /**
  39670. * Default options provided to Popper.js constructor.<br />
  39671. * These can be overridden using the `options` argument of Popper.js.<br />
  39672. * To override an option, simply pass an object with the same
  39673. * structure of the `options` object, as the 3rd argument. For example:
  39674. * ```
  39675. * new Popper(ref, pop, {
  39676. * modifiers: {
  39677. * preventOverflow: { enabled: false }
  39678. * }
  39679. * })
  39680. * ```
  39681. * @type {Object}
  39682. * @static
  39683. * @memberof Popper
  39684. */
  39685. var Defaults = {
  39686. /**
  39687. * Popper's placement.
  39688. * @prop {Popper.placements} placement='bottom'
  39689. */
  39690. placement: 'bottom',
  39691. /**
  39692. * Set this to true if you want popper to position it self in 'fixed' mode
  39693. * @prop {Boolean} positionFixed=false
  39694. */
  39695. positionFixed: false,
  39696. /**
  39697. * Whether events (resize, scroll) are initially enabled.
  39698. * @prop {Boolean} eventsEnabled=true
  39699. */
  39700. eventsEnabled: true,
  39701. /**
  39702. * Set to true if you want to automatically remove the popper when
  39703. * you call the `destroy` method.
  39704. * @prop {Boolean} removeOnDestroy=false
  39705. */
  39706. removeOnDestroy: false,
  39707. /**
  39708. * Callback called when the popper is created.<br />
  39709. * By default, it is set to no-op.<br />
  39710. * Access Popper.js instance with `data.instance`.
  39711. * @prop {onCreate}
  39712. */
  39713. onCreate: function onCreate() {},
  39714. /**
  39715. * Callback called when the popper is updated. This callback is not called
  39716. * on the initialization/creation of the popper, but only on subsequent
  39717. * updates.<br />
  39718. * By default, it is set to no-op.<br />
  39719. * Access Popper.js instance with `data.instance`.
  39720. * @prop {onUpdate}
  39721. */
  39722. onUpdate: function onUpdate() {},
  39723. /**
  39724. * List of modifiers used to modify the offsets before they are applied to the popper.
  39725. * They provide most of the functionalities of Popper.js.
  39726. * @prop {modifiers}
  39727. */
  39728. modifiers: modifiers
  39729. };
  39730. /**
  39731. * @callback onCreate
  39732. * @param {dataObject} data
  39733. */
  39734. /**
  39735. * @callback onUpdate
  39736. * @param {dataObject} data
  39737. */
  39738. // Utils
  39739. // Methods
  39740. var Popper = function () {
  39741. /**
  39742. * Creates a new Popper.js instance.
  39743. * @class Popper
  39744. * @param {Element|referenceObject} reference - The reference element used to position the popper
  39745. * @param {Element} popper - The HTML / XML element used as the popper
  39746. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  39747. * @return {Object} instance - The generated Popper.js instance
  39748. */
  39749. function Popper(reference, popper) {
  39750. var _this = this;
  39751. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  39752. classCallCheck(this, Popper);
  39753. this.scheduleUpdate = function () {
  39754. return requestAnimationFrame(_this.update);
  39755. };
  39756. // make update() debounced, so that it only runs at most once-per-tick
  39757. this.update = debounce(this.update.bind(this));
  39758. // with {} we create a new object with the options inside it
  39759. this.options = _extends({}, Popper.Defaults, options);
  39760. // init state
  39761. this.state = {
  39762. isDestroyed: false,
  39763. isCreated: false,
  39764. scrollParents: []
  39765. };
  39766. // get reference and popper elements (allow jQuery wrappers)
  39767. this.reference = reference && reference.jquery ? reference[0] : reference;
  39768. this.popper = popper && popper.jquery ? popper[0] : popper;
  39769. // Deep merge modifiers options
  39770. this.options.modifiers = {};
  39771. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  39772. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  39773. });
  39774. // Refactoring modifiers' list (Object => Array)
  39775. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  39776. return _extends({
  39777. name: name
  39778. }, _this.options.modifiers[name]);
  39779. })
  39780. // sort the modifiers by order
  39781. .sort(function (a, b) {
  39782. return a.order - b.order;
  39783. });
  39784. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  39785. // such code is executed in the same order of its modifier
  39786. // they could add new properties to their options configuration
  39787. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  39788. this.modifiers.forEach(function (modifierOptions) {
  39789. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  39790. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  39791. }
  39792. });
  39793. // fire the first update to position the popper in the right place
  39794. this.update();
  39795. var eventsEnabled = this.options.eventsEnabled;
  39796. if (eventsEnabled) {
  39797. // setup event listeners, they will take care of update the position in specific situations
  39798. this.enableEventListeners();
  39799. }
  39800. this.state.eventsEnabled = eventsEnabled;
  39801. }
  39802. // We can't use class properties because they don't get listed in the
  39803. // class prototype and break stuff like Sinon stubs
  39804. createClass(Popper, [{
  39805. key: 'update',
  39806. value: function update$$1() {
  39807. return update.call(this);
  39808. }
  39809. }, {
  39810. key: 'destroy',
  39811. value: function destroy$$1() {
  39812. return destroy.call(this);
  39813. }
  39814. }, {
  39815. key: 'enableEventListeners',
  39816. value: function enableEventListeners$$1() {
  39817. return enableEventListeners.call(this);
  39818. }
  39819. }, {
  39820. key: 'disableEventListeners',
  39821. value: function disableEventListeners$$1() {
  39822. return disableEventListeners.call(this);
  39823. }
  39824. /**
  39825. * Schedules an update. It will run on the next UI update available.
  39826. * @method scheduleUpdate
  39827. * @memberof Popper
  39828. */
  39829. /**
  39830. * Collection of utilities useful when writing custom modifiers.
  39831. * Starting from version 1.7, this method is available only if you
  39832. * include `popper-utils.js` before `popper.js`.
  39833. *
  39834. * **DEPRECATION**: This way to access PopperUtils is deprecated
  39835. * and will be removed in v2! Use the PopperUtils module directly instead.
  39836. * Due to the high instability of the methods contained in Utils, we can't
  39837. * guarantee them to follow semver. Use them at your own risk!
  39838. * @static
  39839. * @private
  39840. * @type {Object}
  39841. * @deprecated since version 1.8
  39842. * @member Utils
  39843. * @memberof Popper
  39844. */
  39845. }]);
  39846. return Popper;
  39847. }();
  39848. /**
  39849. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  39850. * and lets you use it as replacement of a real DOM node.<br />
  39851. * You can use this method to position a popper relatively to a set of coordinates
  39852. * in case you don't have a DOM node to use as reference.
  39853. *
  39854. * ```
  39855. * new Popper(referenceObject, popperNode);
  39856. * ```
  39857. *
  39858. * NB: This feature isn't supported in Internet Explorer 10.
  39859. * @name referenceObject
  39860. * @property {Function} data.getBoundingClientRect
  39861. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  39862. * @property {number} data.clientWidth
  39863. * An ES6 getter that will return the width of the virtual reference element.
  39864. * @property {number} data.clientHeight
  39865. * An ES6 getter that will return the height of the virtual reference element.
  39866. */
  39867. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  39868. Popper.placements = placements;
  39869. Popper.Defaults = Defaults;
  39870. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  39871. //# sourceMappingURL=popper.js.map
  39872. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  39873. /***/ }),
  39874. /***/ "./node_modules/process/browser.js":
  39875. /*!*****************************************!*\
  39876. !*** ./node_modules/process/browser.js ***!
  39877. \*****************************************/
  39878. /*! no static exports found */
  39879. /***/ (function(module, exports) {
  39880. // shim for using process in browser
  39881. var process = module.exports = {};
  39882. // cached from whatever global is present so that test runners that stub it
  39883. // don't break things. But we need to wrap it in a try catch in case it is
  39884. // wrapped in strict mode code which doesn't define any globals. It's inside a
  39885. // function because try/catches deoptimize in certain engines.
  39886. var cachedSetTimeout;
  39887. var cachedClearTimeout;
  39888. function defaultSetTimout() {
  39889. throw new Error('setTimeout has not been defined');
  39890. }
  39891. function defaultClearTimeout () {
  39892. throw new Error('clearTimeout has not been defined');
  39893. }
  39894. (function () {
  39895. try {
  39896. if (typeof setTimeout === 'function') {
  39897. cachedSetTimeout = setTimeout;
  39898. } else {
  39899. cachedSetTimeout = defaultSetTimout;
  39900. }
  39901. } catch (e) {
  39902. cachedSetTimeout = defaultSetTimout;
  39903. }
  39904. try {
  39905. if (typeof clearTimeout === 'function') {
  39906. cachedClearTimeout = clearTimeout;
  39907. } else {
  39908. cachedClearTimeout = defaultClearTimeout;
  39909. }
  39910. } catch (e) {
  39911. cachedClearTimeout = defaultClearTimeout;
  39912. }
  39913. } ())
  39914. function runTimeout(fun) {
  39915. if (cachedSetTimeout === setTimeout) {
  39916. //normal enviroments in sane situations
  39917. return setTimeout(fun, 0);
  39918. }
  39919. // if setTimeout wasn't available but was latter defined
  39920. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  39921. cachedSetTimeout = setTimeout;
  39922. return setTimeout(fun, 0);
  39923. }
  39924. try {
  39925. // when when somebody has screwed with setTimeout but no I.E. maddness
  39926. return cachedSetTimeout(fun, 0);
  39927. } catch(e){
  39928. try {
  39929. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  39930. return cachedSetTimeout.call(null, fun, 0);
  39931. } catch(e){
  39932. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  39933. return cachedSetTimeout.call(this, fun, 0);
  39934. }
  39935. }
  39936. }
  39937. function runClearTimeout(marker) {
  39938. if (cachedClearTimeout === clearTimeout) {
  39939. //normal enviroments in sane situations
  39940. return clearTimeout(marker);
  39941. }
  39942. // if clearTimeout wasn't available but was latter defined
  39943. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  39944. cachedClearTimeout = clearTimeout;
  39945. return clearTimeout(marker);
  39946. }
  39947. try {
  39948. // when when somebody has screwed with setTimeout but no I.E. maddness
  39949. return cachedClearTimeout(marker);
  39950. } catch (e){
  39951. try {
  39952. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  39953. return cachedClearTimeout.call(null, marker);
  39954. } catch (e){
  39955. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  39956. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  39957. return cachedClearTimeout.call(this, marker);
  39958. }
  39959. }
  39960. }
  39961. var queue = [];
  39962. var draining = false;
  39963. var currentQueue;
  39964. var queueIndex = -1;
  39965. function cleanUpNextTick() {
  39966. if (!draining || !currentQueue) {
  39967. return;
  39968. }
  39969. draining = false;
  39970. if (currentQueue.length) {
  39971. queue = currentQueue.concat(queue);
  39972. } else {
  39973. queueIndex = -1;
  39974. }
  39975. if (queue.length) {
  39976. drainQueue();
  39977. }
  39978. }
  39979. function drainQueue() {
  39980. if (draining) {
  39981. return;
  39982. }
  39983. var timeout = runTimeout(cleanUpNextTick);
  39984. draining = true;
  39985. var len = queue.length;
  39986. while(len) {
  39987. currentQueue = queue;
  39988. queue = [];
  39989. while (++queueIndex < len) {
  39990. if (currentQueue) {
  39991. currentQueue[queueIndex].run();
  39992. }
  39993. }
  39994. queueIndex = -1;
  39995. len = queue.length;
  39996. }
  39997. currentQueue = null;
  39998. draining = false;
  39999. runClearTimeout(timeout);
  40000. }
  40001. process.nextTick = function (fun) {
  40002. var args = new Array(arguments.length - 1);
  40003. if (arguments.length > 1) {
  40004. for (var i = 1; i < arguments.length; i++) {
  40005. args[i - 1] = arguments[i];
  40006. }
  40007. }
  40008. queue.push(new Item(fun, args));
  40009. if (queue.length === 1 && !draining) {
  40010. runTimeout(drainQueue);
  40011. }
  40012. };
  40013. // v8 likes predictible objects
  40014. function Item(fun, array) {
  40015. this.fun = fun;
  40016. this.array = array;
  40017. }
  40018. Item.prototype.run = function () {
  40019. this.fun.apply(null, this.array);
  40020. };
  40021. process.title = 'browser';
  40022. process.browser = true;
  40023. process.env = {};
  40024. process.argv = [];
  40025. process.version = ''; // empty string to avoid regexp issues
  40026. process.versions = {};
  40027. function noop() {}
  40028. process.on = noop;
  40029. process.addListener = noop;
  40030. process.once = noop;
  40031. process.off = noop;
  40032. process.removeListener = noop;
  40033. process.removeAllListeners = noop;
  40034. process.emit = noop;
  40035. process.prependListener = noop;
  40036. process.prependOnceListener = noop;
  40037. process.listeners = function (name) { return [] }
  40038. process.binding = function (name) {
  40039. throw new Error('process.binding is not supported');
  40040. };
  40041. process.cwd = function () { return '/' };
  40042. process.chdir = function (dir) {
  40043. throw new Error('process.chdir is not supported');
  40044. };
  40045. process.umask = function() { return 0; };
  40046. /***/ }),
  40047. /***/ "./node_modules/setimmediate/setImmediate.js":
  40048. /*!***************************************************!*\
  40049. !*** ./node_modules/setimmediate/setImmediate.js ***!
  40050. \***************************************************/
  40051. /*! no static exports found */
  40052. /***/ (function(module, exports, __webpack_require__) {
  40053. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  40054. "use strict";
  40055. if (global.setImmediate) {
  40056. return;
  40057. }
  40058. var nextHandle = 1; // Spec says greater than zero
  40059. var tasksByHandle = {};
  40060. var currentlyRunningATask = false;
  40061. var doc = global.document;
  40062. var registerImmediate;
  40063. function setImmediate(callback) {
  40064. // Callback can either be a function or a string
  40065. if (typeof callback !== "function") {
  40066. callback = new Function("" + callback);
  40067. }
  40068. // Copy function arguments
  40069. var args = new Array(arguments.length - 1);
  40070. for (var i = 0; i < args.length; i++) {
  40071. args[i] = arguments[i + 1];
  40072. }
  40073. // Store and register the task
  40074. var task = { callback: callback, args: args };
  40075. tasksByHandle[nextHandle] = task;
  40076. registerImmediate(nextHandle);
  40077. return nextHandle++;
  40078. }
  40079. function clearImmediate(handle) {
  40080. delete tasksByHandle[handle];
  40081. }
  40082. function run(task) {
  40083. var callback = task.callback;
  40084. var args = task.args;
  40085. switch (args.length) {
  40086. case 0:
  40087. callback();
  40088. break;
  40089. case 1:
  40090. callback(args[0]);
  40091. break;
  40092. case 2:
  40093. callback(args[0], args[1]);
  40094. break;
  40095. case 3:
  40096. callback(args[0], args[1], args[2]);
  40097. break;
  40098. default:
  40099. callback.apply(undefined, args);
  40100. break;
  40101. }
  40102. }
  40103. function runIfPresent(handle) {
  40104. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  40105. // So if we're currently running a task, we'll need to delay this invocation.
  40106. if (currentlyRunningATask) {
  40107. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  40108. // "too much recursion" error.
  40109. setTimeout(runIfPresent, 0, handle);
  40110. } else {
  40111. var task = tasksByHandle[handle];
  40112. if (task) {
  40113. currentlyRunningATask = true;
  40114. try {
  40115. run(task);
  40116. } finally {
  40117. clearImmediate(handle);
  40118. currentlyRunningATask = false;
  40119. }
  40120. }
  40121. }
  40122. }
  40123. function installNextTickImplementation() {
  40124. registerImmediate = function(handle) {
  40125. process.nextTick(function () { runIfPresent(handle); });
  40126. };
  40127. }
  40128. function canUsePostMessage() {
  40129. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  40130. // where `global.postMessage` means something completely different and can't be used for this purpose.
  40131. if (global.postMessage && !global.importScripts) {
  40132. var postMessageIsAsynchronous = true;
  40133. var oldOnMessage = global.onmessage;
  40134. global.onmessage = function() {
  40135. postMessageIsAsynchronous = false;
  40136. };
  40137. global.postMessage("", "*");
  40138. global.onmessage = oldOnMessage;
  40139. return postMessageIsAsynchronous;
  40140. }
  40141. }
  40142. function installPostMessageImplementation() {
  40143. // Installs an event handler on `global` for the `message` event: see
  40144. // * https://developer.mozilla.org/en/DOM/window.postMessage
  40145. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  40146. var messagePrefix = "setImmediate$" + Math.random() + "$";
  40147. var onGlobalMessage = function(event) {
  40148. if (event.source === global &&
  40149. typeof event.data === "string" &&
  40150. event.data.indexOf(messagePrefix) === 0) {
  40151. runIfPresent(+event.data.slice(messagePrefix.length));
  40152. }
  40153. };
  40154. if (global.addEventListener) {
  40155. global.addEventListener("message", onGlobalMessage, false);
  40156. } else {
  40157. global.attachEvent("onmessage", onGlobalMessage);
  40158. }
  40159. registerImmediate = function(handle) {
  40160. global.postMessage(messagePrefix + handle, "*");
  40161. };
  40162. }
  40163. function installMessageChannelImplementation() {
  40164. var channel = new MessageChannel();
  40165. channel.port1.onmessage = function(event) {
  40166. var handle = event.data;
  40167. runIfPresent(handle);
  40168. };
  40169. registerImmediate = function(handle) {
  40170. channel.port2.postMessage(handle);
  40171. };
  40172. }
  40173. function installReadyStateChangeImplementation() {
  40174. var html = doc.documentElement;
  40175. registerImmediate = function(handle) {
  40176. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  40177. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  40178. var script = doc.createElement("script");
  40179. script.onreadystatechange = function () {
  40180. runIfPresent(handle);
  40181. script.onreadystatechange = null;
  40182. html.removeChild(script);
  40183. script = null;
  40184. };
  40185. html.appendChild(script);
  40186. };
  40187. }
  40188. function installSetTimeoutImplementation() {
  40189. registerImmediate = function(handle) {
  40190. setTimeout(runIfPresent, 0, handle);
  40191. };
  40192. }
  40193. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  40194. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  40195. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  40196. // Don't get fooled by e.g. browserify environments.
  40197. if ({}.toString.call(global.process) === "[object process]") {
  40198. // For Node.js before 0.9
  40199. installNextTickImplementation();
  40200. } else if (canUsePostMessage()) {
  40201. // For non-IE10 modern browsers
  40202. installPostMessageImplementation();
  40203. } else if (global.MessageChannel) {
  40204. // For web workers, where supported
  40205. installMessageChannelImplementation();
  40206. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  40207. // For IE 6–8
  40208. installReadyStateChangeImplementation();
  40209. } else {
  40210. // For older browsers
  40211. installSetTimeoutImplementation();
  40212. }
  40213. attachTo.setImmediate = setImmediate;
  40214. attachTo.clearImmediate = clearImmediate;
  40215. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  40216. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../process/browser.js */ "./node_modules/process/browser.js")))
  40217. /***/ }),
  40218. /***/ "./node_modules/socket.io-client/lib/index.js":
  40219. /*!****************************************************!*\
  40220. !*** ./node_modules/socket.io-client/lib/index.js ***!
  40221. \****************************************************/
  40222. /*! no static exports found */
  40223. /***/ (function(module, exports, __webpack_require__) {
  40224. /**
  40225. * Module dependencies.
  40226. */
  40227. var url = __webpack_require__(/*! ./url */ "./node_modules/socket.io-client/lib/url.js");
  40228. var parser = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/index.js");
  40229. var Manager = __webpack_require__(/*! ./manager */ "./node_modules/socket.io-client/lib/manager.js");
  40230. var debug = __webpack_require__(/*! debug */ "./node_modules/socket.io-client/node_modules/debug/src/browser.js")('socket.io-client');
  40231. /**
  40232. * Module exports.
  40233. */
  40234. module.exports = exports = lookup;
  40235. /**
  40236. * Managers cache.
  40237. */
  40238. var cache = exports.managers = {};
  40239. /**
  40240. * Looks up an existing `Manager` for multiplexing.
  40241. * If the user summons:
  40242. *
  40243. * `io('http://localhost/a');`
  40244. * `io('http://localhost/b');`
  40245. *
  40246. * We reuse the existing instance based on same scheme/port/host,
  40247. * and we initialize sockets for each namespace.
  40248. *
  40249. * @api public
  40250. */
  40251. function lookup (uri, opts) {
  40252. if (typeof uri === 'object') {
  40253. opts = uri;
  40254. uri = undefined;
  40255. }
  40256. opts = opts || {};
  40257. var parsed = url(uri);
  40258. var source = parsed.source;
  40259. var id = parsed.id;
  40260. var path = parsed.path;
  40261. var sameNamespace = cache[id] && path in cache[id].nsps;
  40262. var newConnection = opts.forceNew || opts['force new connection'] ||
  40263. false === opts.multiplex || sameNamespace;
  40264. var io;
  40265. if (newConnection) {
  40266. debug('ignoring socket cache for %s', source);
  40267. io = Manager(source, opts);
  40268. } else {
  40269. if (!cache[id]) {
  40270. debug('new io instance for %s', source);
  40271. cache[id] = Manager(source, opts);
  40272. }
  40273. io = cache[id];
  40274. }
  40275. if (parsed.query && !opts.query) {
  40276. opts.query = parsed.query;
  40277. }
  40278. return io.socket(parsed.path, opts);
  40279. }
  40280. /**
  40281. * Protocol version.
  40282. *
  40283. * @api public
  40284. */
  40285. exports.protocol = parser.protocol;
  40286. /**
  40287. * `connect`.
  40288. *
  40289. * @param {String} uri
  40290. * @api public
  40291. */
  40292. exports.connect = lookup;
  40293. /**
  40294. * Expose constructors for standalone build.
  40295. *
  40296. * @api public
  40297. */
  40298. exports.Manager = __webpack_require__(/*! ./manager */ "./node_modules/socket.io-client/lib/manager.js");
  40299. exports.Socket = __webpack_require__(/*! ./socket */ "./node_modules/socket.io-client/lib/socket.js");
  40300. /***/ }),
  40301. /***/ "./node_modules/socket.io-client/lib/manager.js":
  40302. /*!******************************************************!*\
  40303. !*** ./node_modules/socket.io-client/lib/manager.js ***!
  40304. \******************************************************/
  40305. /*! no static exports found */
  40306. /***/ (function(module, exports, __webpack_require__) {
  40307. /**
  40308. * Module dependencies.
  40309. */
  40310. var eio = __webpack_require__(/*! engine.io-client */ "./node_modules/engine.io-client/lib/index.js");
  40311. var Socket = __webpack_require__(/*! ./socket */ "./node_modules/socket.io-client/lib/socket.js");
  40312. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/socket.io-client/node_modules/component-emitter/index.js");
  40313. var parser = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/index.js");
  40314. var on = __webpack_require__(/*! ./on */ "./node_modules/socket.io-client/lib/on.js");
  40315. var bind = __webpack_require__(/*! component-bind */ "./node_modules/component-bind/index.js");
  40316. var debug = __webpack_require__(/*! debug */ "./node_modules/socket.io-client/node_modules/debug/src/browser.js")('socket.io-client:manager');
  40317. var indexOf = __webpack_require__(/*! indexof */ "./node_modules/indexof/index.js");
  40318. var Backoff = __webpack_require__(/*! backo2 */ "./node_modules/backo2/index.js");
  40319. /**
  40320. * IE6+ hasOwnProperty
  40321. */
  40322. var has = Object.prototype.hasOwnProperty;
  40323. /**
  40324. * Module exports
  40325. */
  40326. module.exports = Manager;
  40327. /**
  40328. * `Manager` constructor.
  40329. *
  40330. * @param {String} engine instance or engine uri/opts
  40331. * @param {Object} options
  40332. * @api public
  40333. */
  40334. function Manager (uri, opts) {
  40335. if (!(this instanceof Manager)) return new Manager(uri, opts);
  40336. if (uri && ('object' === typeof uri)) {
  40337. opts = uri;
  40338. uri = undefined;
  40339. }
  40340. opts = opts || {};
  40341. opts.path = opts.path || '/socket.io';
  40342. this.nsps = {};
  40343. this.subs = [];
  40344. this.opts = opts;
  40345. this.reconnection(opts.reconnection !== false);
  40346. this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
  40347. this.reconnectionDelay(opts.reconnectionDelay || 1000);
  40348. this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
  40349. this.randomizationFactor(opts.randomizationFactor || 0.5);
  40350. this.backoff = new Backoff({
  40351. min: this.reconnectionDelay(),
  40352. max: this.reconnectionDelayMax(),
  40353. jitter: this.randomizationFactor()
  40354. });
  40355. this.timeout(null == opts.timeout ? 20000 : opts.timeout);
  40356. this.readyState = 'closed';
  40357. this.uri = uri;
  40358. this.connecting = [];
  40359. this.lastPing = null;
  40360. this.encoding = false;
  40361. this.packetBuffer = [];
  40362. var _parser = opts.parser || parser;
  40363. this.encoder = new _parser.Encoder();
  40364. this.decoder = new _parser.Decoder();
  40365. this.autoConnect = opts.autoConnect !== false;
  40366. if (this.autoConnect) this.open();
  40367. }
  40368. /**
  40369. * Propagate given event to sockets and emit on `this`
  40370. *
  40371. * @api private
  40372. */
  40373. Manager.prototype.emitAll = function () {
  40374. this.emit.apply(this, arguments);
  40375. for (var nsp in this.nsps) {
  40376. if (has.call(this.nsps, nsp)) {
  40377. this.nsps[nsp].emit.apply(this.nsps[nsp], arguments);
  40378. }
  40379. }
  40380. };
  40381. /**
  40382. * Update `socket.id` of all sockets
  40383. *
  40384. * @api private
  40385. */
  40386. Manager.prototype.updateSocketIds = function () {
  40387. for (var nsp in this.nsps) {
  40388. if (has.call(this.nsps, nsp)) {
  40389. this.nsps[nsp].id = this.generateId(nsp);
  40390. }
  40391. }
  40392. };
  40393. /**
  40394. * generate `socket.id` for the given `nsp`
  40395. *
  40396. * @param {String} nsp
  40397. * @return {String}
  40398. * @api private
  40399. */
  40400. Manager.prototype.generateId = function (nsp) {
  40401. return (nsp === '/' ? '' : (nsp + '#')) + this.engine.id;
  40402. };
  40403. /**
  40404. * Mix in `Emitter`.
  40405. */
  40406. Emitter(Manager.prototype);
  40407. /**
  40408. * Sets the `reconnection` config.
  40409. *
  40410. * @param {Boolean} true/false if it should automatically reconnect
  40411. * @return {Manager} self or value
  40412. * @api public
  40413. */
  40414. Manager.prototype.reconnection = function (v) {
  40415. if (!arguments.length) return this._reconnection;
  40416. this._reconnection = !!v;
  40417. return this;
  40418. };
  40419. /**
  40420. * Sets the reconnection attempts config.
  40421. *
  40422. * @param {Number} max reconnection attempts before giving up
  40423. * @return {Manager} self or value
  40424. * @api public
  40425. */
  40426. Manager.prototype.reconnectionAttempts = function (v) {
  40427. if (!arguments.length) return this._reconnectionAttempts;
  40428. this._reconnectionAttempts = v;
  40429. return this;
  40430. };
  40431. /**
  40432. * Sets the delay between reconnections.
  40433. *
  40434. * @param {Number} delay
  40435. * @return {Manager} self or value
  40436. * @api public
  40437. */
  40438. Manager.prototype.reconnectionDelay = function (v) {
  40439. if (!arguments.length) return this._reconnectionDelay;
  40440. this._reconnectionDelay = v;
  40441. this.backoff && this.backoff.setMin(v);
  40442. return this;
  40443. };
  40444. Manager.prototype.randomizationFactor = function (v) {
  40445. if (!arguments.length) return this._randomizationFactor;
  40446. this._randomizationFactor = v;
  40447. this.backoff && this.backoff.setJitter(v);
  40448. return this;
  40449. };
  40450. /**
  40451. * Sets the maximum delay between reconnections.
  40452. *
  40453. * @param {Number} delay
  40454. * @return {Manager} self or value
  40455. * @api public
  40456. */
  40457. Manager.prototype.reconnectionDelayMax = function (v) {
  40458. if (!arguments.length) return this._reconnectionDelayMax;
  40459. this._reconnectionDelayMax = v;
  40460. this.backoff && this.backoff.setMax(v);
  40461. return this;
  40462. };
  40463. /**
  40464. * Sets the connection timeout. `false` to disable
  40465. *
  40466. * @return {Manager} self or value
  40467. * @api public
  40468. */
  40469. Manager.prototype.timeout = function (v) {
  40470. if (!arguments.length) return this._timeout;
  40471. this._timeout = v;
  40472. return this;
  40473. };
  40474. /**
  40475. * Starts trying to reconnect if reconnection is enabled and we have not
  40476. * started reconnecting yet
  40477. *
  40478. * @api private
  40479. */
  40480. Manager.prototype.maybeReconnectOnOpen = function () {
  40481. // Only try to reconnect if it's the first time we're connecting
  40482. if (!this.reconnecting && this._reconnection && this.backoff.attempts === 0) {
  40483. // keeps reconnection from firing twice for the same reconnection loop
  40484. this.reconnect();
  40485. }
  40486. };
  40487. /**
  40488. * Sets the current transport `socket`.
  40489. *
  40490. * @param {Function} optional, callback
  40491. * @return {Manager} self
  40492. * @api public
  40493. */
  40494. Manager.prototype.open =
  40495. Manager.prototype.connect = function (fn, opts) {
  40496. debug('readyState %s', this.readyState);
  40497. if (~this.readyState.indexOf('open')) return this;
  40498. debug('opening %s', this.uri);
  40499. this.engine = eio(this.uri, this.opts);
  40500. var socket = this.engine;
  40501. var self = this;
  40502. this.readyState = 'opening';
  40503. this.skipReconnect = false;
  40504. // emit `open`
  40505. var openSub = on(socket, 'open', function () {
  40506. self.onopen();
  40507. fn && fn();
  40508. });
  40509. // emit `connect_error`
  40510. var errorSub = on(socket, 'error', function (data) {
  40511. debug('connect_error');
  40512. self.cleanup();
  40513. self.readyState = 'closed';
  40514. self.emitAll('connect_error', data);
  40515. if (fn) {
  40516. var err = new Error('Connection error');
  40517. err.data = data;
  40518. fn(err);
  40519. } else {
  40520. // Only do this if there is no fn to handle the error
  40521. self.maybeReconnectOnOpen();
  40522. }
  40523. });
  40524. // emit `connect_timeout`
  40525. if (false !== this._timeout) {
  40526. var timeout = this._timeout;
  40527. debug('connect attempt will timeout after %d', timeout);
  40528. // set timer
  40529. var timer = setTimeout(function () {
  40530. debug('connect attempt timed out after %d', timeout);
  40531. openSub.destroy();
  40532. socket.close();
  40533. socket.emit('error', 'timeout');
  40534. self.emitAll('connect_timeout', timeout);
  40535. }, timeout);
  40536. this.subs.push({
  40537. destroy: function () {
  40538. clearTimeout(timer);
  40539. }
  40540. });
  40541. }
  40542. this.subs.push(openSub);
  40543. this.subs.push(errorSub);
  40544. return this;
  40545. };
  40546. /**
  40547. * Called upon transport open.
  40548. *
  40549. * @api private
  40550. */
  40551. Manager.prototype.onopen = function () {
  40552. debug('open');
  40553. // clear old subs
  40554. this.cleanup();
  40555. // mark as open
  40556. this.readyState = 'open';
  40557. this.emit('open');
  40558. // add new subs
  40559. var socket = this.engine;
  40560. this.subs.push(on(socket, 'data', bind(this, 'ondata')));
  40561. this.subs.push(on(socket, 'ping', bind(this, 'onping')));
  40562. this.subs.push(on(socket, 'pong', bind(this, 'onpong')));
  40563. this.subs.push(on(socket, 'error', bind(this, 'onerror')));
  40564. this.subs.push(on(socket, 'close', bind(this, 'onclose')));
  40565. this.subs.push(on(this.decoder, 'decoded', bind(this, 'ondecoded')));
  40566. };
  40567. /**
  40568. * Called upon a ping.
  40569. *
  40570. * @api private
  40571. */
  40572. Manager.prototype.onping = function () {
  40573. this.lastPing = new Date();
  40574. this.emitAll('ping');
  40575. };
  40576. /**
  40577. * Called upon a packet.
  40578. *
  40579. * @api private
  40580. */
  40581. Manager.prototype.onpong = function () {
  40582. this.emitAll('pong', new Date() - this.lastPing);
  40583. };
  40584. /**
  40585. * Called with data.
  40586. *
  40587. * @api private
  40588. */
  40589. Manager.prototype.ondata = function (data) {
  40590. this.decoder.add(data);
  40591. };
  40592. /**
  40593. * Called when parser fully decodes a packet.
  40594. *
  40595. * @api private
  40596. */
  40597. Manager.prototype.ondecoded = function (packet) {
  40598. this.emit('packet', packet);
  40599. };
  40600. /**
  40601. * Called upon socket error.
  40602. *
  40603. * @api private
  40604. */
  40605. Manager.prototype.onerror = function (err) {
  40606. debug('error', err);
  40607. this.emitAll('error', err);
  40608. };
  40609. /**
  40610. * Creates a new socket for the given `nsp`.
  40611. *
  40612. * @return {Socket}
  40613. * @api public
  40614. */
  40615. Manager.prototype.socket = function (nsp, opts) {
  40616. var socket = this.nsps[nsp];
  40617. if (!socket) {
  40618. socket = new Socket(this, nsp, opts);
  40619. this.nsps[nsp] = socket;
  40620. var self = this;
  40621. socket.on('connecting', onConnecting);
  40622. socket.on('connect', function () {
  40623. socket.id = self.generateId(nsp);
  40624. });
  40625. if (this.autoConnect) {
  40626. // manually call here since connecting event is fired before listening
  40627. onConnecting();
  40628. }
  40629. }
  40630. function onConnecting () {
  40631. if (!~indexOf(self.connecting, socket)) {
  40632. self.connecting.push(socket);
  40633. }
  40634. }
  40635. return socket;
  40636. };
  40637. /**
  40638. * Called upon a socket close.
  40639. *
  40640. * @param {Socket} socket
  40641. */
  40642. Manager.prototype.destroy = function (socket) {
  40643. var index = indexOf(this.connecting, socket);
  40644. if (~index) this.connecting.splice(index, 1);
  40645. if (this.connecting.length) return;
  40646. this.close();
  40647. };
  40648. /**
  40649. * Writes a packet.
  40650. *
  40651. * @param {Object} packet
  40652. * @api private
  40653. */
  40654. Manager.prototype.packet = function (packet) {
  40655. debug('writing packet %j', packet);
  40656. var self = this;
  40657. if (packet.query && packet.type === 0) packet.nsp += '?' + packet.query;
  40658. if (!self.encoding) {
  40659. // encode, then write to engine with result
  40660. self.encoding = true;
  40661. this.encoder.encode(packet, function (encodedPackets) {
  40662. for (var i = 0; i < encodedPackets.length; i++) {
  40663. self.engine.write(encodedPackets[i], packet.options);
  40664. }
  40665. self.encoding = false;
  40666. self.processPacketQueue();
  40667. });
  40668. } else { // add packet to the queue
  40669. self.packetBuffer.push(packet);
  40670. }
  40671. };
  40672. /**
  40673. * If packet buffer is non-empty, begins encoding the
  40674. * next packet in line.
  40675. *
  40676. * @api private
  40677. */
  40678. Manager.prototype.processPacketQueue = function () {
  40679. if (this.packetBuffer.length > 0 && !this.encoding) {
  40680. var pack = this.packetBuffer.shift();
  40681. this.packet(pack);
  40682. }
  40683. };
  40684. /**
  40685. * Clean up transport subscriptions and packet buffer.
  40686. *
  40687. * @api private
  40688. */
  40689. Manager.prototype.cleanup = function () {
  40690. debug('cleanup');
  40691. var subsLength = this.subs.length;
  40692. for (var i = 0; i < subsLength; i++) {
  40693. var sub = this.subs.shift();
  40694. sub.destroy();
  40695. }
  40696. this.packetBuffer = [];
  40697. this.encoding = false;
  40698. this.lastPing = null;
  40699. this.decoder.destroy();
  40700. };
  40701. /**
  40702. * Close the current socket.
  40703. *
  40704. * @api private
  40705. */
  40706. Manager.prototype.close =
  40707. Manager.prototype.disconnect = function () {
  40708. debug('disconnect');
  40709. this.skipReconnect = true;
  40710. this.reconnecting = false;
  40711. if ('opening' === this.readyState) {
  40712. // `onclose` will not fire because
  40713. // an open event never happened
  40714. this.cleanup();
  40715. }
  40716. this.backoff.reset();
  40717. this.readyState = 'closed';
  40718. if (this.engine) this.engine.close();
  40719. };
  40720. /**
  40721. * Called upon engine close.
  40722. *
  40723. * @api private
  40724. */
  40725. Manager.prototype.onclose = function (reason) {
  40726. debug('onclose');
  40727. this.cleanup();
  40728. this.backoff.reset();
  40729. this.readyState = 'closed';
  40730. this.emit('close', reason);
  40731. if (this._reconnection && !this.skipReconnect) {
  40732. this.reconnect();
  40733. }
  40734. };
  40735. /**
  40736. * Attempt a reconnection.
  40737. *
  40738. * @api private
  40739. */
  40740. Manager.prototype.reconnect = function () {
  40741. if (this.reconnecting || this.skipReconnect) return this;
  40742. var self = this;
  40743. if (this.backoff.attempts >= this._reconnectionAttempts) {
  40744. debug('reconnect failed');
  40745. this.backoff.reset();
  40746. this.emitAll('reconnect_failed');
  40747. this.reconnecting = false;
  40748. } else {
  40749. var delay = this.backoff.duration();
  40750. debug('will wait %dms before reconnect attempt', delay);
  40751. this.reconnecting = true;
  40752. var timer = setTimeout(function () {
  40753. if (self.skipReconnect) return;
  40754. debug('attempting reconnect');
  40755. self.emitAll('reconnect_attempt', self.backoff.attempts);
  40756. self.emitAll('reconnecting', self.backoff.attempts);
  40757. // check again for the case socket closed in above events
  40758. if (self.skipReconnect) return;
  40759. self.open(function (err) {
  40760. if (err) {
  40761. debug('reconnect attempt error');
  40762. self.reconnecting = false;
  40763. self.reconnect();
  40764. self.emitAll('reconnect_error', err.data);
  40765. } else {
  40766. debug('reconnect success');
  40767. self.onreconnect();
  40768. }
  40769. });
  40770. }, delay);
  40771. this.subs.push({
  40772. destroy: function () {
  40773. clearTimeout(timer);
  40774. }
  40775. });
  40776. }
  40777. };
  40778. /**
  40779. * Called upon successful reconnect.
  40780. *
  40781. * @api private
  40782. */
  40783. Manager.prototype.onreconnect = function () {
  40784. var attempt = this.backoff.attempts;
  40785. this.reconnecting = false;
  40786. this.backoff.reset();
  40787. this.updateSocketIds();
  40788. this.emitAll('reconnect', attempt);
  40789. };
  40790. /***/ }),
  40791. /***/ "./node_modules/socket.io-client/lib/on.js":
  40792. /*!*************************************************!*\
  40793. !*** ./node_modules/socket.io-client/lib/on.js ***!
  40794. \*************************************************/
  40795. /*! no static exports found */
  40796. /***/ (function(module, exports) {
  40797. /**
  40798. * Module exports.
  40799. */
  40800. module.exports = on;
  40801. /**
  40802. * Helper for subscriptions.
  40803. *
  40804. * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`
  40805. * @param {String} event name
  40806. * @param {Function} callback
  40807. * @api public
  40808. */
  40809. function on (obj, ev, fn) {
  40810. obj.on(ev, fn);
  40811. return {
  40812. destroy: function () {
  40813. obj.removeListener(ev, fn);
  40814. }
  40815. };
  40816. }
  40817. /***/ }),
  40818. /***/ "./node_modules/socket.io-client/lib/socket.js":
  40819. /*!*****************************************************!*\
  40820. !*** ./node_modules/socket.io-client/lib/socket.js ***!
  40821. \*****************************************************/
  40822. /*! no static exports found */
  40823. /***/ (function(module, exports, __webpack_require__) {
  40824. /**
  40825. * Module dependencies.
  40826. */
  40827. var parser = __webpack_require__(/*! socket.io-parser */ "./node_modules/socket.io-parser/index.js");
  40828. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/socket.io-client/node_modules/component-emitter/index.js");
  40829. var toArray = __webpack_require__(/*! to-array */ "./node_modules/to-array/index.js");
  40830. var on = __webpack_require__(/*! ./on */ "./node_modules/socket.io-client/lib/on.js");
  40831. var bind = __webpack_require__(/*! component-bind */ "./node_modules/component-bind/index.js");
  40832. var debug = __webpack_require__(/*! debug */ "./node_modules/socket.io-client/node_modules/debug/src/browser.js")('socket.io-client:socket');
  40833. var parseqs = __webpack_require__(/*! parseqs */ "./node_modules/parseqs/index.js");
  40834. var hasBin = __webpack_require__(/*! has-binary2 */ "./node_modules/has-binary2/index.js");
  40835. /**
  40836. * Module exports.
  40837. */
  40838. module.exports = exports = Socket;
  40839. /**
  40840. * Internal events (blacklisted).
  40841. * These events can't be emitted by the user.
  40842. *
  40843. * @api private
  40844. */
  40845. var events = {
  40846. connect: 1,
  40847. connect_error: 1,
  40848. connect_timeout: 1,
  40849. connecting: 1,
  40850. disconnect: 1,
  40851. error: 1,
  40852. reconnect: 1,
  40853. reconnect_attempt: 1,
  40854. reconnect_failed: 1,
  40855. reconnect_error: 1,
  40856. reconnecting: 1,
  40857. ping: 1,
  40858. pong: 1
  40859. };
  40860. /**
  40861. * Shortcut to `Emitter#emit`.
  40862. */
  40863. var emit = Emitter.prototype.emit;
  40864. /**
  40865. * `Socket` constructor.
  40866. *
  40867. * @api public
  40868. */
  40869. function Socket (io, nsp, opts) {
  40870. this.io = io;
  40871. this.nsp = nsp;
  40872. this.json = this; // compat
  40873. this.ids = 0;
  40874. this.acks = {};
  40875. this.receiveBuffer = [];
  40876. this.sendBuffer = [];
  40877. this.connected = false;
  40878. this.disconnected = true;
  40879. this.flags = {};
  40880. if (opts && opts.query) {
  40881. this.query = opts.query;
  40882. }
  40883. if (this.io.autoConnect) this.open();
  40884. }
  40885. /**
  40886. * Mix in `Emitter`.
  40887. */
  40888. Emitter(Socket.prototype);
  40889. /**
  40890. * Subscribe to open, close and packet events
  40891. *
  40892. * @api private
  40893. */
  40894. Socket.prototype.subEvents = function () {
  40895. if (this.subs) return;
  40896. var io = this.io;
  40897. this.subs = [
  40898. on(io, 'open', bind(this, 'onopen')),
  40899. on(io, 'packet', bind(this, 'onpacket')),
  40900. on(io, 'close', bind(this, 'onclose'))
  40901. ];
  40902. };
  40903. /**
  40904. * "Opens" the socket.
  40905. *
  40906. * @api public
  40907. */
  40908. Socket.prototype.open =
  40909. Socket.prototype.connect = function () {
  40910. if (this.connected) return this;
  40911. this.subEvents();
  40912. this.io.open(); // ensure open
  40913. if ('open' === this.io.readyState) this.onopen();
  40914. this.emit('connecting');
  40915. return this;
  40916. };
  40917. /**
  40918. * Sends a `message` event.
  40919. *
  40920. * @return {Socket} self
  40921. * @api public
  40922. */
  40923. Socket.prototype.send = function () {
  40924. var args = toArray(arguments);
  40925. args.unshift('message');
  40926. this.emit.apply(this, args);
  40927. return this;
  40928. };
  40929. /**
  40930. * Override `emit`.
  40931. * If the event is in `events`, it's emitted normally.
  40932. *
  40933. * @param {String} event name
  40934. * @return {Socket} self
  40935. * @api public
  40936. */
  40937. Socket.prototype.emit = function (ev) {
  40938. if (events.hasOwnProperty(ev)) {
  40939. emit.apply(this, arguments);
  40940. return this;
  40941. }
  40942. var args = toArray(arguments);
  40943. var packet = {
  40944. type: (this.flags.binary !== undefined ? this.flags.binary : hasBin(args)) ? parser.BINARY_EVENT : parser.EVENT,
  40945. data: args
  40946. };
  40947. packet.options = {};
  40948. packet.options.compress = !this.flags || false !== this.flags.compress;
  40949. // event ack callback
  40950. if ('function' === typeof args[args.length - 1]) {
  40951. debug('emitting packet with ack id %d', this.ids);
  40952. this.acks[this.ids] = args.pop();
  40953. packet.id = this.ids++;
  40954. }
  40955. if (this.connected) {
  40956. this.packet(packet);
  40957. } else {
  40958. this.sendBuffer.push(packet);
  40959. }
  40960. this.flags = {};
  40961. return this;
  40962. };
  40963. /**
  40964. * Sends a packet.
  40965. *
  40966. * @param {Object} packet
  40967. * @api private
  40968. */
  40969. Socket.prototype.packet = function (packet) {
  40970. packet.nsp = this.nsp;
  40971. this.io.packet(packet);
  40972. };
  40973. /**
  40974. * Called upon engine `open`.
  40975. *
  40976. * @api private
  40977. */
  40978. Socket.prototype.onopen = function () {
  40979. debug('transport is open - connecting');
  40980. // write connect packet if necessary
  40981. if ('/' !== this.nsp) {
  40982. if (this.query) {
  40983. var query = typeof this.query === 'object' ? parseqs.encode(this.query) : this.query;
  40984. debug('sending connect packet with query %s', query);
  40985. this.packet({type: parser.CONNECT, query: query});
  40986. } else {
  40987. this.packet({type: parser.CONNECT});
  40988. }
  40989. }
  40990. };
  40991. /**
  40992. * Called upon engine `close`.
  40993. *
  40994. * @param {String} reason
  40995. * @api private
  40996. */
  40997. Socket.prototype.onclose = function (reason) {
  40998. debug('close (%s)', reason);
  40999. this.connected = false;
  41000. this.disconnected = true;
  41001. delete this.id;
  41002. this.emit('disconnect', reason);
  41003. };
  41004. /**
  41005. * Called with socket packet.
  41006. *
  41007. * @param {Object} packet
  41008. * @api private
  41009. */
  41010. Socket.prototype.onpacket = function (packet) {
  41011. var sameNamespace = packet.nsp === this.nsp;
  41012. var rootNamespaceError = packet.type === parser.ERROR && packet.nsp === '/';
  41013. if (!sameNamespace && !rootNamespaceError) return;
  41014. switch (packet.type) {
  41015. case parser.CONNECT:
  41016. this.onconnect();
  41017. break;
  41018. case parser.EVENT:
  41019. this.onevent(packet);
  41020. break;
  41021. case parser.BINARY_EVENT:
  41022. this.onevent(packet);
  41023. break;
  41024. case parser.ACK:
  41025. this.onack(packet);
  41026. break;
  41027. case parser.BINARY_ACK:
  41028. this.onack(packet);
  41029. break;
  41030. case parser.DISCONNECT:
  41031. this.ondisconnect();
  41032. break;
  41033. case parser.ERROR:
  41034. this.emit('error', packet.data);
  41035. break;
  41036. }
  41037. };
  41038. /**
  41039. * Called upon a server event.
  41040. *
  41041. * @param {Object} packet
  41042. * @api private
  41043. */
  41044. Socket.prototype.onevent = function (packet) {
  41045. var args = packet.data || [];
  41046. debug('emitting event %j', args);
  41047. if (null != packet.id) {
  41048. debug('attaching ack callback to event');
  41049. args.push(this.ack(packet.id));
  41050. }
  41051. if (this.connected) {
  41052. emit.apply(this, args);
  41053. } else {
  41054. this.receiveBuffer.push(args);
  41055. }
  41056. };
  41057. /**
  41058. * Produces an ack callback to emit with an event.
  41059. *
  41060. * @api private
  41061. */
  41062. Socket.prototype.ack = function (id) {
  41063. var self = this;
  41064. var sent = false;
  41065. return function () {
  41066. // prevent double callbacks
  41067. if (sent) return;
  41068. sent = true;
  41069. var args = toArray(arguments);
  41070. debug('sending ack %j', args);
  41071. self.packet({
  41072. type: hasBin(args) ? parser.BINARY_ACK : parser.ACK,
  41073. id: id,
  41074. data: args
  41075. });
  41076. };
  41077. };
  41078. /**
  41079. * Called upon a server acknowlegement.
  41080. *
  41081. * @param {Object} packet
  41082. * @api private
  41083. */
  41084. Socket.prototype.onack = function (packet) {
  41085. var ack = this.acks[packet.id];
  41086. if ('function' === typeof ack) {
  41087. debug('calling ack %s with %j', packet.id, packet.data);
  41088. ack.apply(this, packet.data);
  41089. delete this.acks[packet.id];
  41090. } else {
  41091. debug('bad ack %s', packet.id);
  41092. }
  41093. };
  41094. /**
  41095. * Called upon server connect.
  41096. *
  41097. * @api private
  41098. */
  41099. Socket.prototype.onconnect = function () {
  41100. this.connected = true;
  41101. this.disconnected = false;
  41102. this.emit('connect');
  41103. this.emitBuffered();
  41104. };
  41105. /**
  41106. * Emit buffered events (received and emitted).
  41107. *
  41108. * @api private
  41109. */
  41110. Socket.prototype.emitBuffered = function () {
  41111. var i;
  41112. for (i = 0; i < this.receiveBuffer.length; i++) {
  41113. emit.apply(this, this.receiveBuffer[i]);
  41114. }
  41115. this.receiveBuffer = [];
  41116. for (i = 0; i < this.sendBuffer.length; i++) {
  41117. this.packet(this.sendBuffer[i]);
  41118. }
  41119. this.sendBuffer = [];
  41120. };
  41121. /**
  41122. * Called upon server disconnect.
  41123. *
  41124. * @api private
  41125. */
  41126. Socket.prototype.ondisconnect = function () {
  41127. debug('server disconnect (%s)', this.nsp);
  41128. this.destroy();
  41129. this.onclose('io server disconnect');
  41130. };
  41131. /**
  41132. * Called upon forced client/server side disconnections,
  41133. * this method ensures the manager stops tracking us and
  41134. * that reconnections don't get triggered for this.
  41135. *
  41136. * @api private.
  41137. */
  41138. Socket.prototype.destroy = function () {
  41139. if (this.subs) {
  41140. // clean subscriptions to avoid reconnections
  41141. for (var i = 0; i < this.subs.length; i++) {
  41142. this.subs[i].destroy();
  41143. }
  41144. this.subs = null;
  41145. }
  41146. this.io.destroy(this);
  41147. };
  41148. /**
  41149. * Disconnects the socket manually.
  41150. *
  41151. * @return {Socket} self
  41152. * @api public
  41153. */
  41154. Socket.prototype.close =
  41155. Socket.prototype.disconnect = function () {
  41156. if (this.connected) {
  41157. debug('performing disconnect (%s)', this.nsp);
  41158. this.packet({ type: parser.DISCONNECT });
  41159. }
  41160. // remove socket from pool
  41161. this.destroy();
  41162. if (this.connected) {
  41163. // fire events
  41164. this.onclose('io client disconnect');
  41165. }
  41166. return this;
  41167. };
  41168. /**
  41169. * Sets the compress flag.
  41170. *
  41171. * @param {Boolean} if `true`, compresses the sending data
  41172. * @return {Socket} self
  41173. * @api public
  41174. */
  41175. Socket.prototype.compress = function (compress) {
  41176. this.flags.compress = compress;
  41177. return this;
  41178. };
  41179. /**
  41180. * Sets the binary flag
  41181. *
  41182. * @param {Boolean} whether the emitted data contains binary
  41183. * @return {Socket} self
  41184. * @api public
  41185. */
  41186. Socket.prototype.binary = function (binary) {
  41187. this.flags.binary = binary;
  41188. return this;
  41189. };
  41190. /***/ }),
  41191. /***/ "./node_modules/socket.io-client/lib/url.js":
  41192. /*!**************************************************!*\
  41193. !*** ./node_modules/socket.io-client/lib/url.js ***!
  41194. \**************************************************/
  41195. /*! no static exports found */
  41196. /***/ (function(module, exports, __webpack_require__) {
  41197. /**
  41198. * Module dependencies.
  41199. */
  41200. var parseuri = __webpack_require__(/*! parseuri */ "./node_modules/parseuri/index.js");
  41201. var debug = __webpack_require__(/*! debug */ "./node_modules/socket.io-client/node_modules/debug/src/browser.js")('socket.io-client:url');
  41202. /**
  41203. * Module exports.
  41204. */
  41205. module.exports = url;
  41206. /**
  41207. * URL parser.
  41208. *
  41209. * @param {String} url
  41210. * @param {Object} An object meant to mimic window.location.
  41211. * Defaults to window.location.
  41212. * @api public
  41213. */
  41214. function url (uri, loc) {
  41215. var obj = uri;
  41216. // default to window.location
  41217. loc = loc || (typeof location !== 'undefined' && location);
  41218. if (null == uri) uri = loc.protocol + '//' + loc.host;
  41219. // relative path support
  41220. if ('string' === typeof uri) {
  41221. if ('/' === uri.charAt(0)) {
  41222. if ('/' === uri.charAt(1)) {
  41223. uri = loc.protocol + uri;
  41224. } else {
  41225. uri = loc.host + uri;
  41226. }
  41227. }
  41228. if (!/^(https?|wss?):\/\//.test(uri)) {
  41229. debug('protocol-less url %s', uri);
  41230. if ('undefined' !== typeof loc) {
  41231. uri = loc.protocol + '//' + uri;
  41232. } else {
  41233. uri = 'https://' + uri;
  41234. }
  41235. }
  41236. // parse
  41237. debug('parse %s', uri);
  41238. obj = parseuri(uri);
  41239. }
  41240. // make sure we treat `localhost:80` and `localhost` equally
  41241. if (!obj.port) {
  41242. if (/^(http|ws)$/.test(obj.protocol)) {
  41243. obj.port = '80';
  41244. } else if (/^(http|ws)s$/.test(obj.protocol)) {
  41245. obj.port = '443';
  41246. }
  41247. }
  41248. obj.path = obj.path || '/';
  41249. var ipv6 = obj.host.indexOf(':') !== -1;
  41250. var host = ipv6 ? '[' + obj.host + ']' : obj.host;
  41251. // define unique id
  41252. obj.id = obj.protocol + '://' + host + ':' + obj.port;
  41253. // define href
  41254. obj.href = obj.protocol + '://' + host + (loc && loc.port === obj.port ? '' : (':' + obj.port));
  41255. return obj;
  41256. }
  41257. /***/ }),
  41258. /***/ "./node_modules/socket.io-client/node_modules/component-emitter/index.js":
  41259. /*!*******************************************************************************!*\
  41260. !*** ./node_modules/socket.io-client/node_modules/component-emitter/index.js ***!
  41261. \*******************************************************************************/
  41262. /*! no static exports found */
  41263. /***/ (function(module, exports, __webpack_require__) {
  41264. /**
  41265. * Expose `Emitter`.
  41266. */
  41267. if (true) {
  41268. module.exports = Emitter;
  41269. }
  41270. /**
  41271. * Initialize a new `Emitter`.
  41272. *
  41273. * @api public
  41274. */
  41275. function Emitter(obj) {
  41276. if (obj) return mixin(obj);
  41277. };
  41278. /**
  41279. * Mixin the emitter properties.
  41280. *
  41281. * @param {Object} obj
  41282. * @return {Object}
  41283. * @api private
  41284. */
  41285. function mixin(obj) {
  41286. for (var key in Emitter.prototype) {
  41287. obj[key] = Emitter.prototype[key];
  41288. }
  41289. return obj;
  41290. }
  41291. /**
  41292. * Listen on the given `event` with `fn`.
  41293. *
  41294. * @param {String} event
  41295. * @param {Function} fn
  41296. * @return {Emitter}
  41297. * @api public
  41298. */
  41299. Emitter.prototype.on =
  41300. Emitter.prototype.addEventListener = function(event, fn){
  41301. this._callbacks = this._callbacks || {};
  41302. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  41303. .push(fn);
  41304. return this;
  41305. };
  41306. /**
  41307. * Adds an `event` listener that will be invoked a single
  41308. * time then automatically removed.
  41309. *
  41310. * @param {String} event
  41311. * @param {Function} fn
  41312. * @return {Emitter}
  41313. * @api public
  41314. */
  41315. Emitter.prototype.once = function(event, fn){
  41316. function on() {
  41317. this.off(event, on);
  41318. fn.apply(this, arguments);
  41319. }
  41320. on.fn = fn;
  41321. this.on(event, on);
  41322. return this;
  41323. };
  41324. /**
  41325. * Remove the given callback for `event` or all
  41326. * registered callbacks.
  41327. *
  41328. * @param {String} event
  41329. * @param {Function} fn
  41330. * @return {Emitter}
  41331. * @api public
  41332. */
  41333. Emitter.prototype.off =
  41334. Emitter.prototype.removeListener =
  41335. Emitter.prototype.removeAllListeners =
  41336. Emitter.prototype.removeEventListener = function(event, fn){
  41337. this._callbacks = this._callbacks || {};
  41338. // all
  41339. if (0 == arguments.length) {
  41340. this._callbacks = {};
  41341. return this;
  41342. }
  41343. // specific event
  41344. var callbacks = this._callbacks['$' + event];
  41345. if (!callbacks) return this;
  41346. // remove all handlers
  41347. if (1 == arguments.length) {
  41348. delete this._callbacks['$' + event];
  41349. return this;
  41350. }
  41351. // remove specific handler
  41352. var cb;
  41353. for (var i = 0; i < callbacks.length; i++) {
  41354. cb = callbacks[i];
  41355. if (cb === fn || cb.fn === fn) {
  41356. callbacks.splice(i, 1);
  41357. break;
  41358. }
  41359. }
  41360. return this;
  41361. };
  41362. /**
  41363. * Emit `event` with the given args.
  41364. *
  41365. * @param {String} event
  41366. * @param {Mixed} ...
  41367. * @return {Emitter}
  41368. */
  41369. Emitter.prototype.emit = function(event){
  41370. this._callbacks = this._callbacks || {};
  41371. var args = [].slice.call(arguments, 1)
  41372. , callbacks = this._callbacks['$' + event];
  41373. if (callbacks) {
  41374. callbacks = callbacks.slice(0);
  41375. for (var i = 0, len = callbacks.length; i < len; ++i) {
  41376. callbacks[i].apply(this, args);
  41377. }
  41378. }
  41379. return this;
  41380. };
  41381. /**
  41382. * Return array of callbacks for `event`.
  41383. *
  41384. * @param {String} event
  41385. * @return {Array}
  41386. * @api public
  41387. */
  41388. Emitter.prototype.listeners = function(event){
  41389. this._callbacks = this._callbacks || {};
  41390. return this._callbacks['$' + event] || [];
  41391. };
  41392. /**
  41393. * Check if this emitter has `event` handlers.
  41394. *
  41395. * @param {String} event
  41396. * @return {Boolean}
  41397. * @api public
  41398. */
  41399. Emitter.prototype.hasListeners = function(event){
  41400. return !! this.listeners(event).length;
  41401. };
  41402. /***/ }),
  41403. /***/ "./node_modules/socket.io-client/node_modules/debug/src/browser.js":
  41404. /*!*************************************************************************!*\
  41405. !*** ./node_modules/socket.io-client/node_modules/debug/src/browser.js ***!
  41406. \*************************************************************************/
  41407. /*! no static exports found */
  41408. /***/ (function(module, exports, __webpack_require__) {
  41409. /* WEBPACK VAR INJECTION */(function(process) {/* eslint-env browser */
  41410. /**
  41411. * This is the web browser implementation of `debug()`.
  41412. */
  41413. exports.log = log;
  41414. exports.formatArgs = formatArgs;
  41415. exports.save = save;
  41416. exports.load = load;
  41417. exports.useColors = useColors;
  41418. exports.storage = localstorage();
  41419. /**
  41420. * Colors.
  41421. */
  41422. exports.colors = [
  41423. '#0000CC',
  41424. '#0000FF',
  41425. '#0033CC',
  41426. '#0033FF',
  41427. '#0066CC',
  41428. '#0066FF',
  41429. '#0099CC',
  41430. '#0099FF',
  41431. '#00CC00',
  41432. '#00CC33',
  41433. '#00CC66',
  41434. '#00CC99',
  41435. '#00CCCC',
  41436. '#00CCFF',
  41437. '#3300CC',
  41438. '#3300FF',
  41439. '#3333CC',
  41440. '#3333FF',
  41441. '#3366CC',
  41442. '#3366FF',
  41443. '#3399CC',
  41444. '#3399FF',
  41445. '#33CC00',
  41446. '#33CC33',
  41447. '#33CC66',
  41448. '#33CC99',
  41449. '#33CCCC',
  41450. '#33CCFF',
  41451. '#6600CC',
  41452. '#6600FF',
  41453. '#6633CC',
  41454. '#6633FF',
  41455. '#66CC00',
  41456. '#66CC33',
  41457. '#9900CC',
  41458. '#9900FF',
  41459. '#9933CC',
  41460. '#9933FF',
  41461. '#99CC00',
  41462. '#99CC33',
  41463. '#CC0000',
  41464. '#CC0033',
  41465. '#CC0066',
  41466. '#CC0099',
  41467. '#CC00CC',
  41468. '#CC00FF',
  41469. '#CC3300',
  41470. '#CC3333',
  41471. '#CC3366',
  41472. '#CC3399',
  41473. '#CC33CC',
  41474. '#CC33FF',
  41475. '#CC6600',
  41476. '#CC6633',
  41477. '#CC9900',
  41478. '#CC9933',
  41479. '#CCCC00',
  41480. '#CCCC33',
  41481. '#FF0000',
  41482. '#FF0033',
  41483. '#FF0066',
  41484. '#FF0099',
  41485. '#FF00CC',
  41486. '#FF00FF',
  41487. '#FF3300',
  41488. '#FF3333',
  41489. '#FF3366',
  41490. '#FF3399',
  41491. '#FF33CC',
  41492. '#FF33FF',
  41493. '#FF6600',
  41494. '#FF6633',
  41495. '#FF9900',
  41496. '#FF9933',
  41497. '#FFCC00',
  41498. '#FFCC33'
  41499. ];
  41500. /**
  41501. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  41502. * and the Firebug extension (any Firefox version) are known
  41503. * to support "%c" CSS customizations.
  41504. *
  41505. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  41506. */
  41507. // eslint-disable-next-line complexity
  41508. function useColors() {
  41509. // NB: In an Electron preload script, document will be defined but not fully
  41510. // initialized. Since we know we're in Chrome, we'll just detect this case
  41511. // explicitly
  41512. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  41513. return true;
  41514. }
  41515. // Internet Explorer and Edge do not support colors.
  41516. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  41517. return false;
  41518. }
  41519. // Is webkit? http://stackoverflow.com/a/16459606/376773
  41520. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  41521. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  41522. // Is firebug? http://stackoverflow.com/a/398120/376773
  41523. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  41524. // Is firefox >= v31?
  41525. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  41526. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  41527. // Double check webkit in userAgent just in case we are in a worker
  41528. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  41529. }
  41530. /**
  41531. * Colorize log arguments if enabled.
  41532. *
  41533. * @api public
  41534. */
  41535. function formatArgs(args) {
  41536. args[0] = (this.useColors ? '%c' : '') +
  41537. this.namespace +
  41538. (this.useColors ? ' %c' : ' ') +
  41539. args[0] +
  41540. (this.useColors ? '%c ' : ' ') +
  41541. '+' + module.exports.humanize(this.diff);
  41542. if (!this.useColors) {
  41543. return;
  41544. }
  41545. const c = 'color: ' + this.color;
  41546. args.splice(1, 0, c, 'color: inherit');
  41547. // The final "%c" is somewhat tricky, because there could be other
  41548. // arguments passed either before or after the %c, so we need to
  41549. // figure out the correct index to insert the CSS into
  41550. let index = 0;
  41551. let lastC = 0;
  41552. args[0].replace(/%[a-zA-Z%]/g, match => {
  41553. if (match === '%%') {
  41554. return;
  41555. }
  41556. index++;
  41557. if (match === '%c') {
  41558. // We only are interested in the *last* %c
  41559. // (the user may have provided their own)
  41560. lastC = index;
  41561. }
  41562. });
  41563. args.splice(lastC, 0, c);
  41564. }
  41565. /**
  41566. * Invokes `console.log()` when available.
  41567. * No-op when `console.log` is not a "function".
  41568. *
  41569. * @api public
  41570. */
  41571. function log(...args) {
  41572. // This hackery is required for IE8/9, where
  41573. // the `console.log` function doesn't have 'apply'
  41574. return typeof console === 'object' &&
  41575. console.log &&
  41576. console.log(...args);
  41577. }
  41578. /**
  41579. * Save `namespaces`.
  41580. *
  41581. * @param {String} namespaces
  41582. * @api private
  41583. */
  41584. function save(namespaces) {
  41585. try {
  41586. if (namespaces) {
  41587. exports.storage.setItem('debug', namespaces);
  41588. } else {
  41589. exports.storage.removeItem('debug');
  41590. }
  41591. } catch (error) {
  41592. // Swallow
  41593. // XXX (@Qix-) should we be logging these?
  41594. }
  41595. }
  41596. /**
  41597. * Load `namespaces`.
  41598. *
  41599. * @return {String} returns the previously persisted debug modes
  41600. * @api private
  41601. */
  41602. function load() {
  41603. let r;
  41604. try {
  41605. r = exports.storage.getItem('debug');
  41606. } catch (error) {
  41607. // Swallow
  41608. // XXX (@Qix-) should we be logging these?
  41609. }
  41610. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  41611. if (!r && typeof process !== 'undefined' && 'env' in process) {
  41612. r = process.env.DEBUG;
  41613. }
  41614. return r;
  41615. }
  41616. /**
  41617. * Localstorage attempts to return the localstorage.
  41618. *
  41619. * This is necessary because safari throws
  41620. * when a user disables cookies/localstorage
  41621. * and you attempt to access it.
  41622. *
  41623. * @return {LocalStorage}
  41624. * @api private
  41625. */
  41626. function localstorage() {
  41627. try {
  41628. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  41629. // The Browser also has localStorage in the global context.
  41630. return localStorage;
  41631. } catch (error) {
  41632. // Swallow
  41633. // XXX (@Qix-) should we be logging these?
  41634. }
  41635. }
  41636. module.exports = __webpack_require__(/*! ./common */ "./node_modules/socket.io-client/node_modules/debug/src/common.js")(exports);
  41637. const {formatters} = module.exports;
  41638. /**
  41639. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  41640. */
  41641. formatters.j = function (v) {
  41642. try {
  41643. return JSON.stringify(v);
  41644. } catch (error) {
  41645. return '[UnexpectedJSONParseError]: ' + error.message;
  41646. }
  41647. };
  41648. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../process/browser.js */ "./node_modules/process/browser.js")))
  41649. /***/ }),
  41650. /***/ "./node_modules/socket.io-client/node_modules/debug/src/common.js":
  41651. /*!************************************************************************!*\
  41652. !*** ./node_modules/socket.io-client/node_modules/debug/src/common.js ***!
  41653. \************************************************************************/
  41654. /*! no static exports found */
  41655. /***/ (function(module, exports, __webpack_require__) {
  41656. /**
  41657. * This is the common logic for both the Node.js and web browser
  41658. * implementations of `debug()`.
  41659. */
  41660. function setup(env) {
  41661. createDebug.debug = createDebug;
  41662. createDebug.default = createDebug;
  41663. createDebug.coerce = coerce;
  41664. createDebug.disable = disable;
  41665. createDebug.enable = enable;
  41666. createDebug.enabled = enabled;
  41667. createDebug.humanize = __webpack_require__(/*! ms */ "./node_modules/socket.io-client/node_modules/ms/index.js");
  41668. Object.keys(env).forEach(key => {
  41669. createDebug[key] = env[key];
  41670. });
  41671. /**
  41672. * Active `debug` instances.
  41673. */
  41674. createDebug.instances = [];
  41675. /**
  41676. * The currently active debug mode names, and names to skip.
  41677. */
  41678. createDebug.names = [];
  41679. createDebug.skips = [];
  41680. /**
  41681. * Map of special "%n" handling functions, for the debug "format" argument.
  41682. *
  41683. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  41684. */
  41685. createDebug.formatters = {};
  41686. /**
  41687. * Selects a color for a debug namespace
  41688. * @param {String} namespace The namespace string for the for the debug instance to be colored
  41689. * @return {Number|String} An ANSI color code for the given namespace
  41690. * @api private
  41691. */
  41692. function selectColor(namespace) {
  41693. let hash = 0;
  41694. for (let i = 0; i < namespace.length; i++) {
  41695. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  41696. hash |= 0; // Convert to 32bit integer
  41697. }
  41698. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  41699. }
  41700. createDebug.selectColor = selectColor;
  41701. /**
  41702. * Create a debugger with the given `namespace`.
  41703. *
  41704. * @param {String} namespace
  41705. * @return {Function}
  41706. * @api public
  41707. */
  41708. function createDebug(namespace) {
  41709. let prevTime;
  41710. function debug(...args) {
  41711. // Disabled?
  41712. if (!debug.enabled) {
  41713. return;
  41714. }
  41715. const self = debug;
  41716. // Set `diff` timestamp
  41717. const curr = Number(new Date());
  41718. const ms = curr - (prevTime || curr);
  41719. self.diff = ms;
  41720. self.prev = prevTime;
  41721. self.curr = curr;
  41722. prevTime = curr;
  41723. args[0] = createDebug.coerce(args[0]);
  41724. if (typeof args[0] !== 'string') {
  41725. // Anything else let's inspect with %O
  41726. args.unshift('%O');
  41727. }
  41728. // Apply any `formatters` transformations
  41729. let index = 0;
  41730. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  41731. // If we encounter an escaped % then don't increase the array index
  41732. if (match === '%%') {
  41733. return match;
  41734. }
  41735. index++;
  41736. const formatter = createDebug.formatters[format];
  41737. if (typeof formatter === 'function') {
  41738. const val = args[index];
  41739. match = formatter.call(self, val);
  41740. // Now we need to remove `args[index]` since it's inlined in the `format`
  41741. args.splice(index, 1);
  41742. index--;
  41743. }
  41744. return match;
  41745. });
  41746. // Apply env-specific formatting (colors, etc.)
  41747. createDebug.formatArgs.call(self, args);
  41748. const logFn = self.log || createDebug.log;
  41749. logFn.apply(self, args);
  41750. }
  41751. debug.namespace = namespace;
  41752. debug.enabled = createDebug.enabled(namespace);
  41753. debug.useColors = createDebug.useColors();
  41754. debug.color = selectColor(namespace);
  41755. debug.destroy = destroy;
  41756. debug.extend = extend;
  41757. // Debug.formatArgs = formatArgs;
  41758. // debug.rawLog = rawLog;
  41759. // env-specific initialization logic for debug instances
  41760. if (typeof createDebug.init === 'function') {
  41761. createDebug.init(debug);
  41762. }
  41763. createDebug.instances.push(debug);
  41764. return debug;
  41765. }
  41766. function destroy() {
  41767. const index = createDebug.instances.indexOf(this);
  41768. if (index !== -1) {
  41769. createDebug.instances.splice(index, 1);
  41770. return true;
  41771. }
  41772. return false;
  41773. }
  41774. function extend(namespace, delimiter) {
  41775. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  41776. newDebug.log = this.log;
  41777. return newDebug;
  41778. }
  41779. /**
  41780. * Enables a debug mode by namespaces. This can include modes
  41781. * separated by a colon and wildcards.
  41782. *
  41783. * @param {String} namespaces
  41784. * @api public
  41785. */
  41786. function enable(namespaces) {
  41787. createDebug.save(namespaces);
  41788. createDebug.names = [];
  41789. createDebug.skips = [];
  41790. let i;
  41791. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  41792. const len = split.length;
  41793. for (i = 0; i < len; i++) {
  41794. if (!split[i]) {
  41795. // ignore empty strings
  41796. continue;
  41797. }
  41798. namespaces = split[i].replace(/\*/g, '.*?');
  41799. if (namespaces[0] === '-') {
  41800. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  41801. } else {
  41802. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  41803. }
  41804. }
  41805. for (i = 0; i < createDebug.instances.length; i++) {
  41806. const instance = createDebug.instances[i];
  41807. instance.enabled = createDebug.enabled(instance.namespace);
  41808. }
  41809. }
  41810. /**
  41811. * Disable debug output.
  41812. *
  41813. * @return {String} namespaces
  41814. * @api public
  41815. */
  41816. function disable() {
  41817. const namespaces = [
  41818. ...createDebug.names.map(toNamespace),
  41819. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  41820. ].join(',');
  41821. createDebug.enable('');
  41822. return namespaces;
  41823. }
  41824. /**
  41825. * Returns true if the given mode name is enabled, false otherwise.
  41826. *
  41827. * @param {String} name
  41828. * @return {Boolean}
  41829. * @api public
  41830. */
  41831. function enabled(name) {
  41832. if (name[name.length - 1] === '*') {
  41833. return true;
  41834. }
  41835. let i;
  41836. let len;
  41837. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  41838. if (createDebug.skips[i].test(name)) {
  41839. return false;
  41840. }
  41841. }
  41842. for (i = 0, len = createDebug.names.length; i < len; i++) {
  41843. if (createDebug.names[i].test(name)) {
  41844. return true;
  41845. }
  41846. }
  41847. return false;
  41848. }
  41849. /**
  41850. * Convert regexp to namespace
  41851. *
  41852. * @param {RegExp} regxep
  41853. * @return {String} namespace
  41854. * @api private
  41855. */
  41856. function toNamespace(regexp) {
  41857. return regexp.toString()
  41858. .substring(2, regexp.toString().length - 2)
  41859. .replace(/\.\*\?$/, '*');
  41860. }
  41861. /**
  41862. * Coerce `val`.
  41863. *
  41864. * @param {Mixed} val
  41865. * @return {Mixed}
  41866. * @api private
  41867. */
  41868. function coerce(val) {
  41869. if (val instanceof Error) {
  41870. return val.stack || val.message;
  41871. }
  41872. return val;
  41873. }
  41874. createDebug.enable(createDebug.load());
  41875. return createDebug;
  41876. }
  41877. module.exports = setup;
  41878. /***/ }),
  41879. /***/ "./node_modules/socket.io-client/node_modules/ms/index.js":
  41880. /*!****************************************************************!*\
  41881. !*** ./node_modules/socket.io-client/node_modules/ms/index.js ***!
  41882. \****************************************************************/
  41883. /*! no static exports found */
  41884. /***/ (function(module, exports) {
  41885. /**
  41886. * Helpers.
  41887. */
  41888. var s = 1000;
  41889. var m = s * 60;
  41890. var h = m * 60;
  41891. var d = h * 24;
  41892. var w = d * 7;
  41893. var y = d * 365.25;
  41894. /**
  41895. * Parse or format the given `val`.
  41896. *
  41897. * Options:
  41898. *
  41899. * - `long` verbose formatting [false]
  41900. *
  41901. * @param {String|Number} val
  41902. * @param {Object} [options]
  41903. * @throws {Error} throw an error if val is not a non-empty string or a number
  41904. * @return {String|Number}
  41905. * @api public
  41906. */
  41907. module.exports = function(val, options) {
  41908. options = options || {};
  41909. var type = typeof val;
  41910. if (type === 'string' && val.length > 0) {
  41911. return parse(val);
  41912. } else if (type === 'number' && isFinite(val)) {
  41913. return options.long ? fmtLong(val) : fmtShort(val);
  41914. }
  41915. throw new Error(
  41916. 'val is not a non-empty string or a valid number. val=' +
  41917. JSON.stringify(val)
  41918. );
  41919. };
  41920. /**
  41921. * Parse the given `str` and return milliseconds.
  41922. *
  41923. * @param {String} str
  41924. * @return {Number}
  41925. * @api private
  41926. */
  41927. function parse(str) {
  41928. str = String(str);
  41929. if (str.length > 100) {
  41930. return;
  41931. }
  41932. var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  41933. str
  41934. );
  41935. if (!match) {
  41936. return;
  41937. }
  41938. var n = parseFloat(match[1]);
  41939. var type = (match[2] || 'ms').toLowerCase();
  41940. switch (type) {
  41941. case 'years':
  41942. case 'year':
  41943. case 'yrs':
  41944. case 'yr':
  41945. case 'y':
  41946. return n * y;
  41947. case 'weeks':
  41948. case 'week':
  41949. case 'w':
  41950. return n * w;
  41951. case 'days':
  41952. case 'day':
  41953. case 'd':
  41954. return n * d;
  41955. case 'hours':
  41956. case 'hour':
  41957. case 'hrs':
  41958. case 'hr':
  41959. case 'h':
  41960. return n * h;
  41961. case 'minutes':
  41962. case 'minute':
  41963. case 'mins':
  41964. case 'min':
  41965. case 'm':
  41966. return n * m;
  41967. case 'seconds':
  41968. case 'second':
  41969. case 'secs':
  41970. case 'sec':
  41971. case 's':
  41972. return n * s;
  41973. case 'milliseconds':
  41974. case 'millisecond':
  41975. case 'msecs':
  41976. case 'msec':
  41977. case 'ms':
  41978. return n;
  41979. default:
  41980. return undefined;
  41981. }
  41982. }
  41983. /**
  41984. * Short format for `ms`.
  41985. *
  41986. * @param {Number} ms
  41987. * @return {String}
  41988. * @api private
  41989. */
  41990. function fmtShort(ms) {
  41991. var msAbs = Math.abs(ms);
  41992. if (msAbs >= d) {
  41993. return Math.round(ms / d) + 'd';
  41994. }
  41995. if (msAbs >= h) {
  41996. return Math.round(ms / h) + 'h';
  41997. }
  41998. if (msAbs >= m) {
  41999. return Math.round(ms / m) + 'm';
  42000. }
  42001. if (msAbs >= s) {
  42002. return Math.round(ms / s) + 's';
  42003. }
  42004. return ms + 'ms';
  42005. }
  42006. /**
  42007. * Long format for `ms`.
  42008. *
  42009. * @param {Number} ms
  42010. * @return {String}
  42011. * @api private
  42012. */
  42013. function fmtLong(ms) {
  42014. var msAbs = Math.abs(ms);
  42015. if (msAbs >= d) {
  42016. return plural(ms, msAbs, d, 'day');
  42017. }
  42018. if (msAbs >= h) {
  42019. return plural(ms, msAbs, h, 'hour');
  42020. }
  42021. if (msAbs >= m) {
  42022. return plural(ms, msAbs, m, 'minute');
  42023. }
  42024. if (msAbs >= s) {
  42025. return plural(ms, msAbs, s, 'second');
  42026. }
  42027. return ms + ' ms';
  42028. }
  42029. /**
  42030. * Pluralization helper.
  42031. */
  42032. function plural(ms, msAbs, n, name) {
  42033. var isPlural = msAbs >= n * 1.5;
  42034. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  42035. }
  42036. /***/ }),
  42037. /***/ "./node_modules/socket.io-parser/binary.js":
  42038. /*!*************************************************!*\
  42039. !*** ./node_modules/socket.io-parser/binary.js ***!
  42040. \*************************************************/
  42041. /*! no static exports found */
  42042. /***/ (function(module, exports, __webpack_require__) {
  42043. /*global Blob,File*/
  42044. /**
  42045. * Module requirements
  42046. */
  42047. var isArray = __webpack_require__(/*! isarray */ "./node_modules/socket.io-parser/node_modules/isarray/index.js");
  42048. var isBuf = __webpack_require__(/*! ./is-buffer */ "./node_modules/socket.io-parser/is-buffer.js");
  42049. var toString = Object.prototype.toString;
  42050. var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]');
  42051. var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]');
  42052. /**
  42053. * Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
  42054. * Anything with blobs or files should be fed through removeBlobs before coming
  42055. * here.
  42056. *
  42057. * @param {Object} packet - socket.io event packet
  42058. * @return {Object} with deconstructed packet and list of buffers
  42059. * @api public
  42060. */
  42061. exports.deconstructPacket = function(packet) {
  42062. var buffers = [];
  42063. var packetData = packet.data;
  42064. var pack = packet;
  42065. pack.data = _deconstructPacket(packetData, buffers);
  42066. pack.attachments = buffers.length; // number of binary 'attachments'
  42067. return {packet: pack, buffers: buffers};
  42068. };
  42069. function _deconstructPacket(data, buffers) {
  42070. if (!data) return data;
  42071. if (isBuf(data)) {
  42072. var placeholder = { _placeholder: true, num: buffers.length };
  42073. buffers.push(data);
  42074. return placeholder;
  42075. } else if (isArray(data)) {
  42076. var newData = new Array(data.length);
  42077. for (var i = 0; i < data.length; i++) {
  42078. newData[i] = _deconstructPacket(data[i], buffers);
  42079. }
  42080. return newData;
  42081. } else if (typeof data === 'object' && !(data instanceof Date)) {
  42082. var newData = {};
  42083. for (var key in data) {
  42084. newData[key] = _deconstructPacket(data[key], buffers);
  42085. }
  42086. return newData;
  42087. }
  42088. return data;
  42089. }
  42090. /**
  42091. * Reconstructs a binary packet from its placeholder packet and buffers
  42092. *
  42093. * @param {Object} packet - event packet with placeholders
  42094. * @param {Array} buffers - binary buffers to put in placeholder positions
  42095. * @return {Object} reconstructed packet
  42096. * @api public
  42097. */
  42098. exports.reconstructPacket = function(packet, buffers) {
  42099. packet.data = _reconstructPacket(packet.data, buffers);
  42100. packet.attachments = undefined; // no longer useful
  42101. return packet;
  42102. };
  42103. function _reconstructPacket(data, buffers) {
  42104. if (!data) return data;
  42105. if (data && data._placeholder) {
  42106. return buffers[data.num]; // appropriate buffer (should be natural order anyway)
  42107. } else if (isArray(data)) {
  42108. for (var i = 0; i < data.length; i++) {
  42109. data[i] = _reconstructPacket(data[i], buffers);
  42110. }
  42111. } else if (typeof data === 'object') {
  42112. for (var key in data) {
  42113. data[key] = _reconstructPacket(data[key], buffers);
  42114. }
  42115. }
  42116. return data;
  42117. }
  42118. /**
  42119. * Asynchronously removes Blobs or Files from data via
  42120. * FileReader's readAsArrayBuffer method. Used before encoding
  42121. * data as msgpack. Calls callback with the blobless data.
  42122. *
  42123. * @param {Object} data
  42124. * @param {Function} callback
  42125. * @api private
  42126. */
  42127. exports.removeBlobs = function(data, callback) {
  42128. function _removeBlobs(obj, curKey, containingObject) {
  42129. if (!obj) return obj;
  42130. // convert any blob
  42131. if ((withNativeBlob && obj instanceof Blob) ||
  42132. (withNativeFile && obj instanceof File)) {
  42133. pendingBlobs++;
  42134. // async filereader
  42135. var fileReader = new FileReader();
  42136. fileReader.onload = function() { // this.result == arraybuffer
  42137. if (containingObject) {
  42138. containingObject[curKey] = this.result;
  42139. }
  42140. else {
  42141. bloblessData = this.result;
  42142. }
  42143. // if nothing pending its callback time
  42144. if(! --pendingBlobs) {
  42145. callback(bloblessData);
  42146. }
  42147. };
  42148. fileReader.readAsArrayBuffer(obj); // blob -> arraybuffer
  42149. } else if (isArray(obj)) { // handle array
  42150. for (var i = 0; i < obj.length; i++) {
  42151. _removeBlobs(obj[i], i, obj);
  42152. }
  42153. } else if (typeof obj === 'object' && !isBuf(obj)) { // and object
  42154. for (var key in obj) {
  42155. _removeBlobs(obj[key], key, obj);
  42156. }
  42157. }
  42158. }
  42159. var pendingBlobs = 0;
  42160. var bloblessData = data;
  42161. _removeBlobs(bloblessData);
  42162. if (!pendingBlobs) {
  42163. callback(bloblessData);
  42164. }
  42165. };
  42166. /***/ }),
  42167. /***/ "./node_modules/socket.io-parser/index.js":
  42168. /*!************************************************!*\
  42169. !*** ./node_modules/socket.io-parser/index.js ***!
  42170. \************************************************/
  42171. /*! no static exports found */
  42172. /***/ (function(module, exports, __webpack_require__) {
  42173. /**
  42174. * Module dependencies.
  42175. */
  42176. var debug = __webpack_require__(/*! debug */ "./node_modules/debug/src/browser.js")('socket.io-parser');
  42177. var Emitter = __webpack_require__(/*! component-emitter */ "./node_modules/socket.io-parser/node_modules/component-emitter/index.js");
  42178. var binary = __webpack_require__(/*! ./binary */ "./node_modules/socket.io-parser/binary.js");
  42179. var isArray = __webpack_require__(/*! isarray */ "./node_modules/socket.io-parser/node_modules/isarray/index.js");
  42180. var isBuf = __webpack_require__(/*! ./is-buffer */ "./node_modules/socket.io-parser/is-buffer.js");
  42181. /**
  42182. * Protocol version.
  42183. *
  42184. * @api public
  42185. */
  42186. exports.protocol = 4;
  42187. /**
  42188. * Packet types.
  42189. *
  42190. * @api public
  42191. */
  42192. exports.types = [
  42193. 'CONNECT',
  42194. 'DISCONNECT',
  42195. 'EVENT',
  42196. 'ACK',
  42197. 'ERROR',
  42198. 'BINARY_EVENT',
  42199. 'BINARY_ACK'
  42200. ];
  42201. /**
  42202. * Packet type `connect`.
  42203. *
  42204. * @api public
  42205. */
  42206. exports.CONNECT = 0;
  42207. /**
  42208. * Packet type `disconnect`.
  42209. *
  42210. * @api public
  42211. */
  42212. exports.DISCONNECT = 1;
  42213. /**
  42214. * Packet type `event`.
  42215. *
  42216. * @api public
  42217. */
  42218. exports.EVENT = 2;
  42219. /**
  42220. * Packet type `ack`.
  42221. *
  42222. * @api public
  42223. */
  42224. exports.ACK = 3;
  42225. /**
  42226. * Packet type `error`.
  42227. *
  42228. * @api public
  42229. */
  42230. exports.ERROR = 4;
  42231. /**
  42232. * Packet type 'binary event'
  42233. *
  42234. * @api public
  42235. */
  42236. exports.BINARY_EVENT = 5;
  42237. /**
  42238. * Packet type `binary ack`. For acks with binary arguments.
  42239. *
  42240. * @api public
  42241. */
  42242. exports.BINARY_ACK = 6;
  42243. /**
  42244. * Encoder constructor.
  42245. *
  42246. * @api public
  42247. */
  42248. exports.Encoder = Encoder;
  42249. /**
  42250. * Decoder constructor.
  42251. *
  42252. * @api public
  42253. */
  42254. exports.Decoder = Decoder;
  42255. /**
  42256. * A socket.io Encoder instance
  42257. *
  42258. * @api public
  42259. */
  42260. function Encoder() {}
  42261. var ERROR_PACKET = exports.ERROR + '"encode error"';
  42262. /**
  42263. * Encode a packet as a single string if non-binary, or as a
  42264. * buffer sequence, depending on packet type.
  42265. *
  42266. * @param {Object} obj - packet object
  42267. * @param {Function} callback - function to handle encodings (likely engine.write)
  42268. * @return Calls callback with Array of encodings
  42269. * @api public
  42270. */
  42271. Encoder.prototype.encode = function(obj, callback){
  42272. debug('encoding packet %j', obj);
  42273. if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
  42274. encodeAsBinary(obj, callback);
  42275. } else {
  42276. var encoding = encodeAsString(obj);
  42277. callback([encoding]);
  42278. }
  42279. };
  42280. /**
  42281. * Encode packet as string.
  42282. *
  42283. * @param {Object} packet
  42284. * @return {String} encoded
  42285. * @api private
  42286. */
  42287. function encodeAsString(obj) {
  42288. // first is type
  42289. var str = '' + obj.type;
  42290. // attachments if we have them
  42291. if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
  42292. str += obj.attachments + '-';
  42293. }
  42294. // if we have a namespace other than `/`
  42295. // we append it followed by a comma `,`
  42296. if (obj.nsp && '/' !== obj.nsp) {
  42297. str += obj.nsp + ',';
  42298. }
  42299. // immediately followed by the id
  42300. if (null != obj.id) {
  42301. str += obj.id;
  42302. }
  42303. // json data
  42304. if (null != obj.data) {
  42305. var payload = tryStringify(obj.data);
  42306. if (payload !== false) {
  42307. str += payload;
  42308. } else {
  42309. return ERROR_PACKET;
  42310. }
  42311. }
  42312. debug('encoded %j as %s', obj, str);
  42313. return str;
  42314. }
  42315. function tryStringify(str) {
  42316. try {
  42317. return JSON.stringify(str);
  42318. } catch(e){
  42319. return false;
  42320. }
  42321. }
  42322. /**
  42323. * Encode packet as 'buffer sequence' by removing blobs, and
  42324. * deconstructing packet into object with placeholders and
  42325. * a list of buffers.
  42326. *
  42327. * @param {Object} packet
  42328. * @return {Buffer} encoded
  42329. * @api private
  42330. */
  42331. function encodeAsBinary(obj, callback) {
  42332. function writeEncoding(bloblessData) {
  42333. var deconstruction = binary.deconstructPacket(bloblessData);
  42334. var pack = encodeAsString(deconstruction.packet);
  42335. var buffers = deconstruction.buffers;
  42336. buffers.unshift(pack); // add packet info to beginning of data list
  42337. callback(buffers); // write all the buffers
  42338. }
  42339. binary.removeBlobs(obj, writeEncoding);
  42340. }
  42341. /**
  42342. * A socket.io Decoder instance
  42343. *
  42344. * @return {Object} decoder
  42345. * @api public
  42346. */
  42347. function Decoder() {
  42348. this.reconstructor = null;
  42349. }
  42350. /**
  42351. * Mix in `Emitter` with Decoder.
  42352. */
  42353. Emitter(Decoder.prototype);
  42354. /**
  42355. * Decodes an encoded packet string into packet JSON.
  42356. *
  42357. * @param {String} obj - encoded packet
  42358. * @return {Object} packet
  42359. * @api public
  42360. */
  42361. Decoder.prototype.add = function(obj) {
  42362. var packet;
  42363. if (typeof obj === 'string') {
  42364. packet = decodeString(obj);
  42365. if (exports.BINARY_EVENT === packet.type || exports.BINARY_ACK === packet.type) { // binary packet's json
  42366. this.reconstructor = new BinaryReconstructor(packet);
  42367. // no attachments, labeled binary but no binary data to follow
  42368. if (this.reconstructor.reconPack.attachments === 0) {
  42369. this.emit('decoded', packet);
  42370. }
  42371. } else { // non-binary full packet
  42372. this.emit('decoded', packet);
  42373. }
  42374. } else if (isBuf(obj) || obj.base64) { // raw binary data
  42375. if (!this.reconstructor) {
  42376. throw new Error('got binary data when not reconstructing a packet');
  42377. } else {
  42378. packet = this.reconstructor.takeBinaryData(obj);
  42379. if (packet) { // received final buffer
  42380. this.reconstructor = null;
  42381. this.emit('decoded', packet);
  42382. }
  42383. }
  42384. } else {
  42385. throw new Error('Unknown type: ' + obj);
  42386. }
  42387. };
  42388. /**
  42389. * Decode a packet String (JSON data)
  42390. *
  42391. * @param {String} str
  42392. * @return {Object} packet
  42393. * @api private
  42394. */
  42395. function decodeString(str) {
  42396. var i = 0;
  42397. // look up type
  42398. var p = {
  42399. type: Number(str.charAt(0))
  42400. };
  42401. if (null == exports.types[p.type]) {
  42402. return error('unknown packet type ' + p.type);
  42403. }
  42404. // look up attachments if type binary
  42405. if (exports.BINARY_EVENT === p.type || exports.BINARY_ACK === p.type) {
  42406. var buf = '';
  42407. while (str.charAt(++i) !== '-') {
  42408. buf += str.charAt(i);
  42409. if (i == str.length) break;
  42410. }
  42411. if (buf != Number(buf) || str.charAt(i) !== '-') {
  42412. throw new Error('Illegal attachments');
  42413. }
  42414. p.attachments = Number(buf);
  42415. }
  42416. // look up namespace (if any)
  42417. if ('/' === str.charAt(i + 1)) {
  42418. p.nsp = '';
  42419. while (++i) {
  42420. var c = str.charAt(i);
  42421. if (',' === c) break;
  42422. p.nsp += c;
  42423. if (i === str.length) break;
  42424. }
  42425. } else {
  42426. p.nsp = '/';
  42427. }
  42428. // look up id
  42429. var next = str.charAt(i + 1);
  42430. if ('' !== next && Number(next) == next) {
  42431. p.id = '';
  42432. while (++i) {
  42433. var c = str.charAt(i);
  42434. if (null == c || Number(c) != c) {
  42435. --i;
  42436. break;
  42437. }
  42438. p.id += str.charAt(i);
  42439. if (i === str.length) break;
  42440. }
  42441. p.id = Number(p.id);
  42442. }
  42443. // look up json data
  42444. if (str.charAt(++i)) {
  42445. var payload = tryParse(str.substr(i));
  42446. var isPayloadValid = payload !== false && (p.type === exports.ERROR || isArray(payload));
  42447. if (isPayloadValid) {
  42448. p.data = payload;
  42449. } else {
  42450. return error('invalid payload');
  42451. }
  42452. }
  42453. debug('decoded %s as %j', str, p);
  42454. return p;
  42455. }
  42456. function tryParse(str) {
  42457. try {
  42458. return JSON.parse(str);
  42459. } catch(e){
  42460. return false;
  42461. }
  42462. }
  42463. /**
  42464. * Deallocates a parser's resources
  42465. *
  42466. * @api public
  42467. */
  42468. Decoder.prototype.destroy = function() {
  42469. if (this.reconstructor) {
  42470. this.reconstructor.finishedReconstruction();
  42471. }
  42472. };
  42473. /**
  42474. * A manager of a binary event's 'buffer sequence'. Should
  42475. * be constructed whenever a packet of type BINARY_EVENT is
  42476. * decoded.
  42477. *
  42478. * @param {Object} packet
  42479. * @return {BinaryReconstructor} initialized reconstructor
  42480. * @api private
  42481. */
  42482. function BinaryReconstructor(packet) {
  42483. this.reconPack = packet;
  42484. this.buffers = [];
  42485. }
  42486. /**
  42487. * Method to be called when binary data received from connection
  42488. * after a BINARY_EVENT packet.
  42489. *
  42490. * @param {Buffer | ArrayBuffer} binData - the raw binary data received
  42491. * @return {null | Object} returns null if more binary data is expected or
  42492. * a reconstructed packet object if all buffers have been received.
  42493. * @api private
  42494. */
  42495. BinaryReconstructor.prototype.takeBinaryData = function(binData) {
  42496. this.buffers.push(binData);
  42497. if (this.buffers.length === this.reconPack.attachments) { // done with buffer list
  42498. var packet = binary.reconstructPacket(this.reconPack, this.buffers);
  42499. this.finishedReconstruction();
  42500. return packet;
  42501. }
  42502. return null;
  42503. };
  42504. /**
  42505. * Cleans up binary packet reconstruction variables.
  42506. *
  42507. * @api private
  42508. */
  42509. BinaryReconstructor.prototype.finishedReconstruction = function() {
  42510. this.reconPack = null;
  42511. this.buffers = [];
  42512. };
  42513. function error(msg) {
  42514. return {
  42515. type: exports.ERROR,
  42516. data: 'parser error: ' + msg
  42517. };
  42518. }
  42519. /***/ }),
  42520. /***/ "./node_modules/socket.io-parser/is-buffer.js":
  42521. /*!****************************************************!*\
  42522. !*** ./node_modules/socket.io-parser/is-buffer.js ***!
  42523. \****************************************************/
  42524. /*! no static exports found */
  42525. /***/ (function(module, exports, __webpack_require__) {
  42526. /* WEBPACK VAR INJECTION */(function(Buffer) {
  42527. module.exports = isBuf;
  42528. var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function';
  42529. var withNativeArrayBuffer = typeof ArrayBuffer === 'function';
  42530. var isView = function (obj) {
  42531. return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer);
  42532. };
  42533. /**
  42534. * Returns true if obj is a buffer or an arraybuffer.
  42535. *
  42536. * @api private
  42537. */
  42538. function isBuf(obj) {
  42539. return (withNativeBuffer && Buffer.isBuffer(obj)) ||
  42540. (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)));
  42541. }
  42542. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42543. /***/ }),
  42544. /***/ "./node_modules/socket.io-parser/node_modules/component-emitter/index.js":
  42545. /*!*******************************************************************************!*\
  42546. !*** ./node_modules/socket.io-parser/node_modules/component-emitter/index.js ***!
  42547. \*******************************************************************************/
  42548. /*! no static exports found */
  42549. /***/ (function(module, exports, __webpack_require__) {
  42550. /**
  42551. * Expose `Emitter`.
  42552. */
  42553. if (true) {
  42554. module.exports = Emitter;
  42555. }
  42556. /**
  42557. * Initialize a new `Emitter`.
  42558. *
  42559. * @api public
  42560. */
  42561. function Emitter(obj) {
  42562. if (obj) return mixin(obj);
  42563. };
  42564. /**
  42565. * Mixin the emitter properties.
  42566. *
  42567. * @param {Object} obj
  42568. * @return {Object}
  42569. * @api private
  42570. */
  42571. function mixin(obj) {
  42572. for (var key in Emitter.prototype) {
  42573. obj[key] = Emitter.prototype[key];
  42574. }
  42575. return obj;
  42576. }
  42577. /**
  42578. * Listen on the given `event` with `fn`.
  42579. *
  42580. * @param {String} event
  42581. * @param {Function} fn
  42582. * @return {Emitter}
  42583. * @api public
  42584. */
  42585. Emitter.prototype.on =
  42586. Emitter.prototype.addEventListener = function(event, fn){
  42587. this._callbacks = this._callbacks || {};
  42588. (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
  42589. .push(fn);
  42590. return this;
  42591. };
  42592. /**
  42593. * Adds an `event` listener that will be invoked a single
  42594. * time then automatically removed.
  42595. *
  42596. * @param {String} event
  42597. * @param {Function} fn
  42598. * @return {Emitter}
  42599. * @api public
  42600. */
  42601. Emitter.prototype.once = function(event, fn){
  42602. function on() {
  42603. this.off(event, on);
  42604. fn.apply(this, arguments);
  42605. }
  42606. on.fn = fn;
  42607. this.on(event, on);
  42608. return this;
  42609. };
  42610. /**
  42611. * Remove the given callback for `event` or all
  42612. * registered callbacks.
  42613. *
  42614. * @param {String} event
  42615. * @param {Function} fn
  42616. * @return {Emitter}
  42617. * @api public
  42618. */
  42619. Emitter.prototype.off =
  42620. Emitter.prototype.removeListener =
  42621. Emitter.prototype.removeAllListeners =
  42622. Emitter.prototype.removeEventListener = function(event, fn){
  42623. this._callbacks = this._callbacks || {};
  42624. // all
  42625. if (0 == arguments.length) {
  42626. this._callbacks = {};
  42627. return this;
  42628. }
  42629. // specific event
  42630. var callbacks = this._callbacks['$' + event];
  42631. if (!callbacks) return this;
  42632. // remove all handlers
  42633. if (1 == arguments.length) {
  42634. delete this._callbacks['$' + event];
  42635. return this;
  42636. }
  42637. // remove specific handler
  42638. var cb;
  42639. for (var i = 0; i < callbacks.length; i++) {
  42640. cb = callbacks[i];
  42641. if (cb === fn || cb.fn === fn) {
  42642. callbacks.splice(i, 1);
  42643. break;
  42644. }
  42645. }
  42646. return this;
  42647. };
  42648. /**
  42649. * Emit `event` with the given args.
  42650. *
  42651. * @param {String} event
  42652. * @param {Mixed} ...
  42653. * @return {Emitter}
  42654. */
  42655. Emitter.prototype.emit = function(event){
  42656. this._callbacks = this._callbacks || {};
  42657. var args = [].slice.call(arguments, 1)
  42658. , callbacks = this._callbacks['$' + event];
  42659. if (callbacks) {
  42660. callbacks = callbacks.slice(0);
  42661. for (var i = 0, len = callbacks.length; i < len; ++i) {
  42662. callbacks[i].apply(this, args);
  42663. }
  42664. }
  42665. return this;
  42666. };
  42667. /**
  42668. * Return array of callbacks for `event`.
  42669. *
  42670. * @param {String} event
  42671. * @return {Array}
  42672. * @api public
  42673. */
  42674. Emitter.prototype.listeners = function(event){
  42675. this._callbacks = this._callbacks || {};
  42676. return this._callbacks['$' + event] || [];
  42677. };
  42678. /**
  42679. * Check if this emitter has `event` handlers.
  42680. *
  42681. * @param {String} event
  42682. * @return {Boolean}
  42683. * @api public
  42684. */
  42685. Emitter.prototype.hasListeners = function(event){
  42686. return !! this.listeners(event).length;
  42687. };
  42688. /***/ }),
  42689. /***/ "./node_modules/socket.io-parser/node_modules/isarray/index.js":
  42690. /*!*********************************************************************!*\
  42691. !*** ./node_modules/socket.io-parser/node_modules/isarray/index.js ***!
  42692. \*********************************************************************/
  42693. /*! no static exports found */
  42694. /***/ (function(module, exports) {
  42695. var toString = {}.toString;
  42696. module.exports = Array.isArray || function (arr) {
  42697. return toString.call(arr) == '[object Array]';
  42698. };
  42699. /***/ }),
  42700. /***/ "./node_modules/timers-browserify/main.js":
  42701. /*!************************************************!*\
  42702. !*** ./node_modules/timers-browserify/main.js ***!
  42703. \************************************************/
  42704. /*! no static exports found */
  42705. /***/ (function(module, exports, __webpack_require__) {
  42706. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42707. (typeof self !== "undefined" && self) ||
  42708. window;
  42709. var apply = Function.prototype.apply;
  42710. // DOM APIs, for completeness
  42711. exports.setTimeout = function() {
  42712. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42713. };
  42714. exports.setInterval = function() {
  42715. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42716. };
  42717. exports.clearTimeout =
  42718. exports.clearInterval = function(timeout) {
  42719. if (timeout) {
  42720. timeout.close();
  42721. }
  42722. };
  42723. function Timeout(id, clearFn) {
  42724. this._id = id;
  42725. this._clearFn = clearFn;
  42726. }
  42727. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42728. Timeout.prototype.close = function() {
  42729. this._clearFn.call(scope, this._id);
  42730. };
  42731. // Does not start the time, just sets up the members needed.
  42732. exports.enroll = function(item, msecs) {
  42733. clearTimeout(item._idleTimeoutId);
  42734. item._idleTimeout = msecs;
  42735. };
  42736. exports.unenroll = function(item) {
  42737. clearTimeout(item._idleTimeoutId);
  42738. item._idleTimeout = -1;
  42739. };
  42740. exports._unrefActive = exports.active = function(item) {
  42741. clearTimeout(item._idleTimeoutId);
  42742. var msecs = item._idleTimeout;
  42743. if (msecs >= 0) {
  42744. item._idleTimeoutId = setTimeout(function onTimeout() {
  42745. if (item._onTimeout)
  42746. item._onTimeout();
  42747. }, msecs);
  42748. }
  42749. };
  42750. // setimmediate attaches itself to the global object
  42751. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42752. // On some exotic environments, it's not clear which object `setimmediate` was
  42753. // able to install onto. Search each possibility in the same order as the
  42754. // `setimmediate` library.
  42755. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42756. (typeof global !== "undefined" && global.setImmediate) ||
  42757. (this && this.setImmediate);
  42758. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42759. (typeof global !== "undefined" && global.clearImmediate) ||
  42760. (this && this.clearImmediate);
  42761. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42762. /***/ }),
  42763. /***/ "./node_modules/to-array/index.js":
  42764. /*!****************************************!*\
  42765. !*** ./node_modules/to-array/index.js ***!
  42766. \****************************************/
  42767. /*! no static exports found */
  42768. /***/ (function(module, exports) {
  42769. module.exports = toArray
  42770. function toArray(list, index) {
  42771. var array = []
  42772. index = index || 0
  42773. for (var i = index || 0; i < list.length; i++) {
  42774. array[i - index] = list[i]
  42775. }
  42776. return array
  42777. }
  42778. /***/ }),
  42779. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  42780. /*!*************************************************!*\
  42781. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  42782. \*************************************************/
  42783. /*! no static exports found */
  42784. /***/ (function(module, exports, __webpack_require__) {
  42785. "use strict";
  42786. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  42787. * Vue.js v2.6.11
  42788. * (c) 2014-2019 Evan You
  42789. * Released under the MIT License.
  42790. */
  42791. /* */
  42792. var emptyObject = Object.freeze({});
  42793. // These helpers produce better VM code in JS engines due to their
  42794. // explicitness and function inlining.
  42795. function isUndef (v) {
  42796. return v === undefined || v === null
  42797. }
  42798. function isDef (v) {
  42799. return v !== undefined && v !== null
  42800. }
  42801. function isTrue (v) {
  42802. return v === true
  42803. }
  42804. function isFalse (v) {
  42805. return v === false
  42806. }
  42807. /**
  42808. * Check if value is primitive.
  42809. */
  42810. function isPrimitive (value) {
  42811. return (
  42812. typeof value === 'string' ||
  42813. typeof value === 'number' ||
  42814. // $flow-disable-line
  42815. typeof value === 'symbol' ||
  42816. typeof value === 'boolean'
  42817. )
  42818. }
  42819. /**
  42820. * Quick object check - this is primarily used to tell
  42821. * Objects from primitive values when we know the value
  42822. * is a JSON-compliant type.
  42823. */
  42824. function isObject (obj) {
  42825. return obj !== null && typeof obj === 'object'
  42826. }
  42827. /**
  42828. * Get the raw type string of a value, e.g., [object Object].
  42829. */
  42830. var _toString = Object.prototype.toString;
  42831. function toRawType (value) {
  42832. return _toString.call(value).slice(8, -1)
  42833. }
  42834. /**
  42835. * Strict object type check. Only returns true
  42836. * for plain JavaScript objects.
  42837. */
  42838. function isPlainObject (obj) {
  42839. return _toString.call(obj) === '[object Object]'
  42840. }
  42841. function isRegExp (v) {
  42842. return _toString.call(v) === '[object RegExp]'
  42843. }
  42844. /**
  42845. * Check if val is a valid array index.
  42846. */
  42847. function isValidArrayIndex (val) {
  42848. var n = parseFloat(String(val));
  42849. return n >= 0 && Math.floor(n) === n && isFinite(val)
  42850. }
  42851. function isPromise (val) {
  42852. return (
  42853. isDef(val) &&
  42854. typeof val.then === 'function' &&
  42855. typeof val.catch === 'function'
  42856. )
  42857. }
  42858. /**
  42859. * Convert a value to a string that is actually rendered.
  42860. */
  42861. function toString (val) {
  42862. return val == null
  42863. ? ''
  42864. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  42865. ? JSON.stringify(val, null, 2)
  42866. : String(val)
  42867. }
  42868. /**
  42869. * Convert an input value to a number for persistence.
  42870. * If the conversion fails, return original string.
  42871. */
  42872. function toNumber (val) {
  42873. var n = parseFloat(val);
  42874. return isNaN(n) ? val : n
  42875. }
  42876. /**
  42877. * Make a map and return a function for checking if a key
  42878. * is in that map.
  42879. */
  42880. function makeMap (
  42881. str,
  42882. expectsLowerCase
  42883. ) {
  42884. var map = Object.create(null);
  42885. var list = str.split(',');
  42886. for (var i = 0; i < list.length; i++) {
  42887. map[list[i]] = true;
  42888. }
  42889. return expectsLowerCase
  42890. ? function (val) { return map[val.toLowerCase()]; }
  42891. : function (val) { return map[val]; }
  42892. }
  42893. /**
  42894. * Check if a tag is a built-in tag.
  42895. */
  42896. var isBuiltInTag = makeMap('slot,component', true);
  42897. /**
  42898. * Check if an attribute is a reserved attribute.
  42899. */
  42900. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  42901. /**
  42902. * Remove an item from an array.
  42903. */
  42904. function remove (arr, item) {
  42905. if (arr.length) {
  42906. var index = arr.indexOf(item);
  42907. if (index > -1) {
  42908. return arr.splice(index, 1)
  42909. }
  42910. }
  42911. }
  42912. /**
  42913. * Check whether an object has the property.
  42914. */
  42915. var hasOwnProperty = Object.prototype.hasOwnProperty;
  42916. function hasOwn (obj, key) {
  42917. return hasOwnProperty.call(obj, key)
  42918. }
  42919. /**
  42920. * Create a cached version of a pure function.
  42921. */
  42922. function cached (fn) {
  42923. var cache = Object.create(null);
  42924. return (function cachedFn (str) {
  42925. var hit = cache[str];
  42926. return hit || (cache[str] = fn(str))
  42927. })
  42928. }
  42929. /**
  42930. * Camelize a hyphen-delimited string.
  42931. */
  42932. var camelizeRE = /-(\w)/g;
  42933. var camelize = cached(function (str) {
  42934. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  42935. });
  42936. /**
  42937. * Capitalize a string.
  42938. */
  42939. var capitalize = cached(function (str) {
  42940. return str.charAt(0).toUpperCase() + str.slice(1)
  42941. });
  42942. /**
  42943. * Hyphenate a camelCase string.
  42944. */
  42945. var hyphenateRE = /\B([A-Z])/g;
  42946. var hyphenate = cached(function (str) {
  42947. return str.replace(hyphenateRE, '-$1').toLowerCase()
  42948. });
  42949. /**
  42950. * Simple bind polyfill for environments that do not support it,
  42951. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  42952. * since native bind is now performant enough in most browsers.
  42953. * But removing it would mean breaking code that was able to run in
  42954. * PhantomJS 1.x, so this must be kept for backward compatibility.
  42955. */
  42956. /* istanbul ignore next */
  42957. function polyfillBind (fn, ctx) {
  42958. function boundFn (a) {
  42959. var l = arguments.length;
  42960. return l
  42961. ? l > 1
  42962. ? fn.apply(ctx, arguments)
  42963. : fn.call(ctx, a)
  42964. : fn.call(ctx)
  42965. }
  42966. boundFn._length = fn.length;
  42967. return boundFn
  42968. }
  42969. function nativeBind (fn, ctx) {
  42970. return fn.bind(ctx)
  42971. }
  42972. var bind = Function.prototype.bind
  42973. ? nativeBind
  42974. : polyfillBind;
  42975. /**
  42976. * Convert an Array-like object to a real Array.
  42977. */
  42978. function toArray (list, start) {
  42979. start = start || 0;
  42980. var i = list.length - start;
  42981. var ret = new Array(i);
  42982. while (i--) {
  42983. ret[i] = list[i + start];
  42984. }
  42985. return ret
  42986. }
  42987. /**
  42988. * Mix properties into target object.
  42989. */
  42990. function extend (to, _from) {
  42991. for (var key in _from) {
  42992. to[key] = _from[key];
  42993. }
  42994. return to
  42995. }
  42996. /**
  42997. * Merge an Array of Objects into a single Object.
  42998. */
  42999. function toObject (arr) {
  43000. var res = {};
  43001. for (var i = 0; i < arr.length; i++) {
  43002. if (arr[i]) {
  43003. extend(res, arr[i]);
  43004. }
  43005. }
  43006. return res
  43007. }
  43008. /* eslint-disable no-unused-vars */
  43009. /**
  43010. * Perform no operation.
  43011. * Stubbing args to make Flow happy without leaving useless transpiled code
  43012. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  43013. */
  43014. function noop (a, b, c) {}
  43015. /**
  43016. * Always return false.
  43017. */
  43018. var no = function (a, b, c) { return false; };
  43019. /* eslint-enable no-unused-vars */
  43020. /**
  43021. * Return the same value.
  43022. */
  43023. var identity = function (_) { return _; };
  43024. /**
  43025. * Generate a string containing static keys from compiler modules.
  43026. */
  43027. function genStaticKeys (modules) {
  43028. return modules.reduce(function (keys, m) {
  43029. return keys.concat(m.staticKeys || [])
  43030. }, []).join(',')
  43031. }
  43032. /**
  43033. * Check if two values are loosely equal - that is,
  43034. * if they are plain objects, do they have the same shape?
  43035. */
  43036. function looseEqual (a, b) {
  43037. if (a === b) { return true }
  43038. var isObjectA = isObject(a);
  43039. var isObjectB = isObject(b);
  43040. if (isObjectA && isObjectB) {
  43041. try {
  43042. var isArrayA = Array.isArray(a);
  43043. var isArrayB = Array.isArray(b);
  43044. if (isArrayA && isArrayB) {
  43045. return a.length === b.length && a.every(function (e, i) {
  43046. return looseEqual(e, b[i])
  43047. })
  43048. } else if (a instanceof Date && b instanceof Date) {
  43049. return a.getTime() === b.getTime()
  43050. } else if (!isArrayA && !isArrayB) {
  43051. var keysA = Object.keys(a);
  43052. var keysB = Object.keys(b);
  43053. return keysA.length === keysB.length && keysA.every(function (key) {
  43054. return looseEqual(a[key], b[key])
  43055. })
  43056. } else {
  43057. /* istanbul ignore next */
  43058. return false
  43059. }
  43060. } catch (e) {
  43061. /* istanbul ignore next */
  43062. return false
  43063. }
  43064. } else if (!isObjectA && !isObjectB) {
  43065. return String(a) === String(b)
  43066. } else {
  43067. return false
  43068. }
  43069. }
  43070. /**
  43071. * Return the first index at which a loosely equal value can be
  43072. * found in the array (if value is a plain object, the array must
  43073. * contain an object of the same shape), or -1 if it is not present.
  43074. */
  43075. function looseIndexOf (arr, val) {
  43076. for (var i = 0; i < arr.length; i++) {
  43077. if (looseEqual(arr[i], val)) { return i }
  43078. }
  43079. return -1
  43080. }
  43081. /**
  43082. * Ensure a function is called only once.
  43083. */
  43084. function once (fn) {
  43085. var called = false;
  43086. return function () {
  43087. if (!called) {
  43088. called = true;
  43089. fn.apply(this, arguments);
  43090. }
  43091. }
  43092. }
  43093. var SSR_ATTR = 'data-server-rendered';
  43094. var ASSET_TYPES = [
  43095. 'component',
  43096. 'directive',
  43097. 'filter'
  43098. ];
  43099. var LIFECYCLE_HOOKS = [
  43100. 'beforeCreate',
  43101. 'created',
  43102. 'beforeMount',
  43103. 'mounted',
  43104. 'beforeUpdate',
  43105. 'updated',
  43106. 'beforeDestroy',
  43107. 'destroyed',
  43108. 'activated',
  43109. 'deactivated',
  43110. 'errorCaptured',
  43111. 'serverPrefetch'
  43112. ];
  43113. /* */
  43114. var config = ({
  43115. /**
  43116. * Option merge strategies (used in core/util/options)
  43117. */
  43118. // $flow-disable-line
  43119. optionMergeStrategies: Object.create(null),
  43120. /**
  43121. * Whether to suppress warnings.
  43122. */
  43123. silent: false,
  43124. /**
  43125. * Show production mode tip message on boot?
  43126. */
  43127. productionTip: "development" !== 'production',
  43128. /**
  43129. * Whether to enable devtools
  43130. */
  43131. devtools: "development" !== 'production',
  43132. /**
  43133. * Whether to record perf
  43134. */
  43135. performance: false,
  43136. /**
  43137. * Error handler for watcher errors
  43138. */
  43139. errorHandler: null,
  43140. /**
  43141. * Warn handler for watcher warns
  43142. */
  43143. warnHandler: null,
  43144. /**
  43145. * Ignore certain custom elements
  43146. */
  43147. ignoredElements: [],
  43148. /**
  43149. * Custom user key aliases for v-on
  43150. */
  43151. // $flow-disable-line
  43152. keyCodes: Object.create(null),
  43153. /**
  43154. * Check if a tag is reserved so that it cannot be registered as a
  43155. * component. This is platform-dependent and may be overwritten.
  43156. */
  43157. isReservedTag: no,
  43158. /**
  43159. * Check if an attribute is reserved so that it cannot be used as a component
  43160. * prop. This is platform-dependent and may be overwritten.
  43161. */
  43162. isReservedAttr: no,
  43163. /**
  43164. * Check if a tag is an unknown element.
  43165. * Platform-dependent.
  43166. */
  43167. isUnknownElement: no,
  43168. /**
  43169. * Get the namespace of an element
  43170. */
  43171. getTagNamespace: noop,
  43172. /**
  43173. * Parse the real tag name for the specific platform.
  43174. */
  43175. parsePlatformTagName: identity,
  43176. /**
  43177. * Check if an attribute must be bound using property, e.g. value
  43178. * Platform-dependent.
  43179. */
  43180. mustUseProp: no,
  43181. /**
  43182. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  43183. * This will significantly reduce performance if set to false.
  43184. */
  43185. async: true,
  43186. /**
  43187. * Exposed for legacy reasons
  43188. */
  43189. _lifecycleHooks: LIFECYCLE_HOOKS
  43190. });
  43191. /* */
  43192. /**
  43193. * unicode letters used for parsing html tags, component names and property paths.
  43194. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  43195. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  43196. */
  43197. var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  43198. /**
  43199. * Check if a string starts with $ or _
  43200. */
  43201. function isReserved (str) {
  43202. var c = (str + '').charCodeAt(0);
  43203. return c === 0x24 || c === 0x5F
  43204. }
  43205. /**
  43206. * Define a property.
  43207. */
  43208. function def (obj, key, val, enumerable) {
  43209. Object.defineProperty(obj, key, {
  43210. value: val,
  43211. enumerable: !!enumerable,
  43212. writable: true,
  43213. configurable: true
  43214. });
  43215. }
  43216. /**
  43217. * Parse simple path.
  43218. */
  43219. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  43220. function parsePath (path) {
  43221. if (bailRE.test(path)) {
  43222. return
  43223. }
  43224. var segments = path.split('.');
  43225. return function (obj) {
  43226. for (var i = 0; i < segments.length; i++) {
  43227. if (!obj) { return }
  43228. obj = obj[segments[i]];
  43229. }
  43230. return obj
  43231. }
  43232. }
  43233. /* */
  43234. // can we use __proto__?
  43235. var hasProto = '__proto__' in {};
  43236. // Browser environment sniffing
  43237. var inBrowser = typeof window !== 'undefined';
  43238. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  43239. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  43240. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  43241. var isIE = UA && /msie|trident/.test(UA);
  43242. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  43243. var isEdge = UA && UA.indexOf('edge/') > 0;
  43244. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  43245. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  43246. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  43247. var isPhantomJS = UA && /phantomjs/.test(UA);
  43248. var isFF = UA && UA.match(/firefox\/(\d+)/);
  43249. // Firefox has a "watch" function on Object.prototype...
  43250. var nativeWatch = ({}).watch;
  43251. var supportsPassive = false;
  43252. if (inBrowser) {
  43253. try {
  43254. var opts = {};
  43255. Object.defineProperty(opts, 'passive', ({
  43256. get: function get () {
  43257. /* istanbul ignore next */
  43258. supportsPassive = true;
  43259. }
  43260. })); // https://github.com/facebook/flow/issues/285
  43261. window.addEventListener('test-passive', null, opts);
  43262. } catch (e) {}
  43263. }
  43264. // this needs to be lazy-evaled because vue may be required before
  43265. // vue-server-renderer can set VUE_ENV
  43266. var _isServer;
  43267. var isServerRendering = function () {
  43268. if (_isServer === undefined) {
  43269. /* istanbul ignore if */
  43270. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  43271. // detect presence of vue-server-renderer and avoid
  43272. // Webpack shimming the process
  43273. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  43274. } else {
  43275. _isServer = false;
  43276. }
  43277. }
  43278. return _isServer
  43279. };
  43280. // detect devtools
  43281. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  43282. /* istanbul ignore next */
  43283. function isNative (Ctor) {
  43284. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  43285. }
  43286. var hasSymbol =
  43287. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  43288. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  43289. var _Set;
  43290. /* istanbul ignore if */ // $flow-disable-line
  43291. if (typeof Set !== 'undefined' && isNative(Set)) {
  43292. // use native Set when available.
  43293. _Set = Set;
  43294. } else {
  43295. // a non-standard Set polyfill that only works with primitive keys.
  43296. _Set = /*@__PURE__*/(function () {
  43297. function Set () {
  43298. this.set = Object.create(null);
  43299. }
  43300. Set.prototype.has = function has (key) {
  43301. return this.set[key] === true
  43302. };
  43303. Set.prototype.add = function add (key) {
  43304. this.set[key] = true;
  43305. };
  43306. Set.prototype.clear = function clear () {
  43307. this.set = Object.create(null);
  43308. };
  43309. return Set;
  43310. }());
  43311. }
  43312. /* */
  43313. var warn = noop;
  43314. var tip = noop;
  43315. var generateComponentTrace = (noop); // work around flow check
  43316. var formatComponentName = (noop);
  43317. {
  43318. var hasConsole = typeof console !== 'undefined';
  43319. var classifyRE = /(?:^|[-_])(\w)/g;
  43320. var classify = function (str) { return str
  43321. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  43322. .replace(/[-_]/g, ''); };
  43323. warn = function (msg, vm) {
  43324. var trace = vm ? generateComponentTrace(vm) : '';
  43325. if (config.warnHandler) {
  43326. config.warnHandler.call(null, msg, vm, trace);
  43327. } else if (hasConsole && (!config.silent)) {
  43328. console.error(("[Vue warn]: " + msg + trace));
  43329. }
  43330. };
  43331. tip = function (msg, vm) {
  43332. if (hasConsole && (!config.silent)) {
  43333. console.warn("[Vue tip]: " + msg + (
  43334. vm ? generateComponentTrace(vm) : ''
  43335. ));
  43336. }
  43337. };
  43338. formatComponentName = function (vm, includeFile) {
  43339. if (vm.$root === vm) {
  43340. return '<Root>'
  43341. }
  43342. var options = typeof vm === 'function' && vm.cid != null
  43343. ? vm.options
  43344. : vm._isVue
  43345. ? vm.$options || vm.constructor.options
  43346. : vm;
  43347. var name = options.name || options._componentTag;
  43348. var file = options.__file;
  43349. if (!name && file) {
  43350. var match = file.match(/([^/\\]+)\.vue$/);
  43351. name = match && match[1];
  43352. }
  43353. return (
  43354. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  43355. (file && includeFile !== false ? (" at " + file) : '')
  43356. )
  43357. };
  43358. var repeat = function (str, n) {
  43359. var res = '';
  43360. while (n) {
  43361. if (n % 2 === 1) { res += str; }
  43362. if (n > 1) { str += str; }
  43363. n >>= 1;
  43364. }
  43365. return res
  43366. };
  43367. generateComponentTrace = function (vm) {
  43368. if (vm._isVue && vm.$parent) {
  43369. var tree = [];
  43370. var currentRecursiveSequence = 0;
  43371. while (vm) {
  43372. if (tree.length > 0) {
  43373. var last = tree[tree.length - 1];
  43374. if (last.constructor === vm.constructor) {
  43375. currentRecursiveSequence++;
  43376. vm = vm.$parent;
  43377. continue
  43378. } else if (currentRecursiveSequence > 0) {
  43379. tree[tree.length - 1] = [last, currentRecursiveSequence];
  43380. currentRecursiveSequence = 0;
  43381. }
  43382. }
  43383. tree.push(vm);
  43384. vm = vm.$parent;
  43385. }
  43386. return '\n\nfound in\n\n' + tree
  43387. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  43388. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  43389. : formatComponentName(vm))); })
  43390. .join('\n')
  43391. } else {
  43392. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  43393. }
  43394. };
  43395. }
  43396. /* */
  43397. var uid = 0;
  43398. /**
  43399. * A dep is an observable that can have multiple
  43400. * directives subscribing to it.
  43401. */
  43402. var Dep = function Dep () {
  43403. this.id = uid++;
  43404. this.subs = [];
  43405. };
  43406. Dep.prototype.addSub = function addSub (sub) {
  43407. this.subs.push(sub);
  43408. };
  43409. Dep.prototype.removeSub = function removeSub (sub) {
  43410. remove(this.subs, sub);
  43411. };
  43412. Dep.prototype.depend = function depend () {
  43413. if (Dep.target) {
  43414. Dep.target.addDep(this);
  43415. }
  43416. };
  43417. Dep.prototype.notify = function notify () {
  43418. // stabilize the subscriber list first
  43419. var subs = this.subs.slice();
  43420. if (!config.async) {
  43421. // subs aren't sorted in scheduler if not running async
  43422. // we need to sort them now to make sure they fire in correct
  43423. // order
  43424. subs.sort(function (a, b) { return a.id - b.id; });
  43425. }
  43426. for (var i = 0, l = subs.length; i < l; i++) {
  43427. subs[i].update();
  43428. }
  43429. };
  43430. // The current target watcher being evaluated.
  43431. // This is globally unique because only one watcher
  43432. // can be evaluated at a time.
  43433. Dep.target = null;
  43434. var targetStack = [];
  43435. function pushTarget (target) {
  43436. targetStack.push(target);
  43437. Dep.target = target;
  43438. }
  43439. function popTarget () {
  43440. targetStack.pop();
  43441. Dep.target = targetStack[targetStack.length - 1];
  43442. }
  43443. /* */
  43444. var VNode = function VNode (
  43445. tag,
  43446. data,
  43447. children,
  43448. text,
  43449. elm,
  43450. context,
  43451. componentOptions,
  43452. asyncFactory
  43453. ) {
  43454. this.tag = tag;
  43455. this.data = data;
  43456. this.children = children;
  43457. this.text = text;
  43458. this.elm = elm;
  43459. this.ns = undefined;
  43460. this.context = context;
  43461. this.fnContext = undefined;
  43462. this.fnOptions = undefined;
  43463. this.fnScopeId = undefined;
  43464. this.key = data && data.key;
  43465. this.componentOptions = componentOptions;
  43466. this.componentInstance = undefined;
  43467. this.parent = undefined;
  43468. this.raw = false;
  43469. this.isStatic = false;
  43470. this.isRootInsert = true;
  43471. this.isComment = false;
  43472. this.isCloned = false;
  43473. this.isOnce = false;
  43474. this.asyncFactory = asyncFactory;
  43475. this.asyncMeta = undefined;
  43476. this.isAsyncPlaceholder = false;
  43477. };
  43478. var prototypeAccessors = { child: { configurable: true } };
  43479. // DEPRECATED: alias for componentInstance for backwards compat.
  43480. /* istanbul ignore next */
  43481. prototypeAccessors.child.get = function () {
  43482. return this.componentInstance
  43483. };
  43484. Object.defineProperties( VNode.prototype, prototypeAccessors );
  43485. var createEmptyVNode = function (text) {
  43486. if ( text === void 0 ) text = '';
  43487. var node = new VNode();
  43488. node.text = text;
  43489. node.isComment = true;
  43490. return node
  43491. };
  43492. function createTextVNode (val) {
  43493. return new VNode(undefined, undefined, undefined, String(val))
  43494. }
  43495. // optimized shallow clone
  43496. // used for static nodes and slot nodes because they may be reused across
  43497. // multiple renders, cloning them avoids errors when DOM manipulations rely
  43498. // on their elm reference.
  43499. function cloneVNode (vnode) {
  43500. var cloned = new VNode(
  43501. vnode.tag,
  43502. vnode.data,
  43503. // #7975
  43504. // clone children array to avoid mutating original in case of cloning
  43505. // a child.
  43506. vnode.children && vnode.children.slice(),
  43507. vnode.text,
  43508. vnode.elm,
  43509. vnode.context,
  43510. vnode.componentOptions,
  43511. vnode.asyncFactory
  43512. );
  43513. cloned.ns = vnode.ns;
  43514. cloned.isStatic = vnode.isStatic;
  43515. cloned.key = vnode.key;
  43516. cloned.isComment = vnode.isComment;
  43517. cloned.fnContext = vnode.fnContext;
  43518. cloned.fnOptions = vnode.fnOptions;
  43519. cloned.fnScopeId = vnode.fnScopeId;
  43520. cloned.asyncMeta = vnode.asyncMeta;
  43521. cloned.isCloned = true;
  43522. return cloned
  43523. }
  43524. /*
  43525. * not type checking this file because flow doesn't play well with
  43526. * dynamically accessing methods on Array prototype
  43527. */
  43528. var arrayProto = Array.prototype;
  43529. var arrayMethods = Object.create(arrayProto);
  43530. var methodsToPatch = [
  43531. 'push',
  43532. 'pop',
  43533. 'shift',
  43534. 'unshift',
  43535. 'splice',
  43536. 'sort',
  43537. 'reverse'
  43538. ];
  43539. /**
  43540. * Intercept mutating methods and emit events
  43541. */
  43542. methodsToPatch.forEach(function (method) {
  43543. // cache original method
  43544. var original = arrayProto[method];
  43545. def(arrayMethods, method, function mutator () {
  43546. var args = [], len = arguments.length;
  43547. while ( len-- ) args[ len ] = arguments[ len ];
  43548. var result = original.apply(this, args);
  43549. var ob = this.__ob__;
  43550. var inserted;
  43551. switch (method) {
  43552. case 'push':
  43553. case 'unshift':
  43554. inserted = args;
  43555. break
  43556. case 'splice':
  43557. inserted = args.slice(2);
  43558. break
  43559. }
  43560. if (inserted) { ob.observeArray(inserted); }
  43561. // notify change
  43562. ob.dep.notify();
  43563. return result
  43564. });
  43565. });
  43566. /* */
  43567. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  43568. /**
  43569. * In some cases we may want to disable observation inside a component's
  43570. * update computation.
  43571. */
  43572. var shouldObserve = true;
  43573. function toggleObserving (value) {
  43574. shouldObserve = value;
  43575. }
  43576. /**
  43577. * Observer class that is attached to each observed
  43578. * object. Once attached, the observer converts the target
  43579. * object's property keys into getter/setters that
  43580. * collect dependencies and dispatch updates.
  43581. */
  43582. var Observer = function Observer (value) {
  43583. this.value = value;
  43584. this.dep = new Dep();
  43585. this.vmCount = 0;
  43586. def(value, '__ob__', this);
  43587. if (Array.isArray(value)) {
  43588. if (hasProto) {
  43589. protoAugment(value, arrayMethods);
  43590. } else {
  43591. copyAugment(value, arrayMethods, arrayKeys);
  43592. }
  43593. this.observeArray(value);
  43594. } else {
  43595. this.walk(value);
  43596. }
  43597. };
  43598. /**
  43599. * Walk through all properties and convert them into
  43600. * getter/setters. This method should only be called when
  43601. * value type is Object.
  43602. */
  43603. Observer.prototype.walk = function walk (obj) {
  43604. var keys = Object.keys(obj);
  43605. for (var i = 0; i < keys.length; i++) {
  43606. defineReactive$$1(obj, keys[i]);
  43607. }
  43608. };
  43609. /**
  43610. * Observe a list of Array items.
  43611. */
  43612. Observer.prototype.observeArray = function observeArray (items) {
  43613. for (var i = 0, l = items.length; i < l; i++) {
  43614. observe(items[i]);
  43615. }
  43616. };
  43617. // helpers
  43618. /**
  43619. * Augment a target Object or Array by intercepting
  43620. * the prototype chain using __proto__
  43621. */
  43622. function protoAugment (target, src) {
  43623. /* eslint-disable no-proto */
  43624. target.__proto__ = src;
  43625. /* eslint-enable no-proto */
  43626. }
  43627. /**
  43628. * Augment a target Object or Array by defining
  43629. * hidden properties.
  43630. */
  43631. /* istanbul ignore next */
  43632. function copyAugment (target, src, keys) {
  43633. for (var i = 0, l = keys.length; i < l; i++) {
  43634. var key = keys[i];
  43635. def(target, key, src[key]);
  43636. }
  43637. }
  43638. /**
  43639. * Attempt to create an observer instance for a value,
  43640. * returns the new observer if successfully observed,
  43641. * or the existing observer if the value already has one.
  43642. */
  43643. function observe (value, asRootData) {
  43644. if (!isObject(value) || value instanceof VNode) {
  43645. return
  43646. }
  43647. var ob;
  43648. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  43649. ob = value.__ob__;
  43650. } else if (
  43651. shouldObserve &&
  43652. !isServerRendering() &&
  43653. (Array.isArray(value) || isPlainObject(value)) &&
  43654. Object.isExtensible(value) &&
  43655. !value._isVue
  43656. ) {
  43657. ob = new Observer(value);
  43658. }
  43659. if (asRootData && ob) {
  43660. ob.vmCount++;
  43661. }
  43662. return ob
  43663. }
  43664. /**
  43665. * Define a reactive property on an Object.
  43666. */
  43667. function defineReactive$$1 (
  43668. obj,
  43669. key,
  43670. val,
  43671. customSetter,
  43672. shallow
  43673. ) {
  43674. var dep = new Dep();
  43675. var property = Object.getOwnPropertyDescriptor(obj, key);
  43676. if (property && property.configurable === false) {
  43677. return
  43678. }
  43679. // cater for pre-defined getter/setters
  43680. var getter = property && property.get;
  43681. var setter = property && property.set;
  43682. if ((!getter || setter) && arguments.length === 2) {
  43683. val = obj[key];
  43684. }
  43685. var childOb = !shallow && observe(val);
  43686. Object.defineProperty(obj, key, {
  43687. enumerable: true,
  43688. configurable: true,
  43689. get: function reactiveGetter () {
  43690. var value = getter ? getter.call(obj) : val;
  43691. if (Dep.target) {
  43692. dep.depend();
  43693. if (childOb) {
  43694. childOb.dep.depend();
  43695. if (Array.isArray(value)) {
  43696. dependArray(value);
  43697. }
  43698. }
  43699. }
  43700. return value
  43701. },
  43702. set: function reactiveSetter (newVal) {
  43703. var value = getter ? getter.call(obj) : val;
  43704. /* eslint-disable no-self-compare */
  43705. if (newVal === value || (newVal !== newVal && value !== value)) {
  43706. return
  43707. }
  43708. /* eslint-enable no-self-compare */
  43709. if (customSetter) {
  43710. customSetter();
  43711. }
  43712. // #7981: for accessor properties without setter
  43713. if (getter && !setter) { return }
  43714. if (setter) {
  43715. setter.call(obj, newVal);
  43716. } else {
  43717. val = newVal;
  43718. }
  43719. childOb = !shallow && observe(newVal);
  43720. dep.notify();
  43721. }
  43722. });
  43723. }
  43724. /**
  43725. * Set a property on an object. Adds the new property and
  43726. * triggers change notification if the property doesn't
  43727. * already exist.
  43728. */
  43729. function set (target, key, val) {
  43730. if (isUndef(target) || isPrimitive(target)
  43731. ) {
  43732. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  43733. }
  43734. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43735. target.length = Math.max(target.length, key);
  43736. target.splice(key, 1, val);
  43737. return val
  43738. }
  43739. if (key in target && !(key in Object.prototype)) {
  43740. target[key] = val;
  43741. return val
  43742. }
  43743. var ob = (target).__ob__;
  43744. if (target._isVue || (ob && ob.vmCount)) {
  43745. warn(
  43746. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  43747. 'at runtime - declare it upfront in the data option.'
  43748. );
  43749. return val
  43750. }
  43751. if (!ob) {
  43752. target[key] = val;
  43753. return val
  43754. }
  43755. defineReactive$$1(ob.value, key, val);
  43756. ob.dep.notify();
  43757. return val
  43758. }
  43759. /**
  43760. * Delete a property and trigger change if necessary.
  43761. */
  43762. function del (target, key) {
  43763. if (isUndef(target) || isPrimitive(target)
  43764. ) {
  43765. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  43766. }
  43767. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43768. target.splice(key, 1);
  43769. return
  43770. }
  43771. var ob = (target).__ob__;
  43772. if (target._isVue || (ob && ob.vmCount)) {
  43773. warn(
  43774. 'Avoid deleting properties on a Vue instance or its root $data ' +
  43775. '- just set it to null.'
  43776. );
  43777. return
  43778. }
  43779. if (!hasOwn(target, key)) {
  43780. return
  43781. }
  43782. delete target[key];
  43783. if (!ob) {
  43784. return
  43785. }
  43786. ob.dep.notify();
  43787. }
  43788. /**
  43789. * Collect dependencies on array elements when the array is touched, since
  43790. * we cannot intercept array element access like property getters.
  43791. */
  43792. function dependArray (value) {
  43793. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  43794. e = value[i];
  43795. e && e.__ob__ && e.__ob__.dep.depend();
  43796. if (Array.isArray(e)) {
  43797. dependArray(e);
  43798. }
  43799. }
  43800. }
  43801. /* */
  43802. /**
  43803. * Option overwriting strategies are functions that handle
  43804. * how to merge a parent option value and a child option
  43805. * value into the final value.
  43806. */
  43807. var strats = config.optionMergeStrategies;
  43808. /**
  43809. * Options with restrictions
  43810. */
  43811. {
  43812. strats.el = strats.propsData = function (parent, child, vm, key) {
  43813. if (!vm) {
  43814. warn(
  43815. "option \"" + key + "\" can only be used during instance " +
  43816. 'creation with the `new` keyword.'
  43817. );
  43818. }
  43819. return defaultStrat(parent, child)
  43820. };
  43821. }
  43822. /**
  43823. * Helper that recursively merges two data objects together.
  43824. */
  43825. function mergeData (to, from) {
  43826. if (!from) { return to }
  43827. var key, toVal, fromVal;
  43828. var keys = hasSymbol
  43829. ? Reflect.ownKeys(from)
  43830. : Object.keys(from);
  43831. for (var i = 0; i < keys.length; i++) {
  43832. key = keys[i];
  43833. // in case the object is already observed...
  43834. if (key === '__ob__') { continue }
  43835. toVal = to[key];
  43836. fromVal = from[key];
  43837. if (!hasOwn(to, key)) {
  43838. set(to, key, fromVal);
  43839. } else if (
  43840. toVal !== fromVal &&
  43841. isPlainObject(toVal) &&
  43842. isPlainObject(fromVal)
  43843. ) {
  43844. mergeData(toVal, fromVal);
  43845. }
  43846. }
  43847. return to
  43848. }
  43849. /**
  43850. * Data
  43851. */
  43852. function mergeDataOrFn (
  43853. parentVal,
  43854. childVal,
  43855. vm
  43856. ) {
  43857. if (!vm) {
  43858. // in a Vue.extend merge, both should be functions
  43859. if (!childVal) {
  43860. return parentVal
  43861. }
  43862. if (!parentVal) {
  43863. return childVal
  43864. }
  43865. // when parentVal & childVal are both present,
  43866. // we need to return a function that returns the
  43867. // merged result of both functions... no need to
  43868. // check if parentVal is a function here because
  43869. // it has to be a function to pass previous merges.
  43870. return function mergedDataFn () {
  43871. return mergeData(
  43872. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  43873. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  43874. )
  43875. }
  43876. } else {
  43877. return function mergedInstanceDataFn () {
  43878. // instance merge
  43879. var instanceData = typeof childVal === 'function'
  43880. ? childVal.call(vm, vm)
  43881. : childVal;
  43882. var defaultData = typeof parentVal === 'function'
  43883. ? parentVal.call(vm, vm)
  43884. : parentVal;
  43885. if (instanceData) {
  43886. return mergeData(instanceData, defaultData)
  43887. } else {
  43888. return defaultData
  43889. }
  43890. }
  43891. }
  43892. }
  43893. strats.data = function (
  43894. parentVal,
  43895. childVal,
  43896. vm
  43897. ) {
  43898. if (!vm) {
  43899. if (childVal && typeof childVal !== 'function') {
  43900. warn(
  43901. 'The "data" option should be a function ' +
  43902. 'that returns a per-instance value in component ' +
  43903. 'definitions.',
  43904. vm
  43905. );
  43906. return parentVal
  43907. }
  43908. return mergeDataOrFn(parentVal, childVal)
  43909. }
  43910. return mergeDataOrFn(parentVal, childVal, vm)
  43911. };
  43912. /**
  43913. * Hooks and props are merged as arrays.
  43914. */
  43915. function mergeHook (
  43916. parentVal,
  43917. childVal
  43918. ) {
  43919. var res = childVal
  43920. ? parentVal
  43921. ? parentVal.concat(childVal)
  43922. : Array.isArray(childVal)
  43923. ? childVal
  43924. : [childVal]
  43925. : parentVal;
  43926. return res
  43927. ? dedupeHooks(res)
  43928. : res
  43929. }
  43930. function dedupeHooks (hooks) {
  43931. var res = [];
  43932. for (var i = 0; i < hooks.length; i++) {
  43933. if (res.indexOf(hooks[i]) === -1) {
  43934. res.push(hooks[i]);
  43935. }
  43936. }
  43937. return res
  43938. }
  43939. LIFECYCLE_HOOKS.forEach(function (hook) {
  43940. strats[hook] = mergeHook;
  43941. });
  43942. /**
  43943. * Assets
  43944. *
  43945. * When a vm is present (instance creation), we need to do
  43946. * a three-way merge between constructor options, instance
  43947. * options and parent options.
  43948. */
  43949. function mergeAssets (
  43950. parentVal,
  43951. childVal,
  43952. vm,
  43953. key
  43954. ) {
  43955. var res = Object.create(parentVal || null);
  43956. if (childVal) {
  43957. assertObjectType(key, childVal, vm);
  43958. return extend(res, childVal)
  43959. } else {
  43960. return res
  43961. }
  43962. }
  43963. ASSET_TYPES.forEach(function (type) {
  43964. strats[type + 's'] = mergeAssets;
  43965. });
  43966. /**
  43967. * Watchers.
  43968. *
  43969. * Watchers hashes should not overwrite one
  43970. * another, so we merge them as arrays.
  43971. */
  43972. strats.watch = function (
  43973. parentVal,
  43974. childVal,
  43975. vm,
  43976. key
  43977. ) {
  43978. // work around Firefox's Object.prototype.watch...
  43979. if (parentVal === nativeWatch) { parentVal = undefined; }
  43980. if (childVal === nativeWatch) { childVal = undefined; }
  43981. /* istanbul ignore if */
  43982. if (!childVal) { return Object.create(parentVal || null) }
  43983. {
  43984. assertObjectType(key, childVal, vm);
  43985. }
  43986. if (!parentVal) { return childVal }
  43987. var ret = {};
  43988. extend(ret, parentVal);
  43989. for (var key$1 in childVal) {
  43990. var parent = ret[key$1];
  43991. var child = childVal[key$1];
  43992. if (parent && !Array.isArray(parent)) {
  43993. parent = [parent];
  43994. }
  43995. ret[key$1] = parent
  43996. ? parent.concat(child)
  43997. : Array.isArray(child) ? child : [child];
  43998. }
  43999. return ret
  44000. };
  44001. /**
  44002. * Other object hashes.
  44003. */
  44004. strats.props =
  44005. strats.methods =
  44006. strats.inject =
  44007. strats.computed = function (
  44008. parentVal,
  44009. childVal,
  44010. vm,
  44011. key
  44012. ) {
  44013. if (childVal && "development" !== 'production') {
  44014. assertObjectType(key, childVal, vm);
  44015. }
  44016. if (!parentVal) { return childVal }
  44017. var ret = Object.create(null);
  44018. extend(ret, parentVal);
  44019. if (childVal) { extend(ret, childVal); }
  44020. return ret
  44021. };
  44022. strats.provide = mergeDataOrFn;
  44023. /**
  44024. * Default strategy.
  44025. */
  44026. var defaultStrat = function (parentVal, childVal) {
  44027. return childVal === undefined
  44028. ? parentVal
  44029. : childVal
  44030. };
  44031. /**
  44032. * Validate component names
  44033. */
  44034. function checkComponents (options) {
  44035. for (var key in options.components) {
  44036. validateComponentName(key);
  44037. }
  44038. }
  44039. function validateComponentName (name) {
  44040. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  44041. warn(
  44042. 'Invalid component name: "' + name + '". Component names ' +
  44043. 'should conform to valid custom element name in html5 specification.'
  44044. );
  44045. }
  44046. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  44047. warn(
  44048. 'Do not use built-in or reserved HTML elements as component ' +
  44049. 'id: ' + name
  44050. );
  44051. }
  44052. }
  44053. /**
  44054. * Ensure all props option syntax are normalized into the
  44055. * Object-based format.
  44056. */
  44057. function normalizeProps (options, vm) {
  44058. var props = options.props;
  44059. if (!props) { return }
  44060. var res = {};
  44061. var i, val, name;
  44062. if (Array.isArray(props)) {
  44063. i = props.length;
  44064. while (i--) {
  44065. val = props[i];
  44066. if (typeof val === 'string') {
  44067. name = camelize(val);
  44068. res[name] = { type: null };
  44069. } else {
  44070. warn('props must be strings when using array syntax.');
  44071. }
  44072. }
  44073. } else if (isPlainObject(props)) {
  44074. for (var key in props) {
  44075. val = props[key];
  44076. name = camelize(key);
  44077. res[name] = isPlainObject(val)
  44078. ? val
  44079. : { type: val };
  44080. }
  44081. } else {
  44082. warn(
  44083. "Invalid value for option \"props\": expected an Array or an Object, " +
  44084. "but got " + (toRawType(props)) + ".",
  44085. vm
  44086. );
  44087. }
  44088. options.props = res;
  44089. }
  44090. /**
  44091. * Normalize all injections into Object-based format
  44092. */
  44093. function normalizeInject (options, vm) {
  44094. var inject = options.inject;
  44095. if (!inject) { return }
  44096. var normalized = options.inject = {};
  44097. if (Array.isArray(inject)) {
  44098. for (var i = 0; i < inject.length; i++) {
  44099. normalized[inject[i]] = { from: inject[i] };
  44100. }
  44101. } else if (isPlainObject(inject)) {
  44102. for (var key in inject) {
  44103. var val = inject[key];
  44104. normalized[key] = isPlainObject(val)
  44105. ? extend({ from: key }, val)
  44106. : { from: val };
  44107. }
  44108. } else {
  44109. warn(
  44110. "Invalid value for option \"inject\": expected an Array or an Object, " +
  44111. "but got " + (toRawType(inject)) + ".",
  44112. vm
  44113. );
  44114. }
  44115. }
  44116. /**
  44117. * Normalize raw function directives into object format.
  44118. */
  44119. function normalizeDirectives (options) {
  44120. var dirs = options.directives;
  44121. if (dirs) {
  44122. for (var key in dirs) {
  44123. var def$$1 = dirs[key];
  44124. if (typeof def$$1 === 'function') {
  44125. dirs[key] = { bind: def$$1, update: def$$1 };
  44126. }
  44127. }
  44128. }
  44129. }
  44130. function assertObjectType (name, value, vm) {
  44131. if (!isPlainObject(value)) {
  44132. warn(
  44133. "Invalid value for option \"" + name + "\": expected an Object, " +
  44134. "but got " + (toRawType(value)) + ".",
  44135. vm
  44136. );
  44137. }
  44138. }
  44139. /**
  44140. * Merge two option objects into a new one.
  44141. * Core utility used in both instantiation and inheritance.
  44142. */
  44143. function mergeOptions (
  44144. parent,
  44145. child,
  44146. vm
  44147. ) {
  44148. {
  44149. checkComponents(child);
  44150. }
  44151. if (typeof child === 'function') {
  44152. child = child.options;
  44153. }
  44154. normalizeProps(child, vm);
  44155. normalizeInject(child, vm);
  44156. normalizeDirectives(child);
  44157. // Apply extends and mixins on the child options,
  44158. // but only if it is a raw options object that isn't
  44159. // the result of another mergeOptions call.
  44160. // Only merged options has the _base property.
  44161. if (!child._base) {
  44162. if (child.extends) {
  44163. parent = mergeOptions(parent, child.extends, vm);
  44164. }
  44165. if (child.mixins) {
  44166. for (var i = 0, l = child.mixins.length; i < l; i++) {
  44167. parent = mergeOptions(parent, child.mixins[i], vm);
  44168. }
  44169. }
  44170. }
  44171. var options = {};
  44172. var key;
  44173. for (key in parent) {
  44174. mergeField(key);
  44175. }
  44176. for (key in child) {
  44177. if (!hasOwn(parent, key)) {
  44178. mergeField(key);
  44179. }
  44180. }
  44181. function mergeField (key) {
  44182. var strat = strats[key] || defaultStrat;
  44183. options[key] = strat(parent[key], child[key], vm, key);
  44184. }
  44185. return options
  44186. }
  44187. /**
  44188. * Resolve an asset.
  44189. * This function is used because child instances need access
  44190. * to assets defined in its ancestor chain.
  44191. */
  44192. function resolveAsset (
  44193. options,
  44194. type,
  44195. id,
  44196. warnMissing
  44197. ) {
  44198. /* istanbul ignore if */
  44199. if (typeof id !== 'string') {
  44200. return
  44201. }
  44202. var assets = options[type];
  44203. // check local registration variations first
  44204. if (hasOwn(assets, id)) { return assets[id] }
  44205. var camelizedId = camelize(id);
  44206. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  44207. var PascalCaseId = capitalize(camelizedId);
  44208. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  44209. // fallback to prototype chain
  44210. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  44211. if (warnMissing && !res) {
  44212. warn(
  44213. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  44214. options
  44215. );
  44216. }
  44217. return res
  44218. }
  44219. /* */
  44220. function validateProp (
  44221. key,
  44222. propOptions,
  44223. propsData,
  44224. vm
  44225. ) {
  44226. var prop = propOptions[key];
  44227. var absent = !hasOwn(propsData, key);
  44228. var value = propsData[key];
  44229. // boolean casting
  44230. var booleanIndex = getTypeIndex(Boolean, prop.type);
  44231. if (booleanIndex > -1) {
  44232. if (absent && !hasOwn(prop, 'default')) {
  44233. value = false;
  44234. } else if (value === '' || value === hyphenate(key)) {
  44235. // only cast empty string / same name to boolean if
  44236. // boolean has higher priority
  44237. var stringIndex = getTypeIndex(String, prop.type);
  44238. if (stringIndex < 0 || booleanIndex < stringIndex) {
  44239. value = true;
  44240. }
  44241. }
  44242. }
  44243. // check default value
  44244. if (value === undefined) {
  44245. value = getPropDefaultValue(vm, prop, key);
  44246. // since the default value is a fresh copy,
  44247. // make sure to observe it.
  44248. var prevShouldObserve = shouldObserve;
  44249. toggleObserving(true);
  44250. observe(value);
  44251. toggleObserving(prevShouldObserve);
  44252. }
  44253. {
  44254. assertProp(prop, key, value, vm, absent);
  44255. }
  44256. return value
  44257. }
  44258. /**
  44259. * Get the default value of a prop.
  44260. */
  44261. function getPropDefaultValue (vm, prop, key) {
  44262. // no default, return undefined
  44263. if (!hasOwn(prop, 'default')) {
  44264. return undefined
  44265. }
  44266. var def = prop.default;
  44267. // warn against non-factory defaults for Object & Array
  44268. if (isObject(def)) {
  44269. warn(
  44270. 'Invalid default value for prop "' + key + '": ' +
  44271. 'Props with type Object/Array must use a factory function ' +
  44272. 'to return the default value.',
  44273. vm
  44274. );
  44275. }
  44276. // the raw prop value was also undefined from previous render,
  44277. // return previous default value to avoid unnecessary watcher trigger
  44278. if (vm && vm.$options.propsData &&
  44279. vm.$options.propsData[key] === undefined &&
  44280. vm._props[key] !== undefined
  44281. ) {
  44282. return vm._props[key]
  44283. }
  44284. // call factory function for non-Function types
  44285. // a value is Function if its prototype is function even across different execution context
  44286. return typeof def === 'function' && getType(prop.type) !== 'Function'
  44287. ? def.call(vm)
  44288. : def
  44289. }
  44290. /**
  44291. * Assert whether a prop is valid.
  44292. */
  44293. function assertProp (
  44294. prop,
  44295. name,
  44296. value,
  44297. vm,
  44298. absent
  44299. ) {
  44300. if (prop.required && absent) {
  44301. warn(
  44302. 'Missing required prop: "' + name + '"',
  44303. vm
  44304. );
  44305. return
  44306. }
  44307. if (value == null && !prop.required) {
  44308. return
  44309. }
  44310. var type = prop.type;
  44311. var valid = !type || type === true;
  44312. var expectedTypes = [];
  44313. if (type) {
  44314. if (!Array.isArray(type)) {
  44315. type = [type];
  44316. }
  44317. for (var i = 0; i < type.length && !valid; i++) {
  44318. var assertedType = assertType(value, type[i]);
  44319. expectedTypes.push(assertedType.expectedType || '');
  44320. valid = assertedType.valid;
  44321. }
  44322. }
  44323. if (!valid) {
  44324. warn(
  44325. getInvalidTypeMessage(name, value, expectedTypes),
  44326. vm
  44327. );
  44328. return
  44329. }
  44330. var validator = prop.validator;
  44331. if (validator) {
  44332. if (!validator(value)) {
  44333. warn(
  44334. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  44335. vm
  44336. );
  44337. }
  44338. }
  44339. }
  44340. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  44341. function assertType (value, type) {
  44342. var valid;
  44343. var expectedType = getType(type);
  44344. if (simpleCheckRE.test(expectedType)) {
  44345. var t = typeof value;
  44346. valid = t === expectedType.toLowerCase();
  44347. // for primitive wrapper objects
  44348. if (!valid && t === 'object') {
  44349. valid = value instanceof type;
  44350. }
  44351. } else if (expectedType === 'Object') {
  44352. valid = isPlainObject(value);
  44353. } else if (expectedType === 'Array') {
  44354. valid = Array.isArray(value);
  44355. } else {
  44356. valid = value instanceof type;
  44357. }
  44358. return {
  44359. valid: valid,
  44360. expectedType: expectedType
  44361. }
  44362. }
  44363. /**
  44364. * Use function string name to check built-in types,
  44365. * because a simple equality check will fail when running
  44366. * across different vms / iframes.
  44367. */
  44368. function getType (fn) {
  44369. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  44370. return match ? match[1] : ''
  44371. }
  44372. function isSameType (a, b) {
  44373. return getType(a) === getType(b)
  44374. }
  44375. function getTypeIndex (type, expectedTypes) {
  44376. if (!Array.isArray(expectedTypes)) {
  44377. return isSameType(expectedTypes, type) ? 0 : -1
  44378. }
  44379. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  44380. if (isSameType(expectedTypes[i], type)) {
  44381. return i
  44382. }
  44383. }
  44384. return -1
  44385. }
  44386. function getInvalidTypeMessage (name, value, expectedTypes) {
  44387. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  44388. " Expected " + (expectedTypes.map(capitalize).join(', '));
  44389. var expectedType = expectedTypes[0];
  44390. var receivedType = toRawType(value);
  44391. var expectedValue = styleValue(value, expectedType);
  44392. var receivedValue = styleValue(value, receivedType);
  44393. // check if we need to specify expected value
  44394. if (expectedTypes.length === 1 &&
  44395. isExplicable(expectedType) &&
  44396. !isBoolean(expectedType, receivedType)) {
  44397. message += " with value " + expectedValue;
  44398. }
  44399. message += ", got " + receivedType + " ";
  44400. // check if we need to specify received value
  44401. if (isExplicable(receivedType)) {
  44402. message += "with value " + receivedValue + ".";
  44403. }
  44404. return message
  44405. }
  44406. function styleValue (value, type) {
  44407. if (type === 'String') {
  44408. return ("\"" + value + "\"")
  44409. } else if (type === 'Number') {
  44410. return ("" + (Number(value)))
  44411. } else {
  44412. return ("" + value)
  44413. }
  44414. }
  44415. function isExplicable (value) {
  44416. var explicitTypes = ['string', 'number', 'boolean'];
  44417. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  44418. }
  44419. function isBoolean () {
  44420. var args = [], len = arguments.length;
  44421. while ( len-- ) args[ len ] = arguments[ len ];
  44422. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  44423. }
  44424. /* */
  44425. function handleError (err, vm, info) {
  44426. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  44427. // See: https://github.com/vuejs/vuex/issues/1505
  44428. pushTarget();
  44429. try {
  44430. if (vm) {
  44431. var cur = vm;
  44432. while ((cur = cur.$parent)) {
  44433. var hooks = cur.$options.errorCaptured;
  44434. if (hooks) {
  44435. for (var i = 0; i < hooks.length; i++) {
  44436. try {
  44437. var capture = hooks[i].call(cur, err, vm, info) === false;
  44438. if (capture) { return }
  44439. } catch (e) {
  44440. globalHandleError(e, cur, 'errorCaptured hook');
  44441. }
  44442. }
  44443. }
  44444. }
  44445. }
  44446. globalHandleError(err, vm, info);
  44447. } finally {
  44448. popTarget();
  44449. }
  44450. }
  44451. function invokeWithErrorHandling (
  44452. handler,
  44453. context,
  44454. args,
  44455. vm,
  44456. info
  44457. ) {
  44458. var res;
  44459. try {
  44460. res = args ? handler.apply(context, args) : handler.call(context);
  44461. if (res && !res._isVue && isPromise(res) && !res._handled) {
  44462. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  44463. // issue #9511
  44464. // avoid catch triggering multiple times when nested calls
  44465. res._handled = true;
  44466. }
  44467. } catch (e) {
  44468. handleError(e, vm, info);
  44469. }
  44470. return res
  44471. }
  44472. function globalHandleError (err, vm, info) {
  44473. if (config.errorHandler) {
  44474. try {
  44475. return config.errorHandler.call(null, err, vm, info)
  44476. } catch (e) {
  44477. // if the user intentionally throws the original error in the handler,
  44478. // do not log it twice
  44479. if (e !== err) {
  44480. logError(e, null, 'config.errorHandler');
  44481. }
  44482. }
  44483. }
  44484. logError(err, vm, info);
  44485. }
  44486. function logError (err, vm, info) {
  44487. {
  44488. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  44489. }
  44490. /* istanbul ignore else */
  44491. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  44492. console.error(err);
  44493. } else {
  44494. throw err
  44495. }
  44496. }
  44497. /* */
  44498. var isUsingMicroTask = false;
  44499. var callbacks = [];
  44500. var pending = false;
  44501. function flushCallbacks () {
  44502. pending = false;
  44503. var copies = callbacks.slice(0);
  44504. callbacks.length = 0;
  44505. for (var i = 0; i < copies.length; i++) {
  44506. copies[i]();
  44507. }
  44508. }
  44509. // Here we have async deferring wrappers using microtasks.
  44510. // In 2.5 we used (macro) tasks (in combination with microtasks).
  44511. // However, it has subtle problems when state is changed right before repaint
  44512. // (e.g. #6813, out-in transitions).
  44513. // Also, using (macro) tasks in event handler would cause some weird behaviors
  44514. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  44515. // So we now use microtasks everywhere, again.
  44516. // A major drawback of this tradeoff is that there are some scenarios
  44517. // where microtasks have too high a priority and fire in between supposedly
  44518. // sequential events (e.g. #4521, #6690, which have workarounds)
  44519. // or even between bubbling of the same event (#6566).
  44520. var timerFunc;
  44521. // The nextTick behavior leverages the microtask queue, which can be accessed
  44522. // via either native Promise.then or MutationObserver.
  44523. // MutationObserver has wider support, however it is seriously bugged in
  44524. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  44525. // completely stops working after triggering a few times... so, if native
  44526. // Promise is available, we will use it:
  44527. /* istanbul ignore next, $flow-disable-line */
  44528. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  44529. var p = Promise.resolve();
  44530. timerFunc = function () {
  44531. p.then(flushCallbacks);
  44532. // In problematic UIWebViews, Promise.then doesn't completely break, but
  44533. // it can get stuck in a weird state where callbacks are pushed into the
  44534. // microtask queue but the queue isn't being flushed, until the browser
  44535. // needs to do some other work, e.g. handle a timer. Therefore we can
  44536. // "force" the microtask queue to be flushed by adding an empty timer.
  44537. if (isIOS) { setTimeout(noop); }
  44538. };
  44539. isUsingMicroTask = true;
  44540. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  44541. isNative(MutationObserver) ||
  44542. // PhantomJS and iOS 7.x
  44543. MutationObserver.toString() === '[object MutationObserverConstructor]'
  44544. )) {
  44545. // Use MutationObserver where native Promise is not available,
  44546. // e.g. PhantomJS, iOS7, Android 4.4
  44547. // (#6466 MutationObserver is unreliable in IE11)
  44548. var counter = 1;
  44549. var observer = new MutationObserver(flushCallbacks);
  44550. var textNode = document.createTextNode(String(counter));
  44551. observer.observe(textNode, {
  44552. characterData: true
  44553. });
  44554. timerFunc = function () {
  44555. counter = (counter + 1) % 2;
  44556. textNode.data = String(counter);
  44557. };
  44558. isUsingMicroTask = true;
  44559. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  44560. // Fallback to setImmediate.
  44561. // Technically it leverages the (macro) task queue,
  44562. // but it is still a better choice than setTimeout.
  44563. timerFunc = function () {
  44564. setImmediate(flushCallbacks);
  44565. };
  44566. } else {
  44567. // Fallback to setTimeout.
  44568. timerFunc = function () {
  44569. setTimeout(flushCallbacks, 0);
  44570. };
  44571. }
  44572. function nextTick (cb, ctx) {
  44573. var _resolve;
  44574. callbacks.push(function () {
  44575. if (cb) {
  44576. try {
  44577. cb.call(ctx);
  44578. } catch (e) {
  44579. handleError(e, ctx, 'nextTick');
  44580. }
  44581. } else if (_resolve) {
  44582. _resolve(ctx);
  44583. }
  44584. });
  44585. if (!pending) {
  44586. pending = true;
  44587. timerFunc();
  44588. }
  44589. // $flow-disable-line
  44590. if (!cb && typeof Promise !== 'undefined') {
  44591. return new Promise(function (resolve) {
  44592. _resolve = resolve;
  44593. })
  44594. }
  44595. }
  44596. /* */
  44597. var mark;
  44598. var measure;
  44599. {
  44600. var perf = inBrowser && window.performance;
  44601. /* istanbul ignore if */
  44602. if (
  44603. perf &&
  44604. perf.mark &&
  44605. perf.measure &&
  44606. perf.clearMarks &&
  44607. perf.clearMeasures
  44608. ) {
  44609. mark = function (tag) { return perf.mark(tag); };
  44610. measure = function (name, startTag, endTag) {
  44611. perf.measure(name, startTag, endTag);
  44612. perf.clearMarks(startTag);
  44613. perf.clearMarks(endTag);
  44614. // perf.clearMeasures(name)
  44615. };
  44616. }
  44617. }
  44618. /* not type checking this file because flow doesn't play well with Proxy */
  44619. var initProxy;
  44620. {
  44621. var allowedGlobals = makeMap(
  44622. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  44623. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  44624. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  44625. 'require' // for Webpack/Browserify
  44626. );
  44627. var warnNonPresent = function (target, key) {
  44628. warn(
  44629. "Property or method \"" + key + "\" is not defined on the instance but " +
  44630. 'referenced during render. Make sure that this property is reactive, ' +
  44631. 'either in the data option, or for class-based components, by ' +
  44632. 'initializing the property. ' +
  44633. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  44634. target
  44635. );
  44636. };
  44637. var warnReservedPrefix = function (target, key) {
  44638. warn(
  44639. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  44640. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  44641. 'prevent conflicts with Vue internals. ' +
  44642. 'See: https://vuejs.org/v2/api/#data',
  44643. target
  44644. );
  44645. };
  44646. var hasProxy =
  44647. typeof Proxy !== 'undefined' && isNative(Proxy);
  44648. if (hasProxy) {
  44649. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  44650. config.keyCodes = new Proxy(config.keyCodes, {
  44651. set: function set (target, key, value) {
  44652. if (isBuiltInModifier(key)) {
  44653. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  44654. return false
  44655. } else {
  44656. target[key] = value;
  44657. return true
  44658. }
  44659. }
  44660. });
  44661. }
  44662. var hasHandler = {
  44663. has: function has (target, key) {
  44664. var has = key in target;
  44665. var isAllowed = allowedGlobals(key) ||
  44666. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  44667. if (!has && !isAllowed) {
  44668. if (key in target.$data) { warnReservedPrefix(target, key); }
  44669. else { warnNonPresent(target, key); }
  44670. }
  44671. return has || !isAllowed
  44672. }
  44673. };
  44674. var getHandler = {
  44675. get: function get (target, key) {
  44676. if (typeof key === 'string' && !(key in target)) {
  44677. if (key in target.$data) { warnReservedPrefix(target, key); }
  44678. else { warnNonPresent(target, key); }
  44679. }
  44680. return target[key]
  44681. }
  44682. };
  44683. initProxy = function initProxy (vm) {
  44684. if (hasProxy) {
  44685. // determine which proxy handler to use
  44686. var options = vm.$options;
  44687. var handlers = options.render && options.render._withStripped
  44688. ? getHandler
  44689. : hasHandler;
  44690. vm._renderProxy = new Proxy(vm, handlers);
  44691. } else {
  44692. vm._renderProxy = vm;
  44693. }
  44694. };
  44695. }
  44696. /* */
  44697. var seenObjects = new _Set();
  44698. /**
  44699. * Recursively traverse an object to evoke all converted
  44700. * getters, so that every nested property inside the object
  44701. * is collected as a "deep" dependency.
  44702. */
  44703. function traverse (val) {
  44704. _traverse(val, seenObjects);
  44705. seenObjects.clear();
  44706. }
  44707. function _traverse (val, seen) {
  44708. var i, keys;
  44709. var isA = Array.isArray(val);
  44710. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  44711. return
  44712. }
  44713. if (val.__ob__) {
  44714. var depId = val.__ob__.dep.id;
  44715. if (seen.has(depId)) {
  44716. return
  44717. }
  44718. seen.add(depId);
  44719. }
  44720. if (isA) {
  44721. i = val.length;
  44722. while (i--) { _traverse(val[i], seen); }
  44723. } else {
  44724. keys = Object.keys(val);
  44725. i = keys.length;
  44726. while (i--) { _traverse(val[keys[i]], seen); }
  44727. }
  44728. }
  44729. /* */
  44730. var normalizeEvent = cached(function (name) {
  44731. var passive = name.charAt(0) === '&';
  44732. name = passive ? name.slice(1) : name;
  44733. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  44734. name = once$$1 ? name.slice(1) : name;
  44735. var capture = name.charAt(0) === '!';
  44736. name = capture ? name.slice(1) : name;
  44737. return {
  44738. name: name,
  44739. once: once$$1,
  44740. capture: capture,
  44741. passive: passive
  44742. }
  44743. });
  44744. function createFnInvoker (fns, vm) {
  44745. function invoker () {
  44746. var arguments$1 = arguments;
  44747. var fns = invoker.fns;
  44748. if (Array.isArray(fns)) {
  44749. var cloned = fns.slice();
  44750. for (var i = 0; i < cloned.length; i++) {
  44751. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  44752. }
  44753. } else {
  44754. // return handler return value for single handlers
  44755. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  44756. }
  44757. }
  44758. invoker.fns = fns;
  44759. return invoker
  44760. }
  44761. function updateListeners (
  44762. on,
  44763. oldOn,
  44764. add,
  44765. remove$$1,
  44766. createOnceHandler,
  44767. vm
  44768. ) {
  44769. var name, def$$1, cur, old, event;
  44770. for (name in on) {
  44771. def$$1 = cur = on[name];
  44772. old = oldOn[name];
  44773. event = normalizeEvent(name);
  44774. if (isUndef(cur)) {
  44775. warn(
  44776. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  44777. vm
  44778. );
  44779. } else if (isUndef(old)) {
  44780. if (isUndef(cur.fns)) {
  44781. cur = on[name] = createFnInvoker(cur, vm);
  44782. }
  44783. if (isTrue(event.once)) {
  44784. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  44785. }
  44786. add(event.name, cur, event.capture, event.passive, event.params);
  44787. } else if (cur !== old) {
  44788. old.fns = cur;
  44789. on[name] = old;
  44790. }
  44791. }
  44792. for (name in oldOn) {
  44793. if (isUndef(on[name])) {
  44794. event = normalizeEvent(name);
  44795. remove$$1(event.name, oldOn[name], event.capture);
  44796. }
  44797. }
  44798. }
  44799. /* */
  44800. function mergeVNodeHook (def, hookKey, hook) {
  44801. if (def instanceof VNode) {
  44802. def = def.data.hook || (def.data.hook = {});
  44803. }
  44804. var invoker;
  44805. var oldHook = def[hookKey];
  44806. function wrappedHook () {
  44807. hook.apply(this, arguments);
  44808. // important: remove merged hook to ensure it's called only once
  44809. // and prevent memory leak
  44810. remove(invoker.fns, wrappedHook);
  44811. }
  44812. if (isUndef(oldHook)) {
  44813. // no existing hook
  44814. invoker = createFnInvoker([wrappedHook]);
  44815. } else {
  44816. /* istanbul ignore if */
  44817. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  44818. // already a merged invoker
  44819. invoker = oldHook;
  44820. invoker.fns.push(wrappedHook);
  44821. } else {
  44822. // existing plain hook
  44823. invoker = createFnInvoker([oldHook, wrappedHook]);
  44824. }
  44825. }
  44826. invoker.merged = true;
  44827. def[hookKey] = invoker;
  44828. }
  44829. /* */
  44830. function extractPropsFromVNodeData (
  44831. data,
  44832. Ctor,
  44833. tag
  44834. ) {
  44835. // we are only extracting raw values here.
  44836. // validation and default values are handled in the child
  44837. // component itself.
  44838. var propOptions = Ctor.options.props;
  44839. if (isUndef(propOptions)) {
  44840. return
  44841. }
  44842. var res = {};
  44843. var attrs = data.attrs;
  44844. var props = data.props;
  44845. if (isDef(attrs) || isDef(props)) {
  44846. for (var key in propOptions) {
  44847. var altKey = hyphenate(key);
  44848. {
  44849. var keyInLowerCase = key.toLowerCase();
  44850. if (
  44851. key !== keyInLowerCase &&
  44852. attrs && hasOwn(attrs, keyInLowerCase)
  44853. ) {
  44854. tip(
  44855. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  44856. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  44857. " \"" + key + "\". " +
  44858. "Note that HTML attributes are case-insensitive and camelCased " +
  44859. "props need to use their kebab-case equivalents when using in-DOM " +
  44860. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  44861. );
  44862. }
  44863. }
  44864. checkProp(res, props, key, altKey, true) ||
  44865. checkProp(res, attrs, key, altKey, false);
  44866. }
  44867. }
  44868. return res
  44869. }
  44870. function checkProp (
  44871. res,
  44872. hash,
  44873. key,
  44874. altKey,
  44875. preserve
  44876. ) {
  44877. if (isDef(hash)) {
  44878. if (hasOwn(hash, key)) {
  44879. res[key] = hash[key];
  44880. if (!preserve) {
  44881. delete hash[key];
  44882. }
  44883. return true
  44884. } else if (hasOwn(hash, altKey)) {
  44885. res[key] = hash[altKey];
  44886. if (!preserve) {
  44887. delete hash[altKey];
  44888. }
  44889. return true
  44890. }
  44891. }
  44892. return false
  44893. }
  44894. /* */
  44895. // The template compiler attempts to minimize the need for normalization by
  44896. // statically analyzing the template at compile time.
  44897. //
  44898. // For plain HTML markup, normalization can be completely skipped because the
  44899. // generated render function is guaranteed to return Array<VNode>. There are
  44900. // two cases where extra normalization is needed:
  44901. // 1. When the children contains components - because a functional component
  44902. // may return an Array instead of a single root. In this case, just a simple
  44903. // normalization is needed - if any child is an Array, we flatten the whole
  44904. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  44905. // because functional components already normalize their own children.
  44906. function simpleNormalizeChildren (children) {
  44907. for (var i = 0; i < children.length; i++) {
  44908. if (Array.isArray(children[i])) {
  44909. return Array.prototype.concat.apply([], children)
  44910. }
  44911. }
  44912. return children
  44913. }
  44914. // 2. When the children contains constructs that always generated nested Arrays,
  44915. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  44916. // with hand-written render functions / JSX. In such cases a full normalization
  44917. // is needed to cater to all possible types of children values.
  44918. function normalizeChildren (children) {
  44919. return isPrimitive(children)
  44920. ? [createTextVNode(children)]
  44921. : Array.isArray(children)
  44922. ? normalizeArrayChildren(children)
  44923. : undefined
  44924. }
  44925. function isTextNode (node) {
  44926. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  44927. }
  44928. function normalizeArrayChildren (children, nestedIndex) {
  44929. var res = [];
  44930. var i, c, lastIndex, last;
  44931. for (i = 0; i < children.length; i++) {
  44932. c = children[i];
  44933. if (isUndef(c) || typeof c === 'boolean') { continue }
  44934. lastIndex = res.length - 1;
  44935. last = res[lastIndex];
  44936. // nested
  44937. if (Array.isArray(c)) {
  44938. if (c.length > 0) {
  44939. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  44940. // merge adjacent text nodes
  44941. if (isTextNode(c[0]) && isTextNode(last)) {
  44942. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  44943. c.shift();
  44944. }
  44945. res.push.apply(res, c);
  44946. }
  44947. } else if (isPrimitive(c)) {
  44948. if (isTextNode(last)) {
  44949. // merge adjacent text nodes
  44950. // this is necessary for SSR hydration because text nodes are
  44951. // essentially merged when rendered to HTML strings
  44952. res[lastIndex] = createTextVNode(last.text + c);
  44953. } else if (c !== '') {
  44954. // convert primitive to vnode
  44955. res.push(createTextVNode(c));
  44956. }
  44957. } else {
  44958. if (isTextNode(c) && isTextNode(last)) {
  44959. // merge adjacent text nodes
  44960. res[lastIndex] = createTextVNode(last.text + c.text);
  44961. } else {
  44962. // default key for nested array children (likely generated by v-for)
  44963. if (isTrue(children._isVList) &&
  44964. isDef(c.tag) &&
  44965. isUndef(c.key) &&
  44966. isDef(nestedIndex)) {
  44967. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  44968. }
  44969. res.push(c);
  44970. }
  44971. }
  44972. }
  44973. return res
  44974. }
  44975. /* */
  44976. function initProvide (vm) {
  44977. var provide = vm.$options.provide;
  44978. if (provide) {
  44979. vm._provided = typeof provide === 'function'
  44980. ? provide.call(vm)
  44981. : provide;
  44982. }
  44983. }
  44984. function initInjections (vm) {
  44985. var result = resolveInject(vm.$options.inject, vm);
  44986. if (result) {
  44987. toggleObserving(false);
  44988. Object.keys(result).forEach(function (key) {
  44989. /* istanbul ignore else */
  44990. {
  44991. defineReactive$$1(vm, key, result[key], function () {
  44992. warn(
  44993. "Avoid mutating an injected value directly since the changes will be " +
  44994. "overwritten whenever the provided component re-renders. " +
  44995. "injection being mutated: \"" + key + "\"",
  44996. vm
  44997. );
  44998. });
  44999. }
  45000. });
  45001. toggleObserving(true);
  45002. }
  45003. }
  45004. function resolveInject (inject, vm) {
  45005. if (inject) {
  45006. // inject is :any because flow is not smart enough to figure out cached
  45007. var result = Object.create(null);
  45008. var keys = hasSymbol
  45009. ? Reflect.ownKeys(inject)
  45010. : Object.keys(inject);
  45011. for (var i = 0; i < keys.length; i++) {
  45012. var key = keys[i];
  45013. // #6574 in case the inject object is observed...
  45014. if (key === '__ob__') { continue }
  45015. var provideKey = inject[key].from;
  45016. var source = vm;
  45017. while (source) {
  45018. if (source._provided && hasOwn(source._provided, provideKey)) {
  45019. result[key] = source._provided[provideKey];
  45020. break
  45021. }
  45022. source = source.$parent;
  45023. }
  45024. if (!source) {
  45025. if ('default' in inject[key]) {
  45026. var provideDefault = inject[key].default;
  45027. result[key] = typeof provideDefault === 'function'
  45028. ? provideDefault.call(vm)
  45029. : provideDefault;
  45030. } else {
  45031. warn(("Injection \"" + key + "\" not found"), vm);
  45032. }
  45033. }
  45034. }
  45035. return result
  45036. }
  45037. }
  45038. /* */
  45039. /**
  45040. * Runtime helper for resolving raw children VNodes into a slot object.
  45041. */
  45042. function resolveSlots (
  45043. children,
  45044. context
  45045. ) {
  45046. if (!children || !children.length) {
  45047. return {}
  45048. }
  45049. var slots = {};
  45050. for (var i = 0, l = children.length; i < l; i++) {
  45051. var child = children[i];
  45052. var data = child.data;
  45053. // remove slot attribute if the node is resolved as a Vue slot node
  45054. if (data && data.attrs && data.attrs.slot) {
  45055. delete data.attrs.slot;
  45056. }
  45057. // named slots should only be respected if the vnode was rendered in the
  45058. // same context.
  45059. if ((child.context === context || child.fnContext === context) &&
  45060. data && data.slot != null
  45061. ) {
  45062. var name = data.slot;
  45063. var slot = (slots[name] || (slots[name] = []));
  45064. if (child.tag === 'template') {
  45065. slot.push.apply(slot, child.children || []);
  45066. } else {
  45067. slot.push(child);
  45068. }
  45069. } else {
  45070. (slots.default || (slots.default = [])).push(child);
  45071. }
  45072. }
  45073. // ignore slots that contains only whitespace
  45074. for (var name$1 in slots) {
  45075. if (slots[name$1].every(isWhitespace)) {
  45076. delete slots[name$1];
  45077. }
  45078. }
  45079. return slots
  45080. }
  45081. function isWhitespace (node) {
  45082. return (node.isComment && !node.asyncFactory) || node.text === ' '
  45083. }
  45084. /* */
  45085. function normalizeScopedSlots (
  45086. slots,
  45087. normalSlots,
  45088. prevSlots
  45089. ) {
  45090. var res;
  45091. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  45092. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  45093. var key = slots && slots.$key;
  45094. if (!slots) {
  45095. res = {};
  45096. } else if (slots._normalized) {
  45097. // fast path 1: child component re-render only, parent did not change
  45098. return slots._normalized
  45099. } else if (
  45100. isStable &&
  45101. prevSlots &&
  45102. prevSlots !== emptyObject &&
  45103. key === prevSlots.$key &&
  45104. !hasNormalSlots &&
  45105. !prevSlots.$hasNormal
  45106. ) {
  45107. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  45108. // only need to normalize once
  45109. return prevSlots
  45110. } else {
  45111. res = {};
  45112. for (var key$1 in slots) {
  45113. if (slots[key$1] && key$1[0] !== '$') {
  45114. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  45115. }
  45116. }
  45117. }
  45118. // expose normal slots on scopedSlots
  45119. for (var key$2 in normalSlots) {
  45120. if (!(key$2 in res)) {
  45121. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  45122. }
  45123. }
  45124. // avoriaz seems to mock a non-extensible $scopedSlots object
  45125. // and when that is passed down this would cause an error
  45126. if (slots && Object.isExtensible(slots)) {
  45127. (slots)._normalized = res;
  45128. }
  45129. def(res, '$stable', isStable);
  45130. def(res, '$key', key);
  45131. def(res, '$hasNormal', hasNormalSlots);
  45132. return res
  45133. }
  45134. function normalizeScopedSlot(normalSlots, key, fn) {
  45135. var normalized = function () {
  45136. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  45137. res = res && typeof res === 'object' && !Array.isArray(res)
  45138. ? [res] // single vnode
  45139. : normalizeChildren(res);
  45140. return res && (
  45141. res.length === 0 ||
  45142. (res.length === 1 && res[0].isComment) // #9658
  45143. ) ? undefined
  45144. : res
  45145. };
  45146. // this is a slot using the new v-slot syntax without scope. although it is
  45147. // compiled as a scoped slot, render fn users would expect it to be present
  45148. // on this.$slots because the usage is semantically a normal slot.
  45149. if (fn.proxy) {
  45150. Object.defineProperty(normalSlots, key, {
  45151. get: normalized,
  45152. enumerable: true,
  45153. configurable: true
  45154. });
  45155. }
  45156. return normalized
  45157. }
  45158. function proxyNormalSlot(slots, key) {
  45159. return function () { return slots[key]; }
  45160. }
  45161. /* */
  45162. /**
  45163. * Runtime helper for rendering v-for lists.
  45164. */
  45165. function renderList (
  45166. val,
  45167. render
  45168. ) {
  45169. var ret, i, l, keys, key;
  45170. if (Array.isArray(val) || typeof val === 'string') {
  45171. ret = new Array(val.length);
  45172. for (i = 0, l = val.length; i < l; i++) {
  45173. ret[i] = render(val[i], i);
  45174. }
  45175. } else if (typeof val === 'number') {
  45176. ret = new Array(val);
  45177. for (i = 0; i < val; i++) {
  45178. ret[i] = render(i + 1, i);
  45179. }
  45180. } else if (isObject(val)) {
  45181. if (hasSymbol && val[Symbol.iterator]) {
  45182. ret = [];
  45183. var iterator = val[Symbol.iterator]();
  45184. var result = iterator.next();
  45185. while (!result.done) {
  45186. ret.push(render(result.value, ret.length));
  45187. result = iterator.next();
  45188. }
  45189. } else {
  45190. keys = Object.keys(val);
  45191. ret = new Array(keys.length);
  45192. for (i = 0, l = keys.length; i < l; i++) {
  45193. key = keys[i];
  45194. ret[i] = render(val[key], key, i);
  45195. }
  45196. }
  45197. }
  45198. if (!isDef(ret)) {
  45199. ret = [];
  45200. }
  45201. (ret)._isVList = true;
  45202. return ret
  45203. }
  45204. /* */
  45205. /**
  45206. * Runtime helper for rendering <slot>
  45207. */
  45208. function renderSlot (
  45209. name,
  45210. fallback,
  45211. props,
  45212. bindObject
  45213. ) {
  45214. var scopedSlotFn = this.$scopedSlots[name];
  45215. var nodes;
  45216. if (scopedSlotFn) { // scoped slot
  45217. props = props || {};
  45218. if (bindObject) {
  45219. if (!isObject(bindObject)) {
  45220. warn(
  45221. 'slot v-bind without argument expects an Object',
  45222. this
  45223. );
  45224. }
  45225. props = extend(extend({}, bindObject), props);
  45226. }
  45227. nodes = scopedSlotFn(props) || fallback;
  45228. } else {
  45229. nodes = this.$slots[name] || fallback;
  45230. }
  45231. var target = props && props.slot;
  45232. if (target) {
  45233. return this.$createElement('template', { slot: target }, nodes)
  45234. } else {
  45235. return nodes
  45236. }
  45237. }
  45238. /* */
  45239. /**
  45240. * Runtime helper for resolving filters
  45241. */
  45242. function resolveFilter (id) {
  45243. return resolveAsset(this.$options, 'filters', id, true) || identity
  45244. }
  45245. /* */
  45246. function isKeyNotMatch (expect, actual) {
  45247. if (Array.isArray(expect)) {
  45248. return expect.indexOf(actual) === -1
  45249. } else {
  45250. return expect !== actual
  45251. }
  45252. }
  45253. /**
  45254. * Runtime helper for checking keyCodes from config.
  45255. * exposed as Vue.prototype._k
  45256. * passing in eventKeyName as last argument separately for backwards compat
  45257. */
  45258. function checkKeyCodes (
  45259. eventKeyCode,
  45260. key,
  45261. builtInKeyCode,
  45262. eventKeyName,
  45263. builtInKeyName
  45264. ) {
  45265. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  45266. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  45267. return isKeyNotMatch(builtInKeyName, eventKeyName)
  45268. } else if (mappedKeyCode) {
  45269. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  45270. } else if (eventKeyName) {
  45271. return hyphenate(eventKeyName) !== key
  45272. }
  45273. }
  45274. /* */
  45275. /**
  45276. * Runtime helper for merging v-bind="object" into a VNode's data.
  45277. */
  45278. function bindObjectProps (
  45279. data,
  45280. tag,
  45281. value,
  45282. asProp,
  45283. isSync
  45284. ) {
  45285. if (value) {
  45286. if (!isObject(value)) {
  45287. warn(
  45288. 'v-bind without argument expects an Object or Array value',
  45289. this
  45290. );
  45291. } else {
  45292. if (Array.isArray(value)) {
  45293. value = toObject(value);
  45294. }
  45295. var hash;
  45296. var loop = function ( key ) {
  45297. if (
  45298. key === 'class' ||
  45299. key === 'style' ||
  45300. isReservedAttribute(key)
  45301. ) {
  45302. hash = data;
  45303. } else {
  45304. var type = data.attrs && data.attrs.type;
  45305. hash = asProp || config.mustUseProp(tag, type, key)
  45306. ? data.domProps || (data.domProps = {})
  45307. : data.attrs || (data.attrs = {});
  45308. }
  45309. var camelizedKey = camelize(key);
  45310. var hyphenatedKey = hyphenate(key);
  45311. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  45312. hash[key] = value[key];
  45313. if (isSync) {
  45314. var on = data.on || (data.on = {});
  45315. on[("update:" + key)] = function ($event) {
  45316. value[key] = $event;
  45317. };
  45318. }
  45319. }
  45320. };
  45321. for (var key in value) loop( key );
  45322. }
  45323. }
  45324. return data
  45325. }
  45326. /* */
  45327. /**
  45328. * Runtime helper for rendering static trees.
  45329. */
  45330. function renderStatic (
  45331. index,
  45332. isInFor
  45333. ) {
  45334. var cached = this._staticTrees || (this._staticTrees = []);
  45335. var tree = cached[index];
  45336. // if has already-rendered static tree and not inside v-for,
  45337. // we can reuse the same tree.
  45338. if (tree && !isInFor) {
  45339. return tree
  45340. }
  45341. // otherwise, render a fresh tree.
  45342. tree = cached[index] = this.$options.staticRenderFns[index].call(
  45343. this._renderProxy,
  45344. null,
  45345. this // for render fns generated for functional component templates
  45346. );
  45347. markStatic(tree, ("__static__" + index), false);
  45348. return tree
  45349. }
  45350. /**
  45351. * Runtime helper for v-once.
  45352. * Effectively it means marking the node as static with a unique key.
  45353. */
  45354. function markOnce (
  45355. tree,
  45356. index,
  45357. key
  45358. ) {
  45359. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  45360. return tree
  45361. }
  45362. function markStatic (
  45363. tree,
  45364. key,
  45365. isOnce
  45366. ) {
  45367. if (Array.isArray(tree)) {
  45368. for (var i = 0; i < tree.length; i++) {
  45369. if (tree[i] && typeof tree[i] !== 'string') {
  45370. markStaticNode(tree[i], (key + "_" + i), isOnce);
  45371. }
  45372. }
  45373. } else {
  45374. markStaticNode(tree, key, isOnce);
  45375. }
  45376. }
  45377. function markStaticNode (node, key, isOnce) {
  45378. node.isStatic = true;
  45379. node.key = key;
  45380. node.isOnce = isOnce;
  45381. }
  45382. /* */
  45383. function bindObjectListeners (data, value) {
  45384. if (value) {
  45385. if (!isPlainObject(value)) {
  45386. warn(
  45387. 'v-on without argument expects an Object value',
  45388. this
  45389. );
  45390. } else {
  45391. var on = data.on = data.on ? extend({}, data.on) : {};
  45392. for (var key in value) {
  45393. var existing = on[key];
  45394. var ours = value[key];
  45395. on[key] = existing ? [].concat(existing, ours) : ours;
  45396. }
  45397. }
  45398. }
  45399. return data
  45400. }
  45401. /* */
  45402. function resolveScopedSlots (
  45403. fns, // see flow/vnode
  45404. res,
  45405. // the following are added in 2.6
  45406. hasDynamicKeys,
  45407. contentHashKey
  45408. ) {
  45409. res = res || { $stable: !hasDynamicKeys };
  45410. for (var i = 0; i < fns.length; i++) {
  45411. var slot = fns[i];
  45412. if (Array.isArray(slot)) {
  45413. resolveScopedSlots(slot, res, hasDynamicKeys);
  45414. } else if (slot) {
  45415. // marker for reverse proxying v-slot without scope on this.$slots
  45416. if (slot.proxy) {
  45417. slot.fn.proxy = true;
  45418. }
  45419. res[slot.key] = slot.fn;
  45420. }
  45421. }
  45422. if (contentHashKey) {
  45423. (res).$key = contentHashKey;
  45424. }
  45425. return res
  45426. }
  45427. /* */
  45428. function bindDynamicKeys (baseObj, values) {
  45429. for (var i = 0; i < values.length; i += 2) {
  45430. var key = values[i];
  45431. if (typeof key === 'string' && key) {
  45432. baseObj[values[i]] = values[i + 1];
  45433. } else if (key !== '' && key !== null) {
  45434. // null is a special value for explicitly removing a binding
  45435. warn(
  45436. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  45437. this
  45438. );
  45439. }
  45440. }
  45441. return baseObj
  45442. }
  45443. // helper to dynamically append modifier runtime markers to event names.
  45444. // ensure only append when value is already string, otherwise it will be cast
  45445. // to string and cause the type check to miss.
  45446. function prependModifier (value, symbol) {
  45447. return typeof value === 'string' ? symbol + value : value
  45448. }
  45449. /* */
  45450. function installRenderHelpers (target) {
  45451. target._o = markOnce;
  45452. target._n = toNumber;
  45453. target._s = toString;
  45454. target._l = renderList;
  45455. target._t = renderSlot;
  45456. target._q = looseEqual;
  45457. target._i = looseIndexOf;
  45458. target._m = renderStatic;
  45459. target._f = resolveFilter;
  45460. target._k = checkKeyCodes;
  45461. target._b = bindObjectProps;
  45462. target._v = createTextVNode;
  45463. target._e = createEmptyVNode;
  45464. target._u = resolveScopedSlots;
  45465. target._g = bindObjectListeners;
  45466. target._d = bindDynamicKeys;
  45467. target._p = prependModifier;
  45468. }
  45469. /* */
  45470. function FunctionalRenderContext (
  45471. data,
  45472. props,
  45473. children,
  45474. parent,
  45475. Ctor
  45476. ) {
  45477. var this$1 = this;
  45478. var options = Ctor.options;
  45479. // ensure the createElement function in functional components
  45480. // gets a unique context - this is necessary for correct named slot check
  45481. var contextVm;
  45482. if (hasOwn(parent, '_uid')) {
  45483. contextVm = Object.create(parent);
  45484. // $flow-disable-line
  45485. contextVm._original = parent;
  45486. } else {
  45487. // the context vm passed in is a functional context as well.
  45488. // in this case we want to make sure we are able to get a hold to the
  45489. // real context instance.
  45490. contextVm = parent;
  45491. // $flow-disable-line
  45492. parent = parent._original;
  45493. }
  45494. var isCompiled = isTrue(options._compiled);
  45495. var needNormalization = !isCompiled;
  45496. this.data = data;
  45497. this.props = props;
  45498. this.children = children;
  45499. this.parent = parent;
  45500. this.listeners = data.on || emptyObject;
  45501. this.injections = resolveInject(options.inject, parent);
  45502. this.slots = function () {
  45503. if (!this$1.$slots) {
  45504. normalizeScopedSlots(
  45505. data.scopedSlots,
  45506. this$1.$slots = resolveSlots(children, parent)
  45507. );
  45508. }
  45509. return this$1.$slots
  45510. };
  45511. Object.defineProperty(this, 'scopedSlots', ({
  45512. enumerable: true,
  45513. get: function get () {
  45514. return normalizeScopedSlots(data.scopedSlots, this.slots())
  45515. }
  45516. }));
  45517. // support for compiled functional template
  45518. if (isCompiled) {
  45519. // exposing $options for renderStatic()
  45520. this.$options = options;
  45521. // pre-resolve slots for renderSlot()
  45522. this.$slots = this.slots();
  45523. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  45524. }
  45525. if (options._scopeId) {
  45526. this._c = function (a, b, c, d) {
  45527. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  45528. if (vnode && !Array.isArray(vnode)) {
  45529. vnode.fnScopeId = options._scopeId;
  45530. vnode.fnContext = parent;
  45531. }
  45532. return vnode
  45533. };
  45534. } else {
  45535. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  45536. }
  45537. }
  45538. installRenderHelpers(FunctionalRenderContext.prototype);
  45539. function createFunctionalComponent (
  45540. Ctor,
  45541. propsData,
  45542. data,
  45543. contextVm,
  45544. children
  45545. ) {
  45546. var options = Ctor.options;
  45547. var props = {};
  45548. var propOptions = options.props;
  45549. if (isDef(propOptions)) {
  45550. for (var key in propOptions) {
  45551. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  45552. }
  45553. } else {
  45554. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  45555. if (isDef(data.props)) { mergeProps(props, data.props); }
  45556. }
  45557. var renderContext = new FunctionalRenderContext(
  45558. data,
  45559. props,
  45560. children,
  45561. contextVm,
  45562. Ctor
  45563. );
  45564. var vnode = options.render.call(null, renderContext._c, renderContext);
  45565. if (vnode instanceof VNode) {
  45566. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  45567. } else if (Array.isArray(vnode)) {
  45568. var vnodes = normalizeChildren(vnode) || [];
  45569. var res = new Array(vnodes.length);
  45570. for (var i = 0; i < vnodes.length; i++) {
  45571. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  45572. }
  45573. return res
  45574. }
  45575. }
  45576. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  45577. // #7817 clone node before setting fnContext, otherwise if the node is reused
  45578. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  45579. // that should not be matched to match.
  45580. var clone = cloneVNode(vnode);
  45581. clone.fnContext = contextVm;
  45582. clone.fnOptions = options;
  45583. {
  45584. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  45585. }
  45586. if (data.slot) {
  45587. (clone.data || (clone.data = {})).slot = data.slot;
  45588. }
  45589. return clone
  45590. }
  45591. function mergeProps (to, from) {
  45592. for (var key in from) {
  45593. to[camelize(key)] = from[key];
  45594. }
  45595. }
  45596. /* */
  45597. /* */
  45598. /* */
  45599. /* */
  45600. // inline hooks to be invoked on component VNodes during patch
  45601. var componentVNodeHooks = {
  45602. init: function init (vnode, hydrating) {
  45603. if (
  45604. vnode.componentInstance &&
  45605. !vnode.componentInstance._isDestroyed &&
  45606. vnode.data.keepAlive
  45607. ) {
  45608. // kept-alive components, treat as a patch
  45609. var mountedNode = vnode; // work around flow
  45610. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  45611. } else {
  45612. var child = vnode.componentInstance = createComponentInstanceForVnode(
  45613. vnode,
  45614. activeInstance
  45615. );
  45616. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  45617. }
  45618. },
  45619. prepatch: function prepatch (oldVnode, vnode) {
  45620. var options = vnode.componentOptions;
  45621. var child = vnode.componentInstance = oldVnode.componentInstance;
  45622. updateChildComponent(
  45623. child,
  45624. options.propsData, // updated props
  45625. options.listeners, // updated listeners
  45626. vnode, // new parent vnode
  45627. options.children // new children
  45628. );
  45629. },
  45630. insert: function insert (vnode) {
  45631. var context = vnode.context;
  45632. var componentInstance = vnode.componentInstance;
  45633. if (!componentInstance._isMounted) {
  45634. componentInstance._isMounted = true;
  45635. callHook(componentInstance, 'mounted');
  45636. }
  45637. if (vnode.data.keepAlive) {
  45638. if (context._isMounted) {
  45639. // vue-router#1212
  45640. // During updates, a kept-alive component's child components may
  45641. // change, so directly walking the tree here may call activated hooks
  45642. // on incorrect children. Instead we push them into a queue which will
  45643. // be processed after the whole patch process ended.
  45644. queueActivatedComponent(componentInstance);
  45645. } else {
  45646. activateChildComponent(componentInstance, true /* direct */);
  45647. }
  45648. }
  45649. },
  45650. destroy: function destroy (vnode) {
  45651. var componentInstance = vnode.componentInstance;
  45652. if (!componentInstance._isDestroyed) {
  45653. if (!vnode.data.keepAlive) {
  45654. componentInstance.$destroy();
  45655. } else {
  45656. deactivateChildComponent(componentInstance, true /* direct */);
  45657. }
  45658. }
  45659. }
  45660. };
  45661. var hooksToMerge = Object.keys(componentVNodeHooks);
  45662. function createComponent (
  45663. Ctor,
  45664. data,
  45665. context,
  45666. children,
  45667. tag
  45668. ) {
  45669. if (isUndef(Ctor)) {
  45670. return
  45671. }
  45672. var baseCtor = context.$options._base;
  45673. // plain options object: turn it into a constructor
  45674. if (isObject(Ctor)) {
  45675. Ctor = baseCtor.extend(Ctor);
  45676. }
  45677. // if at this stage it's not a constructor or an async component factory,
  45678. // reject.
  45679. if (typeof Ctor !== 'function') {
  45680. {
  45681. warn(("Invalid Component definition: " + (String(Ctor))), context);
  45682. }
  45683. return
  45684. }
  45685. // async component
  45686. var asyncFactory;
  45687. if (isUndef(Ctor.cid)) {
  45688. asyncFactory = Ctor;
  45689. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  45690. if (Ctor === undefined) {
  45691. // return a placeholder node for async component, which is rendered
  45692. // as a comment node but preserves all the raw information for the node.
  45693. // the information will be used for async server-rendering and hydration.
  45694. return createAsyncPlaceholder(
  45695. asyncFactory,
  45696. data,
  45697. context,
  45698. children,
  45699. tag
  45700. )
  45701. }
  45702. }
  45703. data = data || {};
  45704. // resolve constructor options in case global mixins are applied after
  45705. // component constructor creation
  45706. resolveConstructorOptions(Ctor);
  45707. // transform component v-model data into props & events
  45708. if (isDef(data.model)) {
  45709. transformModel(Ctor.options, data);
  45710. }
  45711. // extract props
  45712. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  45713. // functional component
  45714. if (isTrue(Ctor.options.functional)) {
  45715. return createFunctionalComponent(Ctor, propsData, data, context, children)
  45716. }
  45717. // extract listeners, since these needs to be treated as
  45718. // child component listeners instead of DOM listeners
  45719. var listeners = data.on;
  45720. // replace with listeners with .native modifier
  45721. // so it gets processed during parent component patch.
  45722. data.on = data.nativeOn;
  45723. if (isTrue(Ctor.options.abstract)) {
  45724. // abstract components do not keep anything
  45725. // other than props & listeners & slot
  45726. // work around flow
  45727. var slot = data.slot;
  45728. data = {};
  45729. if (slot) {
  45730. data.slot = slot;
  45731. }
  45732. }
  45733. // install component management hooks onto the placeholder node
  45734. installComponentHooks(data);
  45735. // return a placeholder vnode
  45736. var name = Ctor.options.name || tag;
  45737. var vnode = new VNode(
  45738. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  45739. data, undefined, undefined, undefined, context,
  45740. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  45741. asyncFactory
  45742. );
  45743. return vnode
  45744. }
  45745. function createComponentInstanceForVnode (
  45746. vnode, // we know it's MountedComponentVNode but flow doesn't
  45747. parent // activeInstance in lifecycle state
  45748. ) {
  45749. var options = {
  45750. _isComponent: true,
  45751. _parentVnode: vnode,
  45752. parent: parent
  45753. };
  45754. // check inline-template render functions
  45755. var inlineTemplate = vnode.data.inlineTemplate;
  45756. if (isDef(inlineTemplate)) {
  45757. options.render = inlineTemplate.render;
  45758. options.staticRenderFns = inlineTemplate.staticRenderFns;
  45759. }
  45760. return new vnode.componentOptions.Ctor(options)
  45761. }
  45762. function installComponentHooks (data) {
  45763. var hooks = data.hook || (data.hook = {});
  45764. for (var i = 0; i < hooksToMerge.length; i++) {
  45765. var key = hooksToMerge[i];
  45766. var existing = hooks[key];
  45767. var toMerge = componentVNodeHooks[key];
  45768. if (existing !== toMerge && !(existing && existing._merged)) {
  45769. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  45770. }
  45771. }
  45772. }
  45773. function mergeHook$1 (f1, f2) {
  45774. var merged = function (a, b) {
  45775. // flow complains about extra args which is why we use any
  45776. f1(a, b);
  45777. f2(a, b);
  45778. };
  45779. merged._merged = true;
  45780. return merged
  45781. }
  45782. // transform component v-model info (value and callback) into
  45783. // prop and event handler respectively.
  45784. function transformModel (options, data) {
  45785. var prop = (options.model && options.model.prop) || 'value';
  45786. var event = (options.model && options.model.event) || 'input'
  45787. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  45788. var on = data.on || (data.on = {});
  45789. var existing = on[event];
  45790. var callback = data.model.callback;
  45791. if (isDef(existing)) {
  45792. if (
  45793. Array.isArray(existing)
  45794. ? existing.indexOf(callback) === -1
  45795. : existing !== callback
  45796. ) {
  45797. on[event] = [callback].concat(existing);
  45798. }
  45799. } else {
  45800. on[event] = callback;
  45801. }
  45802. }
  45803. /* */
  45804. var SIMPLE_NORMALIZE = 1;
  45805. var ALWAYS_NORMALIZE = 2;
  45806. // wrapper function for providing a more flexible interface
  45807. // without getting yelled at by flow
  45808. function createElement (
  45809. context,
  45810. tag,
  45811. data,
  45812. children,
  45813. normalizationType,
  45814. alwaysNormalize
  45815. ) {
  45816. if (Array.isArray(data) || isPrimitive(data)) {
  45817. normalizationType = children;
  45818. children = data;
  45819. data = undefined;
  45820. }
  45821. if (isTrue(alwaysNormalize)) {
  45822. normalizationType = ALWAYS_NORMALIZE;
  45823. }
  45824. return _createElement(context, tag, data, children, normalizationType)
  45825. }
  45826. function _createElement (
  45827. context,
  45828. tag,
  45829. data,
  45830. children,
  45831. normalizationType
  45832. ) {
  45833. if (isDef(data) && isDef((data).__ob__)) {
  45834. warn(
  45835. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  45836. 'Always create fresh vnode data objects in each render!',
  45837. context
  45838. );
  45839. return createEmptyVNode()
  45840. }
  45841. // object syntax in v-bind
  45842. if (isDef(data) && isDef(data.is)) {
  45843. tag = data.is;
  45844. }
  45845. if (!tag) {
  45846. // in case of component :is set to falsy value
  45847. return createEmptyVNode()
  45848. }
  45849. // warn against non-primitive key
  45850. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  45851. ) {
  45852. {
  45853. warn(
  45854. 'Avoid using non-primitive value as key, ' +
  45855. 'use string/number value instead.',
  45856. context
  45857. );
  45858. }
  45859. }
  45860. // support single function children as default scoped slot
  45861. if (Array.isArray(children) &&
  45862. typeof children[0] === 'function'
  45863. ) {
  45864. data = data || {};
  45865. data.scopedSlots = { default: children[0] };
  45866. children.length = 0;
  45867. }
  45868. if (normalizationType === ALWAYS_NORMALIZE) {
  45869. children = normalizeChildren(children);
  45870. } else if (normalizationType === SIMPLE_NORMALIZE) {
  45871. children = simpleNormalizeChildren(children);
  45872. }
  45873. var vnode, ns;
  45874. if (typeof tag === 'string') {
  45875. var Ctor;
  45876. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  45877. if (config.isReservedTag(tag)) {
  45878. // platform built-in elements
  45879. if (isDef(data) && isDef(data.nativeOn)) {
  45880. warn(
  45881. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  45882. context
  45883. );
  45884. }
  45885. vnode = new VNode(
  45886. config.parsePlatformTagName(tag), data, children,
  45887. undefined, undefined, context
  45888. );
  45889. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  45890. // component
  45891. vnode = createComponent(Ctor, data, context, children, tag);
  45892. } else {
  45893. // unknown or unlisted namespaced elements
  45894. // check at runtime because it may get assigned a namespace when its
  45895. // parent normalizes children
  45896. vnode = new VNode(
  45897. tag, data, children,
  45898. undefined, undefined, context
  45899. );
  45900. }
  45901. } else {
  45902. // direct component options / constructor
  45903. vnode = createComponent(tag, data, context, children);
  45904. }
  45905. if (Array.isArray(vnode)) {
  45906. return vnode
  45907. } else if (isDef(vnode)) {
  45908. if (isDef(ns)) { applyNS(vnode, ns); }
  45909. if (isDef(data)) { registerDeepBindings(data); }
  45910. return vnode
  45911. } else {
  45912. return createEmptyVNode()
  45913. }
  45914. }
  45915. function applyNS (vnode, ns, force) {
  45916. vnode.ns = ns;
  45917. if (vnode.tag === 'foreignObject') {
  45918. // use default namespace inside foreignObject
  45919. ns = undefined;
  45920. force = true;
  45921. }
  45922. if (isDef(vnode.children)) {
  45923. for (var i = 0, l = vnode.children.length; i < l; i++) {
  45924. var child = vnode.children[i];
  45925. if (isDef(child.tag) && (
  45926. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  45927. applyNS(child, ns, force);
  45928. }
  45929. }
  45930. }
  45931. }
  45932. // ref #5318
  45933. // necessary to ensure parent re-render when deep bindings like :style and
  45934. // :class are used on slot nodes
  45935. function registerDeepBindings (data) {
  45936. if (isObject(data.style)) {
  45937. traverse(data.style);
  45938. }
  45939. if (isObject(data.class)) {
  45940. traverse(data.class);
  45941. }
  45942. }
  45943. /* */
  45944. function initRender (vm) {
  45945. vm._vnode = null; // the root of the child tree
  45946. vm._staticTrees = null; // v-once cached trees
  45947. var options = vm.$options;
  45948. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  45949. var renderContext = parentVnode && parentVnode.context;
  45950. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  45951. vm.$scopedSlots = emptyObject;
  45952. // bind the createElement fn to this instance
  45953. // so that we get proper render context inside it.
  45954. // args order: tag, data, children, normalizationType, alwaysNormalize
  45955. // internal version is used by render functions compiled from templates
  45956. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  45957. // normalization is always applied for the public version, used in
  45958. // user-written render functions.
  45959. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  45960. // $attrs & $listeners are exposed for easier HOC creation.
  45961. // they need to be reactive so that HOCs using them are always updated
  45962. var parentData = parentVnode && parentVnode.data;
  45963. /* istanbul ignore else */
  45964. {
  45965. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  45966. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  45967. }, true);
  45968. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  45969. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  45970. }, true);
  45971. }
  45972. }
  45973. var currentRenderingInstance = null;
  45974. function renderMixin (Vue) {
  45975. // install runtime convenience helpers
  45976. installRenderHelpers(Vue.prototype);
  45977. Vue.prototype.$nextTick = function (fn) {
  45978. return nextTick(fn, this)
  45979. };
  45980. Vue.prototype._render = function () {
  45981. var vm = this;
  45982. var ref = vm.$options;
  45983. var render = ref.render;
  45984. var _parentVnode = ref._parentVnode;
  45985. if (_parentVnode) {
  45986. vm.$scopedSlots = normalizeScopedSlots(
  45987. _parentVnode.data.scopedSlots,
  45988. vm.$slots,
  45989. vm.$scopedSlots
  45990. );
  45991. }
  45992. // set parent vnode. this allows render functions to have access
  45993. // to the data on the placeholder node.
  45994. vm.$vnode = _parentVnode;
  45995. // render self
  45996. var vnode;
  45997. try {
  45998. // There's no need to maintain a stack because all render fns are called
  45999. // separately from one another. Nested component's render fns are called
  46000. // when parent component is patched.
  46001. currentRenderingInstance = vm;
  46002. vnode = render.call(vm._renderProxy, vm.$createElement);
  46003. } catch (e) {
  46004. handleError(e, vm, "render");
  46005. // return error render result,
  46006. // or previous vnode to prevent render error causing blank component
  46007. /* istanbul ignore else */
  46008. if (vm.$options.renderError) {
  46009. try {
  46010. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  46011. } catch (e) {
  46012. handleError(e, vm, "renderError");
  46013. vnode = vm._vnode;
  46014. }
  46015. } else {
  46016. vnode = vm._vnode;
  46017. }
  46018. } finally {
  46019. currentRenderingInstance = null;
  46020. }
  46021. // if the returned array contains only a single node, allow it
  46022. if (Array.isArray(vnode) && vnode.length === 1) {
  46023. vnode = vnode[0];
  46024. }
  46025. // return empty vnode in case the render function errored out
  46026. if (!(vnode instanceof VNode)) {
  46027. if (Array.isArray(vnode)) {
  46028. warn(
  46029. 'Multiple root nodes returned from render function. Render function ' +
  46030. 'should return a single root node.',
  46031. vm
  46032. );
  46033. }
  46034. vnode = createEmptyVNode();
  46035. }
  46036. // set parent
  46037. vnode.parent = _parentVnode;
  46038. return vnode
  46039. };
  46040. }
  46041. /* */
  46042. function ensureCtor (comp, base) {
  46043. if (
  46044. comp.__esModule ||
  46045. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  46046. ) {
  46047. comp = comp.default;
  46048. }
  46049. return isObject(comp)
  46050. ? base.extend(comp)
  46051. : comp
  46052. }
  46053. function createAsyncPlaceholder (
  46054. factory,
  46055. data,
  46056. context,
  46057. children,
  46058. tag
  46059. ) {
  46060. var node = createEmptyVNode();
  46061. node.asyncFactory = factory;
  46062. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  46063. return node
  46064. }
  46065. function resolveAsyncComponent (
  46066. factory,
  46067. baseCtor
  46068. ) {
  46069. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  46070. return factory.errorComp
  46071. }
  46072. if (isDef(factory.resolved)) {
  46073. return factory.resolved
  46074. }
  46075. var owner = currentRenderingInstance;
  46076. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  46077. // already pending
  46078. factory.owners.push(owner);
  46079. }
  46080. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  46081. return factory.loadingComp
  46082. }
  46083. if (owner && !isDef(factory.owners)) {
  46084. var owners = factory.owners = [owner];
  46085. var sync = true;
  46086. var timerLoading = null;
  46087. var timerTimeout = null
  46088. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  46089. var forceRender = function (renderCompleted) {
  46090. for (var i = 0, l = owners.length; i < l; i++) {
  46091. (owners[i]).$forceUpdate();
  46092. }
  46093. if (renderCompleted) {
  46094. owners.length = 0;
  46095. if (timerLoading !== null) {
  46096. clearTimeout(timerLoading);
  46097. timerLoading = null;
  46098. }
  46099. if (timerTimeout !== null) {
  46100. clearTimeout(timerTimeout);
  46101. timerTimeout = null;
  46102. }
  46103. }
  46104. };
  46105. var resolve = once(function (res) {
  46106. // cache resolved
  46107. factory.resolved = ensureCtor(res, baseCtor);
  46108. // invoke callbacks only if this is not a synchronous resolve
  46109. // (async resolves are shimmed as synchronous during SSR)
  46110. if (!sync) {
  46111. forceRender(true);
  46112. } else {
  46113. owners.length = 0;
  46114. }
  46115. });
  46116. var reject = once(function (reason) {
  46117. warn(
  46118. "Failed to resolve async component: " + (String(factory)) +
  46119. (reason ? ("\nReason: " + reason) : '')
  46120. );
  46121. if (isDef(factory.errorComp)) {
  46122. factory.error = true;
  46123. forceRender(true);
  46124. }
  46125. });
  46126. var res = factory(resolve, reject);
  46127. if (isObject(res)) {
  46128. if (isPromise(res)) {
  46129. // () => Promise
  46130. if (isUndef(factory.resolved)) {
  46131. res.then(resolve, reject);
  46132. }
  46133. } else if (isPromise(res.component)) {
  46134. res.component.then(resolve, reject);
  46135. if (isDef(res.error)) {
  46136. factory.errorComp = ensureCtor(res.error, baseCtor);
  46137. }
  46138. if (isDef(res.loading)) {
  46139. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  46140. if (res.delay === 0) {
  46141. factory.loading = true;
  46142. } else {
  46143. timerLoading = setTimeout(function () {
  46144. timerLoading = null;
  46145. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  46146. factory.loading = true;
  46147. forceRender(false);
  46148. }
  46149. }, res.delay || 200);
  46150. }
  46151. }
  46152. if (isDef(res.timeout)) {
  46153. timerTimeout = setTimeout(function () {
  46154. timerTimeout = null;
  46155. if (isUndef(factory.resolved)) {
  46156. reject(
  46157. "timeout (" + (res.timeout) + "ms)"
  46158. );
  46159. }
  46160. }, res.timeout);
  46161. }
  46162. }
  46163. }
  46164. sync = false;
  46165. // return in case resolved synchronously
  46166. return factory.loading
  46167. ? factory.loadingComp
  46168. : factory.resolved
  46169. }
  46170. }
  46171. /* */
  46172. function isAsyncPlaceholder (node) {
  46173. return node.isComment && node.asyncFactory
  46174. }
  46175. /* */
  46176. function getFirstComponentChild (children) {
  46177. if (Array.isArray(children)) {
  46178. for (var i = 0; i < children.length; i++) {
  46179. var c = children[i];
  46180. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  46181. return c
  46182. }
  46183. }
  46184. }
  46185. }
  46186. /* */
  46187. /* */
  46188. function initEvents (vm) {
  46189. vm._events = Object.create(null);
  46190. vm._hasHookEvent = false;
  46191. // init parent attached events
  46192. var listeners = vm.$options._parentListeners;
  46193. if (listeners) {
  46194. updateComponentListeners(vm, listeners);
  46195. }
  46196. }
  46197. var target;
  46198. function add (event, fn) {
  46199. target.$on(event, fn);
  46200. }
  46201. function remove$1 (event, fn) {
  46202. target.$off(event, fn);
  46203. }
  46204. function createOnceHandler (event, fn) {
  46205. var _target = target;
  46206. return function onceHandler () {
  46207. var res = fn.apply(null, arguments);
  46208. if (res !== null) {
  46209. _target.$off(event, onceHandler);
  46210. }
  46211. }
  46212. }
  46213. function updateComponentListeners (
  46214. vm,
  46215. listeners,
  46216. oldListeners
  46217. ) {
  46218. target = vm;
  46219. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  46220. target = undefined;
  46221. }
  46222. function eventsMixin (Vue) {
  46223. var hookRE = /^hook:/;
  46224. Vue.prototype.$on = function (event, fn) {
  46225. var vm = this;
  46226. if (Array.isArray(event)) {
  46227. for (var i = 0, l = event.length; i < l; i++) {
  46228. vm.$on(event[i], fn);
  46229. }
  46230. } else {
  46231. (vm._events[event] || (vm._events[event] = [])).push(fn);
  46232. // optimize hook:event cost by using a boolean flag marked at registration
  46233. // instead of a hash lookup
  46234. if (hookRE.test(event)) {
  46235. vm._hasHookEvent = true;
  46236. }
  46237. }
  46238. return vm
  46239. };
  46240. Vue.prototype.$once = function (event, fn) {
  46241. var vm = this;
  46242. function on () {
  46243. vm.$off(event, on);
  46244. fn.apply(vm, arguments);
  46245. }
  46246. on.fn = fn;
  46247. vm.$on(event, on);
  46248. return vm
  46249. };
  46250. Vue.prototype.$off = function (event, fn) {
  46251. var vm = this;
  46252. // all
  46253. if (!arguments.length) {
  46254. vm._events = Object.create(null);
  46255. return vm
  46256. }
  46257. // array of events
  46258. if (Array.isArray(event)) {
  46259. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  46260. vm.$off(event[i$1], fn);
  46261. }
  46262. return vm
  46263. }
  46264. // specific event
  46265. var cbs = vm._events[event];
  46266. if (!cbs) {
  46267. return vm
  46268. }
  46269. if (!fn) {
  46270. vm._events[event] = null;
  46271. return vm
  46272. }
  46273. // specific handler
  46274. var cb;
  46275. var i = cbs.length;
  46276. while (i--) {
  46277. cb = cbs[i];
  46278. if (cb === fn || cb.fn === fn) {
  46279. cbs.splice(i, 1);
  46280. break
  46281. }
  46282. }
  46283. return vm
  46284. };
  46285. Vue.prototype.$emit = function (event) {
  46286. var vm = this;
  46287. {
  46288. var lowerCaseEvent = event.toLowerCase();
  46289. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  46290. tip(
  46291. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  46292. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  46293. "Note that HTML attributes are case-insensitive and you cannot use " +
  46294. "v-on to listen to camelCase events when using in-DOM templates. " +
  46295. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  46296. );
  46297. }
  46298. }
  46299. var cbs = vm._events[event];
  46300. if (cbs) {
  46301. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  46302. var args = toArray(arguments, 1);
  46303. var info = "event handler for \"" + event + "\"";
  46304. for (var i = 0, l = cbs.length; i < l; i++) {
  46305. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  46306. }
  46307. }
  46308. return vm
  46309. };
  46310. }
  46311. /* */
  46312. var activeInstance = null;
  46313. var isUpdatingChildComponent = false;
  46314. function setActiveInstance(vm) {
  46315. var prevActiveInstance = activeInstance;
  46316. activeInstance = vm;
  46317. return function () {
  46318. activeInstance = prevActiveInstance;
  46319. }
  46320. }
  46321. function initLifecycle (vm) {
  46322. var options = vm.$options;
  46323. // locate first non-abstract parent
  46324. var parent = options.parent;
  46325. if (parent && !options.abstract) {
  46326. while (parent.$options.abstract && parent.$parent) {
  46327. parent = parent.$parent;
  46328. }
  46329. parent.$children.push(vm);
  46330. }
  46331. vm.$parent = parent;
  46332. vm.$root = parent ? parent.$root : vm;
  46333. vm.$children = [];
  46334. vm.$refs = {};
  46335. vm._watcher = null;
  46336. vm._inactive = null;
  46337. vm._directInactive = false;
  46338. vm._isMounted = false;
  46339. vm._isDestroyed = false;
  46340. vm._isBeingDestroyed = false;
  46341. }
  46342. function lifecycleMixin (Vue) {
  46343. Vue.prototype._update = function (vnode, hydrating) {
  46344. var vm = this;
  46345. var prevEl = vm.$el;
  46346. var prevVnode = vm._vnode;
  46347. var restoreActiveInstance = setActiveInstance(vm);
  46348. vm._vnode = vnode;
  46349. // Vue.prototype.__patch__ is injected in entry points
  46350. // based on the rendering backend used.
  46351. if (!prevVnode) {
  46352. // initial render
  46353. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  46354. } else {
  46355. // updates
  46356. vm.$el = vm.__patch__(prevVnode, vnode);
  46357. }
  46358. restoreActiveInstance();
  46359. // update __vue__ reference
  46360. if (prevEl) {
  46361. prevEl.__vue__ = null;
  46362. }
  46363. if (vm.$el) {
  46364. vm.$el.__vue__ = vm;
  46365. }
  46366. // if parent is an HOC, update its $el as well
  46367. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  46368. vm.$parent.$el = vm.$el;
  46369. }
  46370. // updated hook is called by the scheduler to ensure that children are
  46371. // updated in a parent's updated hook.
  46372. };
  46373. Vue.prototype.$forceUpdate = function () {
  46374. var vm = this;
  46375. if (vm._watcher) {
  46376. vm._watcher.update();
  46377. }
  46378. };
  46379. Vue.prototype.$destroy = function () {
  46380. var vm = this;
  46381. if (vm._isBeingDestroyed) {
  46382. return
  46383. }
  46384. callHook(vm, 'beforeDestroy');
  46385. vm._isBeingDestroyed = true;
  46386. // remove self from parent
  46387. var parent = vm.$parent;
  46388. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  46389. remove(parent.$children, vm);
  46390. }
  46391. // teardown watchers
  46392. if (vm._watcher) {
  46393. vm._watcher.teardown();
  46394. }
  46395. var i = vm._watchers.length;
  46396. while (i--) {
  46397. vm._watchers[i].teardown();
  46398. }
  46399. // remove reference from data ob
  46400. // frozen object may not have observer.
  46401. if (vm._data.__ob__) {
  46402. vm._data.__ob__.vmCount--;
  46403. }
  46404. // call the last hook...
  46405. vm._isDestroyed = true;
  46406. // invoke destroy hooks on current rendered tree
  46407. vm.__patch__(vm._vnode, null);
  46408. // fire destroyed hook
  46409. callHook(vm, 'destroyed');
  46410. // turn off all instance listeners.
  46411. vm.$off();
  46412. // remove __vue__ reference
  46413. if (vm.$el) {
  46414. vm.$el.__vue__ = null;
  46415. }
  46416. // release circular reference (#6759)
  46417. if (vm.$vnode) {
  46418. vm.$vnode.parent = null;
  46419. }
  46420. };
  46421. }
  46422. function mountComponent (
  46423. vm,
  46424. el,
  46425. hydrating
  46426. ) {
  46427. vm.$el = el;
  46428. if (!vm.$options.render) {
  46429. vm.$options.render = createEmptyVNode;
  46430. {
  46431. /* istanbul ignore if */
  46432. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  46433. vm.$options.el || el) {
  46434. warn(
  46435. 'You are using the runtime-only build of Vue where the template ' +
  46436. 'compiler is not available. Either pre-compile the templates into ' +
  46437. 'render functions, or use the compiler-included build.',
  46438. vm
  46439. );
  46440. } else {
  46441. warn(
  46442. 'Failed to mount component: template or render function not defined.',
  46443. vm
  46444. );
  46445. }
  46446. }
  46447. }
  46448. callHook(vm, 'beforeMount');
  46449. var updateComponent;
  46450. /* istanbul ignore if */
  46451. if (config.performance && mark) {
  46452. updateComponent = function () {
  46453. var name = vm._name;
  46454. var id = vm._uid;
  46455. var startTag = "vue-perf-start:" + id;
  46456. var endTag = "vue-perf-end:" + id;
  46457. mark(startTag);
  46458. var vnode = vm._render();
  46459. mark(endTag);
  46460. measure(("vue " + name + " render"), startTag, endTag);
  46461. mark(startTag);
  46462. vm._update(vnode, hydrating);
  46463. mark(endTag);
  46464. measure(("vue " + name + " patch"), startTag, endTag);
  46465. };
  46466. } else {
  46467. updateComponent = function () {
  46468. vm._update(vm._render(), hydrating);
  46469. };
  46470. }
  46471. // we set this to vm._watcher inside the watcher's constructor
  46472. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  46473. // component's mounted hook), which relies on vm._watcher being already defined
  46474. new Watcher(vm, updateComponent, noop, {
  46475. before: function before () {
  46476. if (vm._isMounted && !vm._isDestroyed) {
  46477. callHook(vm, 'beforeUpdate');
  46478. }
  46479. }
  46480. }, true /* isRenderWatcher */);
  46481. hydrating = false;
  46482. // manually mounted instance, call mounted on self
  46483. // mounted is called for render-created child components in its inserted hook
  46484. if (vm.$vnode == null) {
  46485. vm._isMounted = true;
  46486. callHook(vm, 'mounted');
  46487. }
  46488. return vm
  46489. }
  46490. function updateChildComponent (
  46491. vm,
  46492. propsData,
  46493. listeners,
  46494. parentVnode,
  46495. renderChildren
  46496. ) {
  46497. {
  46498. isUpdatingChildComponent = true;
  46499. }
  46500. // determine whether component has slot children
  46501. // we need to do this before overwriting $options._renderChildren.
  46502. // check if there are dynamic scopedSlots (hand-written or compiled but with
  46503. // dynamic slot names). Static scoped slots compiled from template has the
  46504. // "$stable" marker.
  46505. var newScopedSlots = parentVnode.data.scopedSlots;
  46506. var oldScopedSlots = vm.$scopedSlots;
  46507. var hasDynamicScopedSlot = !!(
  46508. (newScopedSlots && !newScopedSlots.$stable) ||
  46509. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  46510. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  46511. );
  46512. // Any static slot children from the parent may have changed during parent's
  46513. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  46514. // update is necessary to ensure correctness.
  46515. var needsForceUpdate = !!(
  46516. renderChildren || // has new static slots
  46517. vm.$options._renderChildren || // has old static slots
  46518. hasDynamicScopedSlot
  46519. );
  46520. vm.$options._parentVnode = parentVnode;
  46521. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  46522. if (vm._vnode) { // update child tree's parent
  46523. vm._vnode.parent = parentVnode;
  46524. }
  46525. vm.$options._renderChildren = renderChildren;
  46526. // update $attrs and $listeners hash
  46527. // these are also reactive so they may trigger child update if the child
  46528. // used them during render
  46529. vm.$attrs = parentVnode.data.attrs || emptyObject;
  46530. vm.$listeners = listeners || emptyObject;
  46531. // update props
  46532. if (propsData && vm.$options.props) {
  46533. toggleObserving(false);
  46534. var props = vm._props;
  46535. var propKeys = vm.$options._propKeys || [];
  46536. for (var i = 0; i < propKeys.length; i++) {
  46537. var key = propKeys[i];
  46538. var propOptions = vm.$options.props; // wtf flow?
  46539. props[key] = validateProp(key, propOptions, propsData, vm);
  46540. }
  46541. toggleObserving(true);
  46542. // keep a copy of raw propsData
  46543. vm.$options.propsData = propsData;
  46544. }
  46545. // update listeners
  46546. listeners = listeners || emptyObject;
  46547. var oldListeners = vm.$options._parentListeners;
  46548. vm.$options._parentListeners = listeners;
  46549. updateComponentListeners(vm, listeners, oldListeners);
  46550. // resolve slots + force update if has children
  46551. if (needsForceUpdate) {
  46552. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  46553. vm.$forceUpdate();
  46554. }
  46555. {
  46556. isUpdatingChildComponent = false;
  46557. }
  46558. }
  46559. function isInInactiveTree (vm) {
  46560. while (vm && (vm = vm.$parent)) {
  46561. if (vm._inactive) { return true }
  46562. }
  46563. return false
  46564. }
  46565. function activateChildComponent (vm, direct) {
  46566. if (direct) {
  46567. vm._directInactive = false;
  46568. if (isInInactiveTree(vm)) {
  46569. return
  46570. }
  46571. } else if (vm._directInactive) {
  46572. return
  46573. }
  46574. if (vm._inactive || vm._inactive === null) {
  46575. vm._inactive = false;
  46576. for (var i = 0; i < vm.$children.length; i++) {
  46577. activateChildComponent(vm.$children[i]);
  46578. }
  46579. callHook(vm, 'activated');
  46580. }
  46581. }
  46582. function deactivateChildComponent (vm, direct) {
  46583. if (direct) {
  46584. vm._directInactive = true;
  46585. if (isInInactiveTree(vm)) {
  46586. return
  46587. }
  46588. }
  46589. if (!vm._inactive) {
  46590. vm._inactive = true;
  46591. for (var i = 0; i < vm.$children.length; i++) {
  46592. deactivateChildComponent(vm.$children[i]);
  46593. }
  46594. callHook(vm, 'deactivated');
  46595. }
  46596. }
  46597. function callHook (vm, hook) {
  46598. // #7573 disable dep collection when invoking lifecycle hooks
  46599. pushTarget();
  46600. var handlers = vm.$options[hook];
  46601. var info = hook + " hook";
  46602. if (handlers) {
  46603. for (var i = 0, j = handlers.length; i < j; i++) {
  46604. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  46605. }
  46606. }
  46607. if (vm._hasHookEvent) {
  46608. vm.$emit('hook:' + hook);
  46609. }
  46610. popTarget();
  46611. }
  46612. /* */
  46613. var MAX_UPDATE_COUNT = 100;
  46614. var queue = [];
  46615. var activatedChildren = [];
  46616. var has = {};
  46617. var circular = {};
  46618. var waiting = false;
  46619. var flushing = false;
  46620. var index = 0;
  46621. /**
  46622. * Reset the scheduler's state.
  46623. */
  46624. function resetSchedulerState () {
  46625. index = queue.length = activatedChildren.length = 0;
  46626. has = {};
  46627. {
  46628. circular = {};
  46629. }
  46630. waiting = flushing = false;
  46631. }
  46632. // Async edge case #6566 requires saving the timestamp when event listeners are
  46633. // attached. However, calling performance.now() has a perf overhead especially
  46634. // if the page has thousands of event listeners. Instead, we take a timestamp
  46635. // every time the scheduler flushes and use that for all event listeners
  46636. // attached during that flush.
  46637. var currentFlushTimestamp = 0;
  46638. // Async edge case fix requires storing an event listener's attach timestamp.
  46639. var getNow = Date.now;
  46640. // Determine what event timestamp the browser is using. Annoyingly, the
  46641. // timestamp can either be hi-res (relative to page load) or low-res
  46642. // (relative to UNIX epoch), so in order to compare time we have to use the
  46643. // same timestamp type when saving the flush timestamp.
  46644. // All IE versions use low-res event timestamps, and have problematic clock
  46645. // implementations (#9632)
  46646. if (inBrowser && !isIE) {
  46647. var performance = window.performance;
  46648. if (
  46649. performance &&
  46650. typeof performance.now === 'function' &&
  46651. getNow() > document.createEvent('Event').timeStamp
  46652. ) {
  46653. // if the event timestamp, although evaluated AFTER the Date.now(), is
  46654. // smaller than it, it means the event is using a hi-res timestamp,
  46655. // and we need to use the hi-res version for event listener timestamps as
  46656. // well.
  46657. getNow = function () { return performance.now(); };
  46658. }
  46659. }
  46660. /**
  46661. * Flush both queues and run the watchers.
  46662. */
  46663. function flushSchedulerQueue () {
  46664. currentFlushTimestamp = getNow();
  46665. flushing = true;
  46666. var watcher, id;
  46667. // Sort queue before flush.
  46668. // This ensures that:
  46669. // 1. Components are updated from parent to child. (because parent is always
  46670. // created before the child)
  46671. // 2. A component's user watchers are run before its render watcher (because
  46672. // user watchers are created before the render watcher)
  46673. // 3. If a component is destroyed during a parent component's watcher run,
  46674. // its watchers can be skipped.
  46675. queue.sort(function (a, b) { return a.id - b.id; });
  46676. // do not cache length because more watchers might be pushed
  46677. // as we run existing watchers
  46678. for (index = 0; index < queue.length; index++) {
  46679. watcher = queue[index];
  46680. if (watcher.before) {
  46681. watcher.before();
  46682. }
  46683. id = watcher.id;
  46684. has[id] = null;
  46685. watcher.run();
  46686. // in dev build, check and stop circular updates.
  46687. if (has[id] != null) {
  46688. circular[id] = (circular[id] || 0) + 1;
  46689. if (circular[id] > MAX_UPDATE_COUNT) {
  46690. warn(
  46691. 'You may have an infinite update loop ' + (
  46692. watcher.user
  46693. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  46694. : "in a component render function."
  46695. ),
  46696. watcher.vm
  46697. );
  46698. break
  46699. }
  46700. }
  46701. }
  46702. // keep copies of post queues before resetting state
  46703. var activatedQueue = activatedChildren.slice();
  46704. var updatedQueue = queue.slice();
  46705. resetSchedulerState();
  46706. // call component updated and activated hooks
  46707. callActivatedHooks(activatedQueue);
  46708. callUpdatedHooks(updatedQueue);
  46709. // devtool hook
  46710. /* istanbul ignore if */
  46711. if (devtools && config.devtools) {
  46712. devtools.emit('flush');
  46713. }
  46714. }
  46715. function callUpdatedHooks (queue) {
  46716. var i = queue.length;
  46717. while (i--) {
  46718. var watcher = queue[i];
  46719. var vm = watcher.vm;
  46720. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  46721. callHook(vm, 'updated');
  46722. }
  46723. }
  46724. }
  46725. /**
  46726. * Queue a kept-alive component that was activated during patch.
  46727. * The queue will be processed after the entire tree has been patched.
  46728. */
  46729. function queueActivatedComponent (vm) {
  46730. // setting _inactive to false here so that a render function can
  46731. // rely on checking whether it's in an inactive tree (e.g. router-view)
  46732. vm._inactive = false;
  46733. activatedChildren.push(vm);
  46734. }
  46735. function callActivatedHooks (queue) {
  46736. for (var i = 0; i < queue.length; i++) {
  46737. queue[i]._inactive = true;
  46738. activateChildComponent(queue[i], true /* true */);
  46739. }
  46740. }
  46741. /**
  46742. * Push a watcher into the watcher queue.
  46743. * Jobs with duplicate IDs will be skipped unless it's
  46744. * pushed when the queue is being flushed.
  46745. */
  46746. function queueWatcher (watcher) {
  46747. var id = watcher.id;
  46748. if (has[id] == null) {
  46749. has[id] = true;
  46750. if (!flushing) {
  46751. queue.push(watcher);
  46752. } else {
  46753. // if already flushing, splice the watcher based on its id
  46754. // if already past its id, it will be run next immediately.
  46755. var i = queue.length - 1;
  46756. while (i > index && queue[i].id > watcher.id) {
  46757. i--;
  46758. }
  46759. queue.splice(i + 1, 0, watcher);
  46760. }
  46761. // queue the flush
  46762. if (!waiting) {
  46763. waiting = true;
  46764. if (!config.async) {
  46765. flushSchedulerQueue();
  46766. return
  46767. }
  46768. nextTick(flushSchedulerQueue);
  46769. }
  46770. }
  46771. }
  46772. /* */
  46773. var uid$2 = 0;
  46774. /**
  46775. * A watcher parses an expression, collects dependencies,
  46776. * and fires callback when the expression value changes.
  46777. * This is used for both the $watch() api and directives.
  46778. */
  46779. var Watcher = function Watcher (
  46780. vm,
  46781. expOrFn,
  46782. cb,
  46783. options,
  46784. isRenderWatcher
  46785. ) {
  46786. this.vm = vm;
  46787. if (isRenderWatcher) {
  46788. vm._watcher = this;
  46789. }
  46790. vm._watchers.push(this);
  46791. // options
  46792. if (options) {
  46793. this.deep = !!options.deep;
  46794. this.user = !!options.user;
  46795. this.lazy = !!options.lazy;
  46796. this.sync = !!options.sync;
  46797. this.before = options.before;
  46798. } else {
  46799. this.deep = this.user = this.lazy = this.sync = false;
  46800. }
  46801. this.cb = cb;
  46802. this.id = ++uid$2; // uid for batching
  46803. this.active = true;
  46804. this.dirty = this.lazy; // for lazy watchers
  46805. this.deps = [];
  46806. this.newDeps = [];
  46807. this.depIds = new _Set();
  46808. this.newDepIds = new _Set();
  46809. this.expression = expOrFn.toString();
  46810. // parse expression for getter
  46811. if (typeof expOrFn === 'function') {
  46812. this.getter = expOrFn;
  46813. } else {
  46814. this.getter = parsePath(expOrFn);
  46815. if (!this.getter) {
  46816. this.getter = noop;
  46817. warn(
  46818. "Failed watching path: \"" + expOrFn + "\" " +
  46819. 'Watcher only accepts simple dot-delimited paths. ' +
  46820. 'For full control, use a function instead.',
  46821. vm
  46822. );
  46823. }
  46824. }
  46825. this.value = this.lazy
  46826. ? undefined
  46827. : this.get();
  46828. };
  46829. /**
  46830. * Evaluate the getter, and re-collect dependencies.
  46831. */
  46832. Watcher.prototype.get = function get () {
  46833. pushTarget(this);
  46834. var value;
  46835. var vm = this.vm;
  46836. try {
  46837. value = this.getter.call(vm, vm);
  46838. } catch (e) {
  46839. if (this.user) {
  46840. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  46841. } else {
  46842. throw e
  46843. }
  46844. } finally {
  46845. // "touch" every property so they are all tracked as
  46846. // dependencies for deep watching
  46847. if (this.deep) {
  46848. traverse(value);
  46849. }
  46850. popTarget();
  46851. this.cleanupDeps();
  46852. }
  46853. return value
  46854. };
  46855. /**
  46856. * Add a dependency to this directive.
  46857. */
  46858. Watcher.prototype.addDep = function addDep (dep) {
  46859. var id = dep.id;
  46860. if (!this.newDepIds.has(id)) {
  46861. this.newDepIds.add(id);
  46862. this.newDeps.push(dep);
  46863. if (!this.depIds.has(id)) {
  46864. dep.addSub(this);
  46865. }
  46866. }
  46867. };
  46868. /**
  46869. * Clean up for dependency collection.
  46870. */
  46871. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  46872. var i = this.deps.length;
  46873. while (i--) {
  46874. var dep = this.deps[i];
  46875. if (!this.newDepIds.has(dep.id)) {
  46876. dep.removeSub(this);
  46877. }
  46878. }
  46879. var tmp = this.depIds;
  46880. this.depIds = this.newDepIds;
  46881. this.newDepIds = tmp;
  46882. this.newDepIds.clear();
  46883. tmp = this.deps;
  46884. this.deps = this.newDeps;
  46885. this.newDeps = tmp;
  46886. this.newDeps.length = 0;
  46887. };
  46888. /**
  46889. * Subscriber interface.
  46890. * Will be called when a dependency changes.
  46891. */
  46892. Watcher.prototype.update = function update () {
  46893. /* istanbul ignore else */
  46894. if (this.lazy) {
  46895. this.dirty = true;
  46896. } else if (this.sync) {
  46897. this.run();
  46898. } else {
  46899. queueWatcher(this);
  46900. }
  46901. };
  46902. /**
  46903. * Scheduler job interface.
  46904. * Will be called by the scheduler.
  46905. */
  46906. Watcher.prototype.run = function run () {
  46907. if (this.active) {
  46908. var value = this.get();
  46909. if (
  46910. value !== this.value ||
  46911. // Deep watchers and watchers on Object/Arrays should fire even
  46912. // when the value is the same, because the value may
  46913. // have mutated.
  46914. isObject(value) ||
  46915. this.deep
  46916. ) {
  46917. // set new value
  46918. var oldValue = this.value;
  46919. this.value = value;
  46920. if (this.user) {
  46921. try {
  46922. this.cb.call(this.vm, value, oldValue);
  46923. } catch (e) {
  46924. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  46925. }
  46926. } else {
  46927. this.cb.call(this.vm, value, oldValue);
  46928. }
  46929. }
  46930. }
  46931. };
  46932. /**
  46933. * Evaluate the value of the watcher.
  46934. * This only gets called for lazy watchers.
  46935. */
  46936. Watcher.prototype.evaluate = function evaluate () {
  46937. this.value = this.get();
  46938. this.dirty = false;
  46939. };
  46940. /**
  46941. * Depend on all deps collected by this watcher.
  46942. */
  46943. Watcher.prototype.depend = function depend () {
  46944. var i = this.deps.length;
  46945. while (i--) {
  46946. this.deps[i].depend();
  46947. }
  46948. };
  46949. /**
  46950. * Remove self from all dependencies' subscriber list.
  46951. */
  46952. Watcher.prototype.teardown = function teardown () {
  46953. if (this.active) {
  46954. // remove self from vm's watcher list
  46955. // this is a somewhat expensive operation so we skip it
  46956. // if the vm is being destroyed.
  46957. if (!this.vm._isBeingDestroyed) {
  46958. remove(this.vm._watchers, this);
  46959. }
  46960. var i = this.deps.length;
  46961. while (i--) {
  46962. this.deps[i].removeSub(this);
  46963. }
  46964. this.active = false;
  46965. }
  46966. };
  46967. /* */
  46968. var sharedPropertyDefinition = {
  46969. enumerable: true,
  46970. configurable: true,
  46971. get: noop,
  46972. set: noop
  46973. };
  46974. function proxy (target, sourceKey, key) {
  46975. sharedPropertyDefinition.get = function proxyGetter () {
  46976. return this[sourceKey][key]
  46977. };
  46978. sharedPropertyDefinition.set = function proxySetter (val) {
  46979. this[sourceKey][key] = val;
  46980. };
  46981. Object.defineProperty(target, key, sharedPropertyDefinition);
  46982. }
  46983. function initState (vm) {
  46984. vm._watchers = [];
  46985. var opts = vm.$options;
  46986. if (opts.props) { initProps(vm, opts.props); }
  46987. if (opts.methods) { initMethods(vm, opts.methods); }
  46988. if (opts.data) {
  46989. initData(vm);
  46990. } else {
  46991. observe(vm._data = {}, true /* asRootData */);
  46992. }
  46993. if (opts.computed) { initComputed(vm, opts.computed); }
  46994. if (opts.watch && opts.watch !== nativeWatch) {
  46995. initWatch(vm, opts.watch);
  46996. }
  46997. }
  46998. function initProps (vm, propsOptions) {
  46999. var propsData = vm.$options.propsData || {};
  47000. var props = vm._props = {};
  47001. // cache prop keys so that future props updates can iterate using Array
  47002. // instead of dynamic object key enumeration.
  47003. var keys = vm.$options._propKeys = [];
  47004. var isRoot = !vm.$parent;
  47005. // root instance props should be converted
  47006. if (!isRoot) {
  47007. toggleObserving(false);
  47008. }
  47009. var loop = function ( key ) {
  47010. keys.push(key);
  47011. var value = validateProp(key, propsOptions, propsData, vm);
  47012. /* istanbul ignore else */
  47013. {
  47014. var hyphenatedKey = hyphenate(key);
  47015. if (isReservedAttribute(hyphenatedKey) ||
  47016. config.isReservedAttr(hyphenatedKey)) {
  47017. warn(
  47018. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  47019. vm
  47020. );
  47021. }
  47022. defineReactive$$1(props, key, value, function () {
  47023. if (!isRoot && !isUpdatingChildComponent) {
  47024. warn(
  47025. "Avoid mutating a prop directly since the value will be " +
  47026. "overwritten whenever the parent component re-renders. " +
  47027. "Instead, use a data or computed property based on the prop's " +
  47028. "value. Prop being mutated: \"" + key + "\"",
  47029. vm
  47030. );
  47031. }
  47032. });
  47033. }
  47034. // static props are already proxied on the component's prototype
  47035. // during Vue.extend(). We only need to proxy props defined at
  47036. // instantiation here.
  47037. if (!(key in vm)) {
  47038. proxy(vm, "_props", key);
  47039. }
  47040. };
  47041. for (var key in propsOptions) loop( key );
  47042. toggleObserving(true);
  47043. }
  47044. function initData (vm) {
  47045. var data = vm.$options.data;
  47046. data = vm._data = typeof data === 'function'
  47047. ? getData(data, vm)
  47048. : data || {};
  47049. if (!isPlainObject(data)) {
  47050. data = {};
  47051. warn(
  47052. 'data functions should return an object:\n' +
  47053. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  47054. vm
  47055. );
  47056. }
  47057. // proxy data on instance
  47058. var keys = Object.keys(data);
  47059. var props = vm.$options.props;
  47060. var methods = vm.$options.methods;
  47061. var i = keys.length;
  47062. while (i--) {
  47063. var key = keys[i];
  47064. {
  47065. if (methods && hasOwn(methods, key)) {
  47066. warn(
  47067. ("Method \"" + key + "\" has already been defined as a data property."),
  47068. vm
  47069. );
  47070. }
  47071. }
  47072. if (props && hasOwn(props, key)) {
  47073. warn(
  47074. "The data property \"" + key + "\" is already declared as a prop. " +
  47075. "Use prop default value instead.",
  47076. vm
  47077. );
  47078. } else if (!isReserved(key)) {
  47079. proxy(vm, "_data", key);
  47080. }
  47081. }
  47082. // observe data
  47083. observe(data, true /* asRootData */);
  47084. }
  47085. function getData (data, vm) {
  47086. // #7573 disable dep collection when invoking data getters
  47087. pushTarget();
  47088. try {
  47089. return data.call(vm, vm)
  47090. } catch (e) {
  47091. handleError(e, vm, "data()");
  47092. return {}
  47093. } finally {
  47094. popTarget();
  47095. }
  47096. }
  47097. var computedWatcherOptions = { lazy: true };
  47098. function initComputed (vm, computed) {
  47099. // $flow-disable-line
  47100. var watchers = vm._computedWatchers = Object.create(null);
  47101. // computed properties are just getters during SSR
  47102. var isSSR = isServerRendering();
  47103. for (var key in computed) {
  47104. var userDef = computed[key];
  47105. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  47106. if (getter == null) {
  47107. warn(
  47108. ("Getter is missing for computed property \"" + key + "\"."),
  47109. vm
  47110. );
  47111. }
  47112. if (!isSSR) {
  47113. // create internal watcher for the computed property.
  47114. watchers[key] = new Watcher(
  47115. vm,
  47116. getter || noop,
  47117. noop,
  47118. computedWatcherOptions
  47119. );
  47120. }
  47121. // component-defined computed properties are already defined on the
  47122. // component prototype. We only need to define computed properties defined
  47123. // at instantiation here.
  47124. if (!(key in vm)) {
  47125. defineComputed(vm, key, userDef);
  47126. } else {
  47127. if (key in vm.$data) {
  47128. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  47129. } else if (vm.$options.props && key in vm.$options.props) {
  47130. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  47131. }
  47132. }
  47133. }
  47134. }
  47135. function defineComputed (
  47136. target,
  47137. key,
  47138. userDef
  47139. ) {
  47140. var shouldCache = !isServerRendering();
  47141. if (typeof userDef === 'function') {
  47142. sharedPropertyDefinition.get = shouldCache
  47143. ? createComputedGetter(key)
  47144. : createGetterInvoker(userDef);
  47145. sharedPropertyDefinition.set = noop;
  47146. } else {
  47147. sharedPropertyDefinition.get = userDef.get
  47148. ? shouldCache && userDef.cache !== false
  47149. ? createComputedGetter(key)
  47150. : createGetterInvoker(userDef.get)
  47151. : noop;
  47152. sharedPropertyDefinition.set = userDef.set || noop;
  47153. }
  47154. if (sharedPropertyDefinition.set === noop) {
  47155. sharedPropertyDefinition.set = function () {
  47156. warn(
  47157. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  47158. this
  47159. );
  47160. };
  47161. }
  47162. Object.defineProperty(target, key, sharedPropertyDefinition);
  47163. }
  47164. function createComputedGetter (key) {
  47165. return function computedGetter () {
  47166. var watcher = this._computedWatchers && this._computedWatchers[key];
  47167. if (watcher) {
  47168. if (watcher.dirty) {
  47169. watcher.evaluate();
  47170. }
  47171. if (Dep.target) {
  47172. watcher.depend();
  47173. }
  47174. return watcher.value
  47175. }
  47176. }
  47177. }
  47178. function createGetterInvoker(fn) {
  47179. return function computedGetter () {
  47180. return fn.call(this, this)
  47181. }
  47182. }
  47183. function initMethods (vm, methods) {
  47184. var props = vm.$options.props;
  47185. for (var key in methods) {
  47186. {
  47187. if (typeof methods[key] !== 'function') {
  47188. warn(
  47189. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  47190. "Did you reference the function correctly?",
  47191. vm
  47192. );
  47193. }
  47194. if (props && hasOwn(props, key)) {
  47195. warn(
  47196. ("Method \"" + key + "\" has already been defined as a prop."),
  47197. vm
  47198. );
  47199. }
  47200. if ((key in vm) && isReserved(key)) {
  47201. warn(
  47202. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  47203. "Avoid defining component methods that start with _ or $."
  47204. );
  47205. }
  47206. }
  47207. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  47208. }
  47209. }
  47210. function initWatch (vm, watch) {
  47211. for (var key in watch) {
  47212. var handler = watch[key];
  47213. if (Array.isArray(handler)) {
  47214. for (var i = 0; i < handler.length; i++) {
  47215. createWatcher(vm, key, handler[i]);
  47216. }
  47217. } else {
  47218. createWatcher(vm, key, handler);
  47219. }
  47220. }
  47221. }
  47222. function createWatcher (
  47223. vm,
  47224. expOrFn,
  47225. handler,
  47226. options
  47227. ) {
  47228. if (isPlainObject(handler)) {
  47229. options = handler;
  47230. handler = handler.handler;
  47231. }
  47232. if (typeof handler === 'string') {
  47233. handler = vm[handler];
  47234. }
  47235. return vm.$watch(expOrFn, handler, options)
  47236. }
  47237. function stateMixin (Vue) {
  47238. // flow somehow has problems with directly declared definition object
  47239. // when using Object.defineProperty, so we have to procedurally build up
  47240. // the object here.
  47241. var dataDef = {};
  47242. dataDef.get = function () { return this._data };
  47243. var propsDef = {};
  47244. propsDef.get = function () { return this._props };
  47245. {
  47246. dataDef.set = function () {
  47247. warn(
  47248. 'Avoid replacing instance root $data. ' +
  47249. 'Use nested data properties instead.',
  47250. this
  47251. );
  47252. };
  47253. propsDef.set = function () {
  47254. warn("$props is readonly.", this);
  47255. };
  47256. }
  47257. Object.defineProperty(Vue.prototype, '$data', dataDef);
  47258. Object.defineProperty(Vue.prototype, '$props', propsDef);
  47259. Vue.prototype.$set = set;
  47260. Vue.prototype.$delete = del;
  47261. Vue.prototype.$watch = function (
  47262. expOrFn,
  47263. cb,
  47264. options
  47265. ) {
  47266. var vm = this;
  47267. if (isPlainObject(cb)) {
  47268. return createWatcher(vm, expOrFn, cb, options)
  47269. }
  47270. options = options || {};
  47271. options.user = true;
  47272. var watcher = new Watcher(vm, expOrFn, cb, options);
  47273. if (options.immediate) {
  47274. try {
  47275. cb.call(vm, watcher.value);
  47276. } catch (error) {
  47277. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  47278. }
  47279. }
  47280. return function unwatchFn () {
  47281. watcher.teardown();
  47282. }
  47283. };
  47284. }
  47285. /* */
  47286. var uid$3 = 0;
  47287. function initMixin (Vue) {
  47288. Vue.prototype._init = function (options) {
  47289. var vm = this;
  47290. // a uid
  47291. vm._uid = uid$3++;
  47292. var startTag, endTag;
  47293. /* istanbul ignore if */
  47294. if (config.performance && mark) {
  47295. startTag = "vue-perf-start:" + (vm._uid);
  47296. endTag = "vue-perf-end:" + (vm._uid);
  47297. mark(startTag);
  47298. }
  47299. // a flag to avoid this being observed
  47300. vm._isVue = true;
  47301. // merge options
  47302. if (options && options._isComponent) {
  47303. // optimize internal component instantiation
  47304. // since dynamic options merging is pretty slow, and none of the
  47305. // internal component options needs special treatment.
  47306. initInternalComponent(vm, options);
  47307. } else {
  47308. vm.$options = mergeOptions(
  47309. resolveConstructorOptions(vm.constructor),
  47310. options || {},
  47311. vm
  47312. );
  47313. }
  47314. /* istanbul ignore else */
  47315. {
  47316. initProxy(vm);
  47317. }
  47318. // expose real self
  47319. vm._self = vm;
  47320. initLifecycle(vm);
  47321. initEvents(vm);
  47322. initRender(vm);
  47323. callHook(vm, 'beforeCreate');
  47324. initInjections(vm); // resolve injections before data/props
  47325. initState(vm);
  47326. initProvide(vm); // resolve provide after data/props
  47327. callHook(vm, 'created');
  47328. /* istanbul ignore if */
  47329. if (config.performance && mark) {
  47330. vm._name = formatComponentName(vm, false);
  47331. mark(endTag);
  47332. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  47333. }
  47334. if (vm.$options.el) {
  47335. vm.$mount(vm.$options.el);
  47336. }
  47337. };
  47338. }
  47339. function initInternalComponent (vm, options) {
  47340. var opts = vm.$options = Object.create(vm.constructor.options);
  47341. // doing this because it's faster than dynamic enumeration.
  47342. var parentVnode = options._parentVnode;
  47343. opts.parent = options.parent;
  47344. opts._parentVnode = parentVnode;
  47345. var vnodeComponentOptions = parentVnode.componentOptions;
  47346. opts.propsData = vnodeComponentOptions.propsData;
  47347. opts._parentListeners = vnodeComponentOptions.listeners;
  47348. opts._renderChildren = vnodeComponentOptions.children;
  47349. opts._componentTag = vnodeComponentOptions.tag;
  47350. if (options.render) {
  47351. opts.render = options.render;
  47352. opts.staticRenderFns = options.staticRenderFns;
  47353. }
  47354. }
  47355. function resolveConstructorOptions (Ctor) {
  47356. var options = Ctor.options;
  47357. if (Ctor.super) {
  47358. var superOptions = resolveConstructorOptions(Ctor.super);
  47359. var cachedSuperOptions = Ctor.superOptions;
  47360. if (superOptions !== cachedSuperOptions) {
  47361. // super option changed,
  47362. // need to resolve new options.
  47363. Ctor.superOptions = superOptions;
  47364. // check if there are any late-modified/attached options (#4976)
  47365. var modifiedOptions = resolveModifiedOptions(Ctor);
  47366. // update base extend options
  47367. if (modifiedOptions) {
  47368. extend(Ctor.extendOptions, modifiedOptions);
  47369. }
  47370. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  47371. if (options.name) {
  47372. options.components[options.name] = Ctor;
  47373. }
  47374. }
  47375. }
  47376. return options
  47377. }
  47378. function resolveModifiedOptions (Ctor) {
  47379. var modified;
  47380. var latest = Ctor.options;
  47381. var sealed = Ctor.sealedOptions;
  47382. for (var key in latest) {
  47383. if (latest[key] !== sealed[key]) {
  47384. if (!modified) { modified = {}; }
  47385. modified[key] = latest[key];
  47386. }
  47387. }
  47388. return modified
  47389. }
  47390. function Vue (options) {
  47391. if (!(this instanceof Vue)
  47392. ) {
  47393. warn('Vue is a constructor and should be called with the `new` keyword');
  47394. }
  47395. this._init(options);
  47396. }
  47397. initMixin(Vue);
  47398. stateMixin(Vue);
  47399. eventsMixin(Vue);
  47400. lifecycleMixin(Vue);
  47401. renderMixin(Vue);
  47402. /* */
  47403. function initUse (Vue) {
  47404. Vue.use = function (plugin) {
  47405. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  47406. if (installedPlugins.indexOf(plugin) > -1) {
  47407. return this
  47408. }
  47409. // additional parameters
  47410. var args = toArray(arguments, 1);
  47411. args.unshift(this);
  47412. if (typeof plugin.install === 'function') {
  47413. plugin.install.apply(plugin, args);
  47414. } else if (typeof plugin === 'function') {
  47415. plugin.apply(null, args);
  47416. }
  47417. installedPlugins.push(plugin);
  47418. return this
  47419. };
  47420. }
  47421. /* */
  47422. function initMixin$1 (Vue) {
  47423. Vue.mixin = function (mixin) {
  47424. this.options = mergeOptions(this.options, mixin);
  47425. return this
  47426. };
  47427. }
  47428. /* */
  47429. function initExtend (Vue) {
  47430. /**
  47431. * Each instance constructor, including Vue, has a unique
  47432. * cid. This enables us to create wrapped "child
  47433. * constructors" for prototypal inheritance and cache them.
  47434. */
  47435. Vue.cid = 0;
  47436. var cid = 1;
  47437. /**
  47438. * Class inheritance
  47439. */
  47440. Vue.extend = function (extendOptions) {
  47441. extendOptions = extendOptions || {};
  47442. var Super = this;
  47443. var SuperId = Super.cid;
  47444. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  47445. if (cachedCtors[SuperId]) {
  47446. return cachedCtors[SuperId]
  47447. }
  47448. var name = extendOptions.name || Super.options.name;
  47449. if (name) {
  47450. validateComponentName(name);
  47451. }
  47452. var Sub = function VueComponent (options) {
  47453. this._init(options);
  47454. };
  47455. Sub.prototype = Object.create(Super.prototype);
  47456. Sub.prototype.constructor = Sub;
  47457. Sub.cid = cid++;
  47458. Sub.options = mergeOptions(
  47459. Super.options,
  47460. extendOptions
  47461. );
  47462. Sub['super'] = Super;
  47463. // For props and computed properties, we define the proxy getters on
  47464. // the Vue instances at extension time, on the extended prototype. This
  47465. // avoids Object.defineProperty calls for each instance created.
  47466. if (Sub.options.props) {
  47467. initProps$1(Sub);
  47468. }
  47469. if (Sub.options.computed) {
  47470. initComputed$1(Sub);
  47471. }
  47472. // allow further extension/mixin/plugin usage
  47473. Sub.extend = Super.extend;
  47474. Sub.mixin = Super.mixin;
  47475. Sub.use = Super.use;
  47476. // create asset registers, so extended classes
  47477. // can have their private assets too.
  47478. ASSET_TYPES.forEach(function (type) {
  47479. Sub[type] = Super[type];
  47480. });
  47481. // enable recursive self-lookup
  47482. if (name) {
  47483. Sub.options.components[name] = Sub;
  47484. }
  47485. // keep a reference to the super options at extension time.
  47486. // later at instantiation we can check if Super's options have
  47487. // been updated.
  47488. Sub.superOptions = Super.options;
  47489. Sub.extendOptions = extendOptions;
  47490. Sub.sealedOptions = extend({}, Sub.options);
  47491. // cache constructor
  47492. cachedCtors[SuperId] = Sub;
  47493. return Sub
  47494. };
  47495. }
  47496. function initProps$1 (Comp) {
  47497. var props = Comp.options.props;
  47498. for (var key in props) {
  47499. proxy(Comp.prototype, "_props", key);
  47500. }
  47501. }
  47502. function initComputed$1 (Comp) {
  47503. var computed = Comp.options.computed;
  47504. for (var key in computed) {
  47505. defineComputed(Comp.prototype, key, computed[key]);
  47506. }
  47507. }
  47508. /* */
  47509. function initAssetRegisters (Vue) {
  47510. /**
  47511. * Create asset registration methods.
  47512. */
  47513. ASSET_TYPES.forEach(function (type) {
  47514. Vue[type] = function (
  47515. id,
  47516. definition
  47517. ) {
  47518. if (!definition) {
  47519. return this.options[type + 's'][id]
  47520. } else {
  47521. /* istanbul ignore if */
  47522. if (type === 'component') {
  47523. validateComponentName(id);
  47524. }
  47525. if (type === 'component' && isPlainObject(definition)) {
  47526. definition.name = definition.name || id;
  47527. definition = this.options._base.extend(definition);
  47528. }
  47529. if (type === 'directive' && typeof definition === 'function') {
  47530. definition = { bind: definition, update: definition };
  47531. }
  47532. this.options[type + 's'][id] = definition;
  47533. return definition
  47534. }
  47535. };
  47536. });
  47537. }
  47538. /* */
  47539. function getComponentName (opts) {
  47540. return opts && (opts.Ctor.options.name || opts.tag)
  47541. }
  47542. function matches (pattern, name) {
  47543. if (Array.isArray(pattern)) {
  47544. return pattern.indexOf(name) > -1
  47545. } else if (typeof pattern === 'string') {
  47546. return pattern.split(',').indexOf(name) > -1
  47547. } else if (isRegExp(pattern)) {
  47548. return pattern.test(name)
  47549. }
  47550. /* istanbul ignore next */
  47551. return false
  47552. }
  47553. function pruneCache (keepAliveInstance, filter) {
  47554. var cache = keepAliveInstance.cache;
  47555. var keys = keepAliveInstance.keys;
  47556. var _vnode = keepAliveInstance._vnode;
  47557. for (var key in cache) {
  47558. var cachedNode = cache[key];
  47559. if (cachedNode) {
  47560. var name = getComponentName(cachedNode.componentOptions);
  47561. if (name && !filter(name)) {
  47562. pruneCacheEntry(cache, key, keys, _vnode);
  47563. }
  47564. }
  47565. }
  47566. }
  47567. function pruneCacheEntry (
  47568. cache,
  47569. key,
  47570. keys,
  47571. current
  47572. ) {
  47573. var cached$$1 = cache[key];
  47574. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  47575. cached$$1.componentInstance.$destroy();
  47576. }
  47577. cache[key] = null;
  47578. remove(keys, key);
  47579. }
  47580. var patternTypes = [String, RegExp, Array];
  47581. var KeepAlive = {
  47582. name: 'keep-alive',
  47583. abstract: true,
  47584. props: {
  47585. include: patternTypes,
  47586. exclude: patternTypes,
  47587. max: [String, Number]
  47588. },
  47589. created: function created () {
  47590. this.cache = Object.create(null);
  47591. this.keys = [];
  47592. },
  47593. destroyed: function destroyed () {
  47594. for (var key in this.cache) {
  47595. pruneCacheEntry(this.cache, key, this.keys);
  47596. }
  47597. },
  47598. mounted: function mounted () {
  47599. var this$1 = this;
  47600. this.$watch('include', function (val) {
  47601. pruneCache(this$1, function (name) { return matches(val, name); });
  47602. });
  47603. this.$watch('exclude', function (val) {
  47604. pruneCache(this$1, function (name) { return !matches(val, name); });
  47605. });
  47606. },
  47607. render: function render () {
  47608. var slot = this.$slots.default;
  47609. var vnode = getFirstComponentChild(slot);
  47610. var componentOptions = vnode && vnode.componentOptions;
  47611. if (componentOptions) {
  47612. // check pattern
  47613. var name = getComponentName(componentOptions);
  47614. var ref = this;
  47615. var include = ref.include;
  47616. var exclude = ref.exclude;
  47617. if (
  47618. // not included
  47619. (include && (!name || !matches(include, name))) ||
  47620. // excluded
  47621. (exclude && name && matches(exclude, name))
  47622. ) {
  47623. return vnode
  47624. }
  47625. var ref$1 = this;
  47626. var cache = ref$1.cache;
  47627. var keys = ref$1.keys;
  47628. var key = vnode.key == null
  47629. // same constructor may get registered as different local components
  47630. // so cid alone is not enough (#3269)
  47631. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  47632. : vnode.key;
  47633. if (cache[key]) {
  47634. vnode.componentInstance = cache[key].componentInstance;
  47635. // make current key freshest
  47636. remove(keys, key);
  47637. keys.push(key);
  47638. } else {
  47639. cache[key] = vnode;
  47640. keys.push(key);
  47641. // prune oldest entry
  47642. if (this.max && keys.length > parseInt(this.max)) {
  47643. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  47644. }
  47645. }
  47646. vnode.data.keepAlive = true;
  47647. }
  47648. return vnode || (slot && slot[0])
  47649. }
  47650. };
  47651. var builtInComponents = {
  47652. KeepAlive: KeepAlive
  47653. };
  47654. /* */
  47655. function initGlobalAPI (Vue) {
  47656. // config
  47657. var configDef = {};
  47658. configDef.get = function () { return config; };
  47659. {
  47660. configDef.set = function () {
  47661. warn(
  47662. 'Do not replace the Vue.config object, set individual fields instead.'
  47663. );
  47664. };
  47665. }
  47666. Object.defineProperty(Vue, 'config', configDef);
  47667. // exposed util methods.
  47668. // NOTE: these are not considered part of the public API - avoid relying on
  47669. // them unless you are aware of the risk.
  47670. Vue.util = {
  47671. warn: warn,
  47672. extend: extend,
  47673. mergeOptions: mergeOptions,
  47674. defineReactive: defineReactive$$1
  47675. };
  47676. Vue.set = set;
  47677. Vue.delete = del;
  47678. Vue.nextTick = nextTick;
  47679. // 2.6 explicit observable API
  47680. Vue.observable = function (obj) {
  47681. observe(obj);
  47682. return obj
  47683. };
  47684. Vue.options = Object.create(null);
  47685. ASSET_TYPES.forEach(function (type) {
  47686. Vue.options[type + 's'] = Object.create(null);
  47687. });
  47688. // this is used to identify the "base" constructor to extend all plain-object
  47689. // components with in Weex's multi-instance scenarios.
  47690. Vue.options._base = Vue;
  47691. extend(Vue.options.components, builtInComponents);
  47692. initUse(Vue);
  47693. initMixin$1(Vue);
  47694. initExtend(Vue);
  47695. initAssetRegisters(Vue);
  47696. }
  47697. initGlobalAPI(Vue);
  47698. Object.defineProperty(Vue.prototype, '$isServer', {
  47699. get: isServerRendering
  47700. });
  47701. Object.defineProperty(Vue.prototype, '$ssrContext', {
  47702. get: function get () {
  47703. /* istanbul ignore next */
  47704. return this.$vnode && this.$vnode.ssrContext
  47705. }
  47706. });
  47707. // expose FunctionalRenderContext for ssr runtime helper installation
  47708. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  47709. value: FunctionalRenderContext
  47710. });
  47711. Vue.version = '2.6.11';
  47712. /* */
  47713. // these are reserved for web because they are directly compiled away
  47714. // during template compilation
  47715. var isReservedAttr = makeMap('style,class');
  47716. // attributes that should be using props for binding
  47717. var acceptValue = makeMap('input,textarea,option,select,progress');
  47718. var mustUseProp = function (tag, type, attr) {
  47719. return (
  47720. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  47721. (attr === 'selected' && tag === 'option') ||
  47722. (attr === 'checked' && tag === 'input') ||
  47723. (attr === 'muted' && tag === 'video')
  47724. )
  47725. };
  47726. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  47727. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  47728. var convertEnumeratedValue = function (key, value) {
  47729. return isFalsyAttrValue(value) || value === 'false'
  47730. ? 'false'
  47731. // allow arbitrary string value for contenteditable
  47732. : key === 'contenteditable' && isValidContentEditableValue(value)
  47733. ? value
  47734. : 'true'
  47735. };
  47736. var isBooleanAttr = makeMap(
  47737. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  47738. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  47739. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  47740. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  47741. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  47742. 'truespeed,typemustmatch,visible'
  47743. );
  47744. var xlinkNS = 'http://www.w3.org/1999/xlink';
  47745. var isXlink = function (name) {
  47746. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  47747. };
  47748. var getXlinkProp = function (name) {
  47749. return isXlink(name) ? name.slice(6, name.length) : ''
  47750. };
  47751. var isFalsyAttrValue = function (val) {
  47752. return val == null || val === false
  47753. };
  47754. /* */
  47755. function genClassForVnode (vnode) {
  47756. var data = vnode.data;
  47757. var parentNode = vnode;
  47758. var childNode = vnode;
  47759. while (isDef(childNode.componentInstance)) {
  47760. childNode = childNode.componentInstance._vnode;
  47761. if (childNode && childNode.data) {
  47762. data = mergeClassData(childNode.data, data);
  47763. }
  47764. }
  47765. while (isDef(parentNode = parentNode.parent)) {
  47766. if (parentNode && parentNode.data) {
  47767. data = mergeClassData(data, parentNode.data);
  47768. }
  47769. }
  47770. return renderClass(data.staticClass, data.class)
  47771. }
  47772. function mergeClassData (child, parent) {
  47773. return {
  47774. staticClass: concat(child.staticClass, parent.staticClass),
  47775. class: isDef(child.class)
  47776. ? [child.class, parent.class]
  47777. : parent.class
  47778. }
  47779. }
  47780. function renderClass (
  47781. staticClass,
  47782. dynamicClass
  47783. ) {
  47784. if (isDef(staticClass) || isDef(dynamicClass)) {
  47785. return concat(staticClass, stringifyClass(dynamicClass))
  47786. }
  47787. /* istanbul ignore next */
  47788. return ''
  47789. }
  47790. function concat (a, b) {
  47791. return a ? b ? (a + ' ' + b) : a : (b || '')
  47792. }
  47793. function stringifyClass (value) {
  47794. if (Array.isArray(value)) {
  47795. return stringifyArray(value)
  47796. }
  47797. if (isObject(value)) {
  47798. return stringifyObject(value)
  47799. }
  47800. if (typeof value === 'string') {
  47801. return value
  47802. }
  47803. /* istanbul ignore next */
  47804. return ''
  47805. }
  47806. function stringifyArray (value) {
  47807. var res = '';
  47808. var stringified;
  47809. for (var i = 0, l = value.length; i < l; i++) {
  47810. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  47811. if (res) { res += ' '; }
  47812. res += stringified;
  47813. }
  47814. }
  47815. return res
  47816. }
  47817. function stringifyObject (value) {
  47818. var res = '';
  47819. for (var key in value) {
  47820. if (value[key]) {
  47821. if (res) { res += ' '; }
  47822. res += key;
  47823. }
  47824. }
  47825. return res
  47826. }
  47827. /* */
  47828. var namespaceMap = {
  47829. svg: 'http://www.w3.org/2000/svg',
  47830. math: 'http://www.w3.org/1998/Math/MathML'
  47831. };
  47832. var isHTMLTag = makeMap(
  47833. 'html,body,base,head,link,meta,style,title,' +
  47834. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  47835. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  47836. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  47837. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  47838. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  47839. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  47840. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  47841. 'output,progress,select,textarea,' +
  47842. 'details,dialog,menu,menuitem,summary,' +
  47843. 'content,element,shadow,template,blockquote,iframe,tfoot'
  47844. );
  47845. // this map is intentionally selective, only covering SVG elements that may
  47846. // contain child elements.
  47847. var isSVG = makeMap(
  47848. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  47849. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  47850. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  47851. true
  47852. );
  47853. var isPreTag = function (tag) { return tag === 'pre'; };
  47854. var isReservedTag = function (tag) {
  47855. return isHTMLTag(tag) || isSVG(tag)
  47856. };
  47857. function getTagNamespace (tag) {
  47858. if (isSVG(tag)) {
  47859. return 'svg'
  47860. }
  47861. // basic support for MathML
  47862. // note it doesn't support other MathML elements being component roots
  47863. if (tag === 'math') {
  47864. return 'math'
  47865. }
  47866. }
  47867. var unknownElementCache = Object.create(null);
  47868. function isUnknownElement (tag) {
  47869. /* istanbul ignore if */
  47870. if (!inBrowser) {
  47871. return true
  47872. }
  47873. if (isReservedTag(tag)) {
  47874. return false
  47875. }
  47876. tag = tag.toLowerCase();
  47877. /* istanbul ignore if */
  47878. if (unknownElementCache[tag] != null) {
  47879. return unknownElementCache[tag]
  47880. }
  47881. var el = document.createElement(tag);
  47882. if (tag.indexOf('-') > -1) {
  47883. // http://stackoverflow.com/a/28210364/1070244
  47884. return (unknownElementCache[tag] = (
  47885. el.constructor === window.HTMLUnknownElement ||
  47886. el.constructor === window.HTMLElement
  47887. ))
  47888. } else {
  47889. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  47890. }
  47891. }
  47892. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  47893. /* */
  47894. /**
  47895. * Query an element selector if it's not an element already.
  47896. */
  47897. function query (el) {
  47898. if (typeof el === 'string') {
  47899. var selected = document.querySelector(el);
  47900. if (!selected) {
  47901. warn(
  47902. 'Cannot find element: ' + el
  47903. );
  47904. return document.createElement('div')
  47905. }
  47906. return selected
  47907. } else {
  47908. return el
  47909. }
  47910. }
  47911. /* */
  47912. function createElement$1 (tagName, vnode) {
  47913. var elm = document.createElement(tagName);
  47914. if (tagName !== 'select') {
  47915. return elm
  47916. }
  47917. // false or null will remove the attribute but undefined will not
  47918. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  47919. elm.setAttribute('multiple', 'multiple');
  47920. }
  47921. return elm
  47922. }
  47923. function createElementNS (namespace, tagName) {
  47924. return document.createElementNS(namespaceMap[namespace], tagName)
  47925. }
  47926. function createTextNode (text) {
  47927. return document.createTextNode(text)
  47928. }
  47929. function createComment (text) {
  47930. return document.createComment(text)
  47931. }
  47932. function insertBefore (parentNode, newNode, referenceNode) {
  47933. parentNode.insertBefore(newNode, referenceNode);
  47934. }
  47935. function removeChild (node, child) {
  47936. node.removeChild(child);
  47937. }
  47938. function appendChild (node, child) {
  47939. node.appendChild(child);
  47940. }
  47941. function parentNode (node) {
  47942. return node.parentNode
  47943. }
  47944. function nextSibling (node) {
  47945. return node.nextSibling
  47946. }
  47947. function tagName (node) {
  47948. return node.tagName
  47949. }
  47950. function setTextContent (node, text) {
  47951. node.textContent = text;
  47952. }
  47953. function setStyleScope (node, scopeId) {
  47954. node.setAttribute(scopeId, '');
  47955. }
  47956. var nodeOps = /*#__PURE__*/Object.freeze({
  47957. createElement: createElement$1,
  47958. createElementNS: createElementNS,
  47959. createTextNode: createTextNode,
  47960. createComment: createComment,
  47961. insertBefore: insertBefore,
  47962. removeChild: removeChild,
  47963. appendChild: appendChild,
  47964. parentNode: parentNode,
  47965. nextSibling: nextSibling,
  47966. tagName: tagName,
  47967. setTextContent: setTextContent,
  47968. setStyleScope: setStyleScope
  47969. });
  47970. /* */
  47971. var ref = {
  47972. create: function create (_, vnode) {
  47973. registerRef(vnode);
  47974. },
  47975. update: function update (oldVnode, vnode) {
  47976. if (oldVnode.data.ref !== vnode.data.ref) {
  47977. registerRef(oldVnode, true);
  47978. registerRef(vnode);
  47979. }
  47980. },
  47981. destroy: function destroy (vnode) {
  47982. registerRef(vnode, true);
  47983. }
  47984. };
  47985. function registerRef (vnode, isRemoval) {
  47986. var key = vnode.data.ref;
  47987. if (!isDef(key)) { return }
  47988. var vm = vnode.context;
  47989. var ref = vnode.componentInstance || vnode.elm;
  47990. var refs = vm.$refs;
  47991. if (isRemoval) {
  47992. if (Array.isArray(refs[key])) {
  47993. remove(refs[key], ref);
  47994. } else if (refs[key] === ref) {
  47995. refs[key] = undefined;
  47996. }
  47997. } else {
  47998. if (vnode.data.refInFor) {
  47999. if (!Array.isArray(refs[key])) {
  48000. refs[key] = [ref];
  48001. } else if (refs[key].indexOf(ref) < 0) {
  48002. // $flow-disable-line
  48003. refs[key].push(ref);
  48004. }
  48005. } else {
  48006. refs[key] = ref;
  48007. }
  48008. }
  48009. }
  48010. /**
  48011. * Virtual DOM patching algorithm based on Snabbdom by
  48012. * Simon Friis Vindum (@paldepind)
  48013. * Licensed under the MIT License
  48014. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  48015. *
  48016. * modified by Evan You (@yyx990803)
  48017. *
  48018. * Not type-checking this because this file is perf-critical and the cost
  48019. * of making flow understand it is not worth it.
  48020. */
  48021. var emptyNode = new VNode('', {}, []);
  48022. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  48023. function sameVnode (a, b) {
  48024. return (
  48025. a.key === b.key && (
  48026. (
  48027. a.tag === b.tag &&
  48028. a.isComment === b.isComment &&
  48029. isDef(a.data) === isDef(b.data) &&
  48030. sameInputType(a, b)
  48031. ) || (
  48032. isTrue(a.isAsyncPlaceholder) &&
  48033. a.asyncFactory === b.asyncFactory &&
  48034. isUndef(b.asyncFactory.error)
  48035. )
  48036. )
  48037. )
  48038. }
  48039. function sameInputType (a, b) {
  48040. if (a.tag !== 'input') { return true }
  48041. var i;
  48042. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  48043. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  48044. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  48045. }
  48046. function createKeyToOldIdx (children, beginIdx, endIdx) {
  48047. var i, key;
  48048. var map = {};
  48049. for (i = beginIdx; i <= endIdx; ++i) {
  48050. key = children[i].key;
  48051. if (isDef(key)) { map[key] = i; }
  48052. }
  48053. return map
  48054. }
  48055. function createPatchFunction (backend) {
  48056. var i, j;
  48057. var cbs = {};
  48058. var modules = backend.modules;
  48059. var nodeOps = backend.nodeOps;
  48060. for (i = 0; i < hooks.length; ++i) {
  48061. cbs[hooks[i]] = [];
  48062. for (j = 0; j < modules.length; ++j) {
  48063. if (isDef(modules[j][hooks[i]])) {
  48064. cbs[hooks[i]].push(modules[j][hooks[i]]);
  48065. }
  48066. }
  48067. }
  48068. function emptyNodeAt (elm) {
  48069. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  48070. }
  48071. function createRmCb (childElm, listeners) {
  48072. function remove$$1 () {
  48073. if (--remove$$1.listeners === 0) {
  48074. removeNode(childElm);
  48075. }
  48076. }
  48077. remove$$1.listeners = listeners;
  48078. return remove$$1
  48079. }
  48080. function removeNode (el) {
  48081. var parent = nodeOps.parentNode(el);
  48082. // element may have already been removed due to v-html / v-text
  48083. if (isDef(parent)) {
  48084. nodeOps.removeChild(parent, el);
  48085. }
  48086. }
  48087. function isUnknownElement$$1 (vnode, inVPre) {
  48088. return (
  48089. !inVPre &&
  48090. !vnode.ns &&
  48091. !(
  48092. config.ignoredElements.length &&
  48093. config.ignoredElements.some(function (ignore) {
  48094. return isRegExp(ignore)
  48095. ? ignore.test(vnode.tag)
  48096. : ignore === vnode.tag
  48097. })
  48098. ) &&
  48099. config.isUnknownElement(vnode.tag)
  48100. )
  48101. }
  48102. var creatingElmInVPre = 0;
  48103. function createElm (
  48104. vnode,
  48105. insertedVnodeQueue,
  48106. parentElm,
  48107. refElm,
  48108. nested,
  48109. ownerArray,
  48110. index
  48111. ) {
  48112. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48113. // This vnode was used in a previous render!
  48114. // now it's used as a new node, overwriting its elm would cause
  48115. // potential patch errors down the road when it's used as an insertion
  48116. // reference node. Instead, we clone the node on-demand before creating
  48117. // associated DOM element for it.
  48118. vnode = ownerArray[index] = cloneVNode(vnode);
  48119. }
  48120. vnode.isRootInsert = !nested; // for transition enter check
  48121. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  48122. return
  48123. }
  48124. var data = vnode.data;
  48125. var children = vnode.children;
  48126. var tag = vnode.tag;
  48127. if (isDef(tag)) {
  48128. {
  48129. if (data && data.pre) {
  48130. creatingElmInVPre++;
  48131. }
  48132. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  48133. warn(
  48134. 'Unknown custom element: <' + tag + '> - did you ' +
  48135. 'register the component correctly? For recursive components, ' +
  48136. 'make sure to provide the "name" option.',
  48137. vnode.context
  48138. );
  48139. }
  48140. }
  48141. vnode.elm = vnode.ns
  48142. ? nodeOps.createElementNS(vnode.ns, tag)
  48143. : nodeOps.createElement(tag, vnode);
  48144. setScope(vnode);
  48145. /* istanbul ignore if */
  48146. {
  48147. createChildren(vnode, children, insertedVnodeQueue);
  48148. if (isDef(data)) {
  48149. invokeCreateHooks(vnode, insertedVnodeQueue);
  48150. }
  48151. insert(parentElm, vnode.elm, refElm);
  48152. }
  48153. if (data && data.pre) {
  48154. creatingElmInVPre--;
  48155. }
  48156. } else if (isTrue(vnode.isComment)) {
  48157. vnode.elm = nodeOps.createComment(vnode.text);
  48158. insert(parentElm, vnode.elm, refElm);
  48159. } else {
  48160. vnode.elm = nodeOps.createTextNode(vnode.text);
  48161. insert(parentElm, vnode.elm, refElm);
  48162. }
  48163. }
  48164. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48165. var i = vnode.data;
  48166. if (isDef(i)) {
  48167. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  48168. if (isDef(i = i.hook) && isDef(i = i.init)) {
  48169. i(vnode, false /* hydrating */);
  48170. }
  48171. // after calling the init hook, if the vnode is a child component
  48172. // it should've created a child instance and mounted it. the child
  48173. // component also has set the placeholder vnode's elm.
  48174. // in that case we can just return the element and be done.
  48175. if (isDef(vnode.componentInstance)) {
  48176. initComponent(vnode, insertedVnodeQueue);
  48177. insert(parentElm, vnode.elm, refElm);
  48178. if (isTrue(isReactivated)) {
  48179. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  48180. }
  48181. return true
  48182. }
  48183. }
  48184. }
  48185. function initComponent (vnode, insertedVnodeQueue) {
  48186. if (isDef(vnode.data.pendingInsert)) {
  48187. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  48188. vnode.data.pendingInsert = null;
  48189. }
  48190. vnode.elm = vnode.componentInstance.$el;
  48191. if (isPatchable(vnode)) {
  48192. invokeCreateHooks(vnode, insertedVnodeQueue);
  48193. setScope(vnode);
  48194. } else {
  48195. // empty component root.
  48196. // skip all element-related modules except for ref (#3455)
  48197. registerRef(vnode);
  48198. // make sure to invoke the insert hook
  48199. insertedVnodeQueue.push(vnode);
  48200. }
  48201. }
  48202. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48203. var i;
  48204. // hack for #4339: a reactivated component with inner transition
  48205. // does not trigger because the inner node's created hooks are not called
  48206. // again. It's not ideal to involve module-specific logic in here but
  48207. // there doesn't seem to be a better way to do it.
  48208. var innerNode = vnode;
  48209. while (innerNode.componentInstance) {
  48210. innerNode = innerNode.componentInstance._vnode;
  48211. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  48212. for (i = 0; i < cbs.activate.length; ++i) {
  48213. cbs.activate[i](emptyNode, innerNode);
  48214. }
  48215. insertedVnodeQueue.push(innerNode);
  48216. break
  48217. }
  48218. }
  48219. // unlike a newly created component,
  48220. // a reactivated keep-alive component doesn't insert itself
  48221. insert(parentElm, vnode.elm, refElm);
  48222. }
  48223. function insert (parent, elm, ref$$1) {
  48224. if (isDef(parent)) {
  48225. if (isDef(ref$$1)) {
  48226. if (nodeOps.parentNode(ref$$1) === parent) {
  48227. nodeOps.insertBefore(parent, elm, ref$$1);
  48228. }
  48229. } else {
  48230. nodeOps.appendChild(parent, elm);
  48231. }
  48232. }
  48233. }
  48234. function createChildren (vnode, children, insertedVnodeQueue) {
  48235. if (Array.isArray(children)) {
  48236. {
  48237. checkDuplicateKeys(children);
  48238. }
  48239. for (var i = 0; i < children.length; ++i) {
  48240. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  48241. }
  48242. } else if (isPrimitive(vnode.text)) {
  48243. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  48244. }
  48245. }
  48246. function isPatchable (vnode) {
  48247. while (vnode.componentInstance) {
  48248. vnode = vnode.componentInstance._vnode;
  48249. }
  48250. return isDef(vnode.tag)
  48251. }
  48252. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  48253. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48254. cbs.create[i$1](emptyNode, vnode);
  48255. }
  48256. i = vnode.data.hook; // Reuse variable
  48257. if (isDef(i)) {
  48258. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  48259. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  48260. }
  48261. }
  48262. // set scope id attribute for scoped CSS.
  48263. // this is implemented as a special case to avoid the overhead
  48264. // of going through the normal attribute patching process.
  48265. function setScope (vnode) {
  48266. var i;
  48267. if (isDef(i = vnode.fnScopeId)) {
  48268. nodeOps.setStyleScope(vnode.elm, i);
  48269. } else {
  48270. var ancestor = vnode;
  48271. while (ancestor) {
  48272. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  48273. nodeOps.setStyleScope(vnode.elm, i);
  48274. }
  48275. ancestor = ancestor.parent;
  48276. }
  48277. }
  48278. // for slot content they should also get the scopeId from the host instance.
  48279. if (isDef(i = activeInstance) &&
  48280. i !== vnode.context &&
  48281. i !== vnode.fnContext &&
  48282. isDef(i = i.$options._scopeId)
  48283. ) {
  48284. nodeOps.setStyleScope(vnode.elm, i);
  48285. }
  48286. }
  48287. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  48288. for (; startIdx <= endIdx; ++startIdx) {
  48289. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  48290. }
  48291. }
  48292. function invokeDestroyHook (vnode) {
  48293. var i, j;
  48294. var data = vnode.data;
  48295. if (isDef(data)) {
  48296. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  48297. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  48298. }
  48299. if (isDef(i = vnode.children)) {
  48300. for (j = 0; j < vnode.children.length; ++j) {
  48301. invokeDestroyHook(vnode.children[j]);
  48302. }
  48303. }
  48304. }
  48305. function removeVnodes (vnodes, startIdx, endIdx) {
  48306. for (; startIdx <= endIdx; ++startIdx) {
  48307. var ch = vnodes[startIdx];
  48308. if (isDef(ch)) {
  48309. if (isDef(ch.tag)) {
  48310. removeAndInvokeRemoveHook(ch);
  48311. invokeDestroyHook(ch);
  48312. } else { // Text node
  48313. removeNode(ch.elm);
  48314. }
  48315. }
  48316. }
  48317. }
  48318. function removeAndInvokeRemoveHook (vnode, rm) {
  48319. if (isDef(rm) || isDef(vnode.data)) {
  48320. var i;
  48321. var listeners = cbs.remove.length + 1;
  48322. if (isDef(rm)) {
  48323. // we have a recursively passed down rm callback
  48324. // increase the listeners count
  48325. rm.listeners += listeners;
  48326. } else {
  48327. // directly removing
  48328. rm = createRmCb(vnode.elm, listeners);
  48329. }
  48330. // recursively invoke hooks on child component root node
  48331. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  48332. removeAndInvokeRemoveHook(i, rm);
  48333. }
  48334. for (i = 0; i < cbs.remove.length; ++i) {
  48335. cbs.remove[i](vnode, rm);
  48336. }
  48337. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  48338. i(vnode, rm);
  48339. } else {
  48340. rm();
  48341. }
  48342. } else {
  48343. removeNode(vnode.elm);
  48344. }
  48345. }
  48346. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  48347. var oldStartIdx = 0;
  48348. var newStartIdx = 0;
  48349. var oldEndIdx = oldCh.length - 1;
  48350. var oldStartVnode = oldCh[0];
  48351. var oldEndVnode = oldCh[oldEndIdx];
  48352. var newEndIdx = newCh.length - 1;
  48353. var newStartVnode = newCh[0];
  48354. var newEndVnode = newCh[newEndIdx];
  48355. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  48356. // removeOnly is a special flag used only by <transition-group>
  48357. // to ensure removed elements stay in correct relative positions
  48358. // during leaving transitions
  48359. var canMove = !removeOnly;
  48360. {
  48361. checkDuplicateKeys(newCh);
  48362. }
  48363. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  48364. if (isUndef(oldStartVnode)) {
  48365. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  48366. } else if (isUndef(oldEndVnode)) {
  48367. oldEndVnode = oldCh[--oldEndIdx];
  48368. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  48369. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48370. oldStartVnode = oldCh[++oldStartIdx];
  48371. newStartVnode = newCh[++newStartIdx];
  48372. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  48373. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48374. oldEndVnode = oldCh[--oldEndIdx];
  48375. newEndVnode = newCh[--newEndIdx];
  48376. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  48377. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48378. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  48379. oldStartVnode = oldCh[++oldStartIdx];
  48380. newEndVnode = newCh[--newEndIdx];
  48381. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  48382. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48383. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  48384. oldEndVnode = oldCh[--oldEndIdx];
  48385. newStartVnode = newCh[++newStartIdx];
  48386. } else {
  48387. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  48388. idxInOld = isDef(newStartVnode.key)
  48389. ? oldKeyToIdx[newStartVnode.key]
  48390. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  48391. if (isUndef(idxInOld)) { // New element
  48392. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48393. } else {
  48394. vnodeToMove = oldCh[idxInOld];
  48395. if (sameVnode(vnodeToMove, newStartVnode)) {
  48396. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48397. oldCh[idxInOld] = undefined;
  48398. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  48399. } else {
  48400. // same key but different element. treat as new element
  48401. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48402. }
  48403. }
  48404. newStartVnode = newCh[++newStartIdx];
  48405. }
  48406. }
  48407. if (oldStartIdx > oldEndIdx) {
  48408. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  48409. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  48410. } else if (newStartIdx > newEndIdx) {
  48411. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  48412. }
  48413. }
  48414. function checkDuplicateKeys (children) {
  48415. var seenKeys = {};
  48416. for (var i = 0; i < children.length; i++) {
  48417. var vnode = children[i];
  48418. var key = vnode.key;
  48419. if (isDef(key)) {
  48420. if (seenKeys[key]) {
  48421. warn(
  48422. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  48423. vnode.context
  48424. );
  48425. } else {
  48426. seenKeys[key] = true;
  48427. }
  48428. }
  48429. }
  48430. }
  48431. function findIdxInOld (node, oldCh, start, end) {
  48432. for (var i = start; i < end; i++) {
  48433. var c = oldCh[i];
  48434. if (isDef(c) && sameVnode(node, c)) { return i }
  48435. }
  48436. }
  48437. function patchVnode (
  48438. oldVnode,
  48439. vnode,
  48440. insertedVnodeQueue,
  48441. ownerArray,
  48442. index,
  48443. removeOnly
  48444. ) {
  48445. if (oldVnode === vnode) {
  48446. return
  48447. }
  48448. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48449. // clone reused vnode
  48450. vnode = ownerArray[index] = cloneVNode(vnode);
  48451. }
  48452. var elm = vnode.elm = oldVnode.elm;
  48453. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  48454. if (isDef(vnode.asyncFactory.resolved)) {
  48455. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  48456. } else {
  48457. vnode.isAsyncPlaceholder = true;
  48458. }
  48459. return
  48460. }
  48461. // reuse element for static trees.
  48462. // note we only do this if the vnode is cloned -
  48463. // if the new node is not cloned it means the render functions have been
  48464. // reset by the hot-reload-api and we need to do a proper re-render.
  48465. if (isTrue(vnode.isStatic) &&
  48466. isTrue(oldVnode.isStatic) &&
  48467. vnode.key === oldVnode.key &&
  48468. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  48469. ) {
  48470. vnode.componentInstance = oldVnode.componentInstance;
  48471. return
  48472. }
  48473. var i;
  48474. var data = vnode.data;
  48475. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  48476. i(oldVnode, vnode);
  48477. }
  48478. var oldCh = oldVnode.children;
  48479. var ch = vnode.children;
  48480. if (isDef(data) && isPatchable(vnode)) {
  48481. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  48482. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  48483. }
  48484. if (isUndef(vnode.text)) {
  48485. if (isDef(oldCh) && isDef(ch)) {
  48486. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  48487. } else if (isDef(ch)) {
  48488. {
  48489. checkDuplicateKeys(ch);
  48490. }
  48491. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  48492. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  48493. } else if (isDef(oldCh)) {
  48494. removeVnodes(oldCh, 0, oldCh.length - 1);
  48495. } else if (isDef(oldVnode.text)) {
  48496. nodeOps.setTextContent(elm, '');
  48497. }
  48498. } else if (oldVnode.text !== vnode.text) {
  48499. nodeOps.setTextContent(elm, vnode.text);
  48500. }
  48501. if (isDef(data)) {
  48502. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  48503. }
  48504. }
  48505. function invokeInsertHook (vnode, queue, initial) {
  48506. // delay insert hooks for component root nodes, invoke them after the
  48507. // element is really inserted
  48508. if (isTrue(initial) && isDef(vnode.parent)) {
  48509. vnode.parent.data.pendingInsert = queue;
  48510. } else {
  48511. for (var i = 0; i < queue.length; ++i) {
  48512. queue[i].data.hook.insert(queue[i]);
  48513. }
  48514. }
  48515. }
  48516. var hydrationBailed = false;
  48517. // list of modules that can skip create hook during hydration because they
  48518. // are already rendered on the client or has no need for initialization
  48519. // Note: style is excluded because it relies on initial clone for future
  48520. // deep updates (#7063).
  48521. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  48522. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  48523. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  48524. var i;
  48525. var tag = vnode.tag;
  48526. var data = vnode.data;
  48527. var children = vnode.children;
  48528. inVPre = inVPre || (data && data.pre);
  48529. vnode.elm = elm;
  48530. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  48531. vnode.isAsyncPlaceholder = true;
  48532. return true
  48533. }
  48534. // assert node match
  48535. {
  48536. if (!assertNodeMatch(elm, vnode, inVPre)) {
  48537. return false
  48538. }
  48539. }
  48540. if (isDef(data)) {
  48541. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  48542. if (isDef(i = vnode.componentInstance)) {
  48543. // child component. it should have hydrated its own tree.
  48544. initComponent(vnode, insertedVnodeQueue);
  48545. return true
  48546. }
  48547. }
  48548. if (isDef(tag)) {
  48549. if (isDef(children)) {
  48550. // empty element, allow client to pick up and populate children
  48551. if (!elm.hasChildNodes()) {
  48552. createChildren(vnode, children, insertedVnodeQueue);
  48553. } else {
  48554. // v-html and domProps: innerHTML
  48555. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  48556. if (i !== elm.innerHTML) {
  48557. /* istanbul ignore if */
  48558. if (typeof console !== 'undefined' &&
  48559. !hydrationBailed
  48560. ) {
  48561. hydrationBailed = true;
  48562. console.warn('Parent: ', elm);
  48563. console.warn('server innerHTML: ', i);
  48564. console.warn('client innerHTML: ', elm.innerHTML);
  48565. }
  48566. return false
  48567. }
  48568. } else {
  48569. // iterate and compare children lists
  48570. var childrenMatch = true;
  48571. var childNode = elm.firstChild;
  48572. for (var i$1 = 0; i$1 < children.length; i$1++) {
  48573. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  48574. childrenMatch = false;
  48575. break
  48576. }
  48577. childNode = childNode.nextSibling;
  48578. }
  48579. // if childNode is not null, it means the actual childNodes list is
  48580. // longer than the virtual children list.
  48581. if (!childrenMatch || childNode) {
  48582. /* istanbul ignore if */
  48583. if (typeof console !== 'undefined' &&
  48584. !hydrationBailed
  48585. ) {
  48586. hydrationBailed = true;
  48587. console.warn('Parent: ', elm);
  48588. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  48589. }
  48590. return false
  48591. }
  48592. }
  48593. }
  48594. }
  48595. if (isDef(data)) {
  48596. var fullInvoke = false;
  48597. for (var key in data) {
  48598. if (!isRenderedModule(key)) {
  48599. fullInvoke = true;
  48600. invokeCreateHooks(vnode, insertedVnodeQueue);
  48601. break
  48602. }
  48603. }
  48604. if (!fullInvoke && data['class']) {
  48605. // ensure collecting deps for deep class bindings for future updates
  48606. traverse(data['class']);
  48607. }
  48608. }
  48609. } else if (elm.data !== vnode.text) {
  48610. elm.data = vnode.text;
  48611. }
  48612. return true
  48613. }
  48614. function assertNodeMatch (node, vnode, inVPre) {
  48615. if (isDef(vnode.tag)) {
  48616. return vnode.tag.indexOf('vue-component') === 0 || (
  48617. !isUnknownElement$$1(vnode, inVPre) &&
  48618. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  48619. )
  48620. } else {
  48621. return node.nodeType === (vnode.isComment ? 8 : 3)
  48622. }
  48623. }
  48624. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  48625. if (isUndef(vnode)) {
  48626. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  48627. return
  48628. }
  48629. var isInitialPatch = false;
  48630. var insertedVnodeQueue = [];
  48631. if (isUndef(oldVnode)) {
  48632. // empty mount (likely as component), create new root element
  48633. isInitialPatch = true;
  48634. createElm(vnode, insertedVnodeQueue);
  48635. } else {
  48636. var isRealElement = isDef(oldVnode.nodeType);
  48637. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  48638. // patch existing root node
  48639. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  48640. } else {
  48641. if (isRealElement) {
  48642. // mounting to a real element
  48643. // check if this is server-rendered content and if we can perform
  48644. // a successful hydration.
  48645. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  48646. oldVnode.removeAttribute(SSR_ATTR);
  48647. hydrating = true;
  48648. }
  48649. if (isTrue(hydrating)) {
  48650. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  48651. invokeInsertHook(vnode, insertedVnodeQueue, true);
  48652. return oldVnode
  48653. } else {
  48654. warn(
  48655. 'The client-side rendered virtual DOM tree is not matching ' +
  48656. 'server-rendered content. This is likely caused by incorrect ' +
  48657. 'HTML markup, for example nesting block-level elements inside ' +
  48658. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  48659. 'full client-side render.'
  48660. );
  48661. }
  48662. }
  48663. // either not server-rendered, or hydration failed.
  48664. // create an empty node and replace it
  48665. oldVnode = emptyNodeAt(oldVnode);
  48666. }
  48667. // replacing existing element
  48668. var oldElm = oldVnode.elm;
  48669. var parentElm = nodeOps.parentNode(oldElm);
  48670. // create new node
  48671. createElm(
  48672. vnode,
  48673. insertedVnodeQueue,
  48674. // extremely rare edge case: do not insert if old element is in a
  48675. // leaving transition. Only happens when combining transition +
  48676. // keep-alive + HOCs. (#4590)
  48677. oldElm._leaveCb ? null : parentElm,
  48678. nodeOps.nextSibling(oldElm)
  48679. );
  48680. // update parent placeholder node element, recursively
  48681. if (isDef(vnode.parent)) {
  48682. var ancestor = vnode.parent;
  48683. var patchable = isPatchable(vnode);
  48684. while (ancestor) {
  48685. for (var i = 0; i < cbs.destroy.length; ++i) {
  48686. cbs.destroy[i](ancestor);
  48687. }
  48688. ancestor.elm = vnode.elm;
  48689. if (patchable) {
  48690. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48691. cbs.create[i$1](emptyNode, ancestor);
  48692. }
  48693. // #6513
  48694. // invoke insert hooks that may have been merged by create hooks.
  48695. // e.g. for directives that uses the "inserted" hook.
  48696. var insert = ancestor.data.hook.insert;
  48697. if (insert.merged) {
  48698. // start at index 1 to avoid re-invoking component mounted hook
  48699. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  48700. insert.fns[i$2]();
  48701. }
  48702. }
  48703. } else {
  48704. registerRef(ancestor);
  48705. }
  48706. ancestor = ancestor.parent;
  48707. }
  48708. }
  48709. // destroy old node
  48710. if (isDef(parentElm)) {
  48711. removeVnodes([oldVnode], 0, 0);
  48712. } else if (isDef(oldVnode.tag)) {
  48713. invokeDestroyHook(oldVnode);
  48714. }
  48715. }
  48716. }
  48717. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  48718. return vnode.elm
  48719. }
  48720. }
  48721. /* */
  48722. var directives = {
  48723. create: updateDirectives,
  48724. update: updateDirectives,
  48725. destroy: function unbindDirectives (vnode) {
  48726. updateDirectives(vnode, emptyNode);
  48727. }
  48728. };
  48729. function updateDirectives (oldVnode, vnode) {
  48730. if (oldVnode.data.directives || vnode.data.directives) {
  48731. _update(oldVnode, vnode);
  48732. }
  48733. }
  48734. function _update (oldVnode, vnode) {
  48735. var isCreate = oldVnode === emptyNode;
  48736. var isDestroy = vnode === emptyNode;
  48737. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  48738. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  48739. var dirsWithInsert = [];
  48740. var dirsWithPostpatch = [];
  48741. var key, oldDir, dir;
  48742. for (key in newDirs) {
  48743. oldDir = oldDirs[key];
  48744. dir = newDirs[key];
  48745. if (!oldDir) {
  48746. // new directive, bind
  48747. callHook$1(dir, 'bind', vnode, oldVnode);
  48748. if (dir.def && dir.def.inserted) {
  48749. dirsWithInsert.push(dir);
  48750. }
  48751. } else {
  48752. // existing directive, update
  48753. dir.oldValue = oldDir.value;
  48754. dir.oldArg = oldDir.arg;
  48755. callHook$1(dir, 'update', vnode, oldVnode);
  48756. if (dir.def && dir.def.componentUpdated) {
  48757. dirsWithPostpatch.push(dir);
  48758. }
  48759. }
  48760. }
  48761. if (dirsWithInsert.length) {
  48762. var callInsert = function () {
  48763. for (var i = 0; i < dirsWithInsert.length; i++) {
  48764. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  48765. }
  48766. };
  48767. if (isCreate) {
  48768. mergeVNodeHook(vnode, 'insert', callInsert);
  48769. } else {
  48770. callInsert();
  48771. }
  48772. }
  48773. if (dirsWithPostpatch.length) {
  48774. mergeVNodeHook(vnode, 'postpatch', function () {
  48775. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  48776. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  48777. }
  48778. });
  48779. }
  48780. if (!isCreate) {
  48781. for (key in oldDirs) {
  48782. if (!newDirs[key]) {
  48783. // no longer present, unbind
  48784. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  48785. }
  48786. }
  48787. }
  48788. }
  48789. var emptyModifiers = Object.create(null);
  48790. function normalizeDirectives$1 (
  48791. dirs,
  48792. vm
  48793. ) {
  48794. var res = Object.create(null);
  48795. if (!dirs) {
  48796. // $flow-disable-line
  48797. return res
  48798. }
  48799. var i, dir;
  48800. for (i = 0; i < dirs.length; i++) {
  48801. dir = dirs[i];
  48802. if (!dir.modifiers) {
  48803. // $flow-disable-line
  48804. dir.modifiers = emptyModifiers;
  48805. }
  48806. res[getRawDirName(dir)] = dir;
  48807. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  48808. }
  48809. // $flow-disable-line
  48810. return res
  48811. }
  48812. function getRawDirName (dir) {
  48813. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  48814. }
  48815. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  48816. var fn = dir.def && dir.def[hook];
  48817. if (fn) {
  48818. try {
  48819. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  48820. } catch (e) {
  48821. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  48822. }
  48823. }
  48824. }
  48825. var baseModules = [
  48826. ref,
  48827. directives
  48828. ];
  48829. /* */
  48830. function updateAttrs (oldVnode, vnode) {
  48831. var opts = vnode.componentOptions;
  48832. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  48833. return
  48834. }
  48835. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  48836. return
  48837. }
  48838. var key, cur, old;
  48839. var elm = vnode.elm;
  48840. var oldAttrs = oldVnode.data.attrs || {};
  48841. var attrs = vnode.data.attrs || {};
  48842. // clone observed objects, as the user probably wants to mutate it
  48843. if (isDef(attrs.__ob__)) {
  48844. attrs = vnode.data.attrs = extend({}, attrs);
  48845. }
  48846. for (key in attrs) {
  48847. cur = attrs[key];
  48848. old = oldAttrs[key];
  48849. if (old !== cur) {
  48850. setAttr(elm, key, cur);
  48851. }
  48852. }
  48853. // #4391: in IE9, setting type can reset value for input[type=radio]
  48854. // #6666: IE/Edge forces progress value down to 1 before setting a max
  48855. /* istanbul ignore if */
  48856. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  48857. setAttr(elm, 'value', attrs.value);
  48858. }
  48859. for (key in oldAttrs) {
  48860. if (isUndef(attrs[key])) {
  48861. if (isXlink(key)) {
  48862. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  48863. } else if (!isEnumeratedAttr(key)) {
  48864. elm.removeAttribute(key);
  48865. }
  48866. }
  48867. }
  48868. }
  48869. function setAttr (el, key, value) {
  48870. if (el.tagName.indexOf('-') > -1) {
  48871. baseSetAttr(el, key, value);
  48872. } else if (isBooleanAttr(key)) {
  48873. // set attribute for blank value
  48874. // e.g. <option disabled>Select one</option>
  48875. if (isFalsyAttrValue(value)) {
  48876. el.removeAttribute(key);
  48877. } else {
  48878. // technically allowfullscreen is a boolean attribute for <iframe>,
  48879. // but Flash expects a value of "true" when used on <embed> tag
  48880. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  48881. ? 'true'
  48882. : key;
  48883. el.setAttribute(key, value);
  48884. }
  48885. } else if (isEnumeratedAttr(key)) {
  48886. el.setAttribute(key, convertEnumeratedValue(key, value));
  48887. } else if (isXlink(key)) {
  48888. if (isFalsyAttrValue(value)) {
  48889. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  48890. } else {
  48891. el.setAttributeNS(xlinkNS, key, value);
  48892. }
  48893. } else {
  48894. baseSetAttr(el, key, value);
  48895. }
  48896. }
  48897. function baseSetAttr (el, key, value) {
  48898. if (isFalsyAttrValue(value)) {
  48899. el.removeAttribute(key);
  48900. } else {
  48901. // #7138: IE10 & 11 fires input event when setting placeholder on
  48902. // <textarea>... block the first input event and remove the blocker
  48903. // immediately.
  48904. /* istanbul ignore if */
  48905. if (
  48906. isIE && !isIE9 &&
  48907. el.tagName === 'TEXTAREA' &&
  48908. key === 'placeholder' && value !== '' && !el.__ieph
  48909. ) {
  48910. var blocker = function (e) {
  48911. e.stopImmediatePropagation();
  48912. el.removeEventListener('input', blocker);
  48913. };
  48914. el.addEventListener('input', blocker);
  48915. // $flow-disable-line
  48916. el.__ieph = true; /* IE placeholder patched */
  48917. }
  48918. el.setAttribute(key, value);
  48919. }
  48920. }
  48921. var attrs = {
  48922. create: updateAttrs,
  48923. update: updateAttrs
  48924. };
  48925. /* */
  48926. function updateClass (oldVnode, vnode) {
  48927. var el = vnode.elm;
  48928. var data = vnode.data;
  48929. var oldData = oldVnode.data;
  48930. if (
  48931. isUndef(data.staticClass) &&
  48932. isUndef(data.class) && (
  48933. isUndef(oldData) || (
  48934. isUndef(oldData.staticClass) &&
  48935. isUndef(oldData.class)
  48936. )
  48937. )
  48938. ) {
  48939. return
  48940. }
  48941. var cls = genClassForVnode(vnode);
  48942. // handle transition classes
  48943. var transitionClass = el._transitionClasses;
  48944. if (isDef(transitionClass)) {
  48945. cls = concat(cls, stringifyClass(transitionClass));
  48946. }
  48947. // set the class
  48948. if (cls !== el._prevClass) {
  48949. el.setAttribute('class', cls);
  48950. el._prevClass = cls;
  48951. }
  48952. }
  48953. var klass = {
  48954. create: updateClass,
  48955. update: updateClass
  48956. };
  48957. /* */
  48958. var validDivisionCharRE = /[\w).+\-_$\]]/;
  48959. function parseFilters (exp) {
  48960. var inSingle = false;
  48961. var inDouble = false;
  48962. var inTemplateString = false;
  48963. var inRegex = false;
  48964. var curly = 0;
  48965. var square = 0;
  48966. var paren = 0;
  48967. var lastFilterIndex = 0;
  48968. var c, prev, i, expression, filters;
  48969. for (i = 0; i < exp.length; i++) {
  48970. prev = c;
  48971. c = exp.charCodeAt(i);
  48972. if (inSingle) {
  48973. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  48974. } else if (inDouble) {
  48975. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  48976. } else if (inTemplateString) {
  48977. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  48978. } else if (inRegex) {
  48979. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  48980. } else if (
  48981. c === 0x7C && // pipe
  48982. exp.charCodeAt(i + 1) !== 0x7C &&
  48983. exp.charCodeAt(i - 1) !== 0x7C &&
  48984. !curly && !square && !paren
  48985. ) {
  48986. if (expression === undefined) {
  48987. // first filter, end of expression
  48988. lastFilterIndex = i + 1;
  48989. expression = exp.slice(0, i).trim();
  48990. } else {
  48991. pushFilter();
  48992. }
  48993. } else {
  48994. switch (c) {
  48995. case 0x22: inDouble = true; break // "
  48996. case 0x27: inSingle = true; break // '
  48997. case 0x60: inTemplateString = true; break // `
  48998. case 0x28: paren++; break // (
  48999. case 0x29: paren--; break // )
  49000. case 0x5B: square++; break // [
  49001. case 0x5D: square--; break // ]
  49002. case 0x7B: curly++; break // {
  49003. case 0x7D: curly--; break // }
  49004. }
  49005. if (c === 0x2f) { // /
  49006. var j = i - 1;
  49007. var p = (void 0);
  49008. // find first non-whitespace prev char
  49009. for (; j >= 0; j--) {
  49010. p = exp.charAt(j);
  49011. if (p !== ' ') { break }
  49012. }
  49013. if (!p || !validDivisionCharRE.test(p)) {
  49014. inRegex = true;
  49015. }
  49016. }
  49017. }
  49018. }
  49019. if (expression === undefined) {
  49020. expression = exp.slice(0, i).trim();
  49021. } else if (lastFilterIndex !== 0) {
  49022. pushFilter();
  49023. }
  49024. function pushFilter () {
  49025. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  49026. lastFilterIndex = i + 1;
  49027. }
  49028. if (filters) {
  49029. for (i = 0; i < filters.length; i++) {
  49030. expression = wrapFilter(expression, filters[i]);
  49031. }
  49032. }
  49033. return expression
  49034. }
  49035. function wrapFilter (exp, filter) {
  49036. var i = filter.indexOf('(');
  49037. if (i < 0) {
  49038. // _f: resolveFilter
  49039. return ("_f(\"" + filter + "\")(" + exp + ")")
  49040. } else {
  49041. var name = filter.slice(0, i);
  49042. var args = filter.slice(i + 1);
  49043. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  49044. }
  49045. }
  49046. /* */
  49047. /* eslint-disable no-unused-vars */
  49048. function baseWarn (msg, range) {
  49049. console.error(("[Vue compiler]: " + msg));
  49050. }
  49051. /* eslint-enable no-unused-vars */
  49052. function pluckModuleFunction (
  49053. modules,
  49054. key
  49055. ) {
  49056. return modules
  49057. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  49058. : []
  49059. }
  49060. function addProp (el, name, value, range, dynamic) {
  49061. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49062. el.plain = false;
  49063. }
  49064. function addAttr (el, name, value, range, dynamic) {
  49065. var attrs = dynamic
  49066. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  49067. : (el.attrs || (el.attrs = []));
  49068. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49069. el.plain = false;
  49070. }
  49071. // add a raw attr (use this in preTransforms)
  49072. function addRawAttr (el, name, value, range) {
  49073. el.attrsMap[name] = value;
  49074. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  49075. }
  49076. function addDirective (
  49077. el,
  49078. name,
  49079. rawName,
  49080. value,
  49081. arg,
  49082. isDynamicArg,
  49083. modifiers,
  49084. range
  49085. ) {
  49086. (el.directives || (el.directives = [])).push(rangeSetItem({
  49087. name: name,
  49088. rawName: rawName,
  49089. value: value,
  49090. arg: arg,
  49091. isDynamicArg: isDynamicArg,
  49092. modifiers: modifiers
  49093. }, range));
  49094. el.plain = false;
  49095. }
  49096. function prependModifierMarker (symbol, name, dynamic) {
  49097. return dynamic
  49098. ? ("_p(" + name + ",\"" + symbol + "\")")
  49099. : symbol + name // mark the event as captured
  49100. }
  49101. function addHandler (
  49102. el,
  49103. name,
  49104. value,
  49105. modifiers,
  49106. important,
  49107. warn,
  49108. range,
  49109. dynamic
  49110. ) {
  49111. modifiers = modifiers || emptyObject;
  49112. // warn prevent and passive modifier
  49113. /* istanbul ignore if */
  49114. if (
  49115. warn &&
  49116. modifiers.prevent && modifiers.passive
  49117. ) {
  49118. warn(
  49119. 'passive and prevent can\'t be used together. ' +
  49120. 'Passive handler can\'t prevent default event.',
  49121. range
  49122. );
  49123. }
  49124. // normalize click.right and click.middle since they don't actually fire
  49125. // this is technically browser-specific, but at least for now browsers are
  49126. // the only target envs that have right/middle clicks.
  49127. if (modifiers.right) {
  49128. if (dynamic) {
  49129. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  49130. } else if (name === 'click') {
  49131. name = 'contextmenu';
  49132. delete modifiers.right;
  49133. }
  49134. } else if (modifiers.middle) {
  49135. if (dynamic) {
  49136. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  49137. } else if (name === 'click') {
  49138. name = 'mouseup';
  49139. }
  49140. }
  49141. // check capture modifier
  49142. if (modifiers.capture) {
  49143. delete modifiers.capture;
  49144. name = prependModifierMarker('!', name, dynamic);
  49145. }
  49146. if (modifiers.once) {
  49147. delete modifiers.once;
  49148. name = prependModifierMarker('~', name, dynamic);
  49149. }
  49150. /* istanbul ignore if */
  49151. if (modifiers.passive) {
  49152. delete modifiers.passive;
  49153. name = prependModifierMarker('&', name, dynamic);
  49154. }
  49155. var events;
  49156. if (modifiers.native) {
  49157. delete modifiers.native;
  49158. events = el.nativeEvents || (el.nativeEvents = {});
  49159. } else {
  49160. events = el.events || (el.events = {});
  49161. }
  49162. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  49163. if (modifiers !== emptyObject) {
  49164. newHandler.modifiers = modifiers;
  49165. }
  49166. var handlers = events[name];
  49167. /* istanbul ignore if */
  49168. if (Array.isArray(handlers)) {
  49169. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  49170. } else if (handlers) {
  49171. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  49172. } else {
  49173. events[name] = newHandler;
  49174. }
  49175. el.plain = false;
  49176. }
  49177. function getRawBindingAttr (
  49178. el,
  49179. name
  49180. ) {
  49181. return el.rawAttrsMap[':' + name] ||
  49182. el.rawAttrsMap['v-bind:' + name] ||
  49183. el.rawAttrsMap[name]
  49184. }
  49185. function getBindingAttr (
  49186. el,
  49187. name,
  49188. getStatic
  49189. ) {
  49190. var dynamicValue =
  49191. getAndRemoveAttr(el, ':' + name) ||
  49192. getAndRemoveAttr(el, 'v-bind:' + name);
  49193. if (dynamicValue != null) {
  49194. return parseFilters(dynamicValue)
  49195. } else if (getStatic !== false) {
  49196. var staticValue = getAndRemoveAttr(el, name);
  49197. if (staticValue != null) {
  49198. return JSON.stringify(staticValue)
  49199. }
  49200. }
  49201. }
  49202. // note: this only removes the attr from the Array (attrsList) so that it
  49203. // doesn't get processed by processAttrs.
  49204. // By default it does NOT remove it from the map (attrsMap) because the map is
  49205. // needed during codegen.
  49206. function getAndRemoveAttr (
  49207. el,
  49208. name,
  49209. removeFromMap
  49210. ) {
  49211. var val;
  49212. if ((val = el.attrsMap[name]) != null) {
  49213. var list = el.attrsList;
  49214. for (var i = 0, l = list.length; i < l; i++) {
  49215. if (list[i].name === name) {
  49216. list.splice(i, 1);
  49217. break
  49218. }
  49219. }
  49220. }
  49221. if (removeFromMap) {
  49222. delete el.attrsMap[name];
  49223. }
  49224. return val
  49225. }
  49226. function getAndRemoveAttrByRegex (
  49227. el,
  49228. name
  49229. ) {
  49230. var list = el.attrsList;
  49231. for (var i = 0, l = list.length; i < l; i++) {
  49232. var attr = list[i];
  49233. if (name.test(attr.name)) {
  49234. list.splice(i, 1);
  49235. return attr
  49236. }
  49237. }
  49238. }
  49239. function rangeSetItem (
  49240. item,
  49241. range
  49242. ) {
  49243. if (range) {
  49244. if (range.start != null) {
  49245. item.start = range.start;
  49246. }
  49247. if (range.end != null) {
  49248. item.end = range.end;
  49249. }
  49250. }
  49251. return item
  49252. }
  49253. /* */
  49254. /**
  49255. * Cross-platform code generation for component v-model
  49256. */
  49257. function genComponentModel (
  49258. el,
  49259. value,
  49260. modifiers
  49261. ) {
  49262. var ref = modifiers || {};
  49263. var number = ref.number;
  49264. var trim = ref.trim;
  49265. var baseValueExpression = '$$v';
  49266. var valueExpression = baseValueExpression;
  49267. if (trim) {
  49268. valueExpression =
  49269. "(typeof " + baseValueExpression + " === 'string'" +
  49270. "? " + baseValueExpression + ".trim()" +
  49271. ": " + baseValueExpression + ")";
  49272. }
  49273. if (number) {
  49274. valueExpression = "_n(" + valueExpression + ")";
  49275. }
  49276. var assignment = genAssignmentCode(value, valueExpression);
  49277. el.model = {
  49278. value: ("(" + value + ")"),
  49279. expression: JSON.stringify(value),
  49280. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  49281. };
  49282. }
  49283. /**
  49284. * Cross-platform codegen helper for generating v-model value assignment code.
  49285. */
  49286. function genAssignmentCode (
  49287. value,
  49288. assignment
  49289. ) {
  49290. var res = parseModel(value);
  49291. if (res.key === null) {
  49292. return (value + "=" + assignment)
  49293. } else {
  49294. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  49295. }
  49296. }
  49297. /**
  49298. * Parse a v-model expression into a base path and a final key segment.
  49299. * Handles both dot-path and possible square brackets.
  49300. *
  49301. * Possible cases:
  49302. *
  49303. * - test
  49304. * - test[key]
  49305. * - test[test1[key]]
  49306. * - test["a"][key]
  49307. * - xxx.test[a[a].test1[key]]
  49308. * - test.xxx.a["asa"][test1[key]]
  49309. *
  49310. */
  49311. var len, str, chr, index$1, expressionPos, expressionEndPos;
  49312. function parseModel (val) {
  49313. // Fix https://github.com/vuejs/vue/pull/7730
  49314. // allow v-model="obj.val " (trailing whitespace)
  49315. val = val.trim();
  49316. len = val.length;
  49317. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  49318. index$1 = val.lastIndexOf('.');
  49319. if (index$1 > -1) {
  49320. return {
  49321. exp: val.slice(0, index$1),
  49322. key: '"' + val.slice(index$1 + 1) + '"'
  49323. }
  49324. } else {
  49325. return {
  49326. exp: val,
  49327. key: null
  49328. }
  49329. }
  49330. }
  49331. str = val;
  49332. index$1 = expressionPos = expressionEndPos = 0;
  49333. while (!eof()) {
  49334. chr = next();
  49335. /* istanbul ignore if */
  49336. if (isStringStart(chr)) {
  49337. parseString(chr);
  49338. } else if (chr === 0x5B) {
  49339. parseBracket(chr);
  49340. }
  49341. }
  49342. return {
  49343. exp: val.slice(0, expressionPos),
  49344. key: val.slice(expressionPos + 1, expressionEndPos)
  49345. }
  49346. }
  49347. function next () {
  49348. return str.charCodeAt(++index$1)
  49349. }
  49350. function eof () {
  49351. return index$1 >= len
  49352. }
  49353. function isStringStart (chr) {
  49354. return chr === 0x22 || chr === 0x27
  49355. }
  49356. function parseBracket (chr) {
  49357. var inBracket = 1;
  49358. expressionPos = index$1;
  49359. while (!eof()) {
  49360. chr = next();
  49361. if (isStringStart(chr)) {
  49362. parseString(chr);
  49363. continue
  49364. }
  49365. if (chr === 0x5B) { inBracket++; }
  49366. if (chr === 0x5D) { inBracket--; }
  49367. if (inBracket === 0) {
  49368. expressionEndPos = index$1;
  49369. break
  49370. }
  49371. }
  49372. }
  49373. function parseString (chr) {
  49374. var stringQuote = chr;
  49375. while (!eof()) {
  49376. chr = next();
  49377. if (chr === stringQuote) {
  49378. break
  49379. }
  49380. }
  49381. }
  49382. /* */
  49383. var warn$1;
  49384. // in some cases, the event used has to be determined at runtime
  49385. // so we used some reserved tokens during compile.
  49386. var RANGE_TOKEN = '__r';
  49387. var CHECKBOX_RADIO_TOKEN = '__c';
  49388. function model (
  49389. el,
  49390. dir,
  49391. _warn
  49392. ) {
  49393. warn$1 = _warn;
  49394. var value = dir.value;
  49395. var modifiers = dir.modifiers;
  49396. var tag = el.tag;
  49397. var type = el.attrsMap.type;
  49398. {
  49399. // inputs with type="file" are read only and setting the input's
  49400. // value will throw an error.
  49401. if (tag === 'input' && type === 'file') {
  49402. warn$1(
  49403. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  49404. "File inputs are read only. Use a v-on:change listener instead.",
  49405. el.rawAttrsMap['v-model']
  49406. );
  49407. }
  49408. }
  49409. if (el.component) {
  49410. genComponentModel(el, value, modifiers);
  49411. // component v-model doesn't need extra runtime
  49412. return false
  49413. } else if (tag === 'select') {
  49414. genSelect(el, value, modifiers);
  49415. } else if (tag === 'input' && type === 'checkbox') {
  49416. genCheckboxModel(el, value, modifiers);
  49417. } else if (tag === 'input' && type === 'radio') {
  49418. genRadioModel(el, value, modifiers);
  49419. } else if (tag === 'input' || tag === 'textarea') {
  49420. genDefaultModel(el, value, modifiers);
  49421. } else if (!config.isReservedTag(tag)) {
  49422. genComponentModel(el, value, modifiers);
  49423. // component v-model doesn't need extra runtime
  49424. return false
  49425. } else {
  49426. warn$1(
  49427. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  49428. "v-model is not supported on this element type. " +
  49429. 'If you are working with contenteditable, it\'s recommended to ' +
  49430. 'wrap a library dedicated for that purpose inside a custom component.',
  49431. el.rawAttrsMap['v-model']
  49432. );
  49433. }
  49434. // ensure runtime directive metadata
  49435. return true
  49436. }
  49437. function genCheckboxModel (
  49438. el,
  49439. value,
  49440. modifiers
  49441. ) {
  49442. var number = modifiers && modifiers.number;
  49443. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49444. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  49445. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  49446. addProp(el, 'checked',
  49447. "Array.isArray(" + value + ")" +
  49448. "?_i(" + value + "," + valueBinding + ")>-1" + (
  49449. trueValueBinding === 'true'
  49450. ? (":(" + value + ")")
  49451. : (":_q(" + value + "," + trueValueBinding + ")")
  49452. )
  49453. );
  49454. addHandler(el, 'change',
  49455. "var $$a=" + value + "," +
  49456. '$$el=$event.target,' +
  49457. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  49458. 'if(Array.isArray($$a)){' +
  49459. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  49460. '$$i=_i($$a,$$v);' +
  49461. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  49462. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  49463. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  49464. null, true
  49465. );
  49466. }
  49467. function genRadioModel (
  49468. el,
  49469. value,
  49470. modifiers
  49471. ) {
  49472. var number = modifiers && modifiers.number;
  49473. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49474. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  49475. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  49476. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  49477. }
  49478. function genSelect (
  49479. el,
  49480. value,
  49481. modifiers
  49482. ) {
  49483. var number = modifiers && modifiers.number;
  49484. var selectedVal = "Array.prototype.filter" +
  49485. ".call($event.target.options,function(o){return o.selected})" +
  49486. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  49487. "return " + (number ? '_n(val)' : 'val') + "})";
  49488. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  49489. var code = "var $$selectedVal = " + selectedVal + ";";
  49490. code = code + " " + (genAssignmentCode(value, assignment));
  49491. addHandler(el, 'change', code, null, true);
  49492. }
  49493. function genDefaultModel (
  49494. el,
  49495. value,
  49496. modifiers
  49497. ) {
  49498. var type = el.attrsMap.type;
  49499. // warn if v-bind:value conflicts with v-model
  49500. // except for inputs with v-bind:type
  49501. {
  49502. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  49503. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  49504. if (value$1 && !typeBinding) {
  49505. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  49506. warn$1(
  49507. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  49508. 'because the latter already expands to a value binding internally',
  49509. el.rawAttrsMap[binding]
  49510. );
  49511. }
  49512. }
  49513. var ref = modifiers || {};
  49514. var lazy = ref.lazy;
  49515. var number = ref.number;
  49516. var trim = ref.trim;
  49517. var needCompositionGuard = !lazy && type !== 'range';
  49518. var event = lazy
  49519. ? 'change'
  49520. : type === 'range'
  49521. ? RANGE_TOKEN
  49522. : 'input';
  49523. var valueExpression = '$event.target.value';
  49524. if (trim) {
  49525. valueExpression = "$event.target.value.trim()";
  49526. }
  49527. if (number) {
  49528. valueExpression = "_n(" + valueExpression + ")";
  49529. }
  49530. var code = genAssignmentCode(value, valueExpression);
  49531. if (needCompositionGuard) {
  49532. code = "if($event.target.composing)return;" + code;
  49533. }
  49534. addProp(el, 'value', ("(" + value + ")"));
  49535. addHandler(el, event, code, null, true);
  49536. if (trim || number) {
  49537. addHandler(el, 'blur', '$forceUpdate()');
  49538. }
  49539. }
  49540. /* */
  49541. // normalize v-model event tokens that can only be determined at runtime.
  49542. // it's important to place the event as the first in the array because
  49543. // the whole point is ensuring the v-model callback gets called before
  49544. // user-attached handlers.
  49545. function normalizeEvents (on) {
  49546. /* istanbul ignore if */
  49547. if (isDef(on[RANGE_TOKEN])) {
  49548. // IE input[type=range] only supports `change` event
  49549. var event = isIE ? 'change' : 'input';
  49550. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  49551. delete on[RANGE_TOKEN];
  49552. }
  49553. // This was originally intended to fix #4521 but no longer necessary
  49554. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  49555. /* istanbul ignore if */
  49556. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  49557. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  49558. delete on[CHECKBOX_RADIO_TOKEN];
  49559. }
  49560. }
  49561. var target$1;
  49562. function createOnceHandler$1 (event, handler, capture) {
  49563. var _target = target$1; // save current target element in closure
  49564. return function onceHandler () {
  49565. var res = handler.apply(null, arguments);
  49566. if (res !== null) {
  49567. remove$2(event, onceHandler, capture, _target);
  49568. }
  49569. }
  49570. }
  49571. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  49572. // implementation and does not fire microtasks in between event propagation, so
  49573. // safe to exclude.
  49574. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  49575. function add$1 (
  49576. name,
  49577. handler,
  49578. capture,
  49579. passive
  49580. ) {
  49581. // async edge case #6566: inner click event triggers patch, event handler
  49582. // attached to outer element during patch, and triggered again. This
  49583. // happens because browsers fire microtask ticks between event propagation.
  49584. // the solution is simple: we save the timestamp when a handler is attached,
  49585. // and the handler would only fire if the event passed to it was fired
  49586. // AFTER it was attached.
  49587. if (useMicrotaskFix) {
  49588. var attachedTimestamp = currentFlushTimestamp;
  49589. var original = handler;
  49590. handler = original._wrapper = function (e) {
  49591. if (
  49592. // no bubbling, should always fire.
  49593. // this is just a safety net in case event.timeStamp is unreliable in
  49594. // certain weird environments...
  49595. e.target === e.currentTarget ||
  49596. // event is fired after handler attachment
  49597. e.timeStamp >= attachedTimestamp ||
  49598. // bail for environments that have buggy event.timeStamp implementations
  49599. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  49600. // #9681 QtWebEngine event.timeStamp is negative value
  49601. e.timeStamp <= 0 ||
  49602. // #9448 bail if event is fired in another document in a multi-page
  49603. // electron/nw.js app, since event.timeStamp will be using a different
  49604. // starting reference
  49605. e.target.ownerDocument !== document
  49606. ) {
  49607. return original.apply(this, arguments)
  49608. }
  49609. };
  49610. }
  49611. target$1.addEventListener(
  49612. name,
  49613. handler,
  49614. supportsPassive
  49615. ? { capture: capture, passive: passive }
  49616. : capture
  49617. );
  49618. }
  49619. function remove$2 (
  49620. name,
  49621. handler,
  49622. capture,
  49623. _target
  49624. ) {
  49625. (_target || target$1).removeEventListener(
  49626. name,
  49627. handler._wrapper || handler,
  49628. capture
  49629. );
  49630. }
  49631. function updateDOMListeners (oldVnode, vnode) {
  49632. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  49633. return
  49634. }
  49635. var on = vnode.data.on || {};
  49636. var oldOn = oldVnode.data.on || {};
  49637. target$1 = vnode.elm;
  49638. normalizeEvents(on);
  49639. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  49640. target$1 = undefined;
  49641. }
  49642. var events = {
  49643. create: updateDOMListeners,
  49644. update: updateDOMListeners
  49645. };
  49646. /* */
  49647. var svgContainer;
  49648. function updateDOMProps (oldVnode, vnode) {
  49649. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  49650. return
  49651. }
  49652. var key, cur;
  49653. var elm = vnode.elm;
  49654. var oldProps = oldVnode.data.domProps || {};
  49655. var props = vnode.data.domProps || {};
  49656. // clone observed objects, as the user probably wants to mutate it
  49657. if (isDef(props.__ob__)) {
  49658. props = vnode.data.domProps = extend({}, props);
  49659. }
  49660. for (key in oldProps) {
  49661. if (!(key in props)) {
  49662. elm[key] = '';
  49663. }
  49664. }
  49665. for (key in props) {
  49666. cur = props[key];
  49667. // ignore children if the node has textContent or innerHTML,
  49668. // as these will throw away existing DOM nodes and cause removal errors
  49669. // on subsequent patches (#3360)
  49670. if (key === 'textContent' || key === 'innerHTML') {
  49671. if (vnode.children) { vnode.children.length = 0; }
  49672. if (cur === oldProps[key]) { continue }
  49673. // #6601 work around Chrome version <= 55 bug where single textNode
  49674. // replaced by innerHTML/textContent retains its parentNode property
  49675. if (elm.childNodes.length === 1) {
  49676. elm.removeChild(elm.childNodes[0]);
  49677. }
  49678. }
  49679. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  49680. // store value as _value as well since
  49681. // non-string values will be stringified
  49682. elm._value = cur;
  49683. // avoid resetting cursor position when value is the same
  49684. var strCur = isUndef(cur) ? '' : String(cur);
  49685. if (shouldUpdateValue(elm, strCur)) {
  49686. elm.value = strCur;
  49687. }
  49688. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  49689. // IE doesn't support innerHTML for SVG elements
  49690. svgContainer = svgContainer || document.createElement('div');
  49691. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  49692. var svg = svgContainer.firstChild;
  49693. while (elm.firstChild) {
  49694. elm.removeChild(elm.firstChild);
  49695. }
  49696. while (svg.firstChild) {
  49697. elm.appendChild(svg.firstChild);
  49698. }
  49699. } else if (
  49700. // skip the update if old and new VDOM state is the same.
  49701. // `value` is handled separately because the DOM value may be temporarily
  49702. // out of sync with VDOM state due to focus, composition and modifiers.
  49703. // This #4521 by skipping the unnecesarry `checked` update.
  49704. cur !== oldProps[key]
  49705. ) {
  49706. // some property updates can throw
  49707. // e.g. `value` on <progress> w/ non-finite value
  49708. try {
  49709. elm[key] = cur;
  49710. } catch (e) {}
  49711. }
  49712. }
  49713. }
  49714. // check platforms/web/util/attrs.js acceptValue
  49715. function shouldUpdateValue (elm, checkVal) {
  49716. return (!elm.composing && (
  49717. elm.tagName === 'OPTION' ||
  49718. isNotInFocusAndDirty(elm, checkVal) ||
  49719. isDirtyWithModifiers(elm, checkVal)
  49720. ))
  49721. }
  49722. function isNotInFocusAndDirty (elm, checkVal) {
  49723. // return true when textbox (.number and .trim) loses focus and its value is
  49724. // not equal to the updated value
  49725. var notInFocus = true;
  49726. // #6157
  49727. // work around IE bug when accessing document.activeElement in an iframe
  49728. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  49729. return notInFocus && elm.value !== checkVal
  49730. }
  49731. function isDirtyWithModifiers (elm, newVal) {
  49732. var value = elm.value;
  49733. var modifiers = elm._vModifiers; // injected by v-model runtime
  49734. if (isDef(modifiers)) {
  49735. if (modifiers.number) {
  49736. return toNumber(value) !== toNumber(newVal)
  49737. }
  49738. if (modifiers.trim) {
  49739. return value.trim() !== newVal.trim()
  49740. }
  49741. }
  49742. return value !== newVal
  49743. }
  49744. var domProps = {
  49745. create: updateDOMProps,
  49746. update: updateDOMProps
  49747. };
  49748. /* */
  49749. var parseStyleText = cached(function (cssText) {
  49750. var res = {};
  49751. var listDelimiter = /;(?![^(]*\))/g;
  49752. var propertyDelimiter = /:(.+)/;
  49753. cssText.split(listDelimiter).forEach(function (item) {
  49754. if (item) {
  49755. var tmp = item.split(propertyDelimiter);
  49756. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  49757. }
  49758. });
  49759. return res
  49760. });
  49761. // merge static and dynamic style data on the same vnode
  49762. function normalizeStyleData (data) {
  49763. var style = normalizeStyleBinding(data.style);
  49764. // static style is pre-processed into an object during compilation
  49765. // and is always a fresh object, so it's safe to merge into it
  49766. return data.staticStyle
  49767. ? extend(data.staticStyle, style)
  49768. : style
  49769. }
  49770. // normalize possible array / string values into Object
  49771. function normalizeStyleBinding (bindingStyle) {
  49772. if (Array.isArray(bindingStyle)) {
  49773. return toObject(bindingStyle)
  49774. }
  49775. if (typeof bindingStyle === 'string') {
  49776. return parseStyleText(bindingStyle)
  49777. }
  49778. return bindingStyle
  49779. }
  49780. /**
  49781. * parent component style should be after child's
  49782. * so that parent component's style could override it
  49783. */
  49784. function getStyle (vnode, checkChild) {
  49785. var res = {};
  49786. var styleData;
  49787. if (checkChild) {
  49788. var childNode = vnode;
  49789. while (childNode.componentInstance) {
  49790. childNode = childNode.componentInstance._vnode;
  49791. if (
  49792. childNode && childNode.data &&
  49793. (styleData = normalizeStyleData(childNode.data))
  49794. ) {
  49795. extend(res, styleData);
  49796. }
  49797. }
  49798. }
  49799. if ((styleData = normalizeStyleData(vnode.data))) {
  49800. extend(res, styleData);
  49801. }
  49802. var parentNode = vnode;
  49803. while ((parentNode = parentNode.parent)) {
  49804. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  49805. extend(res, styleData);
  49806. }
  49807. }
  49808. return res
  49809. }
  49810. /* */
  49811. var cssVarRE = /^--/;
  49812. var importantRE = /\s*!important$/;
  49813. var setProp = function (el, name, val) {
  49814. /* istanbul ignore if */
  49815. if (cssVarRE.test(name)) {
  49816. el.style.setProperty(name, val);
  49817. } else if (importantRE.test(val)) {
  49818. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  49819. } else {
  49820. var normalizedName = normalize(name);
  49821. if (Array.isArray(val)) {
  49822. // Support values array created by autoprefixer, e.g.
  49823. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  49824. // Set them one by one, and the browser will only set those it can recognize
  49825. for (var i = 0, len = val.length; i < len; i++) {
  49826. el.style[normalizedName] = val[i];
  49827. }
  49828. } else {
  49829. el.style[normalizedName] = val;
  49830. }
  49831. }
  49832. };
  49833. var vendorNames = ['Webkit', 'Moz', 'ms'];
  49834. var emptyStyle;
  49835. var normalize = cached(function (prop) {
  49836. emptyStyle = emptyStyle || document.createElement('div').style;
  49837. prop = camelize(prop);
  49838. if (prop !== 'filter' && (prop in emptyStyle)) {
  49839. return prop
  49840. }
  49841. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  49842. for (var i = 0; i < vendorNames.length; i++) {
  49843. var name = vendorNames[i] + capName;
  49844. if (name in emptyStyle) {
  49845. return name
  49846. }
  49847. }
  49848. });
  49849. function updateStyle (oldVnode, vnode) {
  49850. var data = vnode.data;
  49851. var oldData = oldVnode.data;
  49852. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  49853. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  49854. ) {
  49855. return
  49856. }
  49857. var cur, name;
  49858. var el = vnode.elm;
  49859. var oldStaticStyle = oldData.staticStyle;
  49860. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  49861. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  49862. var oldStyle = oldStaticStyle || oldStyleBinding;
  49863. var style = normalizeStyleBinding(vnode.data.style) || {};
  49864. // store normalized style under a different key for next diff
  49865. // make sure to clone it if it's reactive, since the user likely wants
  49866. // to mutate it.
  49867. vnode.data.normalizedStyle = isDef(style.__ob__)
  49868. ? extend({}, style)
  49869. : style;
  49870. var newStyle = getStyle(vnode, true);
  49871. for (name in oldStyle) {
  49872. if (isUndef(newStyle[name])) {
  49873. setProp(el, name, '');
  49874. }
  49875. }
  49876. for (name in newStyle) {
  49877. cur = newStyle[name];
  49878. if (cur !== oldStyle[name]) {
  49879. // ie9 setting to null has no effect, must use empty string
  49880. setProp(el, name, cur == null ? '' : cur);
  49881. }
  49882. }
  49883. }
  49884. var style = {
  49885. create: updateStyle,
  49886. update: updateStyle
  49887. };
  49888. /* */
  49889. var whitespaceRE = /\s+/;
  49890. /**
  49891. * Add class with compatibility for SVG since classList is not supported on
  49892. * SVG elements in IE
  49893. */
  49894. function addClass (el, cls) {
  49895. /* istanbul ignore if */
  49896. if (!cls || !(cls = cls.trim())) {
  49897. return
  49898. }
  49899. /* istanbul ignore else */
  49900. if (el.classList) {
  49901. if (cls.indexOf(' ') > -1) {
  49902. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  49903. } else {
  49904. el.classList.add(cls);
  49905. }
  49906. } else {
  49907. var cur = " " + (el.getAttribute('class') || '') + " ";
  49908. if (cur.indexOf(' ' + cls + ' ') < 0) {
  49909. el.setAttribute('class', (cur + cls).trim());
  49910. }
  49911. }
  49912. }
  49913. /**
  49914. * Remove class with compatibility for SVG since classList is not supported on
  49915. * SVG elements in IE
  49916. */
  49917. function removeClass (el, cls) {
  49918. /* istanbul ignore if */
  49919. if (!cls || !(cls = cls.trim())) {
  49920. return
  49921. }
  49922. /* istanbul ignore else */
  49923. if (el.classList) {
  49924. if (cls.indexOf(' ') > -1) {
  49925. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  49926. } else {
  49927. el.classList.remove(cls);
  49928. }
  49929. if (!el.classList.length) {
  49930. el.removeAttribute('class');
  49931. }
  49932. } else {
  49933. var cur = " " + (el.getAttribute('class') || '') + " ";
  49934. var tar = ' ' + cls + ' ';
  49935. while (cur.indexOf(tar) >= 0) {
  49936. cur = cur.replace(tar, ' ');
  49937. }
  49938. cur = cur.trim();
  49939. if (cur) {
  49940. el.setAttribute('class', cur);
  49941. } else {
  49942. el.removeAttribute('class');
  49943. }
  49944. }
  49945. }
  49946. /* */
  49947. function resolveTransition (def$$1) {
  49948. if (!def$$1) {
  49949. return
  49950. }
  49951. /* istanbul ignore else */
  49952. if (typeof def$$1 === 'object') {
  49953. var res = {};
  49954. if (def$$1.css !== false) {
  49955. extend(res, autoCssTransition(def$$1.name || 'v'));
  49956. }
  49957. extend(res, def$$1);
  49958. return res
  49959. } else if (typeof def$$1 === 'string') {
  49960. return autoCssTransition(def$$1)
  49961. }
  49962. }
  49963. var autoCssTransition = cached(function (name) {
  49964. return {
  49965. enterClass: (name + "-enter"),
  49966. enterToClass: (name + "-enter-to"),
  49967. enterActiveClass: (name + "-enter-active"),
  49968. leaveClass: (name + "-leave"),
  49969. leaveToClass: (name + "-leave-to"),
  49970. leaveActiveClass: (name + "-leave-active")
  49971. }
  49972. });
  49973. var hasTransition = inBrowser && !isIE9;
  49974. var TRANSITION = 'transition';
  49975. var ANIMATION = 'animation';
  49976. // Transition property/event sniffing
  49977. var transitionProp = 'transition';
  49978. var transitionEndEvent = 'transitionend';
  49979. var animationProp = 'animation';
  49980. var animationEndEvent = 'animationend';
  49981. if (hasTransition) {
  49982. /* istanbul ignore if */
  49983. if (window.ontransitionend === undefined &&
  49984. window.onwebkittransitionend !== undefined
  49985. ) {
  49986. transitionProp = 'WebkitTransition';
  49987. transitionEndEvent = 'webkitTransitionEnd';
  49988. }
  49989. if (window.onanimationend === undefined &&
  49990. window.onwebkitanimationend !== undefined
  49991. ) {
  49992. animationProp = 'WebkitAnimation';
  49993. animationEndEvent = 'webkitAnimationEnd';
  49994. }
  49995. }
  49996. // binding to window is necessary to make hot reload work in IE in strict mode
  49997. var raf = inBrowser
  49998. ? window.requestAnimationFrame
  49999. ? window.requestAnimationFrame.bind(window)
  50000. : setTimeout
  50001. : /* istanbul ignore next */ function (fn) { return fn(); };
  50002. function nextFrame (fn) {
  50003. raf(function () {
  50004. raf(fn);
  50005. });
  50006. }
  50007. function addTransitionClass (el, cls) {
  50008. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  50009. if (transitionClasses.indexOf(cls) < 0) {
  50010. transitionClasses.push(cls);
  50011. addClass(el, cls);
  50012. }
  50013. }
  50014. function removeTransitionClass (el, cls) {
  50015. if (el._transitionClasses) {
  50016. remove(el._transitionClasses, cls);
  50017. }
  50018. removeClass(el, cls);
  50019. }
  50020. function whenTransitionEnds (
  50021. el,
  50022. expectedType,
  50023. cb
  50024. ) {
  50025. var ref = getTransitionInfo(el, expectedType);
  50026. var type = ref.type;
  50027. var timeout = ref.timeout;
  50028. var propCount = ref.propCount;
  50029. if (!type) { return cb() }
  50030. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  50031. var ended = 0;
  50032. var end = function () {
  50033. el.removeEventListener(event, onEnd);
  50034. cb();
  50035. };
  50036. var onEnd = function (e) {
  50037. if (e.target === el) {
  50038. if (++ended >= propCount) {
  50039. end();
  50040. }
  50041. }
  50042. };
  50043. setTimeout(function () {
  50044. if (ended < propCount) {
  50045. end();
  50046. }
  50047. }, timeout + 1);
  50048. el.addEventListener(event, onEnd);
  50049. }
  50050. var transformRE = /\b(transform|all)(,|$)/;
  50051. function getTransitionInfo (el, expectedType) {
  50052. var styles = window.getComputedStyle(el);
  50053. // JSDOM may return undefined for transition properties
  50054. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  50055. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  50056. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  50057. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  50058. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  50059. var animationTimeout = getTimeout(animationDelays, animationDurations);
  50060. var type;
  50061. var timeout = 0;
  50062. var propCount = 0;
  50063. /* istanbul ignore if */
  50064. if (expectedType === TRANSITION) {
  50065. if (transitionTimeout > 0) {
  50066. type = TRANSITION;
  50067. timeout = transitionTimeout;
  50068. propCount = transitionDurations.length;
  50069. }
  50070. } else if (expectedType === ANIMATION) {
  50071. if (animationTimeout > 0) {
  50072. type = ANIMATION;
  50073. timeout = animationTimeout;
  50074. propCount = animationDurations.length;
  50075. }
  50076. } else {
  50077. timeout = Math.max(transitionTimeout, animationTimeout);
  50078. type = timeout > 0
  50079. ? transitionTimeout > animationTimeout
  50080. ? TRANSITION
  50081. : ANIMATION
  50082. : null;
  50083. propCount = type
  50084. ? type === TRANSITION
  50085. ? transitionDurations.length
  50086. : animationDurations.length
  50087. : 0;
  50088. }
  50089. var hasTransform =
  50090. type === TRANSITION &&
  50091. transformRE.test(styles[transitionProp + 'Property']);
  50092. return {
  50093. type: type,
  50094. timeout: timeout,
  50095. propCount: propCount,
  50096. hasTransform: hasTransform
  50097. }
  50098. }
  50099. function getTimeout (delays, durations) {
  50100. /* istanbul ignore next */
  50101. while (delays.length < durations.length) {
  50102. delays = delays.concat(delays);
  50103. }
  50104. return Math.max.apply(null, durations.map(function (d, i) {
  50105. return toMs(d) + toMs(delays[i])
  50106. }))
  50107. }
  50108. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  50109. // in a locale-dependent way, using a comma instead of a dot.
  50110. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  50111. // as a floor function) causing unexpected behaviors
  50112. function toMs (s) {
  50113. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  50114. }
  50115. /* */
  50116. function enter (vnode, toggleDisplay) {
  50117. var el = vnode.elm;
  50118. // call leave callback now
  50119. if (isDef(el._leaveCb)) {
  50120. el._leaveCb.cancelled = true;
  50121. el._leaveCb();
  50122. }
  50123. var data = resolveTransition(vnode.data.transition);
  50124. if (isUndef(data)) {
  50125. return
  50126. }
  50127. /* istanbul ignore if */
  50128. if (isDef(el._enterCb) || el.nodeType !== 1) {
  50129. return
  50130. }
  50131. var css = data.css;
  50132. var type = data.type;
  50133. var enterClass = data.enterClass;
  50134. var enterToClass = data.enterToClass;
  50135. var enterActiveClass = data.enterActiveClass;
  50136. var appearClass = data.appearClass;
  50137. var appearToClass = data.appearToClass;
  50138. var appearActiveClass = data.appearActiveClass;
  50139. var beforeEnter = data.beforeEnter;
  50140. var enter = data.enter;
  50141. var afterEnter = data.afterEnter;
  50142. var enterCancelled = data.enterCancelled;
  50143. var beforeAppear = data.beforeAppear;
  50144. var appear = data.appear;
  50145. var afterAppear = data.afterAppear;
  50146. var appearCancelled = data.appearCancelled;
  50147. var duration = data.duration;
  50148. // activeInstance will always be the <transition> component managing this
  50149. // transition. One edge case to check is when the <transition> is placed
  50150. // as the root node of a child component. In that case we need to check
  50151. // <transition>'s parent for appear check.
  50152. var context = activeInstance;
  50153. var transitionNode = activeInstance.$vnode;
  50154. while (transitionNode && transitionNode.parent) {
  50155. context = transitionNode.context;
  50156. transitionNode = transitionNode.parent;
  50157. }
  50158. var isAppear = !context._isMounted || !vnode.isRootInsert;
  50159. if (isAppear && !appear && appear !== '') {
  50160. return
  50161. }
  50162. var startClass = isAppear && appearClass
  50163. ? appearClass
  50164. : enterClass;
  50165. var activeClass = isAppear && appearActiveClass
  50166. ? appearActiveClass
  50167. : enterActiveClass;
  50168. var toClass = isAppear && appearToClass
  50169. ? appearToClass
  50170. : enterToClass;
  50171. var beforeEnterHook = isAppear
  50172. ? (beforeAppear || beforeEnter)
  50173. : beforeEnter;
  50174. var enterHook = isAppear
  50175. ? (typeof appear === 'function' ? appear : enter)
  50176. : enter;
  50177. var afterEnterHook = isAppear
  50178. ? (afterAppear || afterEnter)
  50179. : afterEnter;
  50180. var enterCancelledHook = isAppear
  50181. ? (appearCancelled || enterCancelled)
  50182. : enterCancelled;
  50183. var explicitEnterDuration = toNumber(
  50184. isObject(duration)
  50185. ? duration.enter
  50186. : duration
  50187. );
  50188. if (explicitEnterDuration != null) {
  50189. checkDuration(explicitEnterDuration, 'enter', vnode);
  50190. }
  50191. var expectsCSS = css !== false && !isIE9;
  50192. var userWantsControl = getHookArgumentsLength(enterHook);
  50193. var cb = el._enterCb = once(function () {
  50194. if (expectsCSS) {
  50195. removeTransitionClass(el, toClass);
  50196. removeTransitionClass(el, activeClass);
  50197. }
  50198. if (cb.cancelled) {
  50199. if (expectsCSS) {
  50200. removeTransitionClass(el, startClass);
  50201. }
  50202. enterCancelledHook && enterCancelledHook(el);
  50203. } else {
  50204. afterEnterHook && afterEnterHook(el);
  50205. }
  50206. el._enterCb = null;
  50207. });
  50208. if (!vnode.data.show) {
  50209. // remove pending leave element on enter by injecting an insert hook
  50210. mergeVNodeHook(vnode, 'insert', function () {
  50211. var parent = el.parentNode;
  50212. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  50213. if (pendingNode &&
  50214. pendingNode.tag === vnode.tag &&
  50215. pendingNode.elm._leaveCb
  50216. ) {
  50217. pendingNode.elm._leaveCb();
  50218. }
  50219. enterHook && enterHook(el, cb);
  50220. });
  50221. }
  50222. // start enter transition
  50223. beforeEnterHook && beforeEnterHook(el);
  50224. if (expectsCSS) {
  50225. addTransitionClass(el, startClass);
  50226. addTransitionClass(el, activeClass);
  50227. nextFrame(function () {
  50228. removeTransitionClass(el, startClass);
  50229. if (!cb.cancelled) {
  50230. addTransitionClass(el, toClass);
  50231. if (!userWantsControl) {
  50232. if (isValidDuration(explicitEnterDuration)) {
  50233. setTimeout(cb, explicitEnterDuration);
  50234. } else {
  50235. whenTransitionEnds(el, type, cb);
  50236. }
  50237. }
  50238. }
  50239. });
  50240. }
  50241. if (vnode.data.show) {
  50242. toggleDisplay && toggleDisplay();
  50243. enterHook && enterHook(el, cb);
  50244. }
  50245. if (!expectsCSS && !userWantsControl) {
  50246. cb();
  50247. }
  50248. }
  50249. function leave (vnode, rm) {
  50250. var el = vnode.elm;
  50251. // call enter callback now
  50252. if (isDef(el._enterCb)) {
  50253. el._enterCb.cancelled = true;
  50254. el._enterCb();
  50255. }
  50256. var data = resolveTransition(vnode.data.transition);
  50257. if (isUndef(data) || el.nodeType !== 1) {
  50258. return rm()
  50259. }
  50260. /* istanbul ignore if */
  50261. if (isDef(el._leaveCb)) {
  50262. return
  50263. }
  50264. var css = data.css;
  50265. var type = data.type;
  50266. var leaveClass = data.leaveClass;
  50267. var leaveToClass = data.leaveToClass;
  50268. var leaveActiveClass = data.leaveActiveClass;
  50269. var beforeLeave = data.beforeLeave;
  50270. var leave = data.leave;
  50271. var afterLeave = data.afterLeave;
  50272. var leaveCancelled = data.leaveCancelled;
  50273. var delayLeave = data.delayLeave;
  50274. var duration = data.duration;
  50275. var expectsCSS = css !== false && !isIE9;
  50276. var userWantsControl = getHookArgumentsLength(leave);
  50277. var explicitLeaveDuration = toNumber(
  50278. isObject(duration)
  50279. ? duration.leave
  50280. : duration
  50281. );
  50282. if (isDef(explicitLeaveDuration)) {
  50283. checkDuration(explicitLeaveDuration, 'leave', vnode);
  50284. }
  50285. var cb = el._leaveCb = once(function () {
  50286. if (el.parentNode && el.parentNode._pending) {
  50287. el.parentNode._pending[vnode.key] = null;
  50288. }
  50289. if (expectsCSS) {
  50290. removeTransitionClass(el, leaveToClass);
  50291. removeTransitionClass(el, leaveActiveClass);
  50292. }
  50293. if (cb.cancelled) {
  50294. if (expectsCSS) {
  50295. removeTransitionClass(el, leaveClass);
  50296. }
  50297. leaveCancelled && leaveCancelled(el);
  50298. } else {
  50299. rm();
  50300. afterLeave && afterLeave(el);
  50301. }
  50302. el._leaveCb = null;
  50303. });
  50304. if (delayLeave) {
  50305. delayLeave(performLeave);
  50306. } else {
  50307. performLeave();
  50308. }
  50309. function performLeave () {
  50310. // the delayed leave may have already been cancelled
  50311. if (cb.cancelled) {
  50312. return
  50313. }
  50314. // record leaving element
  50315. if (!vnode.data.show && el.parentNode) {
  50316. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  50317. }
  50318. beforeLeave && beforeLeave(el);
  50319. if (expectsCSS) {
  50320. addTransitionClass(el, leaveClass);
  50321. addTransitionClass(el, leaveActiveClass);
  50322. nextFrame(function () {
  50323. removeTransitionClass(el, leaveClass);
  50324. if (!cb.cancelled) {
  50325. addTransitionClass(el, leaveToClass);
  50326. if (!userWantsControl) {
  50327. if (isValidDuration(explicitLeaveDuration)) {
  50328. setTimeout(cb, explicitLeaveDuration);
  50329. } else {
  50330. whenTransitionEnds(el, type, cb);
  50331. }
  50332. }
  50333. }
  50334. });
  50335. }
  50336. leave && leave(el, cb);
  50337. if (!expectsCSS && !userWantsControl) {
  50338. cb();
  50339. }
  50340. }
  50341. }
  50342. // only used in dev mode
  50343. function checkDuration (val, name, vnode) {
  50344. if (typeof val !== 'number') {
  50345. warn(
  50346. "<transition> explicit " + name + " duration is not a valid number - " +
  50347. "got " + (JSON.stringify(val)) + ".",
  50348. vnode.context
  50349. );
  50350. } else if (isNaN(val)) {
  50351. warn(
  50352. "<transition> explicit " + name + " duration is NaN - " +
  50353. 'the duration expression might be incorrect.',
  50354. vnode.context
  50355. );
  50356. }
  50357. }
  50358. function isValidDuration (val) {
  50359. return typeof val === 'number' && !isNaN(val)
  50360. }
  50361. /**
  50362. * Normalize a transition hook's argument length. The hook may be:
  50363. * - a merged hook (invoker) with the original in .fns
  50364. * - a wrapped component method (check ._length)
  50365. * - a plain function (.length)
  50366. */
  50367. function getHookArgumentsLength (fn) {
  50368. if (isUndef(fn)) {
  50369. return false
  50370. }
  50371. var invokerFns = fn.fns;
  50372. if (isDef(invokerFns)) {
  50373. // invoker
  50374. return getHookArgumentsLength(
  50375. Array.isArray(invokerFns)
  50376. ? invokerFns[0]
  50377. : invokerFns
  50378. )
  50379. } else {
  50380. return (fn._length || fn.length) > 1
  50381. }
  50382. }
  50383. function _enter (_, vnode) {
  50384. if (vnode.data.show !== true) {
  50385. enter(vnode);
  50386. }
  50387. }
  50388. var transition = inBrowser ? {
  50389. create: _enter,
  50390. activate: _enter,
  50391. remove: function remove$$1 (vnode, rm) {
  50392. /* istanbul ignore else */
  50393. if (vnode.data.show !== true) {
  50394. leave(vnode, rm);
  50395. } else {
  50396. rm();
  50397. }
  50398. }
  50399. } : {};
  50400. var platformModules = [
  50401. attrs,
  50402. klass,
  50403. events,
  50404. domProps,
  50405. style,
  50406. transition
  50407. ];
  50408. /* */
  50409. // the directive module should be applied last, after all
  50410. // built-in modules have been applied.
  50411. var modules = platformModules.concat(baseModules);
  50412. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  50413. /**
  50414. * Not type checking this file because flow doesn't like attaching
  50415. * properties to Elements.
  50416. */
  50417. /* istanbul ignore if */
  50418. if (isIE9) {
  50419. // http://www.matts411.com/post/internet-explorer-9-oninput/
  50420. document.addEventListener('selectionchange', function () {
  50421. var el = document.activeElement;
  50422. if (el && el.vmodel) {
  50423. trigger(el, 'input');
  50424. }
  50425. });
  50426. }
  50427. var directive = {
  50428. inserted: function inserted (el, binding, vnode, oldVnode) {
  50429. if (vnode.tag === 'select') {
  50430. // #6903
  50431. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  50432. mergeVNodeHook(vnode, 'postpatch', function () {
  50433. directive.componentUpdated(el, binding, vnode);
  50434. });
  50435. } else {
  50436. setSelected(el, binding, vnode.context);
  50437. }
  50438. el._vOptions = [].map.call(el.options, getValue);
  50439. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  50440. el._vModifiers = binding.modifiers;
  50441. if (!binding.modifiers.lazy) {
  50442. el.addEventListener('compositionstart', onCompositionStart);
  50443. el.addEventListener('compositionend', onCompositionEnd);
  50444. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  50445. // switching focus before confirming composition choice
  50446. // this also fixes the issue where some browsers e.g. iOS Chrome
  50447. // fires "change" instead of "input" on autocomplete.
  50448. el.addEventListener('change', onCompositionEnd);
  50449. /* istanbul ignore if */
  50450. if (isIE9) {
  50451. el.vmodel = true;
  50452. }
  50453. }
  50454. }
  50455. },
  50456. componentUpdated: function componentUpdated (el, binding, vnode) {
  50457. if (vnode.tag === 'select') {
  50458. setSelected(el, binding, vnode.context);
  50459. // in case the options rendered by v-for have changed,
  50460. // it's possible that the value is out-of-sync with the rendered options.
  50461. // detect such cases and filter out values that no longer has a matching
  50462. // option in the DOM.
  50463. var prevOptions = el._vOptions;
  50464. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  50465. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  50466. // trigger change event if
  50467. // no matching option found for at least one value
  50468. var needReset = el.multiple
  50469. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  50470. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  50471. if (needReset) {
  50472. trigger(el, 'change');
  50473. }
  50474. }
  50475. }
  50476. }
  50477. };
  50478. function setSelected (el, binding, vm) {
  50479. actuallySetSelected(el, binding, vm);
  50480. /* istanbul ignore if */
  50481. if (isIE || isEdge) {
  50482. setTimeout(function () {
  50483. actuallySetSelected(el, binding, vm);
  50484. }, 0);
  50485. }
  50486. }
  50487. function actuallySetSelected (el, binding, vm) {
  50488. var value = binding.value;
  50489. var isMultiple = el.multiple;
  50490. if (isMultiple && !Array.isArray(value)) {
  50491. warn(
  50492. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  50493. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  50494. vm
  50495. );
  50496. return
  50497. }
  50498. var selected, option;
  50499. for (var i = 0, l = el.options.length; i < l; i++) {
  50500. option = el.options[i];
  50501. if (isMultiple) {
  50502. selected = looseIndexOf(value, getValue(option)) > -1;
  50503. if (option.selected !== selected) {
  50504. option.selected = selected;
  50505. }
  50506. } else {
  50507. if (looseEqual(getValue(option), value)) {
  50508. if (el.selectedIndex !== i) {
  50509. el.selectedIndex = i;
  50510. }
  50511. return
  50512. }
  50513. }
  50514. }
  50515. if (!isMultiple) {
  50516. el.selectedIndex = -1;
  50517. }
  50518. }
  50519. function hasNoMatchingOption (value, options) {
  50520. return options.every(function (o) { return !looseEqual(o, value); })
  50521. }
  50522. function getValue (option) {
  50523. return '_value' in option
  50524. ? option._value
  50525. : option.value
  50526. }
  50527. function onCompositionStart (e) {
  50528. e.target.composing = true;
  50529. }
  50530. function onCompositionEnd (e) {
  50531. // prevent triggering an input event for no reason
  50532. if (!e.target.composing) { return }
  50533. e.target.composing = false;
  50534. trigger(e.target, 'input');
  50535. }
  50536. function trigger (el, type) {
  50537. var e = document.createEvent('HTMLEvents');
  50538. e.initEvent(type, true, true);
  50539. el.dispatchEvent(e);
  50540. }
  50541. /* */
  50542. // recursively search for possible transition defined inside the component root
  50543. function locateNode (vnode) {
  50544. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  50545. ? locateNode(vnode.componentInstance._vnode)
  50546. : vnode
  50547. }
  50548. var show = {
  50549. bind: function bind (el, ref, vnode) {
  50550. var value = ref.value;
  50551. vnode = locateNode(vnode);
  50552. var transition$$1 = vnode.data && vnode.data.transition;
  50553. var originalDisplay = el.__vOriginalDisplay =
  50554. el.style.display === 'none' ? '' : el.style.display;
  50555. if (value && transition$$1) {
  50556. vnode.data.show = true;
  50557. enter(vnode, function () {
  50558. el.style.display = originalDisplay;
  50559. });
  50560. } else {
  50561. el.style.display = value ? originalDisplay : 'none';
  50562. }
  50563. },
  50564. update: function update (el, ref, vnode) {
  50565. var value = ref.value;
  50566. var oldValue = ref.oldValue;
  50567. /* istanbul ignore if */
  50568. if (!value === !oldValue) { return }
  50569. vnode = locateNode(vnode);
  50570. var transition$$1 = vnode.data && vnode.data.transition;
  50571. if (transition$$1) {
  50572. vnode.data.show = true;
  50573. if (value) {
  50574. enter(vnode, function () {
  50575. el.style.display = el.__vOriginalDisplay;
  50576. });
  50577. } else {
  50578. leave(vnode, function () {
  50579. el.style.display = 'none';
  50580. });
  50581. }
  50582. } else {
  50583. el.style.display = value ? el.__vOriginalDisplay : 'none';
  50584. }
  50585. },
  50586. unbind: function unbind (
  50587. el,
  50588. binding,
  50589. vnode,
  50590. oldVnode,
  50591. isDestroy
  50592. ) {
  50593. if (!isDestroy) {
  50594. el.style.display = el.__vOriginalDisplay;
  50595. }
  50596. }
  50597. };
  50598. var platformDirectives = {
  50599. model: directive,
  50600. show: show
  50601. };
  50602. /* */
  50603. var transitionProps = {
  50604. name: String,
  50605. appear: Boolean,
  50606. css: Boolean,
  50607. mode: String,
  50608. type: String,
  50609. enterClass: String,
  50610. leaveClass: String,
  50611. enterToClass: String,
  50612. leaveToClass: String,
  50613. enterActiveClass: String,
  50614. leaveActiveClass: String,
  50615. appearClass: String,
  50616. appearActiveClass: String,
  50617. appearToClass: String,
  50618. duration: [Number, String, Object]
  50619. };
  50620. // in case the child is also an abstract component, e.g. <keep-alive>
  50621. // we want to recursively retrieve the real component to be rendered
  50622. function getRealChild (vnode) {
  50623. var compOptions = vnode && vnode.componentOptions;
  50624. if (compOptions && compOptions.Ctor.options.abstract) {
  50625. return getRealChild(getFirstComponentChild(compOptions.children))
  50626. } else {
  50627. return vnode
  50628. }
  50629. }
  50630. function extractTransitionData (comp) {
  50631. var data = {};
  50632. var options = comp.$options;
  50633. // props
  50634. for (var key in options.propsData) {
  50635. data[key] = comp[key];
  50636. }
  50637. // events.
  50638. // extract listeners and pass them directly to the transition methods
  50639. var listeners = options._parentListeners;
  50640. for (var key$1 in listeners) {
  50641. data[camelize(key$1)] = listeners[key$1];
  50642. }
  50643. return data
  50644. }
  50645. function placeholder (h, rawChild) {
  50646. if (/\d-keep-alive$/.test(rawChild.tag)) {
  50647. return h('keep-alive', {
  50648. props: rawChild.componentOptions.propsData
  50649. })
  50650. }
  50651. }
  50652. function hasParentTransition (vnode) {
  50653. while ((vnode = vnode.parent)) {
  50654. if (vnode.data.transition) {
  50655. return true
  50656. }
  50657. }
  50658. }
  50659. function isSameChild (child, oldChild) {
  50660. return oldChild.key === child.key && oldChild.tag === child.tag
  50661. }
  50662. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  50663. var isVShowDirective = function (d) { return d.name === 'show'; };
  50664. var Transition = {
  50665. name: 'transition',
  50666. props: transitionProps,
  50667. abstract: true,
  50668. render: function render (h) {
  50669. var this$1 = this;
  50670. var children = this.$slots.default;
  50671. if (!children) {
  50672. return
  50673. }
  50674. // filter out text nodes (possible whitespaces)
  50675. children = children.filter(isNotTextNode);
  50676. /* istanbul ignore if */
  50677. if (!children.length) {
  50678. return
  50679. }
  50680. // warn multiple elements
  50681. if (children.length > 1) {
  50682. warn(
  50683. '<transition> can only be used on a single element. Use ' +
  50684. '<transition-group> for lists.',
  50685. this.$parent
  50686. );
  50687. }
  50688. var mode = this.mode;
  50689. // warn invalid mode
  50690. if (mode && mode !== 'in-out' && mode !== 'out-in'
  50691. ) {
  50692. warn(
  50693. 'invalid <transition> mode: ' + mode,
  50694. this.$parent
  50695. );
  50696. }
  50697. var rawChild = children[0];
  50698. // if this is a component root node and the component's
  50699. // parent container node also has transition, skip.
  50700. if (hasParentTransition(this.$vnode)) {
  50701. return rawChild
  50702. }
  50703. // apply transition data to child
  50704. // use getRealChild() to ignore abstract components e.g. keep-alive
  50705. var child = getRealChild(rawChild);
  50706. /* istanbul ignore if */
  50707. if (!child) {
  50708. return rawChild
  50709. }
  50710. if (this._leaving) {
  50711. return placeholder(h, rawChild)
  50712. }
  50713. // ensure a key that is unique to the vnode type and to this transition
  50714. // component instance. This key will be used to remove pending leaving nodes
  50715. // during entering.
  50716. var id = "__transition-" + (this._uid) + "-";
  50717. child.key = child.key == null
  50718. ? child.isComment
  50719. ? id + 'comment'
  50720. : id + child.tag
  50721. : isPrimitive(child.key)
  50722. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  50723. : child.key;
  50724. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  50725. var oldRawChild = this._vnode;
  50726. var oldChild = getRealChild(oldRawChild);
  50727. // mark v-show
  50728. // so that the transition module can hand over the control to the directive
  50729. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  50730. child.data.show = true;
  50731. }
  50732. if (
  50733. oldChild &&
  50734. oldChild.data &&
  50735. !isSameChild(child, oldChild) &&
  50736. !isAsyncPlaceholder(oldChild) &&
  50737. // #6687 component root is a comment node
  50738. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  50739. ) {
  50740. // replace old child transition data with fresh one
  50741. // important for dynamic transitions!
  50742. var oldData = oldChild.data.transition = extend({}, data);
  50743. // handle transition mode
  50744. if (mode === 'out-in') {
  50745. // return placeholder node and queue update when leave finishes
  50746. this._leaving = true;
  50747. mergeVNodeHook(oldData, 'afterLeave', function () {
  50748. this$1._leaving = false;
  50749. this$1.$forceUpdate();
  50750. });
  50751. return placeholder(h, rawChild)
  50752. } else if (mode === 'in-out') {
  50753. if (isAsyncPlaceholder(child)) {
  50754. return oldRawChild
  50755. }
  50756. var delayedLeave;
  50757. var performLeave = function () { delayedLeave(); };
  50758. mergeVNodeHook(data, 'afterEnter', performLeave);
  50759. mergeVNodeHook(data, 'enterCancelled', performLeave);
  50760. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  50761. }
  50762. }
  50763. return rawChild
  50764. }
  50765. };
  50766. /* */
  50767. var props = extend({
  50768. tag: String,
  50769. moveClass: String
  50770. }, transitionProps);
  50771. delete props.mode;
  50772. var TransitionGroup = {
  50773. props: props,
  50774. beforeMount: function beforeMount () {
  50775. var this$1 = this;
  50776. var update = this._update;
  50777. this._update = function (vnode, hydrating) {
  50778. var restoreActiveInstance = setActiveInstance(this$1);
  50779. // force removing pass
  50780. this$1.__patch__(
  50781. this$1._vnode,
  50782. this$1.kept,
  50783. false, // hydrating
  50784. true // removeOnly (!important, avoids unnecessary moves)
  50785. );
  50786. this$1._vnode = this$1.kept;
  50787. restoreActiveInstance();
  50788. update.call(this$1, vnode, hydrating);
  50789. };
  50790. },
  50791. render: function render (h) {
  50792. var tag = this.tag || this.$vnode.data.tag || 'span';
  50793. var map = Object.create(null);
  50794. var prevChildren = this.prevChildren = this.children;
  50795. var rawChildren = this.$slots.default || [];
  50796. var children = this.children = [];
  50797. var transitionData = extractTransitionData(this);
  50798. for (var i = 0; i < rawChildren.length; i++) {
  50799. var c = rawChildren[i];
  50800. if (c.tag) {
  50801. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  50802. children.push(c);
  50803. map[c.key] = c
  50804. ;(c.data || (c.data = {})).transition = transitionData;
  50805. } else {
  50806. var opts = c.componentOptions;
  50807. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  50808. warn(("<transition-group> children must be keyed: <" + name + ">"));
  50809. }
  50810. }
  50811. }
  50812. if (prevChildren) {
  50813. var kept = [];
  50814. var removed = [];
  50815. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  50816. var c$1 = prevChildren[i$1];
  50817. c$1.data.transition = transitionData;
  50818. c$1.data.pos = c$1.elm.getBoundingClientRect();
  50819. if (map[c$1.key]) {
  50820. kept.push(c$1);
  50821. } else {
  50822. removed.push(c$1);
  50823. }
  50824. }
  50825. this.kept = h(tag, null, kept);
  50826. this.removed = removed;
  50827. }
  50828. return h(tag, null, children)
  50829. },
  50830. updated: function updated () {
  50831. var children = this.prevChildren;
  50832. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  50833. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  50834. return
  50835. }
  50836. // we divide the work into three loops to avoid mixing DOM reads and writes
  50837. // in each iteration - which helps prevent layout thrashing.
  50838. children.forEach(callPendingCbs);
  50839. children.forEach(recordPosition);
  50840. children.forEach(applyTranslation);
  50841. // force reflow to put everything in position
  50842. // assign to this to avoid being removed in tree-shaking
  50843. // $flow-disable-line
  50844. this._reflow = document.body.offsetHeight;
  50845. children.forEach(function (c) {
  50846. if (c.data.moved) {
  50847. var el = c.elm;
  50848. var s = el.style;
  50849. addTransitionClass(el, moveClass);
  50850. s.transform = s.WebkitTransform = s.transitionDuration = '';
  50851. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  50852. if (e && e.target !== el) {
  50853. return
  50854. }
  50855. if (!e || /transform$/.test(e.propertyName)) {
  50856. el.removeEventListener(transitionEndEvent, cb);
  50857. el._moveCb = null;
  50858. removeTransitionClass(el, moveClass);
  50859. }
  50860. });
  50861. }
  50862. });
  50863. },
  50864. methods: {
  50865. hasMove: function hasMove (el, moveClass) {
  50866. /* istanbul ignore if */
  50867. if (!hasTransition) {
  50868. return false
  50869. }
  50870. /* istanbul ignore if */
  50871. if (this._hasMove) {
  50872. return this._hasMove
  50873. }
  50874. // Detect whether an element with the move class applied has
  50875. // CSS transitions. Since the element may be inside an entering
  50876. // transition at this very moment, we make a clone of it and remove
  50877. // all other transition classes applied to ensure only the move class
  50878. // is applied.
  50879. var clone = el.cloneNode();
  50880. if (el._transitionClasses) {
  50881. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  50882. }
  50883. addClass(clone, moveClass);
  50884. clone.style.display = 'none';
  50885. this.$el.appendChild(clone);
  50886. var info = getTransitionInfo(clone);
  50887. this.$el.removeChild(clone);
  50888. return (this._hasMove = info.hasTransform)
  50889. }
  50890. }
  50891. };
  50892. function callPendingCbs (c) {
  50893. /* istanbul ignore if */
  50894. if (c.elm._moveCb) {
  50895. c.elm._moveCb();
  50896. }
  50897. /* istanbul ignore if */
  50898. if (c.elm._enterCb) {
  50899. c.elm._enterCb();
  50900. }
  50901. }
  50902. function recordPosition (c) {
  50903. c.data.newPos = c.elm.getBoundingClientRect();
  50904. }
  50905. function applyTranslation (c) {
  50906. var oldPos = c.data.pos;
  50907. var newPos = c.data.newPos;
  50908. var dx = oldPos.left - newPos.left;
  50909. var dy = oldPos.top - newPos.top;
  50910. if (dx || dy) {
  50911. c.data.moved = true;
  50912. var s = c.elm.style;
  50913. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  50914. s.transitionDuration = '0s';
  50915. }
  50916. }
  50917. var platformComponents = {
  50918. Transition: Transition,
  50919. TransitionGroup: TransitionGroup
  50920. };
  50921. /* */
  50922. // install platform specific utils
  50923. Vue.config.mustUseProp = mustUseProp;
  50924. Vue.config.isReservedTag = isReservedTag;
  50925. Vue.config.isReservedAttr = isReservedAttr;
  50926. Vue.config.getTagNamespace = getTagNamespace;
  50927. Vue.config.isUnknownElement = isUnknownElement;
  50928. // install platform runtime directives & components
  50929. extend(Vue.options.directives, platformDirectives);
  50930. extend(Vue.options.components, platformComponents);
  50931. // install platform patch function
  50932. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  50933. // public mount method
  50934. Vue.prototype.$mount = function (
  50935. el,
  50936. hydrating
  50937. ) {
  50938. el = el && inBrowser ? query(el) : undefined;
  50939. return mountComponent(this, el, hydrating)
  50940. };
  50941. // devtools global hook
  50942. /* istanbul ignore next */
  50943. if (inBrowser) {
  50944. setTimeout(function () {
  50945. if (config.devtools) {
  50946. if (devtools) {
  50947. devtools.emit('init', Vue);
  50948. } else {
  50949. console[console.info ? 'info' : 'log'](
  50950. 'Download the Vue Devtools extension for a better development experience:\n' +
  50951. 'https://github.com/vuejs/vue-devtools'
  50952. );
  50953. }
  50954. }
  50955. if (config.productionTip !== false &&
  50956. typeof console !== 'undefined'
  50957. ) {
  50958. console[console.info ? 'info' : 'log'](
  50959. "You are running Vue in development mode.\n" +
  50960. "Make sure to turn on production mode when deploying for production.\n" +
  50961. "See more tips at https://vuejs.org/guide/deployment.html"
  50962. );
  50963. }
  50964. }, 0);
  50965. }
  50966. /* */
  50967. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  50968. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  50969. var buildRegex = cached(function (delimiters) {
  50970. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  50971. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  50972. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  50973. });
  50974. function parseText (
  50975. text,
  50976. delimiters
  50977. ) {
  50978. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  50979. if (!tagRE.test(text)) {
  50980. return
  50981. }
  50982. var tokens = [];
  50983. var rawTokens = [];
  50984. var lastIndex = tagRE.lastIndex = 0;
  50985. var match, index, tokenValue;
  50986. while ((match = tagRE.exec(text))) {
  50987. index = match.index;
  50988. // push text token
  50989. if (index > lastIndex) {
  50990. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  50991. tokens.push(JSON.stringify(tokenValue));
  50992. }
  50993. // tag token
  50994. var exp = parseFilters(match[1].trim());
  50995. tokens.push(("_s(" + exp + ")"));
  50996. rawTokens.push({ '@binding': exp });
  50997. lastIndex = index + match[0].length;
  50998. }
  50999. if (lastIndex < text.length) {
  51000. rawTokens.push(tokenValue = text.slice(lastIndex));
  51001. tokens.push(JSON.stringify(tokenValue));
  51002. }
  51003. return {
  51004. expression: tokens.join('+'),
  51005. tokens: rawTokens
  51006. }
  51007. }
  51008. /* */
  51009. function transformNode (el, options) {
  51010. var warn = options.warn || baseWarn;
  51011. var staticClass = getAndRemoveAttr(el, 'class');
  51012. if (staticClass) {
  51013. var res = parseText(staticClass, options.delimiters);
  51014. if (res) {
  51015. warn(
  51016. "class=\"" + staticClass + "\": " +
  51017. 'Interpolation inside attributes has been removed. ' +
  51018. 'Use v-bind or the colon shorthand instead. For example, ' +
  51019. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  51020. el.rawAttrsMap['class']
  51021. );
  51022. }
  51023. }
  51024. if (staticClass) {
  51025. el.staticClass = JSON.stringify(staticClass);
  51026. }
  51027. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  51028. if (classBinding) {
  51029. el.classBinding = classBinding;
  51030. }
  51031. }
  51032. function genData (el) {
  51033. var data = '';
  51034. if (el.staticClass) {
  51035. data += "staticClass:" + (el.staticClass) + ",";
  51036. }
  51037. if (el.classBinding) {
  51038. data += "class:" + (el.classBinding) + ",";
  51039. }
  51040. return data
  51041. }
  51042. var klass$1 = {
  51043. staticKeys: ['staticClass'],
  51044. transformNode: transformNode,
  51045. genData: genData
  51046. };
  51047. /* */
  51048. function transformNode$1 (el, options) {
  51049. var warn = options.warn || baseWarn;
  51050. var staticStyle = getAndRemoveAttr(el, 'style');
  51051. if (staticStyle) {
  51052. /* istanbul ignore if */
  51053. {
  51054. var res = parseText(staticStyle, options.delimiters);
  51055. if (res) {
  51056. warn(
  51057. "style=\"" + staticStyle + "\": " +
  51058. 'Interpolation inside attributes has been removed. ' +
  51059. 'Use v-bind or the colon shorthand instead. For example, ' +
  51060. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  51061. el.rawAttrsMap['style']
  51062. );
  51063. }
  51064. }
  51065. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  51066. }
  51067. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  51068. if (styleBinding) {
  51069. el.styleBinding = styleBinding;
  51070. }
  51071. }
  51072. function genData$1 (el) {
  51073. var data = '';
  51074. if (el.staticStyle) {
  51075. data += "staticStyle:" + (el.staticStyle) + ",";
  51076. }
  51077. if (el.styleBinding) {
  51078. data += "style:(" + (el.styleBinding) + "),";
  51079. }
  51080. return data
  51081. }
  51082. var style$1 = {
  51083. staticKeys: ['staticStyle'],
  51084. transformNode: transformNode$1,
  51085. genData: genData$1
  51086. };
  51087. /* */
  51088. var decoder;
  51089. var he = {
  51090. decode: function decode (html) {
  51091. decoder = decoder || document.createElement('div');
  51092. decoder.innerHTML = html;
  51093. return decoder.textContent
  51094. }
  51095. };
  51096. /* */
  51097. var isUnaryTag = makeMap(
  51098. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  51099. 'link,meta,param,source,track,wbr'
  51100. );
  51101. // Elements that you can, intentionally, leave open
  51102. // (and which close themselves)
  51103. var canBeLeftOpenTag = makeMap(
  51104. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  51105. );
  51106. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  51107. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  51108. var isNonPhrasingTag = makeMap(
  51109. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  51110. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  51111. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  51112. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  51113. 'title,tr,track'
  51114. );
  51115. /**
  51116. * Not type-checking this file because it's mostly vendor code.
  51117. */
  51118. // Regular Expressions for parsing tags and attributes
  51119. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51120. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51121. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  51122. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  51123. var startTagOpen = new RegExp(("^<" + qnameCapture));
  51124. var startTagClose = /^\s*(\/?)>/;
  51125. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  51126. var doctype = /^<!DOCTYPE [^>]+>/i;
  51127. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  51128. var comment = /^<!\--/;
  51129. var conditionalComment = /^<!\[/;
  51130. // Special Elements (can contain anything)
  51131. var isPlainTextElement = makeMap('script,style,textarea', true);
  51132. var reCache = {};
  51133. var decodingMap = {
  51134. '&lt;': '<',
  51135. '&gt;': '>',
  51136. '&quot;': '"',
  51137. '&amp;': '&',
  51138. '&#10;': '\n',
  51139. '&#9;': '\t',
  51140. '&#39;': "'"
  51141. };
  51142. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  51143. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  51144. // #5992
  51145. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  51146. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  51147. function decodeAttr (value, shouldDecodeNewlines) {
  51148. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  51149. return value.replace(re, function (match) { return decodingMap[match]; })
  51150. }
  51151. function parseHTML (html, options) {
  51152. var stack = [];
  51153. var expectHTML = options.expectHTML;
  51154. var isUnaryTag$$1 = options.isUnaryTag || no;
  51155. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  51156. var index = 0;
  51157. var last, lastTag;
  51158. while (html) {
  51159. last = html;
  51160. // Make sure we're not in a plaintext content element like script/style
  51161. if (!lastTag || !isPlainTextElement(lastTag)) {
  51162. var textEnd = html.indexOf('<');
  51163. if (textEnd === 0) {
  51164. // Comment:
  51165. if (comment.test(html)) {
  51166. var commentEnd = html.indexOf('-->');
  51167. if (commentEnd >= 0) {
  51168. if (options.shouldKeepComment) {
  51169. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  51170. }
  51171. advance(commentEnd + 3);
  51172. continue
  51173. }
  51174. }
  51175. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  51176. if (conditionalComment.test(html)) {
  51177. var conditionalEnd = html.indexOf(']>');
  51178. if (conditionalEnd >= 0) {
  51179. advance(conditionalEnd + 2);
  51180. continue
  51181. }
  51182. }
  51183. // Doctype:
  51184. var doctypeMatch = html.match(doctype);
  51185. if (doctypeMatch) {
  51186. advance(doctypeMatch[0].length);
  51187. continue
  51188. }
  51189. // End tag:
  51190. var endTagMatch = html.match(endTag);
  51191. if (endTagMatch) {
  51192. var curIndex = index;
  51193. advance(endTagMatch[0].length);
  51194. parseEndTag(endTagMatch[1], curIndex, index);
  51195. continue
  51196. }
  51197. // Start tag:
  51198. var startTagMatch = parseStartTag();
  51199. if (startTagMatch) {
  51200. handleStartTag(startTagMatch);
  51201. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  51202. advance(1);
  51203. }
  51204. continue
  51205. }
  51206. }
  51207. var text = (void 0), rest = (void 0), next = (void 0);
  51208. if (textEnd >= 0) {
  51209. rest = html.slice(textEnd);
  51210. while (
  51211. !endTag.test(rest) &&
  51212. !startTagOpen.test(rest) &&
  51213. !comment.test(rest) &&
  51214. !conditionalComment.test(rest)
  51215. ) {
  51216. // < in plain text, be forgiving and treat it as text
  51217. next = rest.indexOf('<', 1);
  51218. if (next < 0) { break }
  51219. textEnd += next;
  51220. rest = html.slice(textEnd);
  51221. }
  51222. text = html.substring(0, textEnd);
  51223. }
  51224. if (textEnd < 0) {
  51225. text = html;
  51226. }
  51227. if (text) {
  51228. advance(text.length);
  51229. }
  51230. if (options.chars && text) {
  51231. options.chars(text, index - text.length, index);
  51232. }
  51233. } else {
  51234. var endTagLength = 0;
  51235. var stackedTag = lastTag.toLowerCase();
  51236. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  51237. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  51238. endTagLength = endTag.length;
  51239. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  51240. text = text
  51241. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  51242. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  51243. }
  51244. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  51245. text = text.slice(1);
  51246. }
  51247. if (options.chars) {
  51248. options.chars(text);
  51249. }
  51250. return ''
  51251. });
  51252. index += html.length - rest$1.length;
  51253. html = rest$1;
  51254. parseEndTag(stackedTag, index - endTagLength, index);
  51255. }
  51256. if (html === last) {
  51257. options.chars && options.chars(html);
  51258. if (!stack.length && options.warn) {
  51259. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  51260. }
  51261. break
  51262. }
  51263. }
  51264. // Clean up any remaining tags
  51265. parseEndTag();
  51266. function advance (n) {
  51267. index += n;
  51268. html = html.substring(n);
  51269. }
  51270. function parseStartTag () {
  51271. var start = html.match(startTagOpen);
  51272. if (start) {
  51273. var match = {
  51274. tagName: start[1],
  51275. attrs: [],
  51276. start: index
  51277. };
  51278. advance(start[0].length);
  51279. var end, attr;
  51280. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  51281. attr.start = index;
  51282. advance(attr[0].length);
  51283. attr.end = index;
  51284. match.attrs.push(attr);
  51285. }
  51286. if (end) {
  51287. match.unarySlash = end[1];
  51288. advance(end[0].length);
  51289. match.end = index;
  51290. return match
  51291. }
  51292. }
  51293. }
  51294. function handleStartTag (match) {
  51295. var tagName = match.tagName;
  51296. var unarySlash = match.unarySlash;
  51297. if (expectHTML) {
  51298. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  51299. parseEndTag(lastTag);
  51300. }
  51301. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  51302. parseEndTag(tagName);
  51303. }
  51304. }
  51305. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  51306. var l = match.attrs.length;
  51307. var attrs = new Array(l);
  51308. for (var i = 0; i < l; i++) {
  51309. var args = match.attrs[i];
  51310. var value = args[3] || args[4] || args[5] || '';
  51311. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  51312. ? options.shouldDecodeNewlinesForHref
  51313. : options.shouldDecodeNewlines;
  51314. attrs[i] = {
  51315. name: args[1],
  51316. value: decodeAttr(value, shouldDecodeNewlines)
  51317. };
  51318. if (options.outputSourceRange) {
  51319. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  51320. attrs[i].end = args.end;
  51321. }
  51322. }
  51323. if (!unary) {
  51324. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  51325. lastTag = tagName;
  51326. }
  51327. if (options.start) {
  51328. options.start(tagName, attrs, unary, match.start, match.end);
  51329. }
  51330. }
  51331. function parseEndTag (tagName, start, end) {
  51332. var pos, lowerCasedTagName;
  51333. if (start == null) { start = index; }
  51334. if (end == null) { end = index; }
  51335. // Find the closest opened tag of the same type
  51336. if (tagName) {
  51337. lowerCasedTagName = tagName.toLowerCase();
  51338. for (pos = stack.length - 1; pos >= 0; pos--) {
  51339. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  51340. break
  51341. }
  51342. }
  51343. } else {
  51344. // If no tag name is provided, clean shop
  51345. pos = 0;
  51346. }
  51347. if (pos >= 0) {
  51348. // Close all the open elements, up the stack
  51349. for (var i = stack.length - 1; i >= pos; i--) {
  51350. if (i > pos || !tagName &&
  51351. options.warn
  51352. ) {
  51353. options.warn(
  51354. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  51355. { start: stack[i].start, end: stack[i].end }
  51356. );
  51357. }
  51358. if (options.end) {
  51359. options.end(stack[i].tag, start, end);
  51360. }
  51361. }
  51362. // Remove the open elements from the stack
  51363. stack.length = pos;
  51364. lastTag = pos && stack[pos - 1].tag;
  51365. } else if (lowerCasedTagName === 'br') {
  51366. if (options.start) {
  51367. options.start(tagName, [], true, start, end);
  51368. }
  51369. } else if (lowerCasedTagName === 'p') {
  51370. if (options.start) {
  51371. options.start(tagName, [], false, start, end);
  51372. }
  51373. if (options.end) {
  51374. options.end(tagName, start, end);
  51375. }
  51376. }
  51377. }
  51378. }
  51379. /* */
  51380. var onRE = /^@|^v-on:/;
  51381. var dirRE = /^v-|^@|^:|^#/;
  51382. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  51383. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  51384. var stripParensRE = /^\(|\)$/g;
  51385. var dynamicArgRE = /^\[.*\]$/;
  51386. var argRE = /:(.*)$/;
  51387. var bindRE = /^:|^\.|^v-bind:/;
  51388. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  51389. var slotRE = /^v-slot(:|$)|^#/;
  51390. var lineBreakRE = /[\r\n]/;
  51391. var whitespaceRE$1 = /\s+/g;
  51392. var invalidAttributeRE = /[\s"'<>\/=]/;
  51393. var decodeHTMLCached = cached(he.decode);
  51394. var emptySlotScopeToken = "_empty_";
  51395. // configurable state
  51396. var warn$2;
  51397. var delimiters;
  51398. var transforms;
  51399. var preTransforms;
  51400. var postTransforms;
  51401. var platformIsPreTag;
  51402. var platformMustUseProp;
  51403. var platformGetTagNamespace;
  51404. var maybeComponent;
  51405. function createASTElement (
  51406. tag,
  51407. attrs,
  51408. parent
  51409. ) {
  51410. return {
  51411. type: 1,
  51412. tag: tag,
  51413. attrsList: attrs,
  51414. attrsMap: makeAttrsMap(attrs),
  51415. rawAttrsMap: {},
  51416. parent: parent,
  51417. children: []
  51418. }
  51419. }
  51420. /**
  51421. * Convert HTML string to AST.
  51422. */
  51423. function parse (
  51424. template,
  51425. options
  51426. ) {
  51427. warn$2 = options.warn || baseWarn;
  51428. platformIsPreTag = options.isPreTag || no;
  51429. platformMustUseProp = options.mustUseProp || no;
  51430. platformGetTagNamespace = options.getTagNamespace || no;
  51431. var isReservedTag = options.isReservedTag || no;
  51432. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51433. transforms = pluckModuleFunction(options.modules, 'transformNode');
  51434. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  51435. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  51436. delimiters = options.delimiters;
  51437. var stack = [];
  51438. var preserveWhitespace = options.preserveWhitespace !== false;
  51439. var whitespaceOption = options.whitespace;
  51440. var root;
  51441. var currentParent;
  51442. var inVPre = false;
  51443. var inPre = false;
  51444. var warned = false;
  51445. function warnOnce (msg, range) {
  51446. if (!warned) {
  51447. warned = true;
  51448. warn$2(msg, range);
  51449. }
  51450. }
  51451. function closeElement (element) {
  51452. trimEndingWhitespace(element);
  51453. if (!inVPre && !element.processed) {
  51454. element = processElement(element, options);
  51455. }
  51456. // tree management
  51457. if (!stack.length && element !== root) {
  51458. // allow root elements with v-if, v-else-if and v-else
  51459. if (root.if && (element.elseif || element.else)) {
  51460. {
  51461. checkRootConstraints(element);
  51462. }
  51463. addIfCondition(root, {
  51464. exp: element.elseif,
  51465. block: element
  51466. });
  51467. } else {
  51468. warnOnce(
  51469. "Component template should contain exactly one root element. " +
  51470. "If you are using v-if on multiple elements, " +
  51471. "use v-else-if to chain them instead.",
  51472. { start: element.start }
  51473. );
  51474. }
  51475. }
  51476. if (currentParent && !element.forbidden) {
  51477. if (element.elseif || element.else) {
  51478. processIfConditions(element, currentParent);
  51479. } else {
  51480. if (element.slotScope) {
  51481. // scoped slot
  51482. // keep it in the children list so that v-else(-if) conditions can
  51483. // find it as the prev node.
  51484. var name = element.slotTarget || '"default"'
  51485. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  51486. }
  51487. currentParent.children.push(element);
  51488. element.parent = currentParent;
  51489. }
  51490. }
  51491. // final children cleanup
  51492. // filter out scoped slots
  51493. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  51494. // remove trailing whitespace node again
  51495. trimEndingWhitespace(element);
  51496. // check pre state
  51497. if (element.pre) {
  51498. inVPre = false;
  51499. }
  51500. if (platformIsPreTag(element.tag)) {
  51501. inPre = false;
  51502. }
  51503. // apply post-transforms
  51504. for (var i = 0; i < postTransforms.length; i++) {
  51505. postTransforms[i](element, options);
  51506. }
  51507. }
  51508. function trimEndingWhitespace (el) {
  51509. // remove trailing whitespace node
  51510. if (!inPre) {
  51511. var lastNode;
  51512. while (
  51513. (lastNode = el.children[el.children.length - 1]) &&
  51514. lastNode.type === 3 &&
  51515. lastNode.text === ' '
  51516. ) {
  51517. el.children.pop();
  51518. }
  51519. }
  51520. }
  51521. function checkRootConstraints (el) {
  51522. if (el.tag === 'slot' || el.tag === 'template') {
  51523. warnOnce(
  51524. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  51525. 'contain multiple nodes.',
  51526. { start: el.start }
  51527. );
  51528. }
  51529. if (el.attrsMap.hasOwnProperty('v-for')) {
  51530. warnOnce(
  51531. 'Cannot use v-for on stateful component root element because ' +
  51532. 'it renders multiple elements.',
  51533. el.rawAttrsMap['v-for']
  51534. );
  51535. }
  51536. }
  51537. parseHTML(template, {
  51538. warn: warn$2,
  51539. expectHTML: options.expectHTML,
  51540. isUnaryTag: options.isUnaryTag,
  51541. canBeLeftOpenTag: options.canBeLeftOpenTag,
  51542. shouldDecodeNewlines: options.shouldDecodeNewlines,
  51543. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  51544. shouldKeepComment: options.comments,
  51545. outputSourceRange: options.outputSourceRange,
  51546. start: function start (tag, attrs, unary, start$1, end) {
  51547. // check namespace.
  51548. // inherit parent ns if there is one
  51549. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  51550. // handle IE svg bug
  51551. /* istanbul ignore if */
  51552. if (isIE && ns === 'svg') {
  51553. attrs = guardIESVGBug(attrs);
  51554. }
  51555. var element = createASTElement(tag, attrs, currentParent);
  51556. if (ns) {
  51557. element.ns = ns;
  51558. }
  51559. {
  51560. if (options.outputSourceRange) {
  51561. element.start = start$1;
  51562. element.end = end;
  51563. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  51564. cumulated[attr.name] = attr;
  51565. return cumulated
  51566. }, {});
  51567. }
  51568. attrs.forEach(function (attr) {
  51569. if (invalidAttributeRE.test(attr.name)) {
  51570. warn$2(
  51571. "Invalid dynamic argument expression: attribute names cannot contain " +
  51572. "spaces, quotes, <, >, / or =.",
  51573. {
  51574. start: attr.start + attr.name.indexOf("["),
  51575. end: attr.start + attr.name.length
  51576. }
  51577. );
  51578. }
  51579. });
  51580. }
  51581. if (isForbiddenTag(element) && !isServerRendering()) {
  51582. element.forbidden = true;
  51583. warn$2(
  51584. 'Templates should only be responsible for mapping the state to the ' +
  51585. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  51586. "<" + tag + ">" + ', as they will not be parsed.',
  51587. { start: element.start }
  51588. );
  51589. }
  51590. // apply pre-transforms
  51591. for (var i = 0; i < preTransforms.length; i++) {
  51592. element = preTransforms[i](element, options) || element;
  51593. }
  51594. if (!inVPre) {
  51595. processPre(element);
  51596. if (element.pre) {
  51597. inVPre = true;
  51598. }
  51599. }
  51600. if (platformIsPreTag(element.tag)) {
  51601. inPre = true;
  51602. }
  51603. if (inVPre) {
  51604. processRawAttrs(element);
  51605. } else if (!element.processed) {
  51606. // structural directives
  51607. processFor(element);
  51608. processIf(element);
  51609. processOnce(element);
  51610. }
  51611. if (!root) {
  51612. root = element;
  51613. {
  51614. checkRootConstraints(root);
  51615. }
  51616. }
  51617. if (!unary) {
  51618. currentParent = element;
  51619. stack.push(element);
  51620. } else {
  51621. closeElement(element);
  51622. }
  51623. },
  51624. end: function end (tag, start, end$1) {
  51625. var element = stack[stack.length - 1];
  51626. // pop stack
  51627. stack.length -= 1;
  51628. currentParent = stack[stack.length - 1];
  51629. if (options.outputSourceRange) {
  51630. element.end = end$1;
  51631. }
  51632. closeElement(element);
  51633. },
  51634. chars: function chars (text, start, end) {
  51635. if (!currentParent) {
  51636. {
  51637. if (text === template) {
  51638. warnOnce(
  51639. 'Component template requires a root element, rather than just text.',
  51640. { start: start }
  51641. );
  51642. } else if ((text = text.trim())) {
  51643. warnOnce(
  51644. ("text \"" + text + "\" outside root element will be ignored."),
  51645. { start: start }
  51646. );
  51647. }
  51648. }
  51649. return
  51650. }
  51651. // IE textarea placeholder bug
  51652. /* istanbul ignore if */
  51653. if (isIE &&
  51654. currentParent.tag === 'textarea' &&
  51655. currentParent.attrsMap.placeholder === text
  51656. ) {
  51657. return
  51658. }
  51659. var children = currentParent.children;
  51660. if (inPre || text.trim()) {
  51661. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  51662. } else if (!children.length) {
  51663. // remove the whitespace-only node right after an opening tag
  51664. text = '';
  51665. } else if (whitespaceOption) {
  51666. if (whitespaceOption === 'condense') {
  51667. // in condense mode, remove the whitespace node if it contains
  51668. // line break, otherwise condense to a single space
  51669. text = lineBreakRE.test(text) ? '' : ' ';
  51670. } else {
  51671. text = ' ';
  51672. }
  51673. } else {
  51674. text = preserveWhitespace ? ' ' : '';
  51675. }
  51676. if (text) {
  51677. if (!inPre && whitespaceOption === 'condense') {
  51678. // condense consecutive whitespaces into single space
  51679. text = text.replace(whitespaceRE$1, ' ');
  51680. }
  51681. var res;
  51682. var child;
  51683. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  51684. child = {
  51685. type: 2,
  51686. expression: res.expression,
  51687. tokens: res.tokens,
  51688. text: text
  51689. };
  51690. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  51691. child = {
  51692. type: 3,
  51693. text: text
  51694. };
  51695. }
  51696. if (child) {
  51697. if (options.outputSourceRange) {
  51698. child.start = start;
  51699. child.end = end;
  51700. }
  51701. children.push(child);
  51702. }
  51703. }
  51704. },
  51705. comment: function comment (text, start, end) {
  51706. // adding anyting as a sibling to the root node is forbidden
  51707. // comments should still be allowed, but ignored
  51708. if (currentParent) {
  51709. var child = {
  51710. type: 3,
  51711. text: text,
  51712. isComment: true
  51713. };
  51714. if (options.outputSourceRange) {
  51715. child.start = start;
  51716. child.end = end;
  51717. }
  51718. currentParent.children.push(child);
  51719. }
  51720. }
  51721. });
  51722. return root
  51723. }
  51724. function processPre (el) {
  51725. if (getAndRemoveAttr(el, 'v-pre') != null) {
  51726. el.pre = true;
  51727. }
  51728. }
  51729. function processRawAttrs (el) {
  51730. var list = el.attrsList;
  51731. var len = list.length;
  51732. if (len) {
  51733. var attrs = el.attrs = new Array(len);
  51734. for (var i = 0; i < len; i++) {
  51735. attrs[i] = {
  51736. name: list[i].name,
  51737. value: JSON.stringify(list[i].value)
  51738. };
  51739. if (list[i].start != null) {
  51740. attrs[i].start = list[i].start;
  51741. attrs[i].end = list[i].end;
  51742. }
  51743. }
  51744. } else if (!el.pre) {
  51745. // non root node in pre blocks with no attributes
  51746. el.plain = true;
  51747. }
  51748. }
  51749. function processElement (
  51750. element,
  51751. options
  51752. ) {
  51753. processKey(element);
  51754. // determine whether this is a plain element after
  51755. // removing structural attributes
  51756. element.plain = (
  51757. !element.key &&
  51758. !element.scopedSlots &&
  51759. !element.attrsList.length
  51760. );
  51761. processRef(element);
  51762. processSlotContent(element);
  51763. processSlotOutlet(element);
  51764. processComponent(element);
  51765. for (var i = 0; i < transforms.length; i++) {
  51766. element = transforms[i](element, options) || element;
  51767. }
  51768. processAttrs(element);
  51769. return element
  51770. }
  51771. function processKey (el) {
  51772. var exp = getBindingAttr(el, 'key');
  51773. if (exp) {
  51774. {
  51775. if (el.tag === 'template') {
  51776. warn$2(
  51777. "<template> cannot be keyed. Place the key on real elements instead.",
  51778. getRawBindingAttr(el, 'key')
  51779. );
  51780. }
  51781. if (el.for) {
  51782. var iterator = el.iterator2 || el.iterator1;
  51783. var parent = el.parent;
  51784. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  51785. warn$2(
  51786. "Do not use v-for index as key on <transition-group> children, " +
  51787. "this is the same as not using keys.",
  51788. getRawBindingAttr(el, 'key'),
  51789. true /* tip */
  51790. );
  51791. }
  51792. }
  51793. }
  51794. el.key = exp;
  51795. }
  51796. }
  51797. function processRef (el) {
  51798. var ref = getBindingAttr(el, 'ref');
  51799. if (ref) {
  51800. el.ref = ref;
  51801. el.refInFor = checkInFor(el);
  51802. }
  51803. }
  51804. function processFor (el) {
  51805. var exp;
  51806. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  51807. var res = parseFor(exp);
  51808. if (res) {
  51809. extend(el, res);
  51810. } else {
  51811. warn$2(
  51812. ("Invalid v-for expression: " + exp),
  51813. el.rawAttrsMap['v-for']
  51814. );
  51815. }
  51816. }
  51817. }
  51818. function parseFor (exp) {
  51819. var inMatch = exp.match(forAliasRE);
  51820. if (!inMatch) { return }
  51821. var res = {};
  51822. res.for = inMatch[2].trim();
  51823. var alias = inMatch[1].trim().replace(stripParensRE, '');
  51824. var iteratorMatch = alias.match(forIteratorRE);
  51825. if (iteratorMatch) {
  51826. res.alias = alias.replace(forIteratorRE, '').trim();
  51827. res.iterator1 = iteratorMatch[1].trim();
  51828. if (iteratorMatch[2]) {
  51829. res.iterator2 = iteratorMatch[2].trim();
  51830. }
  51831. } else {
  51832. res.alias = alias;
  51833. }
  51834. return res
  51835. }
  51836. function processIf (el) {
  51837. var exp = getAndRemoveAttr(el, 'v-if');
  51838. if (exp) {
  51839. el.if = exp;
  51840. addIfCondition(el, {
  51841. exp: exp,
  51842. block: el
  51843. });
  51844. } else {
  51845. if (getAndRemoveAttr(el, 'v-else') != null) {
  51846. el.else = true;
  51847. }
  51848. var elseif = getAndRemoveAttr(el, 'v-else-if');
  51849. if (elseif) {
  51850. el.elseif = elseif;
  51851. }
  51852. }
  51853. }
  51854. function processIfConditions (el, parent) {
  51855. var prev = findPrevElement(parent.children);
  51856. if (prev && prev.if) {
  51857. addIfCondition(prev, {
  51858. exp: el.elseif,
  51859. block: el
  51860. });
  51861. } else {
  51862. warn$2(
  51863. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  51864. "used on element <" + (el.tag) + "> without corresponding v-if.",
  51865. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  51866. );
  51867. }
  51868. }
  51869. function findPrevElement (children) {
  51870. var i = children.length;
  51871. while (i--) {
  51872. if (children[i].type === 1) {
  51873. return children[i]
  51874. } else {
  51875. if (children[i].text !== ' ') {
  51876. warn$2(
  51877. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  51878. "will be ignored.",
  51879. children[i]
  51880. );
  51881. }
  51882. children.pop();
  51883. }
  51884. }
  51885. }
  51886. function addIfCondition (el, condition) {
  51887. if (!el.ifConditions) {
  51888. el.ifConditions = [];
  51889. }
  51890. el.ifConditions.push(condition);
  51891. }
  51892. function processOnce (el) {
  51893. var once$$1 = getAndRemoveAttr(el, 'v-once');
  51894. if (once$$1 != null) {
  51895. el.once = true;
  51896. }
  51897. }
  51898. // handle content being passed to a component as slot,
  51899. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  51900. function processSlotContent (el) {
  51901. var slotScope;
  51902. if (el.tag === 'template') {
  51903. slotScope = getAndRemoveAttr(el, 'scope');
  51904. /* istanbul ignore if */
  51905. if (slotScope) {
  51906. warn$2(
  51907. "the \"scope\" attribute for scoped slots have been deprecated and " +
  51908. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  51909. "can also be used on plain elements in addition to <template> to " +
  51910. "denote scoped slots.",
  51911. el.rawAttrsMap['scope'],
  51912. true
  51913. );
  51914. }
  51915. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  51916. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  51917. /* istanbul ignore if */
  51918. if (el.attrsMap['v-for']) {
  51919. warn$2(
  51920. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  51921. "(v-for takes higher priority). Use a wrapper <template> for the " +
  51922. "scoped slot to make it clearer.",
  51923. el.rawAttrsMap['slot-scope'],
  51924. true
  51925. );
  51926. }
  51927. el.slotScope = slotScope;
  51928. }
  51929. // slot="xxx"
  51930. var slotTarget = getBindingAttr(el, 'slot');
  51931. if (slotTarget) {
  51932. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  51933. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  51934. // preserve slot as an attribute for native shadow DOM compat
  51935. // only for non-scoped slots.
  51936. if (el.tag !== 'template' && !el.slotScope) {
  51937. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  51938. }
  51939. }
  51940. // 2.6 v-slot syntax
  51941. {
  51942. if (el.tag === 'template') {
  51943. // v-slot on <template>
  51944. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  51945. if (slotBinding) {
  51946. {
  51947. if (el.slotTarget || el.slotScope) {
  51948. warn$2(
  51949. "Unexpected mixed usage of different slot syntaxes.",
  51950. el
  51951. );
  51952. }
  51953. if (el.parent && !maybeComponent(el.parent)) {
  51954. warn$2(
  51955. "<template v-slot> can only appear at the root level inside " +
  51956. "the receiving component",
  51957. el
  51958. );
  51959. }
  51960. }
  51961. var ref = getSlotName(slotBinding);
  51962. var name = ref.name;
  51963. var dynamic = ref.dynamic;
  51964. el.slotTarget = name;
  51965. el.slotTargetDynamic = dynamic;
  51966. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  51967. }
  51968. } else {
  51969. // v-slot on component, denotes default slot
  51970. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  51971. if (slotBinding$1) {
  51972. {
  51973. if (!maybeComponent(el)) {
  51974. warn$2(
  51975. "v-slot can only be used on components or <template>.",
  51976. slotBinding$1
  51977. );
  51978. }
  51979. if (el.slotScope || el.slotTarget) {
  51980. warn$2(
  51981. "Unexpected mixed usage of different slot syntaxes.",
  51982. el
  51983. );
  51984. }
  51985. if (el.scopedSlots) {
  51986. warn$2(
  51987. "To avoid scope ambiguity, the default slot should also use " +
  51988. "<template> syntax when there are other named slots.",
  51989. slotBinding$1
  51990. );
  51991. }
  51992. }
  51993. // add the component's children to its default slot
  51994. var slots = el.scopedSlots || (el.scopedSlots = {});
  51995. var ref$1 = getSlotName(slotBinding$1);
  51996. var name$1 = ref$1.name;
  51997. var dynamic$1 = ref$1.dynamic;
  51998. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  51999. slotContainer.slotTarget = name$1;
  52000. slotContainer.slotTargetDynamic = dynamic$1;
  52001. slotContainer.children = el.children.filter(function (c) {
  52002. if (!c.slotScope) {
  52003. c.parent = slotContainer;
  52004. return true
  52005. }
  52006. });
  52007. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  52008. // remove children as they are returned from scopedSlots now
  52009. el.children = [];
  52010. // mark el non-plain so data gets generated
  52011. el.plain = false;
  52012. }
  52013. }
  52014. }
  52015. }
  52016. function getSlotName (binding) {
  52017. var name = binding.name.replace(slotRE, '');
  52018. if (!name) {
  52019. if (binding.name[0] !== '#') {
  52020. name = 'default';
  52021. } else {
  52022. warn$2(
  52023. "v-slot shorthand syntax requires a slot name.",
  52024. binding
  52025. );
  52026. }
  52027. }
  52028. return dynamicArgRE.test(name)
  52029. // dynamic [name]
  52030. ? { name: name.slice(1, -1), dynamic: true }
  52031. // static name
  52032. : { name: ("\"" + name + "\""), dynamic: false }
  52033. }
  52034. // handle <slot/> outlets
  52035. function processSlotOutlet (el) {
  52036. if (el.tag === 'slot') {
  52037. el.slotName = getBindingAttr(el, 'name');
  52038. if (el.key) {
  52039. warn$2(
  52040. "`key` does not work on <slot> because slots are abstract outlets " +
  52041. "and can possibly expand into multiple elements. " +
  52042. "Use the key on a wrapping element instead.",
  52043. getRawBindingAttr(el, 'key')
  52044. );
  52045. }
  52046. }
  52047. }
  52048. function processComponent (el) {
  52049. var binding;
  52050. if ((binding = getBindingAttr(el, 'is'))) {
  52051. el.component = binding;
  52052. }
  52053. if (getAndRemoveAttr(el, 'inline-template') != null) {
  52054. el.inlineTemplate = true;
  52055. }
  52056. }
  52057. function processAttrs (el) {
  52058. var list = el.attrsList;
  52059. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  52060. for (i = 0, l = list.length; i < l; i++) {
  52061. name = rawName = list[i].name;
  52062. value = list[i].value;
  52063. if (dirRE.test(name)) {
  52064. // mark element as dynamic
  52065. el.hasBindings = true;
  52066. // modifiers
  52067. modifiers = parseModifiers(name.replace(dirRE, ''));
  52068. // support .foo shorthand syntax for the .prop modifier
  52069. if (modifiers) {
  52070. name = name.replace(modifierRE, '');
  52071. }
  52072. if (bindRE.test(name)) { // v-bind
  52073. name = name.replace(bindRE, '');
  52074. value = parseFilters(value);
  52075. isDynamic = dynamicArgRE.test(name);
  52076. if (isDynamic) {
  52077. name = name.slice(1, -1);
  52078. }
  52079. if (
  52080. value.trim().length === 0
  52081. ) {
  52082. warn$2(
  52083. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  52084. );
  52085. }
  52086. if (modifiers) {
  52087. if (modifiers.prop && !isDynamic) {
  52088. name = camelize(name);
  52089. if (name === 'innerHtml') { name = 'innerHTML'; }
  52090. }
  52091. if (modifiers.camel && !isDynamic) {
  52092. name = camelize(name);
  52093. }
  52094. if (modifiers.sync) {
  52095. syncGen = genAssignmentCode(value, "$event");
  52096. if (!isDynamic) {
  52097. addHandler(
  52098. el,
  52099. ("update:" + (camelize(name))),
  52100. syncGen,
  52101. null,
  52102. false,
  52103. warn$2,
  52104. list[i]
  52105. );
  52106. if (hyphenate(name) !== camelize(name)) {
  52107. addHandler(
  52108. el,
  52109. ("update:" + (hyphenate(name))),
  52110. syncGen,
  52111. null,
  52112. false,
  52113. warn$2,
  52114. list[i]
  52115. );
  52116. }
  52117. } else {
  52118. // handler w/ dynamic event name
  52119. addHandler(
  52120. el,
  52121. ("\"update:\"+(" + name + ")"),
  52122. syncGen,
  52123. null,
  52124. false,
  52125. warn$2,
  52126. list[i],
  52127. true // dynamic
  52128. );
  52129. }
  52130. }
  52131. }
  52132. if ((modifiers && modifiers.prop) || (
  52133. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  52134. )) {
  52135. addProp(el, name, value, list[i], isDynamic);
  52136. } else {
  52137. addAttr(el, name, value, list[i], isDynamic);
  52138. }
  52139. } else if (onRE.test(name)) { // v-on
  52140. name = name.replace(onRE, '');
  52141. isDynamic = dynamicArgRE.test(name);
  52142. if (isDynamic) {
  52143. name = name.slice(1, -1);
  52144. }
  52145. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  52146. } else { // normal directives
  52147. name = name.replace(dirRE, '');
  52148. // parse arg
  52149. var argMatch = name.match(argRE);
  52150. var arg = argMatch && argMatch[1];
  52151. isDynamic = false;
  52152. if (arg) {
  52153. name = name.slice(0, -(arg.length + 1));
  52154. if (dynamicArgRE.test(arg)) {
  52155. arg = arg.slice(1, -1);
  52156. isDynamic = true;
  52157. }
  52158. }
  52159. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  52160. if (name === 'model') {
  52161. checkForAliasModel(el, value);
  52162. }
  52163. }
  52164. } else {
  52165. // literal attribute
  52166. {
  52167. var res = parseText(value, delimiters);
  52168. if (res) {
  52169. warn$2(
  52170. name + "=\"" + value + "\": " +
  52171. 'Interpolation inside attributes has been removed. ' +
  52172. 'Use v-bind or the colon shorthand instead. For example, ' +
  52173. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  52174. list[i]
  52175. );
  52176. }
  52177. }
  52178. addAttr(el, name, JSON.stringify(value), list[i]);
  52179. // #6887 firefox doesn't update muted state if set via attribute
  52180. // even immediately after element creation
  52181. if (!el.component &&
  52182. name === 'muted' &&
  52183. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  52184. addProp(el, name, 'true', list[i]);
  52185. }
  52186. }
  52187. }
  52188. }
  52189. function checkInFor (el) {
  52190. var parent = el;
  52191. while (parent) {
  52192. if (parent.for !== undefined) {
  52193. return true
  52194. }
  52195. parent = parent.parent;
  52196. }
  52197. return false
  52198. }
  52199. function parseModifiers (name) {
  52200. var match = name.match(modifierRE);
  52201. if (match) {
  52202. var ret = {};
  52203. match.forEach(function (m) { ret[m.slice(1)] = true; });
  52204. return ret
  52205. }
  52206. }
  52207. function makeAttrsMap (attrs) {
  52208. var map = {};
  52209. for (var i = 0, l = attrs.length; i < l; i++) {
  52210. if (
  52211. map[attrs[i].name] && !isIE && !isEdge
  52212. ) {
  52213. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  52214. }
  52215. map[attrs[i].name] = attrs[i].value;
  52216. }
  52217. return map
  52218. }
  52219. // for script (e.g. type="x/template") or style, do not decode content
  52220. function isTextTag (el) {
  52221. return el.tag === 'script' || el.tag === 'style'
  52222. }
  52223. function isForbiddenTag (el) {
  52224. return (
  52225. el.tag === 'style' ||
  52226. (el.tag === 'script' && (
  52227. !el.attrsMap.type ||
  52228. el.attrsMap.type === 'text/javascript'
  52229. ))
  52230. )
  52231. }
  52232. var ieNSBug = /^xmlns:NS\d+/;
  52233. var ieNSPrefix = /^NS\d+:/;
  52234. /* istanbul ignore next */
  52235. function guardIESVGBug (attrs) {
  52236. var res = [];
  52237. for (var i = 0; i < attrs.length; i++) {
  52238. var attr = attrs[i];
  52239. if (!ieNSBug.test(attr.name)) {
  52240. attr.name = attr.name.replace(ieNSPrefix, '');
  52241. res.push(attr);
  52242. }
  52243. }
  52244. return res
  52245. }
  52246. function checkForAliasModel (el, value) {
  52247. var _el = el;
  52248. while (_el) {
  52249. if (_el.for && _el.alias === value) {
  52250. warn$2(
  52251. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52252. "You are binding v-model directly to a v-for iteration alias. " +
  52253. "This will not be able to modify the v-for source array because " +
  52254. "writing to the alias is like modifying a function local variable. " +
  52255. "Consider using an array of objects and use v-model on an object property instead.",
  52256. el.rawAttrsMap['v-model']
  52257. );
  52258. }
  52259. _el = _el.parent;
  52260. }
  52261. }
  52262. /* */
  52263. function preTransformNode (el, options) {
  52264. if (el.tag === 'input') {
  52265. var map = el.attrsMap;
  52266. if (!map['v-model']) {
  52267. return
  52268. }
  52269. var typeBinding;
  52270. if (map[':type'] || map['v-bind:type']) {
  52271. typeBinding = getBindingAttr(el, 'type');
  52272. }
  52273. if (!map.type && !typeBinding && map['v-bind']) {
  52274. typeBinding = "(" + (map['v-bind']) + ").type";
  52275. }
  52276. if (typeBinding) {
  52277. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  52278. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  52279. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  52280. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  52281. // 1. checkbox
  52282. var branch0 = cloneASTElement(el);
  52283. // process for on the main node
  52284. processFor(branch0);
  52285. addRawAttr(branch0, 'type', 'checkbox');
  52286. processElement(branch0, options);
  52287. branch0.processed = true; // prevent it from double-processed
  52288. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  52289. addIfCondition(branch0, {
  52290. exp: branch0.if,
  52291. block: branch0
  52292. });
  52293. // 2. add radio else-if condition
  52294. var branch1 = cloneASTElement(el);
  52295. getAndRemoveAttr(branch1, 'v-for', true);
  52296. addRawAttr(branch1, 'type', 'radio');
  52297. processElement(branch1, options);
  52298. addIfCondition(branch0, {
  52299. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  52300. block: branch1
  52301. });
  52302. // 3. other
  52303. var branch2 = cloneASTElement(el);
  52304. getAndRemoveAttr(branch2, 'v-for', true);
  52305. addRawAttr(branch2, ':type', typeBinding);
  52306. processElement(branch2, options);
  52307. addIfCondition(branch0, {
  52308. exp: ifCondition,
  52309. block: branch2
  52310. });
  52311. if (hasElse) {
  52312. branch0.else = true;
  52313. } else if (elseIfCondition) {
  52314. branch0.elseif = elseIfCondition;
  52315. }
  52316. return branch0
  52317. }
  52318. }
  52319. }
  52320. function cloneASTElement (el) {
  52321. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  52322. }
  52323. var model$1 = {
  52324. preTransformNode: preTransformNode
  52325. };
  52326. var modules$1 = [
  52327. klass$1,
  52328. style$1,
  52329. model$1
  52330. ];
  52331. /* */
  52332. function text (el, dir) {
  52333. if (dir.value) {
  52334. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  52335. }
  52336. }
  52337. /* */
  52338. function html (el, dir) {
  52339. if (dir.value) {
  52340. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  52341. }
  52342. }
  52343. var directives$1 = {
  52344. model: model,
  52345. text: text,
  52346. html: html
  52347. };
  52348. /* */
  52349. var baseOptions = {
  52350. expectHTML: true,
  52351. modules: modules$1,
  52352. directives: directives$1,
  52353. isPreTag: isPreTag,
  52354. isUnaryTag: isUnaryTag,
  52355. mustUseProp: mustUseProp,
  52356. canBeLeftOpenTag: canBeLeftOpenTag,
  52357. isReservedTag: isReservedTag,
  52358. getTagNamespace: getTagNamespace,
  52359. staticKeys: genStaticKeys(modules$1)
  52360. };
  52361. /* */
  52362. var isStaticKey;
  52363. var isPlatformReservedTag;
  52364. var genStaticKeysCached = cached(genStaticKeys$1);
  52365. /**
  52366. * Goal of the optimizer: walk the generated template AST tree
  52367. * and detect sub-trees that are purely static, i.e. parts of
  52368. * the DOM that never needs to change.
  52369. *
  52370. * Once we detect these sub-trees, we can:
  52371. *
  52372. * 1. Hoist them into constants, so that we no longer need to
  52373. * create fresh nodes for them on each re-render;
  52374. * 2. Completely skip them in the patching process.
  52375. */
  52376. function optimize (root, options) {
  52377. if (!root) { return }
  52378. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  52379. isPlatformReservedTag = options.isReservedTag || no;
  52380. // first pass: mark all non-static nodes.
  52381. markStatic$1(root);
  52382. // second pass: mark static roots.
  52383. markStaticRoots(root, false);
  52384. }
  52385. function genStaticKeys$1 (keys) {
  52386. return makeMap(
  52387. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  52388. (keys ? ',' + keys : '')
  52389. )
  52390. }
  52391. function markStatic$1 (node) {
  52392. node.static = isStatic(node);
  52393. if (node.type === 1) {
  52394. // do not make component slot content static. this avoids
  52395. // 1. components not able to mutate slot nodes
  52396. // 2. static slot content fails for hot-reloading
  52397. if (
  52398. !isPlatformReservedTag(node.tag) &&
  52399. node.tag !== 'slot' &&
  52400. node.attrsMap['inline-template'] == null
  52401. ) {
  52402. return
  52403. }
  52404. for (var i = 0, l = node.children.length; i < l; i++) {
  52405. var child = node.children[i];
  52406. markStatic$1(child);
  52407. if (!child.static) {
  52408. node.static = false;
  52409. }
  52410. }
  52411. if (node.ifConditions) {
  52412. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52413. var block = node.ifConditions[i$1].block;
  52414. markStatic$1(block);
  52415. if (!block.static) {
  52416. node.static = false;
  52417. }
  52418. }
  52419. }
  52420. }
  52421. }
  52422. function markStaticRoots (node, isInFor) {
  52423. if (node.type === 1) {
  52424. if (node.static || node.once) {
  52425. node.staticInFor = isInFor;
  52426. }
  52427. // For a node to qualify as a static root, it should have children that
  52428. // are not just static text. Otherwise the cost of hoisting out will
  52429. // outweigh the benefits and it's better off to just always render it fresh.
  52430. if (node.static && node.children.length && !(
  52431. node.children.length === 1 &&
  52432. node.children[0].type === 3
  52433. )) {
  52434. node.staticRoot = true;
  52435. return
  52436. } else {
  52437. node.staticRoot = false;
  52438. }
  52439. if (node.children) {
  52440. for (var i = 0, l = node.children.length; i < l; i++) {
  52441. markStaticRoots(node.children[i], isInFor || !!node.for);
  52442. }
  52443. }
  52444. if (node.ifConditions) {
  52445. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52446. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  52447. }
  52448. }
  52449. }
  52450. }
  52451. function isStatic (node) {
  52452. if (node.type === 2) { // expression
  52453. return false
  52454. }
  52455. if (node.type === 3) { // text
  52456. return true
  52457. }
  52458. return !!(node.pre || (
  52459. !node.hasBindings && // no dynamic bindings
  52460. !node.if && !node.for && // not v-if or v-for or v-else
  52461. !isBuiltInTag(node.tag) && // not a built-in
  52462. isPlatformReservedTag(node.tag) && // not a component
  52463. !isDirectChildOfTemplateFor(node) &&
  52464. Object.keys(node).every(isStaticKey)
  52465. ))
  52466. }
  52467. function isDirectChildOfTemplateFor (node) {
  52468. while (node.parent) {
  52469. node = node.parent;
  52470. if (node.tag !== 'template') {
  52471. return false
  52472. }
  52473. if (node.for) {
  52474. return true
  52475. }
  52476. }
  52477. return false
  52478. }
  52479. /* */
  52480. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  52481. var fnInvokeRE = /\([^)]*?\);*$/;
  52482. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  52483. // KeyboardEvent.keyCode aliases
  52484. var keyCodes = {
  52485. esc: 27,
  52486. tab: 9,
  52487. enter: 13,
  52488. space: 32,
  52489. up: 38,
  52490. left: 37,
  52491. right: 39,
  52492. down: 40,
  52493. 'delete': [8, 46]
  52494. };
  52495. // KeyboardEvent.key aliases
  52496. var keyNames = {
  52497. // #7880: IE11 and Edge use `Esc` for Escape key name.
  52498. esc: ['Esc', 'Escape'],
  52499. tab: 'Tab',
  52500. enter: 'Enter',
  52501. // #9112: IE11 uses `Spacebar` for Space key name.
  52502. space: [' ', 'Spacebar'],
  52503. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  52504. up: ['Up', 'ArrowUp'],
  52505. left: ['Left', 'ArrowLeft'],
  52506. right: ['Right', 'ArrowRight'],
  52507. down: ['Down', 'ArrowDown'],
  52508. // #9112: IE11 uses `Del` for Delete key name.
  52509. 'delete': ['Backspace', 'Delete', 'Del']
  52510. };
  52511. // #4868: modifiers that prevent the execution of the listener
  52512. // need to explicitly return null so that we can determine whether to remove
  52513. // the listener for .once
  52514. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  52515. var modifierCode = {
  52516. stop: '$event.stopPropagation();',
  52517. prevent: '$event.preventDefault();',
  52518. self: genGuard("$event.target !== $event.currentTarget"),
  52519. ctrl: genGuard("!$event.ctrlKey"),
  52520. shift: genGuard("!$event.shiftKey"),
  52521. alt: genGuard("!$event.altKey"),
  52522. meta: genGuard("!$event.metaKey"),
  52523. left: genGuard("'button' in $event && $event.button !== 0"),
  52524. middle: genGuard("'button' in $event && $event.button !== 1"),
  52525. right: genGuard("'button' in $event && $event.button !== 2")
  52526. };
  52527. function genHandlers (
  52528. events,
  52529. isNative
  52530. ) {
  52531. var prefix = isNative ? 'nativeOn:' : 'on:';
  52532. var staticHandlers = "";
  52533. var dynamicHandlers = "";
  52534. for (var name in events) {
  52535. var handlerCode = genHandler(events[name]);
  52536. if (events[name] && events[name].dynamic) {
  52537. dynamicHandlers += name + "," + handlerCode + ",";
  52538. } else {
  52539. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  52540. }
  52541. }
  52542. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  52543. if (dynamicHandlers) {
  52544. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  52545. } else {
  52546. return prefix + staticHandlers
  52547. }
  52548. }
  52549. function genHandler (handler) {
  52550. if (!handler) {
  52551. return 'function(){}'
  52552. }
  52553. if (Array.isArray(handler)) {
  52554. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  52555. }
  52556. var isMethodPath = simplePathRE.test(handler.value);
  52557. var isFunctionExpression = fnExpRE.test(handler.value);
  52558. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  52559. if (!handler.modifiers) {
  52560. if (isMethodPath || isFunctionExpression) {
  52561. return handler.value
  52562. }
  52563. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  52564. } else {
  52565. var code = '';
  52566. var genModifierCode = '';
  52567. var keys = [];
  52568. for (var key in handler.modifiers) {
  52569. if (modifierCode[key]) {
  52570. genModifierCode += modifierCode[key];
  52571. // left/right
  52572. if (keyCodes[key]) {
  52573. keys.push(key);
  52574. }
  52575. } else if (key === 'exact') {
  52576. var modifiers = (handler.modifiers);
  52577. genModifierCode += genGuard(
  52578. ['ctrl', 'shift', 'alt', 'meta']
  52579. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  52580. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  52581. .join('||')
  52582. );
  52583. } else {
  52584. keys.push(key);
  52585. }
  52586. }
  52587. if (keys.length) {
  52588. code += genKeyFilter(keys);
  52589. }
  52590. // Make sure modifiers like prevent and stop get executed after key filtering
  52591. if (genModifierCode) {
  52592. code += genModifierCode;
  52593. }
  52594. var handlerCode = isMethodPath
  52595. ? ("return " + (handler.value) + "($event)")
  52596. : isFunctionExpression
  52597. ? ("return (" + (handler.value) + ")($event)")
  52598. : isFunctionInvocation
  52599. ? ("return " + (handler.value))
  52600. : handler.value;
  52601. return ("function($event){" + code + handlerCode + "}")
  52602. }
  52603. }
  52604. function genKeyFilter (keys) {
  52605. return (
  52606. // make sure the key filters only apply to KeyboardEvents
  52607. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  52608. // key events that do not have keyCode property...
  52609. "if(!$event.type.indexOf('key')&&" +
  52610. (keys.map(genFilterCode).join('&&')) + ")return null;"
  52611. )
  52612. }
  52613. function genFilterCode (key) {
  52614. var keyVal = parseInt(key, 10);
  52615. if (keyVal) {
  52616. return ("$event.keyCode!==" + keyVal)
  52617. }
  52618. var keyCode = keyCodes[key];
  52619. var keyName = keyNames[key];
  52620. return (
  52621. "_k($event.keyCode," +
  52622. (JSON.stringify(key)) + "," +
  52623. (JSON.stringify(keyCode)) + "," +
  52624. "$event.key," +
  52625. "" + (JSON.stringify(keyName)) +
  52626. ")"
  52627. )
  52628. }
  52629. /* */
  52630. function on (el, dir) {
  52631. if (dir.modifiers) {
  52632. warn("v-on without argument does not support modifiers.");
  52633. }
  52634. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  52635. }
  52636. /* */
  52637. function bind$1 (el, dir) {
  52638. el.wrapData = function (code) {
  52639. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  52640. };
  52641. }
  52642. /* */
  52643. var baseDirectives = {
  52644. on: on,
  52645. bind: bind$1,
  52646. cloak: noop
  52647. };
  52648. /* */
  52649. var CodegenState = function CodegenState (options) {
  52650. this.options = options;
  52651. this.warn = options.warn || baseWarn;
  52652. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  52653. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  52654. this.directives = extend(extend({}, baseDirectives), options.directives);
  52655. var isReservedTag = options.isReservedTag || no;
  52656. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  52657. this.onceId = 0;
  52658. this.staticRenderFns = [];
  52659. this.pre = false;
  52660. };
  52661. function generate (
  52662. ast,
  52663. options
  52664. ) {
  52665. var state = new CodegenState(options);
  52666. var code = ast ? genElement(ast, state) : '_c("div")';
  52667. return {
  52668. render: ("with(this){return " + code + "}"),
  52669. staticRenderFns: state.staticRenderFns
  52670. }
  52671. }
  52672. function genElement (el, state) {
  52673. if (el.parent) {
  52674. el.pre = el.pre || el.parent.pre;
  52675. }
  52676. if (el.staticRoot && !el.staticProcessed) {
  52677. return genStatic(el, state)
  52678. } else if (el.once && !el.onceProcessed) {
  52679. return genOnce(el, state)
  52680. } else if (el.for && !el.forProcessed) {
  52681. return genFor(el, state)
  52682. } else if (el.if && !el.ifProcessed) {
  52683. return genIf(el, state)
  52684. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  52685. return genChildren(el, state) || 'void 0'
  52686. } else if (el.tag === 'slot') {
  52687. return genSlot(el, state)
  52688. } else {
  52689. // component or element
  52690. var code;
  52691. if (el.component) {
  52692. code = genComponent(el.component, el, state);
  52693. } else {
  52694. var data;
  52695. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  52696. data = genData$2(el, state);
  52697. }
  52698. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52699. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  52700. }
  52701. // module transforms
  52702. for (var i = 0; i < state.transforms.length; i++) {
  52703. code = state.transforms[i](el, code);
  52704. }
  52705. return code
  52706. }
  52707. }
  52708. // hoist static sub-trees out
  52709. function genStatic (el, state) {
  52710. el.staticProcessed = true;
  52711. // Some elements (templates) need to behave differently inside of a v-pre
  52712. // node. All pre nodes are static roots, so we can use this as a location to
  52713. // wrap a state change and reset it upon exiting the pre node.
  52714. var originalPreState = state.pre;
  52715. if (el.pre) {
  52716. state.pre = el.pre;
  52717. }
  52718. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  52719. state.pre = originalPreState;
  52720. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  52721. }
  52722. // v-once
  52723. function genOnce (el, state) {
  52724. el.onceProcessed = true;
  52725. if (el.if && !el.ifProcessed) {
  52726. return genIf(el, state)
  52727. } else if (el.staticInFor) {
  52728. var key = '';
  52729. var parent = el.parent;
  52730. while (parent) {
  52731. if (parent.for) {
  52732. key = parent.key;
  52733. break
  52734. }
  52735. parent = parent.parent;
  52736. }
  52737. if (!key) {
  52738. state.warn(
  52739. "v-once can only be used inside v-for that is keyed. ",
  52740. el.rawAttrsMap['v-once']
  52741. );
  52742. return genElement(el, state)
  52743. }
  52744. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  52745. } else {
  52746. return genStatic(el, state)
  52747. }
  52748. }
  52749. function genIf (
  52750. el,
  52751. state,
  52752. altGen,
  52753. altEmpty
  52754. ) {
  52755. el.ifProcessed = true; // avoid recursion
  52756. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  52757. }
  52758. function genIfConditions (
  52759. conditions,
  52760. state,
  52761. altGen,
  52762. altEmpty
  52763. ) {
  52764. if (!conditions.length) {
  52765. return altEmpty || '_e()'
  52766. }
  52767. var condition = conditions.shift();
  52768. if (condition.exp) {
  52769. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  52770. } else {
  52771. return ("" + (genTernaryExp(condition.block)))
  52772. }
  52773. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  52774. function genTernaryExp (el) {
  52775. return altGen
  52776. ? altGen(el, state)
  52777. : el.once
  52778. ? genOnce(el, state)
  52779. : genElement(el, state)
  52780. }
  52781. }
  52782. function genFor (
  52783. el,
  52784. state,
  52785. altGen,
  52786. altHelper
  52787. ) {
  52788. var exp = el.for;
  52789. var alias = el.alias;
  52790. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  52791. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  52792. if (state.maybeComponent(el) &&
  52793. el.tag !== 'slot' &&
  52794. el.tag !== 'template' &&
  52795. !el.key
  52796. ) {
  52797. state.warn(
  52798. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  52799. "v-for should have explicit keys. " +
  52800. "See https://vuejs.org/guide/list.html#key for more info.",
  52801. el.rawAttrsMap['v-for'],
  52802. true /* tip */
  52803. );
  52804. }
  52805. el.forProcessed = true; // avoid recursion
  52806. return (altHelper || '_l') + "((" + exp + ")," +
  52807. "function(" + alias + iterator1 + iterator2 + "){" +
  52808. "return " + ((altGen || genElement)(el, state)) +
  52809. '})'
  52810. }
  52811. function genData$2 (el, state) {
  52812. var data = '{';
  52813. // directives first.
  52814. // directives may mutate the el's other properties before they are generated.
  52815. var dirs = genDirectives(el, state);
  52816. if (dirs) { data += dirs + ','; }
  52817. // key
  52818. if (el.key) {
  52819. data += "key:" + (el.key) + ",";
  52820. }
  52821. // ref
  52822. if (el.ref) {
  52823. data += "ref:" + (el.ref) + ",";
  52824. }
  52825. if (el.refInFor) {
  52826. data += "refInFor:true,";
  52827. }
  52828. // pre
  52829. if (el.pre) {
  52830. data += "pre:true,";
  52831. }
  52832. // record original tag name for components using "is" attribute
  52833. if (el.component) {
  52834. data += "tag:\"" + (el.tag) + "\",";
  52835. }
  52836. // module data generation functions
  52837. for (var i = 0; i < state.dataGenFns.length; i++) {
  52838. data += state.dataGenFns[i](el);
  52839. }
  52840. // attributes
  52841. if (el.attrs) {
  52842. data += "attrs:" + (genProps(el.attrs)) + ",";
  52843. }
  52844. // DOM props
  52845. if (el.props) {
  52846. data += "domProps:" + (genProps(el.props)) + ",";
  52847. }
  52848. // event handlers
  52849. if (el.events) {
  52850. data += (genHandlers(el.events, false)) + ",";
  52851. }
  52852. if (el.nativeEvents) {
  52853. data += (genHandlers(el.nativeEvents, true)) + ",";
  52854. }
  52855. // slot target
  52856. // only for non-scoped slots
  52857. if (el.slotTarget && !el.slotScope) {
  52858. data += "slot:" + (el.slotTarget) + ",";
  52859. }
  52860. // scoped slots
  52861. if (el.scopedSlots) {
  52862. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  52863. }
  52864. // component v-model
  52865. if (el.model) {
  52866. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  52867. }
  52868. // inline-template
  52869. if (el.inlineTemplate) {
  52870. var inlineTemplate = genInlineTemplate(el, state);
  52871. if (inlineTemplate) {
  52872. data += inlineTemplate + ",";
  52873. }
  52874. }
  52875. data = data.replace(/,$/, '') + '}';
  52876. // v-bind dynamic argument wrap
  52877. // v-bind with dynamic arguments must be applied using the same v-bind object
  52878. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  52879. if (el.dynamicAttrs) {
  52880. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  52881. }
  52882. // v-bind data wrap
  52883. if (el.wrapData) {
  52884. data = el.wrapData(data);
  52885. }
  52886. // v-on data wrap
  52887. if (el.wrapListeners) {
  52888. data = el.wrapListeners(data);
  52889. }
  52890. return data
  52891. }
  52892. function genDirectives (el, state) {
  52893. var dirs = el.directives;
  52894. if (!dirs) { return }
  52895. var res = 'directives:[';
  52896. var hasRuntime = false;
  52897. var i, l, dir, needRuntime;
  52898. for (i = 0, l = dirs.length; i < l; i++) {
  52899. dir = dirs[i];
  52900. needRuntime = true;
  52901. var gen = state.directives[dir.name];
  52902. if (gen) {
  52903. // compile-time directive that manipulates AST.
  52904. // returns true if it also needs a runtime counterpart.
  52905. needRuntime = !!gen(el, dir, state.warn);
  52906. }
  52907. if (needRuntime) {
  52908. hasRuntime = true;
  52909. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  52910. }
  52911. }
  52912. if (hasRuntime) {
  52913. return res.slice(0, -1) + ']'
  52914. }
  52915. }
  52916. function genInlineTemplate (el, state) {
  52917. var ast = el.children[0];
  52918. if (el.children.length !== 1 || ast.type !== 1) {
  52919. state.warn(
  52920. 'Inline-template components must have exactly one child element.',
  52921. { start: el.start }
  52922. );
  52923. }
  52924. if (ast && ast.type === 1) {
  52925. var inlineRenderFns = generate(ast, state.options);
  52926. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  52927. }
  52928. }
  52929. function genScopedSlots (
  52930. el,
  52931. slots,
  52932. state
  52933. ) {
  52934. // by default scoped slots are considered "stable", this allows child
  52935. // components with only scoped slots to skip forced updates from parent.
  52936. // but in some cases we have to bail-out of this optimization
  52937. // for example if the slot contains dynamic names, has v-if or v-for on them...
  52938. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  52939. var slot = slots[key];
  52940. return (
  52941. slot.slotTargetDynamic ||
  52942. slot.if ||
  52943. slot.for ||
  52944. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  52945. )
  52946. });
  52947. // #9534: if a component with scoped slots is inside a conditional branch,
  52948. // it's possible for the same component to be reused but with different
  52949. // compiled slot content. To avoid that, we generate a unique key based on
  52950. // the generated code of all the slot contents.
  52951. var needsKey = !!el.if;
  52952. // OR when it is inside another scoped slot or v-for (the reactivity may be
  52953. // disconnected due to the intermediate scope variable)
  52954. // #9438, #9506
  52955. // TODO: this can be further optimized by properly analyzing in-scope bindings
  52956. // and skip force updating ones that do not actually use scope variables.
  52957. if (!needsForceUpdate) {
  52958. var parent = el.parent;
  52959. while (parent) {
  52960. if (
  52961. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  52962. parent.for
  52963. ) {
  52964. needsForceUpdate = true;
  52965. break
  52966. }
  52967. if (parent.if) {
  52968. needsKey = true;
  52969. }
  52970. parent = parent.parent;
  52971. }
  52972. }
  52973. var generatedSlots = Object.keys(slots)
  52974. .map(function (key) { return genScopedSlot(slots[key], state); })
  52975. .join(',');
  52976. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  52977. }
  52978. function hash(str) {
  52979. var hash = 5381;
  52980. var i = str.length;
  52981. while(i) {
  52982. hash = (hash * 33) ^ str.charCodeAt(--i);
  52983. }
  52984. return hash >>> 0
  52985. }
  52986. function containsSlotChild (el) {
  52987. if (el.type === 1) {
  52988. if (el.tag === 'slot') {
  52989. return true
  52990. }
  52991. return el.children.some(containsSlotChild)
  52992. }
  52993. return false
  52994. }
  52995. function genScopedSlot (
  52996. el,
  52997. state
  52998. ) {
  52999. var isLegacySyntax = el.attrsMap['slot-scope'];
  53000. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  53001. return genIf(el, state, genScopedSlot, "null")
  53002. }
  53003. if (el.for && !el.forProcessed) {
  53004. return genFor(el, state, genScopedSlot)
  53005. }
  53006. var slotScope = el.slotScope === emptySlotScopeToken
  53007. ? ""
  53008. : String(el.slotScope);
  53009. var fn = "function(" + slotScope + "){" +
  53010. "return " + (el.tag === 'template'
  53011. ? el.if && isLegacySyntax
  53012. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  53013. : genChildren(el, state) || 'undefined'
  53014. : genElement(el, state)) + "}";
  53015. // reverse proxy v-slot without scope on this.$slots
  53016. var reverseProxy = slotScope ? "" : ",proxy:true";
  53017. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  53018. }
  53019. function genChildren (
  53020. el,
  53021. state,
  53022. checkSkip,
  53023. altGenElement,
  53024. altGenNode
  53025. ) {
  53026. var children = el.children;
  53027. if (children.length) {
  53028. var el$1 = children[0];
  53029. // optimize single v-for
  53030. if (children.length === 1 &&
  53031. el$1.for &&
  53032. el$1.tag !== 'template' &&
  53033. el$1.tag !== 'slot'
  53034. ) {
  53035. var normalizationType = checkSkip
  53036. ? state.maybeComponent(el$1) ? ",1" : ",0"
  53037. : "";
  53038. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  53039. }
  53040. var normalizationType$1 = checkSkip
  53041. ? getNormalizationType(children, state.maybeComponent)
  53042. : 0;
  53043. var gen = altGenNode || genNode;
  53044. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  53045. }
  53046. }
  53047. // determine the normalization needed for the children array.
  53048. // 0: no normalization needed
  53049. // 1: simple normalization needed (possible 1-level deep nested array)
  53050. // 2: full normalization needed
  53051. function getNormalizationType (
  53052. children,
  53053. maybeComponent
  53054. ) {
  53055. var res = 0;
  53056. for (var i = 0; i < children.length; i++) {
  53057. var el = children[i];
  53058. if (el.type !== 1) {
  53059. continue
  53060. }
  53061. if (needsNormalization(el) ||
  53062. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  53063. res = 2;
  53064. break
  53065. }
  53066. if (maybeComponent(el) ||
  53067. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  53068. res = 1;
  53069. }
  53070. }
  53071. return res
  53072. }
  53073. function needsNormalization (el) {
  53074. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  53075. }
  53076. function genNode (node, state) {
  53077. if (node.type === 1) {
  53078. return genElement(node, state)
  53079. } else if (node.type === 3 && node.isComment) {
  53080. return genComment(node)
  53081. } else {
  53082. return genText(node)
  53083. }
  53084. }
  53085. function genText (text) {
  53086. return ("_v(" + (text.type === 2
  53087. ? text.expression // no need for () because already wrapped in _s()
  53088. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  53089. }
  53090. function genComment (comment) {
  53091. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  53092. }
  53093. function genSlot (el, state) {
  53094. var slotName = el.slotName || '"default"';
  53095. var children = genChildren(el, state);
  53096. var res = "_t(" + slotName + (children ? ("," + children) : '');
  53097. var attrs = el.attrs || el.dynamicAttrs
  53098. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  53099. // slot props are camelized
  53100. name: camelize(attr.name),
  53101. value: attr.value,
  53102. dynamic: attr.dynamic
  53103. }); }))
  53104. : null;
  53105. var bind$$1 = el.attrsMap['v-bind'];
  53106. if ((attrs || bind$$1) && !children) {
  53107. res += ",null";
  53108. }
  53109. if (attrs) {
  53110. res += "," + attrs;
  53111. }
  53112. if (bind$$1) {
  53113. res += (attrs ? '' : ',null') + "," + bind$$1;
  53114. }
  53115. return res + ')'
  53116. }
  53117. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  53118. function genComponent (
  53119. componentName,
  53120. el,
  53121. state
  53122. ) {
  53123. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53124. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  53125. }
  53126. function genProps (props) {
  53127. var staticProps = "";
  53128. var dynamicProps = "";
  53129. for (var i = 0; i < props.length; i++) {
  53130. var prop = props[i];
  53131. var value = transformSpecialNewlines(prop.value);
  53132. if (prop.dynamic) {
  53133. dynamicProps += (prop.name) + "," + value + ",";
  53134. } else {
  53135. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  53136. }
  53137. }
  53138. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  53139. if (dynamicProps) {
  53140. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  53141. } else {
  53142. return staticProps
  53143. }
  53144. }
  53145. // #3895, #4268
  53146. function transformSpecialNewlines (text) {
  53147. return text
  53148. .replace(/\u2028/g, '\\u2028')
  53149. .replace(/\u2029/g, '\\u2029')
  53150. }
  53151. /* */
  53152. // these keywords should not appear inside expressions, but operators like
  53153. // typeof, instanceof and in are allowed
  53154. var prohibitedKeywordRE = new RegExp('\\b' + (
  53155. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  53156. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  53157. 'extends,finally,continue,debugger,function,arguments'
  53158. ).split(',').join('\\b|\\b') + '\\b');
  53159. // these unary operators should not be used as property/method names
  53160. var unaryOperatorsRE = new RegExp('\\b' + (
  53161. 'delete,typeof,void'
  53162. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  53163. // strip strings in expressions
  53164. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  53165. // detect problematic expressions in a template
  53166. function detectErrors (ast, warn) {
  53167. if (ast) {
  53168. checkNode(ast, warn);
  53169. }
  53170. }
  53171. function checkNode (node, warn) {
  53172. if (node.type === 1) {
  53173. for (var name in node.attrsMap) {
  53174. if (dirRE.test(name)) {
  53175. var value = node.attrsMap[name];
  53176. if (value) {
  53177. var range = node.rawAttrsMap[name];
  53178. if (name === 'v-for') {
  53179. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  53180. } else if (name === 'v-slot' || name[0] === '#') {
  53181. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  53182. } else if (onRE.test(name)) {
  53183. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  53184. } else {
  53185. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  53186. }
  53187. }
  53188. }
  53189. }
  53190. if (node.children) {
  53191. for (var i = 0; i < node.children.length; i++) {
  53192. checkNode(node.children[i], warn);
  53193. }
  53194. }
  53195. } else if (node.type === 2) {
  53196. checkExpression(node.expression, node.text, warn, node);
  53197. }
  53198. }
  53199. function checkEvent (exp, text, warn, range) {
  53200. var stripped = exp.replace(stripStringRE, '');
  53201. var keywordMatch = stripped.match(unaryOperatorsRE);
  53202. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  53203. warn(
  53204. "avoid using JavaScript unary operator as property name: " +
  53205. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  53206. range
  53207. );
  53208. }
  53209. checkExpression(exp, text, warn, range);
  53210. }
  53211. function checkFor (node, text, warn, range) {
  53212. checkExpression(node.for || '', text, warn, range);
  53213. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  53214. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  53215. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  53216. }
  53217. function checkIdentifier (
  53218. ident,
  53219. type,
  53220. text,
  53221. warn,
  53222. range
  53223. ) {
  53224. if (typeof ident === 'string') {
  53225. try {
  53226. new Function(("var " + ident + "=_"));
  53227. } catch (e) {
  53228. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  53229. }
  53230. }
  53231. }
  53232. function checkExpression (exp, text, warn, range) {
  53233. try {
  53234. new Function(("return " + exp));
  53235. } catch (e) {
  53236. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  53237. if (keywordMatch) {
  53238. warn(
  53239. "avoid using JavaScript keyword as property name: " +
  53240. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  53241. range
  53242. );
  53243. } else {
  53244. warn(
  53245. "invalid expression: " + (e.message) + " in\n\n" +
  53246. " " + exp + "\n\n" +
  53247. " Raw expression: " + (text.trim()) + "\n",
  53248. range
  53249. );
  53250. }
  53251. }
  53252. }
  53253. function checkFunctionParameterExpression (exp, text, warn, range) {
  53254. try {
  53255. new Function(exp, '');
  53256. } catch (e) {
  53257. warn(
  53258. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  53259. " " + exp + "\n\n" +
  53260. " Raw expression: " + (text.trim()) + "\n",
  53261. range
  53262. );
  53263. }
  53264. }
  53265. /* */
  53266. var range = 2;
  53267. function generateCodeFrame (
  53268. source,
  53269. start,
  53270. end
  53271. ) {
  53272. if ( start === void 0 ) start = 0;
  53273. if ( end === void 0 ) end = source.length;
  53274. var lines = source.split(/\r?\n/);
  53275. var count = 0;
  53276. var res = [];
  53277. for (var i = 0; i < lines.length; i++) {
  53278. count += lines[i].length + 1;
  53279. if (count >= start) {
  53280. for (var j = i - range; j <= i + range || end > count; j++) {
  53281. if (j < 0 || j >= lines.length) { continue }
  53282. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  53283. var lineLength = lines[j].length;
  53284. if (j === i) {
  53285. // push underline
  53286. var pad = start - (count - lineLength) + 1;
  53287. var length = end > count ? lineLength - pad : end - start;
  53288. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  53289. } else if (j > i) {
  53290. if (end > count) {
  53291. var length$1 = Math.min(end - count, lineLength);
  53292. res.push(" | " + repeat$1("^", length$1));
  53293. }
  53294. count += lineLength + 1;
  53295. }
  53296. }
  53297. break
  53298. }
  53299. }
  53300. return res.join('\n')
  53301. }
  53302. function repeat$1 (str, n) {
  53303. var result = '';
  53304. if (n > 0) {
  53305. while (true) { // eslint-disable-line
  53306. if (n & 1) { result += str; }
  53307. n >>>= 1;
  53308. if (n <= 0) { break }
  53309. str += str;
  53310. }
  53311. }
  53312. return result
  53313. }
  53314. /* */
  53315. function createFunction (code, errors) {
  53316. try {
  53317. return new Function(code)
  53318. } catch (err) {
  53319. errors.push({ err: err, code: code });
  53320. return noop
  53321. }
  53322. }
  53323. function createCompileToFunctionFn (compile) {
  53324. var cache = Object.create(null);
  53325. return function compileToFunctions (
  53326. template,
  53327. options,
  53328. vm
  53329. ) {
  53330. options = extend({}, options);
  53331. var warn$$1 = options.warn || warn;
  53332. delete options.warn;
  53333. /* istanbul ignore if */
  53334. {
  53335. // detect possible CSP restriction
  53336. try {
  53337. new Function('return 1');
  53338. } catch (e) {
  53339. if (e.toString().match(/unsafe-eval|CSP/)) {
  53340. warn$$1(
  53341. 'It seems you are using the standalone build of Vue.js in an ' +
  53342. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  53343. 'The template compiler cannot work in this environment. Consider ' +
  53344. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  53345. 'templates into render functions.'
  53346. );
  53347. }
  53348. }
  53349. }
  53350. // check cache
  53351. var key = options.delimiters
  53352. ? String(options.delimiters) + template
  53353. : template;
  53354. if (cache[key]) {
  53355. return cache[key]
  53356. }
  53357. // compile
  53358. var compiled = compile(template, options);
  53359. // check compilation errors/tips
  53360. {
  53361. if (compiled.errors && compiled.errors.length) {
  53362. if (options.outputSourceRange) {
  53363. compiled.errors.forEach(function (e) {
  53364. warn$$1(
  53365. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  53366. generateCodeFrame(template, e.start, e.end),
  53367. vm
  53368. );
  53369. });
  53370. } else {
  53371. warn$$1(
  53372. "Error compiling template:\n\n" + template + "\n\n" +
  53373. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  53374. vm
  53375. );
  53376. }
  53377. }
  53378. if (compiled.tips && compiled.tips.length) {
  53379. if (options.outputSourceRange) {
  53380. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  53381. } else {
  53382. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  53383. }
  53384. }
  53385. }
  53386. // turn code into functions
  53387. var res = {};
  53388. var fnGenErrors = [];
  53389. res.render = createFunction(compiled.render, fnGenErrors);
  53390. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  53391. return createFunction(code, fnGenErrors)
  53392. });
  53393. // check function generation errors.
  53394. // this should only happen if there is a bug in the compiler itself.
  53395. // mostly for codegen development use
  53396. /* istanbul ignore if */
  53397. {
  53398. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  53399. warn$$1(
  53400. "Failed to generate render function:\n\n" +
  53401. fnGenErrors.map(function (ref) {
  53402. var err = ref.err;
  53403. var code = ref.code;
  53404. return ((err.toString()) + " in\n\n" + code + "\n");
  53405. }).join('\n'),
  53406. vm
  53407. );
  53408. }
  53409. }
  53410. return (cache[key] = res)
  53411. }
  53412. }
  53413. /* */
  53414. function createCompilerCreator (baseCompile) {
  53415. return function createCompiler (baseOptions) {
  53416. function compile (
  53417. template,
  53418. options
  53419. ) {
  53420. var finalOptions = Object.create(baseOptions);
  53421. var errors = [];
  53422. var tips = [];
  53423. var warn = function (msg, range, tip) {
  53424. (tip ? tips : errors).push(msg);
  53425. };
  53426. if (options) {
  53427. if (options.outputSourceRange) {
  53428. // $flow-disable-line
  53429. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  53430. warn = function (msg, range, tip) {
  53431. var data = { msg: msg };
  53432. if (range) {
  53433. if (range.start != null) {
  53434. data.start = range.start + leadingSpaceLength;
  53435. }
  53436. if (range.end != null) {
  53437. data.end = range.end + leadingSpaceLength;
  53438. }
  53439. }
  53440. (tip ? tips : errors).push(data);
  53441. };
  53442. }
  53443. // merge custom modules
  53444. if (options.modules) {
  53445. finalOptions.modules =
  53446. (baseOptions.modules || []).concat(options.modules);
  53447. }
  53448. // merge custom directives
  53449. if (options.directives) {
  53450. finalOptions.directives = extend(
  53451. Object.create(baseOptions.directives || null),
  53452. options.directives
  53453. );
  53454. }
  53455. // copy other options
  53456. for (var key in options) {
  53457. if (key !== 'modules' && key !== 'directives') {
  53458. finalOptions[key] = options[key];
  53459. }
  53460. }
  53461. }
  53462. finalOptions.warn = warn;
  53463. var compiled = baseCompile(template.trim(), finalOptions);
  53464. {
  53465. detectErrors(compiled.ast, warn);
  53466. }
  53467. compiled.errors = errors;
  53468. compiled.tips = tips;
  53469. return compiled
  53470. }
  53471. return {
  53472. compile: compile,
  53473. compileToFunctions: createCompileToFunctionFn(compile)
  53474. }
  53475. }
  53476. }
  53477. /* */
  53478. // `createCompilerCreator` allows creating compilers that use alternative
  53479. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  53480. // Here we just export a default compiler using the default parts.
  53481. var createCompiler = createCompilerCreator(function baseCompile (
  53482. template,
  53483. options
  53484. ) {
  53485. var ast = parse(template.trim(), options);
  53486. if (options.optimize !== false) {
  53487. optimize(ast, options);
  53488. }
  53489. var code = generate(ast, options);
  53490. return {
  53491. ast: ast,
  53492. render: code.render,
  53493. staticRenderFns: code.staticRenderFns
  53494. }
  53495. });
  53496. /* */
  53497. var ref$1 = createCompiler(baseOptions);
  53498. var compile = ref$1.compile;
  53499. var compileToFunctions = ref$1.compileToFunctions;
  53500. /* */
  53501. // check whether current browser encodes a char inside attribute values
  53502. var div;
  53503. function getShouldDecode (href) {
  53504. div = div || document.createElement('div');
  53505. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  53506. return div.innerHTML.indexOf('&#10;') > 0
  53507. }
  53508. // #3663: IE encodes newlines inside attribute values while other browsers don't
  53509. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  53510. // #6828: chrome encodes content in a[href]
  53511. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  53512. /* */
  53513. var idToTemplate = cached(function (id) {
  53514. var el = query(id);
  53515. return el && el.innerHTML
  53516. });
  53517. var mount = Vue.prototype.$mount;
  53518. Vue.prototype.$mount = function (
  53519. el,
  53520. hydrating
  53521. ) {
  53522. el = el && query(el);
  53523. /* istanbul ignore if */
  53524. if (el === document.body || el === document.documentElement) {
  53525. warn(
  53526. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  53527. );
  53528. return this
  53529. }
  53530. var options = this.$options;
  53531. // resolve template/el and convert to render function
  53532. if (!options.render) {
  53533. var template = options.template;
  53534. if (template) {
  53535. if (typeof template === 'string') {
  53536. if (template.charAt(0) === '#') {
  53537. template = idToTemplate(template);
  53538. /* istanbul ignore if */
  53539. if (!template) {
  53540. warn(
  53541. ("Template element not found or is empty: " + (options.template)),
  53542. this
  53543. );
  53544. }
  53545. }
  53546. } else if (template.nodeType) {
  53547. template = template.innerHTML;
  53548. } else {
  53549. {
  53550. warn('invalid template option:' + template, this);
  53551. }
  53552. return this
  53553. }
  53554. } else if (el) {
  53555. template = getOuterHTML(el);
  53556. }
  53557. if (template) {
  53558. /* istanbul ignore if */
  53559. if (config.performance && mark) {
  53560. mark('compile');
  53561. }
  53562. var ref = compileToFunctions(template, {
  53563. outputSourceRange: "development" !== 'production',
  53564. shouldDecodeNewlines: shouldDecodeNewlines,
  53565. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  53566. delimiters: options.delimiters,
  53567. comments: options.comments
  53568. }, this);
  53569. var render = ref.render;
  53570. var staticRenderFns = ref.staticRenderFns;
  53571. options.render = render;
  53572. options.staticRenderFns = staticRenderFns;
  53573. /* istanbul ignore if */
  53574. if (config.performance && mark) {
  53575. mark('compile end');
  53576. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  53577. }
  53578. }
  53579. }
  53580. return mount.call(this, el, hydrating)
  53581. };
  53582. /**
  53583. * Get outerHTML of elements, taking care
  53584. * of SVG elements in IE as well.
  53585. */
  53586. function getOuterHTML (el) {
  53587. if (el.outerHTML) {
  53588. return el.outerHTML
  53589. } else {
  53590. var container = document.createElement('div');
  53591. container.appendChild(el.cloneNode(true));
  53592. return container.innerHTML
  53593. }
  53594. }
  53595. Vue.compile = compileToFunctions;
  53596. module.exports = Vue;
  53597. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../../timers-browserify/main.js */ "./node_modules/timers-browserify/main.js").setImmediate))
  53598. /***/ }),
  53599. /***/ "./node_modules/vue/dist/vue.common.js":
  53600. /*!*********************************************!*\
  53601. !*** ./node_modules/vue/dist/vue.common.js ***!
  53602. \*********************************************/
  53603. /*! no static exports found */
  53604. /***/ (function(module, exports, __webpack_require__) {
  53605. if (false) {} else {
  53606. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  53607. }
  53608. /***/ }),
  53609. /***/ "./node_modules/webpack/buildin/global.js":
  53610. /*!***********************************!*\
  53611. !*** (webpack)/buildin/global.js ***!
  53612. \***********************************/
  53613. /*! no static exports found */
  53614. /***/ (function(module, exports) {
  53615. var g;
  53616. // This works in non-strict mode
  53617. g = (function() {
  53618. return this;
  53619. })();
  53620. try {
  53621. // This works if eval is allowed (see CSP)
  53622. g = g || new Function("return this")();
  53623. } catch (e) {
  53624. // This works if the window reference is available
  53625. if (typeof window === "object") g = window;
  53626. }
  53627. // g can still be undefined, but nothing to do about it...
  53628. // We return undefined, instead of nothing here, so it's
  53629. // easier to handle this case. if(!global) { ...}
  53630. module.exports = g;
  53631. /***/ }),
  53632. /***/ "./node_modules/webpack/buildin/module.js":
  53633. /*!***********************************!*\
  53634. !*** (webpack)/buildin/module.js ***!
  53635. \***********************************/
  53636. /*! no static exports found */
  53637. /***/ (function(module, exports) {
  53638. module.exports = function(module) {
  53639. if (!module.webpackPolyfill) {
  53640. module.deprecate = function() {};
  53641. module.paths = [];
  53642. // module.parent = undefined by default
  53643. if (!module.children) module.children = [];
  53644. Object.defineProperty(module, "loaded", {
  53645. enumerable: true,
  53646. get: function() {
  53647. return module.l;
  53648. }
  53649. });
  53650. Object.defineProperty(module, "id", {
  53651. enumerable: true,
  53652. get: function() {
  53653. return module.i;
  53654. }
  53655. });
  53656. module.webpackPolyfill = 1;
  53657. }
  53658. return module;
  53659. };
  53660. /***/ }),
  53661. /***/ "./node_modules/yeast/index.js":
  53662. /*!*************************************!*\
  53663. !*** ./node_modules/yeast/index.js ***!
  53664. \*************************************/
  53665. /*! no static exports found */
  53666. /***/ (function(module, exports, __webpack_require__) {
  53667. "use strict";
  53668. var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')
  53669. , length = 64
  53670. , map = {}
  53671. , seed = 0
  53672. , i = 0
  53673. , prev;
  53674. /**
  53675. * Return a string representing the specified number.
  53676. *
  53677. * @param {Number} num The number to convert.
  53678. * @returns {String} The string representation of the number.
  53679. * @api public
  53680. */
  53681. function encode(num) {
  53682. var encoded = '';
  53683. do {
  53684. encoded = alphabet[num % length] + encoded;
  53685. num = Math.floor(num / length);
  53686. } while (num > 0);
  53687. return encoded;
  53688. }
  53689. /**
  53690. * Return the integer value specified by the given string.
  53691. *
  53692. * @param {String} str The string to convert.
  53693. * @returns {Number} The integer value represented by the string.
  53694. * @api public
  53695. */
  53696. function decode(str) {
  53697. var decoded = 0;
  53698. for (i = 0; i < str.length; i++) {
  53699. decoded = decoded * length + map[str.charAt(i)];
  53700. }
  53701. return decoded;
  53702. }
  53703. /**
  53704. * Yeast: A tiny growing id generator.
  53705. *
  53706. * @returns {String} A unique id.
  53707. * @api public
  53708. */
  53709. function yeast() {
  53710. var now = encode(+new Date());
  53711. if (now !== prev) return seed = 0, prev = now;
  53712. return now +'.'+ encode(seed++);
  53713. }
  53714. //
  53715. // Map each character to its index.
  53716. //
  53717. for (; i < length; i++) map[alphabet[i]] = i;
  53718. //
  53719. // Expose the `yeast`, `encode` and `decode` functions.
  53720. //
  53721. yeast.encode = encode;
  53722. yeast.decode = decode;
  53723. module.exports = yeast;
  53724. /***/ }),
  53725. /***/ "./resources/js/app.js":
  53726. /*!*****************************!*\
  53727. !*** ./resources/js/app.js ***!
  53728. \*****************************/
  53729. /*! no static exports found */
  53730. /***/ (function(module, exports, __webpack_require__) {
  53731. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  53732. __webpack_require__(/*! ./mounted */ "./resources/js/mounted.js");
  53733. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  53734. window.tempTip = __webpack_require__(/*! ./utilities/tempTip */ "./resources/js/utilities/tempTip.js");
  53735. window.getGetVal = __webpack_require__(/*! ./utilities/getGetVal */ "./resources/js/utilities/getGetVal.js");
  53736. window.scanner = __webpack_require__(/*! ./utilities/scanner */ "./resources/js/utilities/scanner.js");
  53737. window.datetimeRelating = __webpack_require__(/*! ./utilities/datetimeRelating */ "./resources/js/utilities/datetimeRelating.js");
  53738. /***/ }),
  53739. /***/ "./resources/js/bootstrap.js":
  53740. /*!***********************************!*\
  53741. !*** ./resources/js/bootstrap.js ***!
  53742. \***********************************/
  53743. /*! no exports provided */
  53744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53745. "use strict";
  53746. __webpack_require__.r(__webpack_exports__);
  53747. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  53748. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  53749. /**
  53750. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  53751. * for JavaScript based Bootstrap features such as modals and tabs. This
  53752. * code may be modified to fit the specific needs of your application.
  53753. */
  53754. try {
  53755. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  53756. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  53757. window.$.cookie = __webpack_require__(/*! js-cookie */ "./node_modules/js-cookie/src/js.cookie.js");
  53758. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  53759. } catch (e) {}
  53760. /**
  53761. * We'll load the axios HTTP library which allows us to easily issue requests
  53762. * to our Laravel back-end. This library automatically handles sending the
  53763. * CSRF token as a header based on the value of the "XSRF" token cookie.
  53764. */
  53765. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  53766. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  53767. /**
  53768. * Next we will register the CSRF Token as a common header with Axios so that
  53769. * all outgoing HTTP requests automatically have it attached. This is just
  53770. * a simple convenience so we don't have to attach every token manually.
  53771. */
  53772. var token = document.head.querySelector('meta[name="csrf-token"]');
  53773. if (token) {
  53774. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  53775. } else {
  53776. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  53777. }
  53778. /**
  53779. * Echo exposes an expressive API for subscribing to channels and listening
  53780. * for events that are broadcast by Laravel. Echo and event broadcasting
  53781. * allows your team to easily build robust real-time web applications.
  53782. */
  53783. //
  53784. // const client = require('pusher-js');
  53785. window.io = __webpack_require__(/*! socket.io-client */ "./node_modules/socket.io-client/lib/index.js");
  53786. window.initEcho = function () {
  53787. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  53788. broadcaster: 'socket.io',
  53789. host: window.location.hostname + ':6001' //broadcaster: 'pusher',
  53790. // key: process.env.MIX_PUSHER_APP_KEY,
  53791. // key: 'bo20alg-1',
  53792. // authEndpoint: '/custom/endpoint/auth',
  53793. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  53794. // encrypted: true,
  53795. // client:client
  53796. });
  53797. };
  53798. /***/ }),
  53799. /***/ "./resources/js/mounted.js":
  53800. /*!*********************************!*\
  53801. !*** ./resources/js/mounted.js ***!
  53802. \*********************************/
  53803. /*! no static exports found */
  53804. /***/ (function(module, exports) {
  53805. //解决input number类型上下滚动 禁用滚轮事件
  53806. setTimeout(function () {
  53807. for (var i = 0; i < $("input[type='number']").length; i++) {
  53808. $("input[type='number']")[i].setAttribute('onmousewheel', 'return false'); //禁止谷歌浏览器、Opera浏览器以及360浏览器等采用谷歌内核的浏览器
  53809. $("input[type='number']")[i].addEventListener('DOMMouseScroll', MouseWheel, false); //禁止Firefox浏览器
  53810. }
  53811. }, 100);
  53812. function MouseWheel(event) {
  53813. event = event || window.event;
  53814. event.preventDefault();
  53815. }
  53816. /***/ }),
  53817. /***/ "./resources/js/utilities/datetimeRelating.js":
  53818. /*!****************************************************!*\
  53819. !*** ./resources/js/utilities/datetimeRelating.js ***!
  53820. \****************************************************/
  53821. /*! no static exports found */
  53822. /***/ (function(module, exports) {
  53823. var datetime = {
  53824. verifyTime: function verifyTime(time) {
  53825. setTimeout(function () {
  53826. time.target.value = time.target.value.replace(':', ':');
  53827. time.target.value = time.target.value.replace(/[a-zA-Z]/, '');
  53828. time.target.value = time.target.value.replace(/^([\d]{1})([\s]{1})/, "$1:");
  53829. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})([\s]{1})/, "$1$2:");
  53830. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})/, "$1$2:$3");
  53831. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})(.*?)/, "$1$2$3$4");
  53832. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})([\d]{1})/, "$1$2:$3$4");
  53833. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1}):([\d]{1})([\d]{1})([\s\S]{1})/, "$1$2:$3$4");
  53834. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1}):([\D]{1,99})/, "$1$2:");
  53835. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})([\d]{1})\./, "$1:$2$3");
  53836. time.target.value = time.target.value.replace(/^([\d]{1})\.([\d]{1})([\d]{1})/, "$1:$2$3");
  53837. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{2})([\S\s]{1,99})/, "$1$2:$3");
  53838. time.target.value = time.target.value.replace(/^([\d]{1}):([\d]{2})([\S\s]{1,99})/, "$1:$2");
  53839. time.target.value = time.target.value.replace(/^([\d])/, "$1");
  53840. time.target.value = time.target.value.replace(/^([1])([\d]{1})/, "$1$2");
  53841. time.target.value = time.target.value.replace(/^([3-9])([\d]{1})/, "2$2");
  53842. time.target.value = time.target.value.replace(/^([2-9]{1})([4-9]{1})/, "$13");
  53843. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1}):([6-9]{1})/, "$1$2:5");
  53844. time.target.value = time.target.value.replace(/^([\d]{1})([\d]{1})$/, "$1$2:");
  53845. }, 10);
  53846. }
  53847. };
  53848. module.exports = datetime;
  53849. /***/ }),
  53850. /***/ "./resources/js/utilities/getGetVal.js":
  53851. /*!*********************************************!*\
  53852. !*** ./resources/js/utilities/getGetVal.js ***!
  53853. \*********************************************/
  53854. /*! no static exports found */
  53855. /***/ (function(module, exports) {
  53856. var get = function get(name) {
  53857. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  53858. var r = window.location.search.substr(1).match(reg);
  53859. if (r != null) {
  53860. return unescape(r[2]);
  53861. }
  53862. return null;
  53863. };
  53864. module.exports = get;
  53865. /***/ }),
  53866. /***/ "./resources/js/utilities/scanner.js":
  53867. /*!*******************************************!*\
  53868. !*** ./resources/js/utilities/scanner.js ***!
  53869. \*******************************************/
  53870. /*! no static exports found */
  53871. /***/ (function(module, exports) {
  53872. var scanner = {
  53873. /**
  53874. * 监听document的扫描枪活动,扫描后调用doFunc执行,doFunc(str)
  53875. * str是扫到的内容,在doFunc内执行
  53876. * @param doFunc
  53877. */
  53878. monitorScan: function monitorScan(doFunc) {
  53879. var tightInputInterval = 50;
  53880. var leastCodeLength = 3;
  53881. var lastPressedAt = 0;
  53882. var scannedStr = "";
  53883. $(document).on('keyup', function (e) {
  53884. var nowAtMilli = new Date().getTime();
  53885. var inputInterval = nowAtMilli - lastPressedAt;
  53886. if (inputInterval < tightInputInterval) {
  53887. if (e.key !== 'Enter') {
  53888. scannedStr += e.key;
  53889. } else {
  53890. if (scannedStr.length >= leastCodeLength) {
  53891. doFunc(scannedStr);
  53892. }
  53893. scannedStr = '';
  53894. }
  53895. } else {
  53896. if (e.key !== 'Enter') {
  53897. scannedStr = e.key;
  53898. } else {
  53899. scannedStr = '';
  53900. }
  53901. }
  53902. lastPressedAt = nowAtMilli;
  53903. });
  53904. },
  53905. monitorFocusingTarget: function monitorFocusingTarget(doFunc) {
  53906. $('input').on('focus', function (e) {
  53907. doFunc(e.target);
  53908. });
  53909. }
  53910. };
  53911. module.exports = scanner;
  53912. /***/ }),
  53913. /***/ "./resources/js/utilities/tempTip.js":
  53914. /*!*******************************************!*\
  53915. !*** ./resources/js/utilities/tempTip.js ***!
  53916. \*******************************************/
  53917. /*! no static exports found */
  53918. /***/ (function(module, exports) {
  53919. var tempTip = {
  53920. fadingDuration: 4500,
  53921. inputType: 'input',
  53922. index: 99,
  53923. setIndex: function setIndex(index) {
  53924. this.index = parseInt(index);
  53925. },
  53926. setDuration: function setDuration(milliSec) {
  53927. this.fadingDuration = parseInt(milliSec);
  53928. },
  53929. setInputType: function setInputType(type) {
  53930. this.inputType = type;
  53931. },
  53932. showSuccess: function showSuccess(text) {
  53933. var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h4 bg-success text-center'>" + text + "</div></div></div></div>");
  53934. tiper.animate({
  53935. opacity: '0'
  53936. }, this.fadingDuration, 'swing', function () {
  53937. tiper.remove();
  53938. });
  53939. $('body').append(tiper);
  53940. },
  53941. show: function show(text) {
  53942. var tiper = $("<div class='row' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + this.index + ";'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 bg-danger text-center'>" + text + "</div></div></div></div>");
  53943. tiper.animate({
  53944. opacity: '0'
  53945. }, this.fadingDuration, 'swing', function () {
  53946. tiper.remove();
  53947. });
  53948. $('body').append(tiper);
  53949. },
  53950. okWindow: function okWindow(text, okText) {
  53951. var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
  53952. if (typeof okText == 'undefined') okText = '确定';
  53953. var tiper = $("<div class='row' style='opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body h2 text-center'>" + text + "<p><button class='btn btn-success btn-lg okWindow'>" + okText + "</button></p><div>" + "</div></div></div>");
  53954. tiper.find('.okWindow').on('click', function () {
  53955. tiper.off('click');
  53956. tiper.remove();
  53957. bg.remove();
  53958. });
  53959. $('html').css('height', '100%').append(bg);
  53960. $('body').append(tiper);
  53961. },
  53962. waitingTip: function waitingTip(text) {
  53963. var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#fff;' class='tipperBg'></div>");
  53964. var tipper = $("<div class='row tipper' style='color:white;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + ";'>" + "<div class='col-8 offset-2'><div class='card-body h5 bg-dark text-center' style='border-radius: 50px'>" + text + "</div></div></div>");
  53965. tipper.animate({
  53966. opacity: '0'
  53967. }, this.fadingDuration, 'swing', function () {
  53968. tipper.remove();
  53969. bg.remove();
  53970. });
  53971. $('html').css('height', '100%').append(bg);
  53972. $('body').append(tipper);
  53973. },
  53974. cancelWaitingTip: function cancelWaitingTip() {
  53975. var bg = $(".tipperBg");
  53976. var tipper = $(".tipper");
  53977. tipper.remove();
  53978. bg.remove();
  53979. },
  53980. confirm: function confirm(text, yesFunc, noFunc) {
  53981. var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
  53982. var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + (this.index + 1) + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h4'>" + text + "</div><div class='card-text'><button class='btn btn-dark btn-lg ok'>确定</button>" + "<button class='btn btn-success btn-lg cancel ml-4'>取消</button></div>" + "</div></div></div></div>");
  53983. var $ok = tiper.find('.ok');
  53984. var $cancel = tiper.find('.cancel');
  53985. $ok.on('click', function () {
  53986. $ok.off('click');
  53987. $cancel.off('click');
  53988. tiper.remove();
  53989. bg.remove();
  53990. yesFunc();
  53991. });
  53992. $cancel.on('click', function () {
  53993. $ok.off('click');
  53994. $cancel.off('click');
  53995. tiper.remove();
  53996. bg.remove();
  53997. if (typeof noFunc != 'undefined') noFunc();
  53998. });
  53999. $('html').css('height', '100%').append(bg);
  54000. $('body').append(tiper);
  54001. },
  54002. inputVal: function inputVal(tipText, resultFunc) {
  54003. var bg = $("<div style='opacity:0.4;position:fixed;top:0;width:100%;height:100%;z-index:" + this.index + ";background-color:#000;'></div>");
  54004. var tiper = $("<div class='row' style='color:#000;opacity:0.9;position:fixed;top:40%;transform:translateY(-50%);width:100%;z-index:" + this.index + "'>" + "<div class='col-8 offset-2'><div class='card'><div class='card-body'><div class='card-title h5'>" + tipText + "</div><div><input type='" + this.inputType + "' class='input form-control mb-3'/></div>" + "<div class='card-text'><button class='btn btn-outline-success ok'>确定</button></div>" + "</div></div></div></div>");
  54005. var $ok = tiper.find('.ok');
  54006. var $input = tiper.find('.input');
  54007. $ok.on('click', function () {
  54008. $ok.off('click');
  54009. tiper.remove();
  54010. bg.remove();
  54011. resultFunc($input.val());
  54012. });
  54013. $('html').css('height', '100%').append(bg);
  54014. $('body').append(tiper);
  54015. $input.focus();
  54016. }
  54017. };
  54018. module.exports = tempTip;
  54019. /***/ }),
  54020. /***/ "./resources/sass/app.scss":
  54021. /*!*********************************!*\
  54022. !*** ./resources/sass/app.scss ***!
  54023. \*********************************/
  54024. /*! no static exports found */
  54025. /***/ (function(module, exports) {
  54026. // removed by extract-text-webpack-plugin
  54027. /***/ }),
  54028. /***/ 0:
  54029. /*!*************************************************************!*\
  54030. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  54031. \*************************************************************/
  54032. /*! no static exports found */
  54033. /***/ (function(module, exports, __webpack_require__) {
  54034. __webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\js\app.js */"./resources/js/app.js");
  54035. module.exports = __webpack_require__(/*! D:\phpstudy_pro\WWW\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
  54036. /***/ }),
  54037. /***/ 1:
  54038. /*!********************!*\
  54039. !*** ws (ignored) ***!
  54040. \********************/
  54041. /*! no static exports found */
  54042. /***/ (function(module, exports) {
  54043. /* (ignored) */
  54044. /***/ })
  54045. /******/ });