app.js 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  1574. /*!***************************************************************************************************************************************************************************!*\
  1575. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  1576. \***************************************************************************************************************************************************************************/
  1577. /*! exports provided: default */
  1578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1579. "use strict";
  1580. __webpack_require__.r(__webpack_exports__);
  1581. //
  1582. //
  1583. //
  1584. //
  1585. //
  1586. //
  1587. //
  1588. //
  1589. //
  1590. //
  1591. //
  1592. //
  1593. //
  1594. //
  1595. //
  1596. //
  1597. /* harmony default export */ __webpack_exports__["default"] = ({
  1598. mounted: function mounted() {
  1599. console.log('Component mounted.');
  1600. }
  1601. });
  1602. /***/ }),
  1603. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=script&lang=js&":
  1604. /*!*******************************************************************************************************************************************************************!*\
  1605. !*** ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/probdesc.vue?vue&type=script&lang=js& ***!
  1606. \*******************************************************************************************************************************************************************/
  1607. /*! exports provided: default */
  1608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1609. "use strict";
  1610. __webpack_require__.r(__webpack_exports__);
  1611. //
  1612. //
  1613. //
  1614. //
  1615. //
  1616. //
  1617. /* harmony default export */ __webpack_exports__["default"] = ({
  1618. data: function data() {
  1619. return {
  1620. probdesc: "",
  1621. suggested: ""
  1622. };
  1623. },
  1624. mounted: function mounted() {
  1625. var _this = this;
  1626. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1627. _this.probdesc = e.probdesc;
  1628. _this.suggested = e.suggested;
  1629. console.log('Received Websocket Update');
  1630. });
  1631. }
  1632. });
  1633. /***/ }),
  1634. /***/ "./node_modules/base64-js/index.js":
  1635. /*!*****************************************!*\
  1636. !*** ./node_modules/base64-js/index.js ***!
  1637. \*****************************************/
  1638. /*! no static exports found */
  1639. /***/ (function(module, exports, __webpack_require__) {
  1640. "use strict";
  1641. exports.byteLength = byteLength
  1642. exports.toByteArray = toByteArray
  1643. exports.fromByteArray = fromByteArray
  1644. var lookup = []
  1645. var revLookup = []
  1646. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1647. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1648. for (var i = 0, len = code.length; i < len; ++i) {
  1649. lookup[i] = code[i]
  1650. revLookup[code.charCodeAt(i)] = i
  1651. }
  1652. // Support decoding URL-safe base64 strings, as Node.js does.
  1653. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1654. revLookup['-'.charCodeAt(0)] = 62
  1655. revLookup['_'.charCodeAt(0)] = 63
  1656. function getLens (b64) {
  1657. var len = b64.length
  1658. if (len % 4 > 0) {
  1659. throw new Error('Invalid string. Length must be a multiple of 4')
  1660. }
  1661. // Trim off extra bytes after placeholder bytes are found
  1662. // See: https://github.com/beatgammit/base64-js/issues/42
  1663. var validLen = b64.indexOf('=')
  1664. if (validLen === -1) validLen = len
  1665. var placeHoldersLen = validLen === len
  1666. ? 0
  1667. : 4 - (validLen % 4)
  1668. return [validLen, placeHoldersLen]
  1669. }
  1670. // base64 is 4/3 + up to two characters of the original data
  1671. function byteLength (b64) {
  1672. var lens = getLens(b64)
  1673. var validLen = lens[0]
  1674. var placeHoldersLen = lens[1]
  1675. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1676. }
  1677. function _byteLength (b64, validLen, placeHoldersLen) {
  1678. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1679. }
  1680. function toByteArray (b64) {
  1681. var tmp
  1682. var lens = getLens(b64)
  1683. var validLen = lens[0]
  1684. var placeHoldersLen = lens[1]
  1685. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1686. var curByte = 0
  1687. // if there are placeholders, only get up to the last complete 4 chars
  1688. var len = placeHoldersLen > 0
  1689. ? validLen - 4
  1690. : validLen
  1691. var i
  1692. for (i = 0; i < len; i += 4) {
  1693. tmp =
  1694. (revLookup[b64.charCodeAt(i)] << 18) |
  1695. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1696. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1697. revLookup[b64.charCodeAt(i + 3)]
  1698. arr[curByte++] = (tmp >> 16) & 0xFF
  1699. arr[curByte++] = (tmp >> 8) & 0xFF
  1700. arr[curByte++] = tmp & 0xFF
  1701. }
  1702. if (placeHoldersLen === 2) {
  1703. tmp =
  1704. (revLookup[b64.charCodeAt(i)] << 2) |
  1705. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1706. arr[curByte++] = tmp & 0xFF
  1707. }
  1708. if (placeHoldersLen === 1) {
  1709. tmp =
  1710. (revLookup[b64.charCodeAt(i)] << 10) |
  1711. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1712. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1713. arr[curByte++] = (tmp >> 8) & 0xFF
  1714. arr[curByte++] = tmp & 0xFF
  1715. }
  1716. return arr
  1717. }
  1718. function tripletToBase64 (num) {
  1719. return lookup[num >> 18 & 0x3F] +
  1720. lookup[num >> 12 & 0x3F] +
  1721. lookup[num >> 6 & 0x3F] +
  1722. lookup[num & 0x3F]
  1723. }
  1724. function encodeChunk (uint8, start, end) {
  1725. var tmp
  1726. var output = []
  1727. for (var i = start; i < end; i += 3) {
  1728. tmp =
  1729. ((uint8[i] << 16) & 0xFF0000) +
  1730. ((uint8[i + 1] << 8) & 0xFF00) +
  1731. (uint8[i + 2] & 0xFF)
  1732. output.push(tripletToBase64(tmp))
  1733. }
  1734. return output.join('')
  1735. }
  1736. function fromByteArray (uint8) {
  1737. var tmp
  1738. var len = uint8.length
  1739. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1740. var parts = []
  1741. var maxChunkLength = 16383 // must be multiple of 3
  1742. // go through the array every three bytes, we'll deal with trailing stuff later
  1743. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1744. parts.push(encodeChunk(
  1745. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1746. ))
  1747. }
  1748. // pad the end with zeros, but make sure to not forget the extra bytes
  1749. if (extraBytes === 1) {
  1750. tmp = uint8[len - 1]
  1751. parts.push(
  1752. lookup[tmp >> 2] +
  1753. lookup[(tmp << 4) & 0x3F] +
  1754. '=='
  1755. )
  1756. } else if (extraBytes === 2) {
  1757. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1758. parts.push(
  1759. lookup[tmp >> 10] +
  1760. lookup[(tmp >> 4) & 0x3F] +
  1761. lookup[(tmp << 2) & 0x3F] +
  1762. '='
  1763. )
  1764. }
  1765. return parts.join('')
  1766. }
  1767. /***/ }),
  1768. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1769. /*!*****************************************************!*\
  1770. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1771. \*****************************************************/
  1772. /*! no static exports found */
  1773. /***/ (function(module, exports, __webpack_require__) {
  1774. /*!
  1775. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1776. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1777. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1778. */
  1779. (function (global, factory) {
  1780. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1781. undefined;
  1782. }(this, (function (exports, $, Popper) { 'use strict';
  1783. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1784. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1785. function _defineProperties(target, props) {
  1786. for (var i = 0; i < props.length; i++) {
  1787. var descriptor = props[i];
  1788. descriptor.enumerable = descriptor.enumerable || false;
  1789. descriptor.configurable = true;
  1790. if ("value" in descriptor) descriptor.writable = true;
  1791. Object.defineProperty(target, descriptor.key, descriptor);
  1792. }
  1793. }
  1794. function _createClass(Constructor, protoProps, staticProps) {
  1795. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1796. if (staticProps) _defineProperties(Constructor, staticProps);
  1797. return Constructor;
  1798. }
  1799. function _defineProperty(obj, key, value) {
  1800. if (key in obj) {
  1801. Object.defineProperty(obj, key, {
  1802. value: value,
  1803. enumerable: true,
  1804. configurable: true,
  1805. writable: true
  1806. });
  1807. } else {
  1808. obj[key] = value;
  1809. }
  1810. return obj;
  1811. }
  1812. function ownKeys(object, enumerableOnly) {
  1813. var keys = Object.keys(object);
  1814. if (Object.getOwnPropertySymbols) {
  1815. var symbols = Object.getOwnPropertySymbols(object);
  1816. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1817. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1818. });
  1819. keys.push.apply(keys, symbols);
  1820. }
  1821. return keys;
  1822. }
  1823. function _objectSpread2(target) {
  1824. for (var i = 1; i < arguments.length; i++) {
  1825. var source = arguments[i] != null ? arguments[i] : {};
  1826. if (i % 2) {
  1827. ownKeys(Object(source), true).forEach(function (key) {
  1828. _defineProperty(target, key, source[key]);
  1829. });
  1830. } else if (Object.getOwnPropertyDescriptors) {
  1831. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1832. } else {
  1833. ownKeys(Object(source)).forEach(function (key) {
  1834. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1835. });
  1836. }
  1837. }
  1838. return target;
  1839. }
  1840. function _inheritsLoose(subClass, superClass) {
  1841. subClass.prototype = Object.create(superClass.prototype);
  1842. subClass.prototype.constructor = subClass;
  1843. subClass.__proto__ = superClass;
  1844. }
  1845. /**
  1846. * --------------------------------------------------------------------------
  1847. * Bootstrap (v4.4.1): util.js
  1848. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1849. * --------------------------------------------------------------------------
  1850. */
  1851. /**
  1852. * ------------------------------------------------------------------------
  1853. * Private TransitionEnd Helpers
  1854. * ------------------------------------------------------------------------
  1855. */
  1856. var TRANSITION_END = 'transitionend';
  1857. var MAX_UID = 1000000;
  1858. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1859. function toType(obj) {
  1860. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1861. }
  1862. function getSpecialTransitionEndEvent() {
  1863. return {
  1864. bindType: TRANSITION_END,
  1865. delegateType: TRANSITION_END,
  1866. handle: function handle(event) {
  1867. if ($(event.target).is(this)) {
  1868. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1869. }
  1870. return undefined; // eslint-disable-line no-undefined
  1871. }
  1872. };
  1873. }
  1874. function transitionEndEmulator(duration) {
  1875. var _this = this;
  1876. var called = false;
  1877. $(this).one(Util.TRANSITION_END, function () {
  1878. called = true;
  1879. });
  1880. setTimeout(function () {
  1881. if (!called) {
  1882. Util.triggerTransitionEnd(_this);
  1883. }
  1884. }, duration);
  1885. return this;
  1886. }
  1887. function setTransitionEndSupport() {
  1888. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1889. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1890. }
  1891. /**
  1892. * --------------------------------------------------------------------------
  1893. * Public Util Api
  1894. * --------------------------------------------------------------------------
  1895. */
  1896. var Util = {
  1897. TRANSITION_END: 'bsTransitionEnd',
  1898. getUID: function getUID(prefix) {
  1899. do {
  1900. // eslint-disable-next-line no-bitwise
  1901. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1902. } while (document.getElementById(prefix));
  1903. return prefix;
  1904. },
  1905. getSelectorFromElement: function getSelectorFromElement(element) {
  1906. var selector = element.getAttribute('data-target');
  1907. if (!selector || selector === '#') {
  1908. var hrefAttr = element.getAttribute('href');
  1909. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1910. }
  1911. try {
  1912. return document.querySelector(selector) ? selector : null;
  1913. } catch (err) {
  1914. return null;
  1915. }
  1916. },
  1917. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1918. if (!element) {
  1919. return 0;
  1920. } // Get transition-duration of the element
  1921. var transitionDuration = $(element).css('transition-duration');
  1922. var transitionDelay = $(element).css('transition-delay');
  1923. var floatTransitionDuration = parseFloat(transitionDuration);
  1924. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1925. if (!floatTransitionDuration && !floatTransitionDelay) {
  1926. return 0;
  1927. } // If multiple durations are defined, take the first
  1928. transitionDuration = transitionDuration.split(',')[0];
  1929. transitionDelay = transitionDelay.split(',')[0];
  1930. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1931. },
  1932. reflow: function reflow(element) {
  1933. return element.offsetHeight;
  1934. },
  1935. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1936. $(element).trigger(TRANSITION_END);
  1937. },
  1938. // TODO: Remove in v5
  1939. supportsTransitionEnd: function supportsTransitionEnd() {
  1940. return Boolean(TRANSITION_END);
  1941. },
  1942. isElement: function isElement(obj) {
  1943. return (obj[0] || obj).nodeType;
  1944. },
  1945. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1946. for (var property in configTypes) {
  1947. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1948. var expectedTypes = configTypes[property];
  1949. var value = config[property];
  1950. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1951. if (!new RegExp(expectedTypes).test(valueType)) {
  1952. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1953. }
  1954. }
  1955. }
  1956. },
  1957. findShadowRoot: function findShadowRoot(element) {
  1958. if (!document.documentElement.attachShadow) {
  1959. return null;
  1960. } // Can find the shadow root otherwise it'll return the document
  1961. if (typeof element.getRootNode === 'function') {
  1962. var root = element.getRootNode();
  1963. return root instanceof ShadowRoot ? root : null;
  1964. }
  1965. if (element instanceof ShadowRoot) {
  1966. return element;
  1967. } // when we don't find a shadow root
  1968. if (!element.parentNode) {
  1969. return null;
  1970. }
  1971. return Util.findShadowRoot(element.parentNode);
  1972. },
  1973. jQueryDetection: function jQueryDetection() {
  1974. if (typeof $ === 'undefined') {
  1975. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  1976. }
  1977. var version = $.fn.jquery.split(' ')[0].split('.');
  1978. var minMajor = 1;
  1979. var ltMajor = 2;
  1980. var minMinor = 9;
  1981. var minPatch = 1;
  1982. var maxMajor = 4;
  1983. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  1984. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  1985. }
  1986. }
  1987. };
  1988. Util.jQueryDetection();
  1989. setTransitionEndSupport();
  1990. /**
  1991. * ------------------------------------------------------------------------
  1992. * Constants
  1993. * ------------------------------------------------------------------------
  1994. */
  1995. var NAME = 'alert';
  1996. var VERSION = '4.4.1';
  1997. var DATA_KEY = 'bs.alert';
  1998. var EVENT_KEY = "." + DATA_KEY;
  1999. var DATA_API_KEY = '.data-api';
  2000. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2001. var Selector = {
  2002. DISMISS: '[data-dismiss="alert"]'
  2003. };
  2004. var Event = {
  2005. CLOSE: "close" + EVENT_KEY,
  2006. CLOSED: "closed" + EVENT_KEY,
  2007. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2008. };
  2009. var ClassName = {
  2010. ALERT: 'alert',
  2011. FADE: 'fade',
  2012. SHOW: 'show'
  2013. };
  2014. /**
  2015. * ------------------------------------------------------------------------
  2016. * Class Definition
  2017. * ------------------------------------------------------------------------
  2018. */
  2019. var Alert =
  2020. /*#__PURE__*/
  2021. function () {
  2022. function Alert(element) {
  2023. this._element = element;
  2024. } // Getters
  2025. var _proto = Alert.prototype;
  2026. // Public
  2027. _proto.close = function close(element) {
  2028. var rootElement = this._element;
  2029. if (element) {
  2030. rootElement = this._getRootElement(element);
  2031. }
  2032. var customEvent = this._triggerCloseEvent(rootElement);
  2033. if (customEvent.isDefaultPrevented()) {
  2034. return;
  2035. }
  2036. this._removeElement(rootElement);
  2037. };
  2038. _proto.dispose = function dispose() {
  2039. $.removeData(this._element, DATA_KEY);
  2040. this._element = null;
  2041. } // Private
  2042. ;
  2043. _proto._getRootElement = function _getRootElement(element) {
  2044. var selector = Util.getSelectorFromElement(element);
  2045. var parent = false;
  2046. if (selector) {
  2047. parent = document.querySelector(selector);
  2048. }
  2049. if (!parent) {
  2050. parent = $(element).closest("." + ClassName.ALERT)[0];
  2051. }
  2052. return parent;
  2053. };
  2054. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2055. var closeEvent = $.Event(Event.CLOSE);
  2056. $(element).trigger(closeEvent);
  2057. return closeEvent;
  2058. };
  2059. _proto._removeElement = function _removeElement(element) {
  2060. var _this = this;
  2061. $(element).removeClass(ClassName.SHOW);
  2062. if (!$(element).hasClass(ClassName.FADE)) {
  2063. this._destroyElement(element);
  2064. return;
  2065. }
  2066. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2067. $(element).one(Util.TRANSITION_END, function (event) {
  2068. return _this._destroyElement(element, event);
  2069. }).emulateTransitionEnd(transitionDuration);
  2070. };
  2071. _proto._destroyElement = function _destroyElement(element) {
  2072. $(element).detach().trigger(Event.CLOSED).remove();
  2073. } // Static
  2074. ;
  2075. Alert._jQueryInterface = function _jQueryInterface(config) {
  2076. return this.each(function () {
  2077. var $element = $(this);
  2078. var data = $element.data(DATA_KEY);
  2079. if (!data) {
  2080. data = new Alert(this);
  2081. $element.data(DATA_KEY, data);
  2082. }
  2083. if (config === 'close') {
  2084. data[config](this);
  2085. }
  2086. });
  2087. };
  2088. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2089. return function (event) {
  2090. if (event) {
  2091. event.preventDefault();
  2092. }
  2093. alertInstance.close(this);
  2094. };
  2095. };
  2096. _createClass(Alert, null, [{
  2097. key: "VERSION",
  2098. get: function get() {
  2099. return VERSION;
  2100. }
  2101. }]);
  2102. return Alert;
  2103. }();
  2104. /**
  2105. * ------------------------------------------------------------------------
  2106. * Data Api implementation
  2107. * ------------------------------------------------------------------------
  2108. */
  2109. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2110. /**
  2111. * ------------------------------------------------------------------------
  2112. * jQuery
  2113. * ------------------------------------------------------------------------
  2114. */
  2115. $.fn[NAME] = Alert._jQueryInterface;
  2116. $.fn[NAME].Constructor = Alert;
  2117. $.fn[NAME].noConflict = function () {
  2118. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2119. return Alert._jQueryInterface;
  2120. };
  2121. /**
  2122. * ------------------------------------------------------------------------
  2123. * Constants
  2124. * ------------------------------------------------------------------------
  2125. */
  2126. var NAME$1 = 'button';
  2127. var VERSION$1 = '4.4.1';
  2128. var DATA_KEY$1 = 'bs.button';
  2129. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2130. var DATA_API_KEY$1 = '.data-api';
  2131. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2132. var ClassName$1 = {
  2133. ACTIVE: 'active',
  2134. BUTTON: 'btn',
  2135. FOCUS: 'focus'
  2136. };
  2137. var Selector$1 = {
  2138. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2139. DATA_TOGGLES: '[data-toggle="buttons"]',
  2140. DATA_TOGGLE: '[data-toggle="button"]',
  2141. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2142. INPUT: 'input:not([type="hidden"])',
  2143. ACTIVE: '.active',
  2144. BUTTON: '.btn'
  2145. };
  2146. var Event$1 = {
  2147. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2148. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2149. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2150. };
  2151. /**
  2152. * ------------------------------------------------------------------------
  2153. * Class Definition
  2154. * ------------------------------------------------------------------------
  2155. */
  2156. var Button =
  2157. /*#__PURE__*/
  2158. function () {
  2159. function Button(element) {
  2160. this._element = element;
  2161. } // Getters
  2162. var _proto = Button.prototype;
  2163. // Public
  2164. _proto.toggle = function toggle() {
  2165. var triggerChangeEvent = true;
  2166. var addAriaPressed = true;
  2167. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2168. if (rootElement) {
  2169. var input = this._element.querySelector(Selector$1.INPUT);
  2170. if (input) {
  2171. if (input.type === 'radio') {
  2172. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2173. triggerChangeEvent = false;
  2174. } else {
  2175. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2176. if (activeElement) {
  2177. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2178. }
  2179. }
  2180. } else if (input.type === 'checkbox') {
  2181. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2182. triggerChangeEvent = false;
  2183. }
  2184. } else {
  2185. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2186. triggerChangeEvent = false;
  2187. }
  2188. if (triggerChangeEvent) {
  2189. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2190. $(input).trigger('change');
  2191. }
  2192. input.focus();
  2193. addAriaPressed = false;
  2194. }
  2195. }
  2196. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2197. if (addAriaPressed) {
  2198. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2199. }
  2200. if (triggerChangeEvent) {
  2201. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2202. }
  2203. }
  2204. };
  2205. _proto.dispose = function dispose() {
  2206. $.removeData(this._element, DATA_KEY$1);
  2207. this._element = null;
  2208. } // Static
  2209. ;
  2210. Button._jQueryInterface = function _jQueryInterface(config) {
  2211. return this.each(function () {
  2212. var data = $(this).data(DATA_KEY$1);
  2213. if (!data) {
  2214. data = new Button(this);
  2215. $(this).data(DATA_KEY$1, data);
  2216. }
  2217. if (config === 'toggle') {
  2218. data[config]();
  2219. }
  2220. });
  2221. };
  2222. _createClass(Button, null, [{
  2223. key: "VERSION",
  2224. get: function get() {
  2225. return VERSION$1;
  2226. }
  2227. }]);
  2228. return Button;
  2229. }();
  2230. /**
  2231. * ------------------------------------------------------------------------
  2232. * Data Api implementation
  2233. * ------------------------------------------------------------------------
  2234. */
  2235. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2236. var button = event.target;
  2237. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2238. button = $(button).closest(Selector$1.BUTTON)[0];
  2239. }
  2240. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2241. event.preventDefault(); // work around Firefox bug #1540995
  2242. } else {
  2243. var inputBtn = button.querySelector(Selector$1.INPUT);
  2244. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2245. event.preventDefault(); // work around Firefox bug #1540995
  2246. return;
  2247. }
  2248. Button._jQueryInterface.call($(button), 'toggle');
  2249. }
  2250. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2251. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2252. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2253. });
  2254. $(window).on(Event$1.LOAD_DATA_API, function () {
  2255. // ensure correct active class is set to match the controls' actual values/states
  2256. // find all checkboxes/readio buttons inside data-toggle groups
  2257. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2258. for (var i = 0, len = buttons.length; i < len; i++) {
  2259. var button = buttons[i];
  2260. var input = button.querySelector(Selector$1.INPUT);
  2261. if (input.checked || input.hasAttribute('checked')) {
  2262. button.classList.add(ClassName$1.ACTIVE);
  2263. } else {
  2264. button.classList.remove(ClassName$1.ACTIVE);
  2265. }
  2266. } // find all button toggles
  2267. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2268. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2269. var _button = buttons[_i];
  2270. if (_button.getAttribute('aria-pressed') === 'true') {
  2271. _button.classList.add(ClassName$1.ACTIVE);
  2272. } else {
  2273. _button.classList.remove(ClassName$1.ACTIVE);
  2274. }
  2275. }
  2276. });
  2277. /**
  2278. * ------------------------------------------------------------------------
  2279. * jQuery
  2280. * ------------------------------------------------------------------------
  2281. */
  2282. $.fn[NAME$1] = Button._jQueryInterface;
  2283. $.fn[NAME$1].Constructor = Button;
  2284. $.fn[NAME$1].noConflict = function () {
  2285. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2286. return Button._jQueryInterface;
  2287. };
  2288. /**
  2289. * ------------------------------------------------------------------------
  2290. * Constants
  2291. * ------------------------------------------------------------------------
  2292. */
  2293. var NAME$2 = 'carousel';
  2294. var VERSION$2 = '4.4.1';
  2295. var DATA_KEY$2 = 'bs.carousel';
  2296. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2297. var DATA_API_KEY$2 = '.data-api';
  2298. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2299. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2300. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2301. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2302. var SWIPE_THRESHOLD = 40;
  2303. var Default = {
  2304. interval: 5000,
  2305. keyboard: true,
  2306. slide: false,
  2307. pause: 'hover',
  2308. wrap: true,
  2309. touch: true
  2310. };
  2311. var DefaultType = {
  2312. interval: '(number|boolean)',
  2313. keyboard: 'boolean',
  2314. slide: '(boolean|string)',
  2315. pause: '(string|boolean)',
  2316. wrap: 'boolean',
  2317. touch: 'boolean'
  2318. };
  2319. var Direction = {
  2320. NEXT: 'next',
  2321. PREV: 'prev',
  2322. LEFT: 'left',
  2323. RIGHT: 'right'
  2324. };
  2325. var Event$2 = {
  2326. SLIDE: "slide" + EVENT_KEY$2,
  2327. SLID: "slid" + EVENT_KEY$2,
  2328. KEYDOWN: "keydown" + EVENT_KEY$2,
  2329. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2330. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2331. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2332. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2333. TOUCHEND: "touchend" + EVENT_KEY$2,
  2334. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2335. POINTERUP: "pointerup" + EVENT_KEY$2,
  2336. DRAG_START: "dragstart" + EVENT_KEY$2,
  2337. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2338. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2339. };
  2340. var ClassName$2 = {
  2341. CAROUSEL: 'carousel',
  2342. ACTIVE: 'active',
  2343. SLIDE: 'slide',
  2344. RIGHT: 'carousel-item-right',
  2345. LEFT: 'carousel-item-left',
  2346. NEXT: 'carousel-item-next',
  2347. PREV: 'carousel-item-prev',
  2348. ITEM: 'carousel-item',
  2349. POINTER_EVENT: 'pointer-event'
  2350. };
  2351. var Selector$2 = {
  2352. ACTIVE: '.active',
  2353. ACTIVE_ITEM: '.active.carousel-item',
  2354. ITEM: '.carousel-item',
  2355. ITEM_IMG: '.carousel-item img',
  2356. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2357. INDICATORS: '.carousel-indicators',
  2358. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2359. DATA_RIDE: '[data-ride="carousel"]'
  2360. };
  2361. var PointerType = {
  2362. TOUCH: 'touch',
  2363. PEN: 'pen'
  2364. };
  2365. /**
  2366. * ------------------------------------------------------------------------
  2367. * Class Definition
  2368. * ------------------------------------------------------------------------
  2369. */
  2370. var Carousel =
  2371. /*#__PURE__*/
  2372. function () {
  2373. function Carousel(element, config) {
  2374. this._items = null;
  2375. this._interval = null;
  2376. this._activeElement = null;
  2377. this._isPaused = false;
  2378. this._isSliding = false;
  2379. this.touchTimeout = null;
  2380. this.touchStartX = 0;
  2381. this.touchDeltaX = 0;
  2382. this._config = this._getConfig(config);
  2383. this._element = element;
  2384. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2385. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2386. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2387. this._addEventListeners();
  2388. } // Getters
  2389. var _proto = Carousel.prototype;
  2390. // Public
  2391. _proto.next = function next() {
  2392. if (!this._isSliding) {
  2393. this._slide(Direction.NEXT);
  2394. }
  2395. };
  2396. _proto.nextWhenVisible = function nextWhenVisible() {
  2397. // Don't call next when the page isn't visible
  2398. // or the carousel or its parent isn't visible
  2399. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2400. this.next();
  2401. }
  2402. };
  2403. _proto.prev = function prev() {
  2404. if (!this._isSliding) {
  2405. this._slide(Direction.PREV);
  2406. }
  2407. };
  2408. _proto.pause = function pause(event) {
  2409. if (!event) {
  2410. this._isPaused = true;
  2411. }
  2412. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2413. Util.triggerTransitionEnd(this._element);
  2414. this.cycle(true);
  2415. }
  2416. clearInterval(this._interval);
  2417. this._interval = null;
  2418. };
  2419. _proto.cycle = function cycle(event) {
  2420. if (!event) {
  2421. this._isPaused = false;
  2422. }
  2423. if (this._interval) {
  2424. clearInterval(this._interval);
  2425. this._interval = null;
  2426. }
  2427. if (this._config.interval && !this._isPaused) {
  2428. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2429. }
  2430. };
  2431. _proto.to = function to(index) {
  2432. var _this = this;
  2433. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2434. var activeIndex = this._getItemIndex(this._activeElement);
  2435. if (index > this._items.length - 1 || index < 0) {
  2436. return;
  2437. }
  2438. if (this._isSliding) {
  2439. $(this._element).one(Event$2.SLID, function () {
  2440. return _this.to(index);
  2441. });
  2442. return;
  2443. }
  2444. if (activeIndex === index) {
  2445. this.pause();
  2446. this.cycle();
  2447. return;
  2448. }
  2449. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2450. this._slide(direction, this._items[index]);
  2451. };
  2452. _proto.dispose = function dispose() {
  2453. $(this._element).off(EVENT_KEY$2);
  2454. $.removeData(this._element, DATA_KEY$2);
  2455. this._items = null;
  2456. this._config = null;
  2457. this._element = null;
  2458. this._interval = null;
  2459. this._isPaused = null;
  2460. this._isSliding = null;
  2461. this._activeElement = null;
  2462. this._indicatorsElement = null;
  2463. } // Private
  2464. ;
  2465. _proto._getConfig = function _getConfig(config) {
  2466. config = _objectSpread2({}, Default, {}, config);
  2467. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2468. return config;
  2469. };
  2470. _proto._handleSwipe = function _handleSwipe() {
  2471. var absDeltax = Math.abs(this.touchDeltaX);
  2472. if (absDeltax <= SWIPE_THRESHOLD) {
  2473. return;
  2474. }
  2475. var direction = absDeltax / this.touchDeltaX;
  2476. this.touchDeltaX = 0; // swipe left
  2477. if (direction > 0) {
  2478. this.prev();
  2479. } // swipe right
  2480. if (direction < 0) {
  2481. this.next();
  2482. }
  2483. };
  2484. _proto._addEventListeners = function _addEventListeners() {
  2485. var _this2 = this;
  2486. if (this._config.keyboard) {
  2487. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2488. return _this2._keydown(event);
  2489. });
  2490. }
  2491. if (this._config.pause === 'hover') {
  2492. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2493. return _this2.pause(event);
  2494. }).on(Event$2.MOUSELEAVE, function (event) {
  2495. return _this2.cycle(event);
  2496. });
  2497. }
  2498. if (this._config.touch) {
  2499. this._addTouchEventListeners();
  2500. }
  2501. };
  2502. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2503. var _this3 = this;
  2504. if (!this._touchSupported) {
  2505. return;
  2506. }
  2507. var start = function start(event) {
  2508. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2509. _this3.touchStartX = event.originalEvent.clientX;
  2510. } else if (!_this3._pointerEvent) {
  2511. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2512. }
  2513. };
  2514. var move = function move(event) {
  2515. // ensure swiping with one touch and not pinching
  2516. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2517. _this3.touchDeltaX = 0;
  2518. } else {
  2519. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2520. }
  2521. };
  2522. var end = function end(event) {
  2523. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2524. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2525. }
  2526. _this3._handleSwipe();
  2527. if (_this3._config.pause === 'hover') {
  2528. // If it's a touch-enabled device, mouseenter/leave are fired as
  2529. // part of the mouse compatibility events on first tap - the carousel
  2530. // would stop cycling until user tapped out of it;
  2531. // here, we listen for touchend, explicitly pause the carousel
  2532. // (as if it's the second time we tap on it, mouseenter compat event
  2533. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2534. // events to fire) we explicitly restart cycling
  2535. _this3.pause();
  2536. if (_this3.touchTimeout) {
  2537. clearTimeout(_this3.touchTimeout);
  2538. }
  2539. _this3.touchTimeout = setTimeout(function (event) {
  2540. return _this3.cycle(event);
  2541. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2542. }
  2543. };
  2544. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2545. return e.preventDefault();
  2546. });
  2547. if (this._pointerEvent) {
  2548. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2549. return start(event);
  2550. });
  2551. $(this._element).on(Event$2.POINTERUP, function (event) {
  2552. return end(event);
  2553. });
  2554. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2555. } else {
  2556. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2557. return start(event);
  2558. });
  2559. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2560. return move(event);
  2561. });
  2562. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2563. return end(event);
  2564. });
  2565. }
  2566. };
  2567. _proto._keydown = function _keydown(event) {
  2568. if (/input|textarea/i.test(event.target.tagName)) {
  2569. return;
  2570. }
  2571. switch (event.which) {
  2572. case ARROW_LEFT_KEYCODE:
  2573. event.preventDefault();
  2574. this.prev();
  2575. break;
  2576. case ARROW_RIGHT_KEYCODE:
  2577. event.preventDefault();
  2578. this.next();
  2579. break;
  2580. }
  2581. };
  2582. _proto._getItemIndex = function _getItemIndex(element) {
  2583. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2584. return this._items.indexOf(element);
  2585. };
  2586. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2587. var isNextDirection = direction === Direction.NEXT;
  2588. var isPrevDirection = direction === Direction.PREV;
  2589. var activeIndex = this._getItemIndex(activeElement);
  2590. var lastItemIndex = this._items.length - 1;
  2591. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2592. if (isGoingToWrap && !this._config.wrap) {
  2593. return activeElement;
  2594. }
  2595. var delta = direction === Direction.PREV ? -1 : 1;
  2596. var itemIndex = (activeIndex + delta) % this._items.length;
  2597. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2598. };
  2599. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2600. var targetIndex = this._getItemIndex(relatedTarget);
  2601. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2602. var slideEvent = $.Event(Event$2.SLIDE, {
  2603. relatedTarget: relatedTarget,
  2604. direction: eventDirectionName,
  2605. from: fromIndex,
  2606. to: targetIndex
  2607. });
  2608. $(this._element).trigger(slideEvent);
  2609. return slideEvent;
  2610. };
  2611. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2612. if (this._indicatorsElement) {
  2613. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2614. $(indicators).removeClass(ClassName$2.ACTIVE);
  2615. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2616. if (nextIndicator) {
  2617. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2618. }
  2619. }
  2620. };
  2621. _proto._slide = function _slide(direction, element) {
  2622. var _this4 = this;
  2623. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2624. var activeElementIndex = this._getItemIndex(activeElement);
  2625. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2626. var nextElementIndex = this._getItemIndex(nextElement);
  2627. var isCycling = Boolean(this._interval);
  2628. var directionalClassName;
  2629. var orderClassName;
  2630. var eventDirectionName;
  2631. if (direction === Direction.NEXT) {
  2632. directionalClassName = ClassName$2.LEFT;
  2633. orderClassName = ClassName$2.NEXT;
  2634. eventDirectionName = Direction.LEFT;
  2635. } else {
  2636. directionalClassName = ClassName$2.RIGHT;
  2637. orderClassName = ClassName$2.PREV;
  2638. eventDirectionName = Direction.RIGHT;
  2639. }
  2640. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2641. this._isSliding = false;
  2642. return;
  2643. }
  2644. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2645. if (slideEvent.isDefaultPrevented()) {
  2646. return;
  2647. }
  2648. if (!activeElement || !nextElement) {
  2649. // Some weirdness is happening, so we bail
  2650. return;
  2651. }
  2652. this._isSliding = true;
  2653. if (isCycling) {
  2654. this.pause();
  2655. }
  2656. this._setActiveIndicatorElement(nextElement);
  2657. var slidEvent = $.Event(Event$2.SLID, {
  2658. relatedTarget: nextElement,
  2659. direction: eventDirectionName,
  2660. from: activeElementIndex,
  2661. to: nextElementIndex
  2662. });
  2663. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2664. $(nextElement).addClass(orderClassName);
  2665. Util.reflow(nextElement);
  2666. $(activeElement).addClass(directionalClassName);
  2667. $(nextElement).addClass(directionalClassName);
  2668. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2669. if (nextElementInterval) {
  2670. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2671. this._config.interval = nextElementInterval;
  2672. } else {
  2673. this._config.interval = this._config.defaultInterval || this._config.interval;
  2674. }
  2675. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2676. $(activeElement).one(Util.TRANSITION_END, function () {
  2677. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2678. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2679. _this4._isSliding = false;
  2680. setTimeout(function () {
  2681. return $(_this4._element).trigger(slidEvent);
  2682. }, 0);
  2683. }).emulateTransitionEnd(transitionDuration);
  2684. } else {
  2685. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2686. $(nextElement).addClass(ClassName$2.ACTIVE);
  2687. this._isSliding = false;
  2688. $(this._element).trigger(slidEvent);
  2689. }
  2690. if (isCycling) {
  2691. this.cycle();
  2692. }
  2693. } // Static
  2694. ;
  2695. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2696. return this.each(function () {
  2697. var data = $(this).data(DATA_KEY$2);
  2698. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2699. if (typeof config === 'object') {
  2700. _config = _objectSpread2({}, _config, {}, config);
  2701. }
  2702. var action = typeof config === 'string' ? config : _config.slide;
  2703. if (!data) {
  2704. data = new Carousel(this, _config);
  2705. $(this).data(DATA_KEY$2, data);
  2706. }
  2707. if (typeof config === 'number') {
  2708. data.to(config);
  2709. } else if (typeof action === 'string') {
  2710. if (typeof data[action] === 'undefined') {
  2711. throw new TypeError("No method named \"" + action + "\"");
  2712. }
  2713. data[action]();
  2714. } else if (_config.interval && _config.ride) {
  2715. data.pause();
  2716. data.cycle();
  2717. }
  2718. });
  2719. };
  2720. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2721. var selector = Util.getSelectorFromElement(this);
  2722. if (!selector) {
  2723. return;
  2724. }
  2725. var target = $(selector)[0];
  2726. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2727. return;
  2728. }
  2729. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2730. var slideIndex = this.getAttribute('data-slide-to');
  2731. if (slideIndex) {
  2732. config.interval = false;
  2733. }
  2734. Carousel._jQueryInterface.call($(target), config);
  2735. if (slideIndex) {
  2736. $(target).data(DATA_KEY$2).to(slideIndex);
  2737. }
  2738. event.preventDefault();
  2739. };
  2740. _createClass(Carousel, null, [{
  2741. key: "VERSION",
  2742. get: function get() {
  2743. return VERSION$2;
  2744. }
  2745. }, {
  2746. key: "Default",
  2747. get: function get() {
  2748. return Default;
  2749. }
  2750. }]);
  2751. return Carousel;
  2752. }();
  2753. /**
  2754. * ------------------------------------------------------------------------
  2755. * Data Api implementation
  2756. * ------------------------------------------------------------------------
  2757. */
  2758. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2759. $(window).on(Event$2.LOAD_DATA_API, function () {
  2760. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2761. for (var i = 0, len = carousels.length; i < len; i++) {
  2762. var $carousel = $(carousels[i]);
  2763. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2764. }
  2765. });
  2766. /**
  2767. * ------------------------------------------------------------------------
  2768. * jQuery
  2769. * ------------------------------------------------------------------------
  2770. */
  2771. $.fn[NAME$2] = Carousel._jQueryInterface;
  2772. $.fn[NAME$2].Constructor = Carousel;
  2773. $.fn[NAME$2].noConflict = function () {
  2774. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2775. return Carousel._jQueryInterface;
  2776. };
  2777. /**
  2778. * ------------------------------------------------------------------------
  2779. * Constants
  2780. * ------------------------------------------------------------------------
  2781. */
  2782. var NAME$3 = 'collapse';
  2783. var VERSION$3 = '4.4.1';
  2784. var DATA_KEY$3 = 'bs.collapse';
  2785. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2786. var DATA_API_KEY$3 = '.data-api';
  2787. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2788. var Default$1 = {
  2789. toggle: true,
  2790. parent: ''
  2791. };
  2792. var DefaultType$1 = {
  2793. toggle: 'boolean',
  2794. parent: '(string|element)'
  2795. };
  2796. var Event$3 = {
  2797. SHOW: "show" + EVENT_KEY$3,
  2798. SHOWN: "shown" + EVENT_KEY$3,
  2799. HIDE: "hide" + EVENT_KEY$3,
  2800. HIDDEN: "hidden" + EVENT_KEY$3,
  2801. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2802. };
  2803. var ClassName$3 = {
  2804. SHOW: 'show',
  2805. COLLAPSE: 'collapse',
  2806. COLLAPSING: 'collapsing',
  2807. COLLAPSED: 'collapsed'
  2808. };
  2809. var Dimension = {
  2810. WIDTH: 'width',
  2811. HEIGHT: 'height'
  2812. };
  2813. var Selector$3 = {
  2814. ACTIVES: '.show, .collapsing',
  2815. DATA_TOGGLE: '[data-toggle="collapse"]'
  2816. };
  2817. /**
  2818. * ------------------------------------------------------------------------
  2819. * Class Definition
  2820. * ------------------------------------------------------------------------
  2821. */
  2822. var Collapse =
  2823. /*#__PURE__*/
  2824. function () {
  2825. function Collapse(element, config) {
  2826. this._isTransitioning = false;
  2827. this._element = element;
  2828. this._config = this._getConfig(config);
  2829. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2830. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2831. for (var i = 0, len = toggleList.length; i < len; i++) {
  2832. var elem = toggleList[i];
  2833. var selector = Util.getSelectorFromElement(elem);
  2834. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2835. return foundElem === element;
  2836. });
  2837. if (selector !== null && filterElement.length > 0) {
  2838. this._selector = selector;
  2839. this._triggerArray.push(elem);
  2840. }
  2841. }
  2842. this._parent = this._config.parent ? this._getParent() : null;
  2843. if (!this._config.parent) {
  2844. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2845. }
  2846. if (this._config.toggle) {
  2847. this.toggle();
  2848. }
  2849. } // Getters
  2850. var _proto = Collapse.prototype;
  2851. // Public
  2852. _proto.toggle = function toggle() {
  2853. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2854. this.hide();
  2855. } else {
  2856. this.show();
  2857. }
  2858. };
  2859. _proto.show = function show() {
  2860. var _this = this;
  2861. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2862. return;
  2863. }
  2864. var actives;
  2865. var activesData;
  2866. if (this._parent) {
  2867. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2868. if (typeof _this._config.parent === 'string') {
  2869. return elem.getAttribute('data-parent') === _this._config.parent;
  2870. }
  2871. return elem.classList.contains(ClassName$3.COLLAPSE);
  2872. });
  2873. if (actives.length === 0) {
  2874. actives = null;
  2875. }
  2876. }
  2877. if (actives) {
  2878. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2879. if (activesData && activesData._isTransitioning) {
  2880. return;
  2881. }
  2882. }
  2883. var startEvent = $.Event(Event$3.SHOW);
  2884. $(this._element).trigger(startEvent);
  2885. if (startEvent.isDefaultPrevented()) {
  2886. return;
  2887. }
  2888. if (actives) {
  2889. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2890. if (!activesData) {
  2891. $(actives).data(DATA_KEY$3, null);
  2892. }
  2893. }
  2894. var dimension = this._getDimension();
  2895. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  2896. this._element.style[dimension] = 0;
  2897. if (this._triggerArray.length) {
  2898. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  2899. }
  2900. this.setTransitioning(true);
  2901. var complete = function complete() {
  2902. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  2903. _this._element.style[dimension] = '';
  2904. _this.setTransitioning(false);
  2905. $(_this._element).trigger(Event$3.SHOWN);
  2906. };
  2907. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2908. var scrollSize = "scroll" + capitalizedDimension;
  2909. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2910. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2911. this._element.style[dimension] = this._element[scrollSize] + "px";
  2912. };
  2913. _proto.hide = function hide() {
  2914. var _this2 = this;
  2915. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  2916. return;
  2917. }
  2918. var startEvent = $.Event(Event$3.HIDE);
  2919. $(this._element).trigger(startEvent);
  2920. if (startEvent.isDefaultPrevented()) {
  2921. return;
  2922. }
  2923. var dimension = this._getDimension();
  2924. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2925. Util.reflow(this._element);
  2926. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  2927. var triggerArrayLength = this._triggerArray.length;
  2928. if (triggerArrayLength > 0) {
  2929. for (var i = 0; i < triggerArrayLength; i++) {
  2930. var trigger = this._triggerArray[i];
  2931. var selector = Util.getSelectorFromElement(trigger);
  2932. if (selector !== null) {
  2933. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2934. if (!$elem.hasClass(ClassName$3.SHOW)) {
  2935. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  2936. }
  2937. }
  2938. }
  2939. }
  2940. this.setTransitioning(true);
  2941. var complete = function complete() {
  2942. _this2.setTransitioning(false);
  2943. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  2944. };
  2945. this._element.style[dimension] = '';
  2946. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2947. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2948. };
  2949. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2950. this._isTransitioning = isTransitioning;
  2951. };
  2952. _proto.dispose = function dispose() {
  2953. $.removeData(this._element, DATA_KEY$3);
  2954. this._config = null;
  2955. this._parent = null;
  2956. this._element = null;
  2957. this._triggerArray = null;
  2958. this._isTransitioning = null;
  2959. } // Private
  2960. ;
  2961. _proto._getConfig = function _getConfig(config) {
  2962. config = _objectSpread2({}, Default$1, {}, config);
  2963. config.toggle = Boolean(config.toggle); // Coerce string values
  2964. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2965. return config;
  2966. };
  2967. _proto._getDimension = function _getDimension() {
  2968. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  2969. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  2970. };
  2971. _proto._getParent = function _getParent() {
  2972. var _this3 = this;
  2973. var parent;
  2974. if (Util.isElement(this._config.parent)) {
  2975. parent = this._config.parent; // It's a jQuery object
  2976. if (typeof this._config.parent.jquery !== 'undefined') {
  2977. parent = this._config.parent[0];
  2978. }
  2979. } else {
  2980. parent = document.querySelector(this._config.parent);
  2981. }
  2982. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  2983. var children = [].slice.call(parent.querySelectorAll(selector));
  2984. $(children).each(function (i, element) {
  2985. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  2986. });
  2987. return parent;
  2988. };
  2989. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  2990. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  2991. if (triggerArray.length) {
  2992. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  2993. }
  2994. } // Static
  2995. ;
  2996. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  2997. var selector = Util.getSelectorFromElement(element);
  2998. return selector ? document.querySelector(selector) : null;
  2999. };
  3000. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3001. return this.each(function () {
  3002. var $this = $(this);
  3003. var data = $this.data(DATA_KEY$3);
  3004. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3005. if (!data && _config.toggle && /show|hide/.test(config)) {
  3006. _config.toggle = false;
  3007. }
  3008. if (!data) {
  3009. data = new Collapse(this, _config);
  3010. $this.data(DATA_KEY$3, data);
  3011. }
  3012. if (typeof config === 'string') {
  3013. if (typeof data[config] === 'undefined') {
  3014. throw new TypeError("No method named \"" + config + "\"");
  3015. }
  3016. data[config]();
  3017. }
  3018. });
  3019. };
  3020. _createClass(Collapse, null, [{
  3021. key: "VERSION",
  3022. get: function get() {
  3023. return VERSION$3;
  3024. }
  3025. }, {
  3026. key: "Default",
  3027. get: function get() {
  3028. return Default$1;
  3029. }
  3030. }]);
  3031. return Collapse;
  3032. }();
  3033. /**
  3034. * ------------------------------------------------------------------------
  3035. * Data Api implementation
  3036. * ------------------------------------------------------------------------
  3037. */
  3038. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3039. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3040. if (event.currentTarget.tagName === 'A') {
  3041. event.preventDefault();
  3042. }
  3043. var $trigger = $(this);
  3044. var selector = Util.getSelectorFromElement(this);
  3045. var selectors = [].slice.call(document.querySelectorAll(selector));
  3046. $(selectors).each(function () {
  3047. var $target = $(this);
  3048. var data = $target.data(DATA_KEY$3);
  3049. var config = data ? 'toggle' : $trigger.data();
  3050. Collapse._jQueryInterface.call($target, config);
  3051. });
  3052. });
  3053. /**
  3054. * ------------------------------------------------------------------------
  3055. * jQuery
  3056. * ------------------------------------------------------------------------
  3057. */
  3058. $.fn[NAME$3] = Collapse._jQueryInterface;
  3059. $.fn[NAME$3].Constructor = Collapse;
  3060. $.fn[NAME$3].noConflict = function () {
  3061. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3062. return Collapse._jQueryInterface;
  3063. };
  3064. /**
  3065. * ------------------------------------------------------------------------
  3066. * Constants
  3067. * ------------------------------------------------------------------------
  3068. */
  3069. var NAME$4 = 'dropdown';
  3070. var VERSION$4 = '4.4.1';
  3071. var DATA_KEY$4 = 'bs.dropdown';
  3072. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3073. var DATA_API_KEY$4 = '.data-api';
  3074. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3075. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3076. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3077. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3078. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3079. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3080. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3081. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3082. var Event$4 = {
  3083. HIDE: "hide" + EVENT_KEY$4,
  3084. HIDDEN: "hidden" + EVENT_KEY$4,
  3085. SHOW: "show" + EVENT_KEY$4,
  3086. SHOWN: "shown" + EVENT_KEY$4,
  3087. CLICK: "click" + EVENT_KEY$4,
  3088. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3089. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3090. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3091. };
  3092. var ClassName$4 = {
  3093. DISABLED: 'disabled',
  3094. SHOW: 'show',
  3095. DROPUP: 'dropup',
  3096. DROPRIGHT: 'dropright',
  3097. DROPLEFT: 'dropleft',
  3098. MENURIGHT: 'dropdown-menu-right',
  3099. MENULEFT: 'dropdown-menu-left',
  3100. POSITION_STATIC: 'position-static'
  3101. };
  3102. var Selector$4 = {
  3103. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3104. FORM_CHILD: '.dropdown form',
  3105. MENU: '.dropdown-menu',
  3106. NAVBAR_NAV: '.navbar-nav',
  3107. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3108. };
  3109. var AttachmentMap = {
  3110. TOP: 'top-start',
  3111. TOPEND: 'top-end',
  3112. BOTTOM: 'bottom-start',
  3113. BOTTOMEND: 'bottom-end',
  3114. RIGHT: 'right-start',
  3115. RIGHTEND: 'right-end',
  3116. LEFT: 'left-start',
  3117. LEFTEND: 'left-end'
  3118. };
  3119. var Default$2 = {
  3120. offset: 0,
  3121. flip: true,
  3122. boundary: 'scrollParent',
  3123. reference: 'toggle',
  3124. display: 'dynamic',
  3125. popperConfig: null
  3126. };
  3127. var DefaultType$2 = {
  3128. offset: '(number|string|function)',
  3129. flip: 'boolean',
  3130. boundary: '(string|element)',
  3131. reference: '(string|element)',
  3132. display: 'string',
  3133. popperConfig: '(null|object)'
  3134. };
  3135. /**
  3136. * ------------------------------------------------------------------------
  3137. * Class Definition
  3138. * ------------------------------------------------------------------------
  3139. */
  3140. var Dropdown =
  3141. /*#__PURE__*/
  3142. function () {
  3143. function Dropdown(element, config) {
  3144. this._element = element;
  3145. this._popper = null;
  3146. this._config = this._getConfig(config);
  3147. this._menu = this._getMenuElement();
  3148. this._inNavbar = this._detectNavbar();
  3149. this._addEventListeners();
  3150. } // Getters
  3151. var _proto = Dropdown.prototype;
  3152. // Public
  3153. _proto.toggle = function toggle() {
  3154. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3155. return;
  3156. }
  3157. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3158. Dropdown._clearMenus();
  3159. if (isActive) {
  3160. return;
  3161. }
  3162. this.show(true);
  3163. };
  3164. _proto.show = function show(usePopper) {
  3165. if (usePopper === void 0) {
  3166. usePopper = false;
  3167. }
  3168. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3169. return;
  3170. }
  3171. var relatedTarget = {
  3172. relatedTarget: this._element
  3173. };
  3174. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3175. var parent = Dropdown._getParentFromElement(this._element);
  3176. $(parent).trigger(showEvent);
  3177. if (showEvent.isDefaultPrevented()) {
  3178. return;
  3179. } // Disable totally Popper.js for Dropdown in Navbar
  3180. if (!this._inNavbar && usePopper) {
  3181. /**
  3182. * Check for Popper dependency
  3183. * Popper - https://popper.js.org
  3184. */
  3185. if (typeof Popper === 'undefined') {
  3186. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3187. }
  3188. var referenceElement = this._element;
  3189. if (this._config.reference === 'parent') {
  3190. referenceElement = parent;
  3191. } else if (Util.isElement(this._config.reference)) {
  3192. referenceElement = this._config.reference; // Check if it's jQuery element
  3193. if (typeof this._config.reference.jquery !== 'undefined') {
  3194. referenceElement = this._config.reference[0];
  3195. }
  3196. } // If boundary is not `scrollParent`, then set position to `static`
  3197. // to allow the menu to "escape" the scroll parent's boundaries
  3198. // https://github.com/twbs/bootstrap/issues/24251
  3199. if (this._config.boundary !== 'scrollParent') {
  3200. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3201. }
  3202. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3203. } // If this is a touch-enabled device we add extra
  3204. // empty mouseover listeners to the body's immediate children;
  3205. // only needed because of broken event delegation on iOS
  3206. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3207. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3208. $(document.body).children().on('mouseover', null, $.noop);
  3209. }
  3210. this._element.focus();
  3211. this._element.setAttribute('aria-expanded', true);
  3212. $(this._menu).toggleClass(ClassName$4.SHOW);
  3213. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3214. };
  3215. _proto.hide = function hide() {
  3216. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3217. return;
  3218. }
  3219. var relatedTarget = {
  3220. relatedTarget: this._element
  3221. };
  3222. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3223. var parent = Dropdown._getParentFromElement(this._element);
  3224. $(parent).trigger(hideEvent);
  3225. if (hideEvent.isDefaultPrevented()) {
  3226. return;
  3227. }
  3228. if (this._popper) {
  3229. this._popper.destroy();
  3230. }
  3231. $(this._menu).toggleClass(ClassName$4.SHOW);
  3232. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3233. };
  3234. _proto.dispose = function dispose() {
  3235. $.removeData(this._element, DATA_KEY$4);
  3236. $(this._element).off(EVENT_KEY$4);
  3237. this._element = null;
  3238. this._menu = null;
  3239. if (this._popper !== null) {
  3240. this._popper.destroy();
  3241. this._popper = null;
  3242. }
  3243. };
  3244. _proto.update = function update() {
  3245. this._inNavbar = this._detectNavbar();
  3246. if (this._popper !== null) {
  3247. this._popper.scheduleUpdate();
  3248. }
  3249. } // Private
  3250. ;
  3251. _proto._addEventListeners = function _addEventListeners() {
  3252. var _this = this;
  3253. $(this._element).on(Event$4.CLICK, function (event) {
  3254. event.preventDefault();
  3255. event.stopPropagation();
  3256. _this.toggle();
  3257. });
  3258. };
  3259. _proto._getConfig = function _getConfig(config) {
  3260. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3261. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3262. return config;
  3263. };
  3264. _proto._getMenuElement = function _getMenuElement() {
  3265. if (!this._menu) {
  3266. var parent = Dropdown._getParentFromElement(this._element);
  3267. if (parent) {
  3268. this._menu = parent.querySelector(Selector$4.MENU);
  3269. }
  3270. }
  3271. return this._menu;
  3272. };
  3273. _proto._getPlacement = function _getPlacement() {
  3274. var $parentDropdown = $(this._element.parentNode);
  3275. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3276. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3277. placement = AttachmentMap.TOP;
  3278. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3279. placement = AttachmentMap.TOPEND;
  3280. }
  3281. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3282. placement = AttachmentMap.RIGHT;
  3283. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3284. placement = AttachmentMap.LEFT;
  3285. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3286. placement = AttachmentMap.BOTTOMEND;
  3287. }
  3288. return placement;
  3289. };
  3290. _proto._detectNavbar = function _detectNavbar() {
  3291. return $(this._element).closest('.navbar').length > 0;
  3292. };
  3293. _proto._getOffset = function _getOffset() {
  3294. var _this2 = this;
  3295. var offset = {};
  3296. if (typeof this._config.offset === 'function') {
  3297. offset.fn = function (data) {
  3298. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3299. return data;
  3300. };
  3301. } else {
  3302. offset.offset = this._config.offset;
  3303. }
  3304. return offset;
  3305. };
  3306. _proto._getPopperConfig = function _getPopperConfig() {
  3307. var popperConfig = {
  3308. placement: this._getPlacement(),
  3309. modifiers: {
  3310. offset: this._getOffset(),
  3311. flip: {
  3312. enabled: this._config.flip
  3313. },
  3314. preventOverflow: {
  3315. boundariesElement: this._config.boundary
  3316. }
  3317. }
  3318. }; // Disable Popper.js if we have a static display
  3319. if (this._config.display === 'static') {
  3320. popperConfig.modifiers.applyStyle = {
  3321. enabled: false
  3322. };
  3323. }
  3324. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3325. } // Static
  3326. ;
  3327. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3328. return this.each(function () {
  3329. var data = $(this).data(DATA_KEY$4);
  3330. var _config = typeof config === 'object' ? config : null;
  3331. if (!data) {
  3332. data = new Dropdown(this, _config);
  3333. $(this).data(DATA_KEY$4, data);
  3334. }
  3335. if (typeof config === 'string') {
  3336. if (typeof data[config] === 'undefined') {
  3337. throw new TypeError("No method named \"" + config + "\"");
  3338. }
  3339. data[config]();
  3340. }
  3341. });
  3342. };
  3343. Dropdown._clearMenus = function _clearMenus(event) {
  3344. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3345. return;
  3346. }
  3347. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3348. for (var i = 0, len = toggles.length; i < len; i++) {
  3349. var parent = Dropdown._getParentFromElement(toggles[i]);
  3350. var context = $(toggles[i]).data(DATA_KEY$4);
  3351. var relatedTarget = {
  3352. relatedTarget: toggles[i]
  3353. };
  3354. if (event && event.type === 'click') {
  3355. relatedTarget.clickEvent = event;
  3356. }
  3357. if (!context) {
  3358. continue;
  3359. }
  3360. var dropdownMenu = context._menu;
  3361. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3362. continue;
  3363. }
  3364. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3365. continue;
  3366. }
  3367. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3368. $(parent).trigger(hideEvent);
  3369. if (hideEvent.isDefaultPrevented()) {
  3370. continue;
  3371. } // If this is a touch-enabled device we remove the extra
  3372. // empty mouseover listeners we added for iOS support
  3373. if ('ontouchstart' in document.documentElement) {
  3374. $(document.body).children().off('mouseover', null, $.noop);
  3375. }
  3376. toggles[i].setAttribute('aria-expanded', 'false');
  3377. if (context._popper) {
  3378. context._popper.destroy();
  3379. }
  3380. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3381. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3382. }
  3383. };
  3384. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3385. var parent;
  3386. var selector = Util.getSelectorFromElement(element);
  3387. if (selector) {
  3388. parent = document.querySelector(selector);
  3389. }
  3390. return parent || element.parentNode;
  3391. } // eslint-disable-next-line complexity
  3392. ;
  3393. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3394. // If not input/textarea:
  3395. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3396. // If input/textarea:
  3397. // - If space key => not a dropdown command
  3398. // - If key is other than escape
  3399. // - If key is not up or down => not a dropdown command
  3400. // - If trigger inside the menu => not a dropdown command
  3401. 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$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  3402. return;
  3403. }
  3404. event.preventDefault();
  3405. event.stopPropagation();
  3406. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3407. return;
  3408. }
  3409. var parent = Dropdown._getParentFromElement(this);
  3410. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3411. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3412. return;
  3413. }
  3414. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3415. if (event.which === ESCAPE_KEYCODE) {
  3416. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3417. $(toggle).trigger('focus');
  3418. }
  3419. $(this).trigger('click');
  3420. return;
  3421. }
  3422. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3423. return $(item).is(':visible');
  3424. });
  3425. if (items.length === 0) {
  3426. return;
  3427. }
  3428. var index = items.indexOf(event.target);
  3429. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3430. // Up
  3431. index--;
  3432. }
  3433. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3434. // Down
  3435. index++;
  3436. }
  3437. if (index < 0) {
  3438. index = 0;
  3439. }
  3440. items[index].focus();
  3441. };
  3442. _createClass(Dropdown, null, [{
  3443. key: "VERSION",
  3444. get: function get() {
  3445. return VERSION$4;
  3446. }
  3447. }, {
  3448. key: "Default",
  3449. get: function get() {
  3450. return Default$2;
  3451. }
  3452. }, {
  3453. key: "DefaultType",
  3454. get: function get() {
  3455. return DefaultType$2;
  3456. }
  3457. }]);
  3458. return Dropdown;
  3459. }();
  3460. /**
  3461. * ------------------------------------------------------------------------
  3462. * Data Api implementation
  3463. * ------------------------------------------------------------------------
  3464. */
  3465. $(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
  3466. event.preventDefault();
  3467. event.stopPropagation();
  3468. Dropdown._jQueryInterface.call($(this), 'toggle');
  3469. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3470. e.stopPropagation();
  3471. });
  3472. /**
  3473. * ------------------------------------------------------------------------
  3474. * jQuery
  3475. * ------------------------------------------------------------------------
  3476. */
  3477. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3478. $.fn[NAME$4].Constructor = Dropdown;
  3479. $.fn[NAME$4].noConflict = function () {
  3480. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3481. return Dropdown._jQueryInterface;
  3482. };
  3483. /**
  3484. * ------------------------------------------------------------------------
  3485. * Constants
  3486. * ------------------------------------------------------------------------
  3487. */
  3488. var NAME$5 = 'modal';
  3489. var VERSION$5 = '4.4.1';
  3490. var DATA_KEY$5 = 'bs.modal';
  3491. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3492. var DATA_API_KEY$5 = '.data-api';
  3493. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3494. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3495. var Default$3 = {
  3496. backdrop: true,
  3497. keyboard: true,
  3498. focus: true,
  3499. show: true
  3500. };
  3501. var DefaultType$3 = {
  3502. backdrop: '(boolean|string)',
  3503. keyboard: 'boolean',
  3504. focus: 'boolean',
  3505. show: 'boolean'
  3506. };
  3507. var Event$5 = {
  3508. HIDE: "hide" + EVENT_KEY$5,
  3509. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3510. HIDDEN: "hidden" + EVENT_KEY$5,
  3511. SHOW: "show" + EVENT_KEY$5,
  3512. SHOWN: "shown" + EVENT_KEY$5,
  3513. FOCUSIN: "focusin" + EVENT_KEY$5,
  3514. RESIZE: "resize" + EVENT_KEY$5,
  3515. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3516. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3517. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3518. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3519. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3520. };
  3521. var ClassName$5 = {
  3522. SCROLLABLE: 'modal-dialog-scrollable',
  3523. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3524. BACKDROP: 'modal-backdrop',
  3525. OPEN: 'modal-open',
  3526. FADE: 'fade',
  3527. SHOW: 'show',
  3528. STATIC: 'modal-static'
  3529. };
  3530. var Selector$5 = {
  3531. DIALOG: '.modal-dialog',
  3532. MODAL_BODY: '.modal-body',
  3533. DATA_TOGGLE: '[data-toggle="modal"]',
  3534. DATA_DISMISS: '[data-dismiss="modal"]',
  3535. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3536. STICKY_CONTENT: '.sticky-top'
  3537. };
  3538. /**
  3539. * ------------------------------------------------------------------------
  3540. * Class Definition
  3541. * ------------------------------------------------------------------------
  3542. */
  3543. var Modal =
  3544. /*#__PURE__*/
  3545. function () {
  3546. function Modal(element, config) {
  3547. this._config = this._getConfig(config);
  3548. this._element = element;
  3549. this._dialog = element.querySelector(Selector$5.DIALOG);
  3550. this._backdrop = null;
  3551. this._isShown = false;
  3552. this._isBodyOverflowing = false;
  3553. this._ignoreBackdropClick = false;
  3554. this._isTransitioning = false;
  3555. this._scrollbarWidth = 0;
  3556. } // Getters
  3557. var _proto = Modal.prototype;
  3558. // Public
  3559. _proto.toggle = function toggle(relatedTarget) {
  3560. return this._isShown ? this.hide() : this.show(relatedTarget);
  3561. };
  3562. _proto.show = function show(relatedTarget) {
  3563. var _this = this;
  3564. if (this._isShown || this._isTransitioning) {
  3565. return;
  3566. }
  3567. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3568. this._isTransitioning = true;
  3569. }
  3570. var showEvent = $.Event(Event$5.SHOW, {
  3571. relatedTarget: relatedTarget
  3572. });
  3573. $(this._element).trigger(showEvent);
  3574. if (this._isShown || showEvent.isDefaultPrevented()) {
  3575. return;
  3576. }
  3577. this._isShown = true;
  3578. this._checkScrollbar();
  3579. this._setScrollbar();
  3580. this._adjustDialog();
  3581. this._setEscapeEvent();
  3582. this._setResizeEvent();
  3583. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3584. return _this.hide(event);
  3585. });
  3586. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3587. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3588. if ($(event.target).is(_this._element)) {
  3589. _this._ignoreBackdropClick = true;
  3590. }
  3591. });
  3592. });
  3593. this._showBackdrop(function () {
  3594. return _this._showElement(relatedTarget);
  3595. });
  3596. };
  3597. _proto.hide = function hide(event) {
  3598. var _this2 = this;
  3599. if (event) {
  3600. event.preventDefault();
  3601. }
  3602. if (!this._isShown || this._isTransitioning) {
  3603. return;
  3604. }
  3605. var hideEvent = $.Event(Event$5.HIDE);
  3606. $(this._element).trigger(hideEvent);
  3607. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3608. return;
  3609. }
  3610. this._isShown = false;
  3611. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3612. if (transition) {
  3613. this._isTransitioning = true;
  3614. }
  3615. this._setEscapeEvent();
  3616. this._setResizeEvent();
  3617. $(document).off(Event$5.FOCUSIN);
  3618. $(this._element).removeClass(ClassName$5.SHOW);
  3619. $(this._element).off(Event$5.CLICK_DISMISS);
  3620. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3621. if (transition) {
  3622. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3623. $(this._element).one(Util.TRANSITION_END, function (event) {
  3624. return _this2._hideModal(event);
  3625. }).emulateTransitionEnd(transitionDuration);
  3626. } else {
  3627. this._hideModal();
  3628. }
  3629. };
  3630. _proto.dispose = function dispose() {
  3631. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3632. return $(htmlElement).off(EVENT_KEY$5);
  3633. });
  3634. /**
  3635. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3636. * Do not move `document` in `htmlElements` array
  3637. * It will remove `Event.CLICK_DATA_API` event that should remain
  3638. */
  3639. $(document).off(Event$5.FOCUSIN);
  3640. $.removeData(this._element, DATA_KEY$5);
  3641. this._config = null;
  3642. this._element = null;
  3643. this._dialog = null;
  3644. this._backdrop = null;
  3645. this._isShown = null;
  3646. this._isBodyOverflowing = null;
  3647. this._ignoreBackdropClick = null;
  3648. this._isTransitioning = null;
  3649. this._scrollbarWidth = null;
  3650. };
  3651. _proto.handleUpdate = function handleUpdate() {
  3652. this._adjustDialog();
  3653. } // Private
  3654. ;
  3655. _proto._getConfig = function _getConfig(config) {
  3656. config = _objectSpread2({}, Default$3, {}, config);
  3657. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3658. return config;
  3659. };
  3660. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3661. var _this3 = this;
  3662. if (this._config.backdrop === 'static') {
  3663. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3664. $(this._element).trigger(hideEventPrevented);
  3665. if (hideEventPrevented.defaultPrevented) {
  3666. return;
  3667. }
  3668. this._element.classList.add(ClassName$5.STATIC);
  3669. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3670. $(this._element).one(Util.TRANSITION_END, function () {
  3671. _this3._element.classList.remove(ClassName$5.STATIC);
  3672. }).emulateTransitionEnd(modalTransitionDuration);
  3673. this._element.focus();
  3674. } else {
  3675. this.hide();
  3676. }
  3677. };
  3678. _proto._showElement = function _showElement(relatedTarget) {
  3679. var _this4 = this;
  3680. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3681. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3682. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3683. // Don't move modal's DOM position
  3684. document.body.appendChild(this._element);
  3685. }
  3686. this._element.style.display = 'block';
  3687. this._element.removeAttribute('aria-hidden');
  3688. this._element.setAttribute('aria-modal', true);
  3689. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3690. modalBody.scrollTop = 0;
  3691. } else {
  3692. this._element.scrollTop = 0;
  3693. }
  3694. if (transition) {
  3695. Util.reflow(this._element);
  3696. }
  3697. $(this._element).addClass(ClassName$5.SHOW);
  3698. if (this._config.focus) {
  3699. this._enforceFocus();
  3700. }
  3701. var shownEvent = $.Event(Event$5.SHOWN, {
  3702. relatedTarget: relatedTarget
  3703. });
  3704. var transitionComplete = function transitionComplete() {
  3705. if (_this4._config.focus) {
  3706. _this4._element.focus();
  3707. }
  3708. _this4._isTransitioning = false;
  3709. $(_this4._element).trigger(shownEvent);
  3710. };
  3711. if (transition) {
  3712. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3713. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3714. } else {
  3715. transitionComplete();
  3716. }
  3717. };
  3718. _proto._enforceFocus = function _enforceFocus() {
  3719. var _this5 = this;
  3720. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3721. .on(Event$5.FOCUSIN, function (event) {
  3722. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3723. _this5._element.focus();
  3724. }
  3725. });
  3726. };
  3727. _proto._setEscapeEvent = function _setEscapeEvent() {
  3728. var _this6 = this;
  3729. if (this._isShown && this._config.keyboard) {
  3730. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3731. if (event.which === ESCAPE_KEYCODE$1) {
  3732. _this6._triggerBackdropTransition();
  3733. }
  3734. });
  3735. } else if (!this._isShown) {
  3736. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3737. }
  3738. };
  3739. _proto._setResizeEvent = function _setResizeEvent() {
  3740. var _this7 = this;
  3741. if (this._isShown) {
  3742. $(window).on(Event$5.RESIZE, function (event) {
  3743. return _this7.handleUpdate(event);
  3744. });
  3745. } else {
  3746. $(window).off(Event$5.RESIZE);
  3747. }
  3748. };
  3749. _proto._hideModal = function _hideModal() {
  3750. var _this8 = this;
  3751. this._element.style.display = 'none';
  3752. this._element.setAttribute('aria-hidden', true);
  3753. this._element.removeAttribute('aria-modal');
  3754. this._isTransitioning = false;
  3755. this._showBackdrop(function () {
  3756. $(document.body).removeClass(ClassName$5.OPEN);
  3757. _this8._resetAdjustments();
  3758. _this8._resetScrollbar();
  3759. $(_this8._element).trigger(Event$5.HIDDEN);
  3760. });
  3761. };
  3762. _proto._removeBackdrop = function _removeBackdrop() {
  3763. if (this._backdrop) {
  3764. $(this._backdrop).remove();
  3765. this._backdrop = null;
  3766. }
  3767. };
  3768. _proto._showBackdrop = function _showBackdrop(callback) {
  3769. var _this9 = this;
  3770. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3771. if (this._isShown && this._config.backdrop) {
  3772. this._backdrop = document.createElement('div');
  3773. this._backdrop.className = ClassName$5.BACKDROP;
  3774. if (animate) {
  3775. this._backdrop.classList.add(animate);
  3776. }
  3777. $(this._backdrop).appendTo(document.body);
  3778. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3779. if (_this9._ignoreBackdropClick) {
  3780. _this9._ignoreBackdropClick = false;
  3781. return;
  3782. }
  3783. if (event.target !== event.currentTarget) {
  3784. return;
  3785. }
  3786. _this9._triggerBackdropTransition();
  3787. });
  3788. if (animate) {
  3789. Util.reflow(this._backdrop);
  3790. }
  3791. $(this._backdrop).addClass(ClassName$5.SHOW);
  3792. if (!callback) {
  3793. return;
  3794. }
  3795. if (!animate) {
  3796. callback();
  3797. return;
  3798. }
  3799. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3800. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3801. } else if (!this._isShown && this._backdrop) {
  3802. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3803. var callbackRemove = function callbackRemove() {
  3804. _this9._removeBackdrop();
  3805. if (callback) {
  3806. callback();
  3807. }
  3808. };
  3809. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3810. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3811. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3812. } else {
  3813. callbackRemove();
  3814. }
  3815. } else if (callback) {
  3816. callback();
  3817. }
  3818. } // ----------------------------------------------------------------------
  3819. // the following methods are used to handle overflowing modals
  3820. // todo (fat): these should probably be refactored out of modal.js
  3821. // ----------------------------------------------------------------------
  3822. ;
  3823. _proto._adjustDialog = function _adjustDialog() {
  3824. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3825. if (!this._isBodyOverflowing && isModalOverflowing) {
  3826. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3827. }
  3828. if (this._isBodyOverflowing && !isModalOverflowing) {
  3829. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3830. }
  3831. };
  3832. _proto._resetAdjustments = function _resetAdjustments() {
  3833. this._element.style.paddingLeft = '';
  3834. this._element.style.paddingRight = '';
  3835. };
  3836. _proto._checkScrollbar = function _checkScrollbar() {
  3837. var rect = document.body.getBoundingClientRect();
  3838. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3839. this._scrollbarWidth = this._getScrollbarWidth();
  3840. };
  3841. _proto._setScrollbar = function _setScrollbar() {
  3842. var _this10 = this;
  3843. if (this._isBodyOverflowing) {
  3844. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3845. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3846. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3847. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3848. $(fixedContent).each(function (index, element) {
  3849. var actualPadding = element.style.paddingRight;
  3850. var calculatedPadding = $(element).css('padding-right');
  3851. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3852. }); // Adjust sticky content margin
  3853. $(stickyContent).each(function (index, element) {
  3854. var actualMargin = element.style.marginRight;
  3855. var calculatedMargin = $(element).css('margin-right');
  3856. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3857. }); // Adjust body padding
  3858. var actualPadding = document.body.style.paddingRight;
  3859. var calculatedPadding = $(document.body).css('padding-right');
  3860. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3861. }
  3862. $(document.body).addClass(ClassName$5.OPEN);
  3863. };
  3864. _proto._resetScrollbar = function _resetScrollbar() {
  3865. // Restore fixed content padding
  3866. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3867. $(fixedContent).each(function (index, element) {
  3868. var padding = $(element).data('padding-right');
  3869. $(element).removeData('padding-right');
  3870. element.style.paddingRight = padding ? padding : '';
  3871. }); // Restore sticky content
  3872. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  3873. $(elements).each(function (index, element) {
  3874. var margin = $(element).data('margin-right');
  3875. if (typeof margin !== 'undefined') {
  3876. $(element).css('margin-right', margin).removeData('margin-right');
  3877. }
  3878. }); // Restore body padding
  3879. var padding = $(document.body).data('padding-right');
  3880. $(document.body).removeData('padding-right');
  3881. document.body.style.paddingRight = padding ? padding : '';
  3882. };
  3883. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3884. // thx d.walsh
  3885. var scrollDiv = document.createElement('div');
  3886. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  3887. document.body.appendChild(scrollDiv);
  3888. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3889. document.body.removeChild(scrollDiv);
  3890. return scrollbarWidth;
  3891. } // Static
  3892. ;
  3893. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3894. return this.each(function () {
  3895. var data = $(this).data(DATA_KEY$5);
  3896. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  3897. if (!data) {
  3898. data = new Modal(this, _config);
  3899. $(this).data(DATA_KEY$5, data);
  3900. }
  3901. if (typeof config === 'string') {
  3902. if (typeof data[config] === 'undefined') {
  3903. throw new TypeError("No method named \"" + config + "\"");
  3904. }
  3905. data[config](relatedTarget);
  3906. } else if (_config.show) {
  3907. data.show(relatedTarget);
  3908. }
  3909. });
  3910. };
  3911. _createClass(Modal, null, [{
  3912. key: "VERSION",
  3913. get: function get() {
  3914. return VERSION$5;
  3915. }
  3916. }, {
  3917. key: "Default",
  3918. get: function get() {
  3919. return Default$3;
  3920. }
  3921. }]);
  3922. return Modal;
  3923. }();
  3924. /**
  3925. * ------------------------------------------------------------------------
  3926. * Data Api implementation
  3927. * ------------------------------------------------------------------------
  3928. */
  3929. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  3930. var _this11 = this;
  3931. var target;
  3932. var selector = Util.getSelectorFromElement(this);
  3933. if (selector) {
  3934. target = document.querySelector(selector);
  3935. }
  3936. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  3937. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3938. event.preventDefault();
  3939. }
  3940. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  3941. if (showEvent.isDefaultPrevented()) {
  3942. // Only register focus restorer if modal will actually get shown
  3943. return;
  3944. }
  3945. $target.one(Event$5.HIDDEN, function () {
  3946. if ($(_this11).is(':visible')) {
  3947. _this11.focus();
  3948. }
  3949. });
  3950. });
  3951. Modal._jQueryInterface.call($(target), config, this);
  3952. });
  3953. /**
  3954. * ------------------------------------------------------------------------
  3955. * jQuery
  3956. * ------------------------------------------------------------------------
  3957. */
  3958. $.fn[NAME$5] = Modal._jQueryInterface;
  3959. $.fn[NAME$5].Constructor = Modal;
  3960. $.fn[NAME$5].noConflict = function () {
  3961. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3962. return Modal._jQueryInterface;
  3963. };
  3964. /**
  3965. * --------------------------------------------------------------------------
  3966. * Bootstrap (v4.4.1): tools/sanitizer.js
  3967. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  3968. * --------------------------------------------------------------------------
  3969. */
  3970. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  3971. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  3972. var DefaultWhitelist = {
  3973. // Global attributes allowed on any supplied element below.
  3974. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  3975. a: ['target', 'href', 'title', 'rel'],
  3976. area: [],
  3977. b: [],
  3978. br: [],
  3979. col: [],
  3980. code: [],
  3981. div: [],
  3982. em: [],
  3983. hr: [],
  3984. h1: [],
  3985. h2: [],
  3986. h3: [],
  3987. h4: [],
  3988. h5: [],
  3989. h6: [],
  3990. i: [],
  3991. img: ['src', 'alt', 'title', 'width', 'height'],
  3992. li: [],
  3993. ol: [],
  3994. p: [],
  3995. pre: [],
  3996. s: [],
  3997. small: [],
  3998. span: [],
  3999. sub: [],
  4000. sup: [],
  4001. strong: [],
  4002. u: [],
  4003. ul: []
  4004. };
  4005. /**
  4006. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4007. *
  4008. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4009. */
  4010. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4011. /**
  4012. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4013. *
  4014. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4015. */
  4016. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
  4017. function allowedAttribute(attr, allowedAttributeList) {
  4018. var attrName = attr.nodeName.toLowerCase();
  4019. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4020. if (uriAttrs.indexOf(attrName) !== -1) {
  4021. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4022. }
  4023. return true;
  4024. }
  4025. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4026. return attrRegex instanceof RegExp;
  4027. }); // Check if a regular expression validates the attribute.
  4028. for (var i = 0, l = regExp.length; i < l; i++) {
  4029. if (attrName.match(regExp[i])) {
  4030. return true;
  4031. }
  4032. }
  4033. return false;
  4034. }
  4035. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4036. if (unsafeHtml.length === 0) {
  4037. return unsafeHtml;
  4038. }
  4039. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4040. return sanitizeFn(unsafeHtml);
  4041. }
  4042. var domParser = new window.DOMParser();
  4043. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4044. var whitelistKeys = Object.keys(whiteList);
  4045. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4046. var _loop = function _loop(i, len) {
  4047. var el = elements[i];
  4048. var elName = el.nodeName.toLowerCase();
  4049. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4050. el.parentNode.removeChild(el);
  4051. return "continue";
  4052. }
  4053. var attributeList = [].slice.call(el.attributes);
  4054. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4055. attributeList.forEach(function (attr) {
  4056. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4057. el.removeAttribute(attr.nodeName);
  4058. }
  4059. });
  4060. };
  4061. for (var i = 0, len = elements.length; i < len; i++) {
  4062. var _ret = _loop(i);
  4063. if (_ret === "continue") continue;
  4064. }
  4065. return createdDocument.body.innerHTML;
  4066. }
  4067. /**
  4068. * ------------------------------------------------------------------------
  4069. * Constants
  4070. * ------------------------------------------------------------------------
  4071. */
  4072. var NAME$6 = 'tooltip';
  4073. var VERSION$6 = '4.4.1';
  4074. var DATA_KEY$6 = 'bs.tooltip';
  4075. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4076. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4077. var CLASS_PREFIX = 'bs-tooltip';
  4078. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4079. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4080. var DefaultType$4 = {
  4081. animation: 'boolean',
  4082. template: 'string',
  4083. title: '(string|element|function)',
  4084. trigger: 'string',
  4085. delay: '(number|object)',
  4086. html: 'boolean',
  4087. selector: '(string|boolean)',
  4088. placement: '(string|function)',
  4089. offset: '(number|string|function)',
  4090. container: '(string|element|boolean)',
  4091. fallbackPlacement: '(string|array)',
  4092. boundary: '(string|element)',
  4093. sanitize: 'boolean',
  4094. sanitizeFn: '(null|function)',
  4095. whiteList: 'object',
  4096. popperConfig: '(null|object)'
  4097. };
  4098. var AttachmentMap$1 = {
  4099. AUTO: 'auto',
  4100. TOP: 'top',
  4101. RIGHT: 'right',
  4102. BOTTOM: 'bottom',
  4103. LEFT: 'left'
  4104. };
  4105. var Default$4 = {
  4106. animation: true,
  4107. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4108. trigger: 'hover focus',
  4109. title: '',
  4110. delay: 0,
  4111. html: false,
  4112. selector: false,
  4113. placement: 'top',
  4114. offset: 0,
  4115. container: false,
  4116. fallbackPlacement: 'flip',
  4117. boundary: 'scrollParent',
  4118. sanitize: true,
  4119. sanitizeFn: null,
  4120. whiteList: DefaultWhitelist,
  4121. popperConfig: null
  4122. };
  4123. var HoverState = {
  4124. SHOW: 'show',
  4125. OUT: 'out'
  4126. };
  4127. var Event$6 = {
  4128. HIDE: "hide" + EVENT_KEY$6,
  4129. HIDDEN: "hidden" + EVENT_KEY$6,
  4130. SHOW: "show" + EVENT_KEY$6,
  4131. SHOWN: "shown" + EVENT_KEY$6,
  4132. INSERTED: "inserted" + EVENT_KEY$6,
  4133. CLICK: "click" + EVENT_KEY$6,
  4134. FOCUSIN: "focusin" + EVENT_KEY$6,
  4135. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4136. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4137. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4138. };
  4139. var ClassName$6 = {
  4140. FADE: 'fade',
  4141. SHOW: 'show'
  4142. };
  4143. var Selector$6 = {
  4144. TOOLTIP: '.tooltip',
  4145. TOOLTIP_INNER: '.tooltip-inner',
  4146. ARROW: '.arrow'
  4147. };
  4148. var Trigger = {
  4149. HOVER: 'hover',
  4150. FOCUS: 'focus',
  4151. CLICK: 'click',
  4152. MANUAL: 'manual'
  4153. };
  4154. /**
  4155. * ------------------------------------------------------------------------
  4156. * Class Definition
  4157. * ------------------------------------------------------------------------
  4158. */
  4159. var Tooltip =
  4160. /*#__PURE__*/
  4161. function () {
  4162. function Tooltip(element, config) {
  4163. if (typeof Popper === 'undefined') {
  4164. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4165. } // private
  4166. this._isEnabled = true;
  4167. this._timeout = 0;
  4168. this._hoverState = '';
  4169. this._activeTrigger = {};
  4170. this._popper = null; // Protected
  4171. this.element = element;
  4172. this.config = this._getConfig(config);
  4173. this.tip = null;
  4174. this._setListeners();
  4175. } // Getters
  4176. var _proto = Tooltip.prototype;
  4177. // Public
  4178. _proto.enable = function enable() {
  4179. this._isEnabled = true;
  4180. };
  4181. _proto.disable = function disable() {
  4182. this._isEnabled = false;
  4183. };
  4184. _proto.toggleEnabled = function toggleEnabled() {
  4185. this._isEnabled = !this._isEnabled;
  4186. };
  4187. _proto.toggle = function toggle(event) {
  4188. if (!this._isEnabled) {
  4189. return;
  4190. }
  4191. if (event) {
  4192. var dataKey = this.constructor.DATA_KEY;
  4193. var context = $(event.currentTarget).data(dataKey);
  4194. if (!context) {
  4195. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4196. $(event.currentTarget).data(dataKey, context);
  4197. }
  4198. context._activeTrigger.click = !context._activeTrigger.click;
  4199. if (context._isWithActiveTrigger()) {
  4200. context._enter(null, context);
  4201. } else {
  4202. context._leave(null, context);
  4203. }
  4204. } else {
  4205. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4206. this._leave(null, this);
  4207. return;
  4208. }
  4209. this._enter(null, this);
  4210. }
  4211. };
  4212. _proto.dispose = function dispose() {
  4213. clearTimeout(this._timeout);
  4214. $.removeData(this.element, this.constructor.DATA_KEY);
  4215. $(this.element).off(this.constructor.EVENT_KEY);
  4216. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4217. if (this.tip) {
  4218. $(this.tip).remove();
  4219. }
  4220. this._isEnabled = null;
  4221. this._timeout = null;
  4222. this._hoverState = null;
  4223. this._activeTrigger = null;
  4224. if (this._popper) {
  4225. this._popper.destroy();
  4226. }
  4227. this._popper = null;
  4228. this.element = null;
  4229. this.config = null;
  4230. this.tip = null;
  4231. };
  4232. _proto.show = function show() {
  4233. var _this = this;
  4234. if ($(this.element).css('display') === 'none') {
  4235. throw new Error('Please use show on visible elements');
  4236. }
  4237. var showEvent = $.Event(this.constructor.Event.SHOW);
  4238. if (this.isWithContent() && this._isEnabled) {
  4239. $(this.element).trigger(showEvent);
  4240. var shadowRoot = Util.findShadowRoot(this.element);
  4241. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4242. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4243. return;
  4244. }
  4245. var tip = this.getTipElement();
  4246. var tipId = Util.getUID(this.constructor.NAME);
  4247. tip.setAttribute('id', tipId);
  4248. this.element.setAttribute('aria-describedby', tipId);
  4249. this.setContent();
  4250. if (this.config.animation) {
  4251. $(tip).addClass(ClassName$6.FADE);
  4252. }
  4253. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4254. var attachment = this._getAttachment(placement);
  4255. this.addAttachmentClass(attachment);
  4256. var container = this._getContainer();
  4257. $(tip).data(this.constructor.DATA_KEY, this);
  4258. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4259. $(tip).appendTo(container);
  4260. }
  4261. $(this.element).trigger(this.constructor.Event.INSERTED);
  4262. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4263. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4264. // empty mouseover listeners to the body's immediate children;
  4265. // only needed because of broken event delegation on iOS
  4266. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4267. if ('ontouchstart' in document.documentElement) {
  4268. $(document.body).children().on('mouseover', null, $.noop);
  4269. }
  4270. var complete = function complete() {
  4271. if (_this.config.animation) {
  4272. _this._fixTransition();
  4273. }
  4274. var prevHoverState = _this._hoverState;
  4275. _this._hoverState = null;
  4276. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4277. if (prevHoverState === HoverState.OUT) {
  4278. _this._leave(null, _this);
  4279. }
  4280. };
  4281. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4282. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4283. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4284. } else {
  4285. complete();
  4286. }
  4287. }
  4288. };
  4289. _proto.hide = function hide(callback) {
  4290. var _this2 = this;
  4291. var tip = this.getTipElement();
  4292. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4293. var complete = function complete() {
  4294. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4295. tip.parentNode.removeChild(tip);
  4296. }
  4297. _this2._cleanTipClass();
  4298. _this2.element.removeAttribute('aria-describedby');
  4299. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4300. if (_this2._popper !== null) {
  4301. _this2._popper.destroy();
  4302. }
  4303. if (callback) {
  4304. callback();
  4305. }
  4306. };
  4307. $(this.element).trigger(hideEvent);
  4308. if (hideEvent.isDefaultPrevented()) {
  4309. return;
  4310. }
  4311. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4312. // empty mouseover listeners we added for iOS support
  4313. if ('ontouchstart' in document.documentElement) {
  4314. $(document.body).children().off('mouseover', null, $.noop);
  4315. }
  4316. this._activeTrigger[Trigger.CLICK] = false;
  4317. this._activeTrigger[Trigger.FOCUS] = false;
  4318. this._activeTrigger[Trigger.HOVER] = false;
  4319. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4320. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4321. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4322. } else {
  4323. complete();
  4324. }
  4325. this._hoverState = '';
  4326. };
  4327. _proto.update = function update() {
  4328. if (this._popper !== null) {
  4329. this._popper.scheduleUpdate();
  4330. }
  4331. } // Protected
  4332. ;
  4333. _proto.isWithContent = function isWithContent() {
  4334. return Boolean(this.getTitle());
  4335. };
  4336. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4337. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4338. };
  4339. _proto.getTipElement = function getTipElement() {
  4340. this.tip = this.tip || $(this.config.template)[0];
  4341. return this.tip;
  4342. };
  4343. _proto.setContent = function setContent() {
  4344. var tip = this.getTipElement();
  4345. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4346. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4347. };
  4348. _proto.setElementContent = function setElementContent($element, content) {
  4349. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4350. // Content is a DOM node or a jQuery
  4351. if (this.config.html) {
  4352. if (!$(content).parent().is($element)) {
  4353. $element.empty().append(content);
  4354. }
  4355. } else {
  4356. $element.text($(content).text());
  4357. }
  4358. return;
  4359. }
  4360. if (this.config.html) {
  4361. if (this.config.sanitize) {
  4362. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4363. }
  4364. $element.html(content);
  4365. } else {
  4366. $element.text(content);
  4367. }
  4368. };
  4369. _proto.getTitle = function getTitle() {
  4370. var title = this.element.getAttribute('data-original-title');
  4371. if (!title) {
  4372. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4373. }
  4374. return title;
  4375. } // Private
  4376. ;
  4377. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4378. var _this3 = this;
  4379. var defaultBsConfig = {
  4380. placement: attachment,
  4381. modifiers: {
  4382. offset: this._getOffset(),
  4383. flip: {
  4384. behavior: this.config.fallbackPlacement
  4385. },
  4386. arrow: {
  4387. element: Selector$6.ARROW
  4388. },
  4389. preventOverflow: {
  4390. boundariesElement: this.config.boundary
  4391. }
  4392. },
  4393. onCreate: function onCreate(data) {
  4394. if (data.originalPlacement !== data.placement) {
  4395. _this3._handlePopperPlacementChange(data);
  4396. }
  4397. },
  4398. onUpdate: function onUpdate(data) {
  4399. return _this3._handlePopperPlacementChange(data);
  4400. }
  4401. };
  4402. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4403. };
  4404. _proto._getOffset = function _getOffset() {
  4405. var _this4 = this;
  4406. var offset = {};
  4407. if (typeof this.config.offset === 'function') {
  4408. offset.fn = function (data) {
  4409. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4410. return data;
  4411. };
  4412. } else {
  4413. offset.offset = this.config.offset;
  4414. }
  4415. return offset;
  4416. };
  4417. _proto._getContainer = function _getContainer() {
  4418. if (this.config.container === false) {
  4419. return document.body;
  4420. }
  4421. if (Util.isElement(this.config.container)) {
  4422. return $(this.config.container);
  4423. }
  4424. return $(document).find(this.config.container);
  4425. };
  4426. _proto._getAttachment = function _getAttachment(placement) {
  4427. return AttachmentMap$1[placement.toUpperCase()];
  4428. };
  4429. _proto._setListeners = function _setListeners() {
  4430. var _this5 = this;
  4431. var triggers = this.config.trigger.split(' ');
  4432. triggers.forEach(function (trigger) {
  4433. if (trigger === 'click') {
  4434. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4435. return _this5.toggle(event);
  4436. });
  4437. } else if (trigger !== Trigger.MANUAL) {
  4438. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4439. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4440. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4441. return _this5._enter(event);
  4442. }).on(eventOut, _this5.config.selector, function (event) {
  4443. return _this5._leave(event);
  4444. });
  4445. }
  4446. });
  4447. this._hideModalHandler = function () {
  4448. if (_this5.element) {
  4449. _this5.hide();
  4450. }
  4451. };
  4452. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4453. if (this.config.selector) {
  4454. this.config = _objectSpread2({}, this.config, {
  4455. trigger: 'manual',
  4456. selector: ''
  4457. });
  4458. } else {
  4459. this._fixTitle();
  4460. }
  4461. };
  4462. _proto._fixTitle = function _fixTitle() {
  4463. var titleType = typeof this.element.getAttribute('data-original-title');
  4464. if (this.element.getAttribute('title') || titleType !== 'string') {
  4465. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4466. this.element.setAttribute('title', '');
  4467. }
  4468. };
  4469. _proto._enter = function _enter(event, context) {
  4470. var dataKey = this.constructor.DATA_KEY;
  4471. context = context || $(event.currentTarget).data(dataKey);
  4472. if (!context) {
  4473. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4474. $(event.currentTarget).data(dataKey, context);
  4475. }
  4476. if (event) {
  4477. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4478. }
  4479. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4480. context._hoverState = HoverState.SHOW;
  4481. return;
  4482. }
  4483. clearTimeout(context._timeout);
  4484. context._hoverState = HoverState.SHOW;
  4485. if (!context.config.delay || !context.config.delay.show) {
  4486. context.show();
  4487. return;
  4488. }
  4489. context._timeout = setTimeout(function () {
  4490. if (context._hoverState === HoverState.SHOW) {
  4491. context.show();
  4492. }
  4493. }, context.config.delay.show);
  4494. };
  4495. _proto._leave = function _leave(event, context) {
  4496. var dataKey = this.constructor.DATA_KEY;
  4497. context = context || $(event.currentTarget).data(dataKey);
  4498. if (!context) {
  4499. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4500. $(event.currentTarget).data(dataKey, context);
  4501. }
  4502. if (event) {
  4503. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4504. }
  4505. if (context._isWithActiveTrigger()) {
  4506. return;
  4507. }
  4508. clearTimeout(context._timeout);
  4509. context._hoverState = HoverState.OUT;
  4510. if (!context.config.delay || !context.config.delay.hide) {
  4511. context.hide();
  4512. return;
  4513. }
  4514. context._timeout = setTimeout(function () {
  4515. if (context._hoverState === HoverState.OUT) {
  4516. context.hide();
  4517. }
  4518. }, context.config.delay.hide);
  4519. };
  4520. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4521. for (var trigger in this._activeTrigger) {
  4522. if (this._activeTrigger[trigger]) {
  4523. return true;
  4524. }
  4525. }
  4526. return false;
  4527. };
  4528. _proto._getConfig = function _getConfig(config) {
  4529. var dataAttributes = $(this.element).data();
  4530. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4531. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4532. delete dataAttributes[dataAttr];
  4533. }
  4534. });
  4535. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4536. if (typeof config.delay === 'number') {
  4537. config.delay = {
  4538. show: config.delay,
  4539. hide: config.delay
  4540. };
  4541. }
  4542. if (typeof config.title === 'number') {
  4543. config.title = config.title.toString();
  4544. }
  4545. if (typeof config.content === 'number') {
  4546. config.content = config.content.toString();
  4547. }
  4548. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4549. if (config.sanitize) {
  4550. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4551. }
  4552. return config;
  4553. };
  4554. _proto._getDelegateConfig = function _getDelegateConfig() {
  4555. var config = {};
  4556. if (this.config) {
  4557. for (var key in this.config) {
  4558. if (this.constructor.Default[key] !== this.config[key]) {
  4559. config[key] = this.config[key];
  4560. }
  4561. }
  4562. }
  4563. return config;
  4564. };
  4565. _proto._cleanTipClass = function _cleanTipClass() {
  4566. var $tip = $(this.getTipElement());
  4567. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4568. if (tabClass !== null && tabClass.length) {
  4569. $tip.removeClass(tabClass.join(''));
  4570. }
  4571. };
  4572. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4573. var popperInstance = popperData.instance;
  4574. this.tip = popperInstance.popper;
  4575. this._cleanTipClass();
  4576. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4577. };
  4578. _proto._fixTransition = function _fixTransition() {
  4579. var tip = this.getTipElement();
  4580. var initConfigAnimation = this.config.animation;
  4581. if (tip.getAttribute('x-placement') !== null) {
  4582. return;
  4583. }
  4584. $(tip).removeClass(ClassName$6.FADE);
  4585. this.config.animation = false;
  4586. this.hide();
  4587. this.show();
  4588. this.config.animation = initConfigAnimation;
  4589. } // Static
  4590. ;
  4591. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4592. return this.each(function () {
  4593. var data = $(this).data(DATA_KEY$6);
  4594. var _config = typeof config === 'object' && config;
  4595. if (!data && /dispose|hide/.test(config)) {
  4596. return;
  4597. }
  4598. if (!data) {
  4599. data = new Tooltip(this, _config);
  4600. $(this).data(DATA_KEY$6, data);
  4601. }
  4602. if (typeof config === 'string') {
  4603. if (typeof data[config] === 'undefined') {
  4604. throw new TypeError("No method named \"" + config + "\"");
  4605. }
  4606. data[config]();
  4607. }
  4608. });
  4609. };
  4610. _createClass(Tooltip, null, [{
  4611. key: "VERSION",
  4612. get: function get() {
  4613. return VERSION$6;
  4614. }
  4615. }, {
  4616. key: "Default",
  4617. get: function get() {
  4618. return Default$4;
  4619. }
  4620. }, {
  4621. key: "NAME",
  4622. get: function get() {
  4623. return NAME$6;
  4624. }
  4625. }, {
  4626. key: "DATA_KEY",
  4627. get: function get() {
  4628. return DATA_KEY$6;
  4629. }
  4630. }, {
  4631. key: "Event",
  4632. get: function get() {
  4633. return Event$6;
  4634. }
  4635. }, {
  4636. key: "EVENT_KEY",
  4637. get: function get() {
  4638. return EVENT_KEY$6;
  4639. }
  4640. }, {
  4641. key: "DefaultType",
  4642. get: function get() {
  4643. return DefaultType$4;
  4644. }
  4645. }]);
  4646. return Tooltip;
  4647. }();
  4648. /**
  4649. * ------------------------------------------------------------------------
  4650. * jQuery
  4651. * ------------------------------------------------------------------------
  4652. */
  4653. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4654. $.fn[NAME$6].Constructor = Tooltip;
  4655. $.fn[NAME$6].noConflict = function () {
  4656. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4657. return Tooltip._jQueryInterface;
  4658. };
  4659. /**
  4660. * ------------------------------------------------------------------------
  4661. * Constants
  4662. * ------------------------------------------------------------------------
  4663. */
  4664. var NAME$7 = 'popover';
  4665. var VERSION$7 = '4.4.1';
  4666. var DATA_KEY$7 = 'bs.popover';
  4667. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4668. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4669. var CLASS_PREFIX$1 = 'bs-popover';
  4670. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4671. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4672. placement: 'right',
  4673. trigger: 'click',
  4674. content: '',
  4675. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4676. });
  4677. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4678. content: '(string|element|function)'
  4679. });
  4680. var ClassName$7 = {
  4681. FADE: 'fade',
  4682. SHOW: 'show'
  4683. };
  4684. var Selector$7 = {
  4685. TITLE: '.popover-header',
  4686. CONTENT: '.popover-body'
  4687. };
  4688. var Event$7 = {
  4689. HIDE: "hide" + EVENT_KEY$7,
  4690. HIDDEN: "hidden" + EVENT_KEY$7,
  4691. SHOW: "show" + EVENT_KEY$7,
  4692. SHOWN: "shown" + EVENT_KEY$7,
  4693. INSERTED: "inserted" + EVENT_KEY$7,
  4694. CLICK: "click" + EVENT_KEY$7,
  4695. FOCUSIN: "focusin" + EVENT_KEY$7,
  4696. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4697. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4698. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4699. };
  4700. /**
  4701. * ------------------------------------------------------------------------
  4702. * Class Definition
  4703. * ------------------------------------------------------------------------
  4704. */
  4705. var Popover =
  4706. /*#__PURE__*/
  4707. function (_Tooltip) {
  4708. _inheritsLoose(Popover, _Tooltip);
  4709. function Popover() {
  4710. return _Tooltip.apply(this, arguments) || this;
  4711. }
  4712. var _proto = Popover.prototype;
  4713. // Overrides
  4714. _proto.isWithContent = function isWithContent() {
  4715. return this.getTitle() || this._getContent();
  4716. };
  4717. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4718. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4719. };
  4720. _proto.getTipElement = function getTipElement() {
  4721. this.tip = this.tip || $(this.config.template)[0];
  4722. return this.tip;
  4723. };
  4724. _proto.setContent = function setContent() {
  4725. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4726. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4727. var content = this._getContent();
  4728. if (typeof content === 'function') {
  4729. content = content.call(this.element);
  4730. }
  4731. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4732. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4733. } // Private
  4734. ;
  4735. _proto._getContent = function _getContent() {
  4736. return this.element.getAttribute('data-content') || this.config.content;
  4737. };
  4738. _proto._cleanTipClass = function _cleanTipClass() {
  4739. var $tip = $(this.getTipElement());
  4740. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4741. if (tabClass !== null && tabClass.length > 0) {
  4742. $tip.removeClass(tabClass.join(''));
  4743. }
  4744. } // Static
  4745. ;
  4746. Popover._jQueryInterface = function _jQueryInterface(config) {
  4747. return this.each(function () {
  4748. var data = $(this).data(DATA_KEY$7);
  4749. var _config = typeof config === 'object' ? config : null;
  4750. if (!data && /dispose|hide/.test(config)) {
  4751. return;
  4752. }
  4753. if (!data) {
  4754. data = new Popover(this, _config);
  4755. $(this).data(DATA_KEY$7, data);
  4756. }
  4757. if (typeof config === 'string') {
  4758. if (typeof data[config] === 'undefined') {
  4759. throw new TypeError("No method named \"" + config + "\"");
  4760. }
  4761. data[config]();
  4762. }
  4763. });
  4764. };
  4765. _createClass(Popover, null, [{
  4766. key: "VERSION",
  4767. // Getters
  4768. get: function get() {
  4769. return VERSION$7;
  4770. }
  4771. }, {
  4772. key: "Default",
  4773. get: function get() {
  4774. return Default$5;
  4775. }
  4776. }, {
  4777. key: "NAME",
  4778. get: function get() {
  4779. return NAME$7;
  4780. }
  4781. }, {
  4782. key: "DATA_KEY",
  4783. get: function get() {
  4784. return DATA_KEY$7;
  4785. }
  4786. }, {
  4787. key: "Event",
  4788. get: function get() {
  4789. return Event$7;
  4790. }
  4791. }, {
  4792. key: "EVENT_KEY",
  4793. get: function get() {
  4794. return EVENT_KEY$7;
  4795. }
  4796. }, {
  4797. key: "DefaultType",
  4798. get: function get() {
  4799. return DefaultType$5;
  4800. }
  4801. }]);
  4802. return Popover;
  4803. }(Tooltip);
  4804. /**
  4805. * ------------------------------------------------------------------------
  4806. * jQuery
  4807. * ------------------------------------------------------------------------
  4808. */
  4809. $.fn[NAME$7] = Popover._jQueryInterface;
  4810. $.fn[NAME$7].Constructor = Popover;
  4811. $.fn[NAME$7].noConflict = function () {
  4812. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4813. return Popover._jQueryInterface;
  4814. };
  4815. /**
  4816. * ------------------------------------------------------------------------
  4817. * Constants
  4818. * ------------------------------------------------------------------------
  4819. */
  4820. var NAME$8 = 'scrollspy';
  4821. var VERSION$8 = '4.4.1';
  4822. var DATA_KEY$8 = 'bs.scrollspy';
  4823. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4824. var DATA_API_KEY$6 = '.data-api';
  4825. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4826. var Default$6 = {
  4827. offset: 10,
  4828. method: 'auto',
  4829. target: ''
  4830. };
  4831. var DefaultType$6 = {
  4832. offset: 'number',
  4833. method: 'string',
  4834. target: '(string|element)'
  4835. };
  4836. var Event$8 = {
  4837. ACTIVATE: "activate" + EVENT_KEY$8,
  4838. SCROLL: "scroll" + EVENT_KEY$8,
  4839. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4840. };
  4841. var ClassName$8 = {
  4842. DROPDOWN_ITEM: 'dropdown-item',
  4843. DROPDOWN_MENU: 'dropdown-menu',
  4844. ACTIVE: 'active'
  4845. };
  4846. var Selector$8 = {
  4847. DATA_SPY: '[data-spy="scroll"]',
  4848. ACTIVE: '.active',
  4849. NAV_LIST_GROUP: '.nav, .list-group',
  4850. NAV_LINKS: '.nav-link',
  4851. NAV_ITEMS: '.nav-item',
  4852. LIST_ITEMS: '.list-group-item',
  4853. DROPDOWN: '.dropdown',
  4854. DROPDOWN_ITEMS: '.dropdown-item',
  4855. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4856. };
  4857. var OffsetMethod = {
  4858. OFFSET: 'offset',
  4859. POSITION: 'position'
  4860. };
  4861. /**
  4862. * ------------------------------------------------------------------------
  4863. * Class Definition
  4864. * ------------------------------------------------------------------------
  4865. */
  4866. var ScrollSpy =
  4867. /*#__PURE__*/
  4868. function () {
  4869. function ScrollSpy(element, config) {
  4870. var _this = this;
  4871. this._element = element;
  4872. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4873. this._config = this._getConfig(config);
  4874. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  4875. this._offsets = [];
  4876. this._targets = [];
  4877. this._activeTarget = null;
  4878. this._scrollHeight = 0;
  4879. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  4880. return _this._process(event);
  4881. });
  4882. this.refresh();
  4883. this._process();
  4884. } // Getters
  4885. var _proto = ScrollSpy.prototype;
  4886. // Public
  4887. _proto.refresh = function refresh() {
  4888. var _this2 = this;
  4889. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  4890. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4891. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  4892. this._offsets = [];
  4893. this._targets = [];
  4894. this._scrollHeight = this._getScrollHeight();
  4895. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4896. targets.map(function (element) {
  4897. var target;
  4898. var targetSelector = Util.getSelectorFromElement(element);
  4899. if (targetSelector) {
  4900. target = document.querySelector(targetSelector);
  4901. }
  4902. if (target) {
  4903. var targetBCR = target.getBoundingClientRect();
  4904. if (targetBCR.width || targetBCR.height) {
  4905. // TODO (fat): remove sketch reliance on jQuery position/offset
  4906. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4907. }
  4908. }
  4909. return null;
  4910. }).filter(function (item) {
  4911. return item;
  4912. }).sort(function (a, b) {
  4913. return a[0] - b[0];
  4914. }).forEach(function (item) {
  4915. _this2._offsets.push(item[0]);
  4916. _this2._targets.push(item[1]);
  4917. });
  4918. };
  4919. _proto.dispose = function dispose() {
  4920. $.removeData(this._element, DATA_KEY$8);
  4921. $(this._scrollElement).off(EVENT_KEY$8);
  4922. this._element = null;
  4923. this._scrollElement = null;
  4924. this._config = null;
  4925. this._selector = null;
  4926. this._offsets = null;
  4927. this._targets = null;
  4928. this._activeTarget = null;
  4929. this._scrollHeight = null;
  4930. } // Private
  4931. ;
  4932. _proto._getConfig = function _getConfig(config) {
  4933. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  4934. if (typeof config.target !== 'string') {
  4935. var id = $(config.target).attr('id');
  4936. if (!id) {
  4937. id = Util.getUID(NAME$8);
  4938. $(config.target).attr('id', id);
  4939. }
  4940. config.target = "#" + id;
  4941. }
  4942. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4943. return config;
  4944. };
  4945. _proto._getScrollTop = function _getScrollTop() {
  4946. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4947. };
  4948. _proto._getScrollHeight = function _getScrollHeight() {
  4949. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4950. };
  4951. _proto._getOffsetHeight = function _getOffsetHeight() {
  4952. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4953. };
  4954. _proto._process = function _process() {
  4955. var scrollTop = this._getScrollTop() + this._config.offset;
  4956. var scrollHeight = this._getScrollHeight();
  4957. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4958. if (this._scrollHeight !== scrollHeight) {
  4959. this.refresh();
  4960. }
  4961. if (scrollTop >= maxScroll) {
  4962. var target = this._targets[this._targets.length - 1];
  4963. if (this._activeTarget !== target) {
  4964. this._activate(target);
  4965. }
  4966. return;
  4967. }
  4968. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  4969. this._activeTarget = null;
  4970. this._clear();
  4971. return;
  4972. }
  4973. var offsetLength = this._offsets.length;
  4974. for (var i = offsetLength; i--;) {
  4975. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  4976. if (isActiveTarget) {
  4977. this._activate(this._targets[i]);
  4978. }
  4979. }
  4980. };
  4981. _proto._activate = function _activate(target) {
  4982. this._activeTarget = target;
  4983. this._clear();
  4984. var queries = this._selector.split(',').map(function (selector) {
  4985. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  4986. });
  4987. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  4988. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  4989. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  4990. $link.addClass(ClassName$8.ACTIVE);
  4991. } else {
  4992. // Set triggered link as active
  4993. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  4994. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  4995. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); // Handle special case when .nav-link is inside .nav-item
  4996. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  4997. }
  4998. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  4999. relatedTarget: target
  5000. });
  5001. };
  5002. _proto._clear = function _clear() {
  5003. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5004. return node.classList.contains(ClassName$8.ACTIVE);
  5005. }).forEach(function (node) {
  5006. return node.classList.remove(ClassName$8.ACTIVE);
  5007. });
  5008. } // Static
  5009. ;
  5010. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5011. return this.each(function () {
  5012. var data = $(this).data(DATA_KEY$8);
  5013. var _config = typeof config === 'object' && config;
  5014. if (!data) {
  5015. data = new ScrollSpy(this, _config);
  5016. $(this).data(DATA_KEY$8, data);
  5017. }
  5018. if (typeof config === 'string') {
  5019. if (typeof data[config] === 'undefined') {
  5020. throw new TypeError("No method named \"" + config + "\"");
  5021. }
  5022. data[config]();
  5023. }
  5024. });
  5025. };
  5026. _createClass(ScrollSpy, null, [{
  5027. key: "VERSION",
  5028. get: function get() {
  5029. return VERSION$8;
  5030. }
  5031. }, {
  5032. key: "Default",
  5033. get: function get() {
  5034. return Default$6;
  5035. }
  5036. }]);
  5037. return ScrollSpy;
  5038. }();
  5039. /**
  5040. * ------------------------------------------------------------------------
  5041. * Data Api implementation
  5042. * ------------------------------------------------------------------------
  5043. */
  5044. $(window).on(Event$8.LOAD_DATA_API, function () {
  5045. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5046. var scrollSpysLength = scrollSpys.length;
  5047. for (var i = scrollSpysLength; i--;) {
  5048. var $spy = $(scrollSpys[i]);
  5049. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5050. }
  5051. });
  5052. /**
  5053. * ------------------------------------------------------------------------
  5054. * jQuery
  5055. * ------------------------------------------------------------------------
  5056. */
  5057. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5058. $.fn[NAME$8].Constructor = ScrollSpy;
  5059. $.fn[NAME$8].noConflict = function () {
  5060. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5061. return ScrollSpy._jQueryInterface;
  5062. };
  5063. /**
  5064. * ------------------------------------------------------------------------
  5065. * Constants
  5066. * ------------------------------------------------------------------------
  5067. */
  5068. var NAME$9 = 'tab';
  5069. var VERSION$9 = '4.4.1';
  5070. var DATA_KEY$9 = 'bs.tab';
  5071. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5072. var DATA_API_KEY$7 = '.data-api';
  5073. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5074. var Event$9 = {
  5075. HIDE: "hide" + EVENT_KEY$9,
  5076. HIDDEN: "hidden" + EVENT_KEY$9,
  5077. SHOW: "show" + EVENT_KEY$9,
  5078. SHOWN: "shown" + EVENT_KEY$9,
  5079. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5080. };
  5081. var ClassName$9 = {
  5082. DROPDOWN_MENU: 'dropdown-menu',
  5083. ACTIVE: 'active',
  5084. DISABLED: 'disabled',
  5085. FADE: 'fade',
  5086. SHOW: 'show'
  5087. };
  5088. var Selector$9 = {
  5089. DROPDOWN: '.dropdown',
  5090. NAV_LIST_GROUP: '.nav, .list-group',
  5091. ACTIVE: '.active',
  5092. ACTIVE_UL: '> li > .active',
  5093. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5094. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5095. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5096. };
  5097. /**
  5098. * ------------------------------------------------------------------------
  5099. * Class Definition
  5100. * ------------------------------------------------------------------------
  5101. */
  5102. var Tab =
  5103. /*#__PURE__*/
  5104. function () {
  5105. function Tab(element) {
  5106. this._element = element;
  5107. } // Getters
  5108. var _proto = Tab.prototype;
  5109. // Public
  5110. _proto.show = function show() {
  5111. var _this = this;
  5112. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5113. return;
  5114. }
  5115. var target;
  5116. var previous;
  5117. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5118. var selector = Util.getSelectorFromElement(this._element);
  5119. if (listElement) {
  5120. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5121. previous = $.makeArray($(listElement).find(itemSelector));
  5122. previous = previous[previous.length - 1];
  5123. }
  5124. var hideEvent = $.Event(Event$9.HIDE, {
  5125. relatedTarget: this._element
  5126. });
  5127. var showEvent = $.Event(Event$9.SHOW, {
  5128. relatedTarget: previous
  5129. });
  5130. if (previous) {
  5131. $(previous).trigger(hideEvent);
  5132. }
  5133. $(this._element).trigger(showEvent);
  5134. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5135. return;
  5136. }
  5137. if (selector) {
  5138. target = document.querySelector(selector);
  5139. }
  5140. this._activate(this._element, listElement);
  5141. var complete = function complete() {
  5142. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5143. relatedTarget: _this._element
  5144. });
  5145. var shownEvent = $.Event(Event$9.SHOWN, {
  5146. relatedTarget: previous
  5147. });
  5148. $(previous).trigger(hiddenEvent);
  5149. $(_this._element).trigger(shownEvent);
  5150. };
  5151. if (target) {
  5152. this._activate(target, target.parentNode, complete);
  5153. } else {
  5154. complete();
  5155. }
  5156. };
  5157. _proto.dispose = function dispose() {
  5158. $.removeData(this._element, DATA_KEY$9);
  5159. this._element = null;
  5160. } // Private
  5161. ;
  5162. _proto._activate = function _activate(element, container, callback) {
  5163. var _this2 = this;
  5164. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5165. var active = activeElements[0];
  5166. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5167. var complete = function complete() {
  5168. return _this2._transitionComplete(element, active, callback);
  5169. };
  5170. if (active && isTransitioning) {
  5171. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5172. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5173. } else {
  5174. complete();
  5175. }
  5176. };
  5177. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5178. if (active) {
  5179. $(active).removeClass(ClassName$9.ACTIVE);
  5180. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5181. if (dropdownChild) {
  5182. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5183. }
  5184. if (active.getAttribute('role') === 'tab') {
  5185. active.setAttribute('aria-selected', false);
  5186. }
  5187. }
  5188. $(element).addClass(ClassName$9.ACTIVE);
  5189. if (element.getAttribute('role') === 'tab') {
  5190. element.setAttribute('aria-selected', true);
  5191. }
  5192. Util.reflow(element);
  5193. if (element.classList.contains(ClassName$9.FADE)) {
  5194. element.classList.add(ClassName$9.SHOW);
  5195. }
  5196. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5197. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5198. if (dropdownElement) {
  5199. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5200. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5201. }
  5202. element.setAttribute('aria-expanded', true);
  5203. }
  5204. if (callback) {
  5205. callback();
  5206. }
  5207. } // Static
  5208. ;
  5209. Tab._jQueryInterface = function _jQueryInterface(config) {
  5210. return this.each(function () {
  5211. var $this = $(this);
  5212. var data = $this.data(DATA_KEY$9);
  5213. if (!data) {
  5214. data = new Tab(this);
  5215. $this.data(DATA_KEY$9, data);
  5216. }
  5217. if (typeof config === 'string') {
  5218. if (typeof data[config] === 'undefined') {
  5219. throw new TypeError("No method named \"" + config + "\"");
  5220. }
  5221. data[config]();
  5222. }
  5223. });
  5224. };
  5225. _createClass(Tab, null, [{
  5226. key: "VERSION",
  5227. get: function get() {
  5228. return VERSION$9;
  5229. }
  5230. }]);
  5231. return Tab;
  5232. }();
  5233. /**
  5234. * ------------------------------------------------------------------------
  5235. * Data Api implementation
  5236. * ------------------------------------------------------------------------
  5237. */
  5238. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5239. event.preventDefault();
  5240. Tab._jQueryInterface.call($(this), 'show');
  5241. });
  5242. /**
  5243. * ------------------------------------------------------------------------
  5244. * jQuery
  5245. * ------------------------------------------------------------------------
  5246. */
  5247. $.fn[NAME$9] = Tab._jQueryInterface;
  5248. $.fn[NAME$9].Constructor = Tab;
  5249. $.fn[NAME$9].noConflict = function () {
  5250. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5251. return Tab._jQueryInterface;
  5252. };
  5253. /**
  5254. * ------------------------------------------------------------------------
  5255. * Constants
  5256. * ------------------------------------------------------------------------
  5257. */
  5258. var NAME$a = 'toast';
  5259. var VERSION$a = '4.4.1';
  5260. var DATA_KEY$a = 'bs.toast';
  5261. var EVENT_KEY$a = "." + DATA_KEY$a;
  5262. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5263. var Event$a = {
  5264. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5265. HIDE: "hide" + EVENT_KEY$a,
  5266. HIDDEN: "hidden" + EVENT_KEY$a,
  5267. SHOW: "show" + EVENT_KEY$a,
  5268. SHOWN: "shown" + EVENT_KEY$a
  5269. };
  5270. var ClassName$a = {
  5271. FADE: 'fade',
  5272. HIDE: 'hide',
  5273. SHOW: 'show',
  5274. SHOWING: 'showing'
  5275. };
  5276. var DefaultType$7 = {
  5277. animation: 'boolean',
  5278. autohide: 'boolean',
  5279. delay: 'number'
  5280. };
  5281. var Default$7 = {
  5282. animation: true,
  5283. autohide: true,
  5284. delay: 500
  5285. };
  5286. var Selector$a = {
  5287. DATA_DISMISS: '[data-dismiss="toast"]'
  5288. };
  5289. /**
  5290. * ------------------------------------------------------------------------
  5291. * Class Definition
  5292. * ------------------------------------------------------------------------
  5293. */
  5294. var Toast =
  5295. /*#__PURE__*/
  5296. function () {
  5297. function Toast(element, config) {
  5298. this._element = element;
  5299. this._config = this._getConfig(config);
  5300. this._timeout = null;
  5301. this._setListeners();
  5302. } // Getters
  5303. var _proto = Toast.prototype;
  5304. // Public
  5305. _proto.show = function show() {
  5306. var _this = this;
  5307. var showEvent = $.Event(Event$a.SHOW);
  5308. $(this._element).trigger(showEvent);
  5309. if (showEvent.isDefaultPrevented()) {
  5310. return;
  5311. }
  5312. if (this._config.animation) {
  5313. this._element.classList.add(ClassName$a.FADE);
  5314. }
  5315. var complete = function complete() {
  5316. _this._element.classList.remove(ClassName$a.SHOWING);
  5317. _this._element.classList.add(ClassName$a.SHOW);
  5318. $(_this._element).trigger(Event$a.SHOWN);
  5319. if (_this._config.autohide) {
  5320. _this._timeout = setTimeout(function () {
  5321. _this.hide();
  5322. }, _this._config.delay);
  5323. }
  5324. };
  5325. this._element.classList.remove(ClassName$a.HIDE);
  5326. Util.reflow(this._element);
  5327. this._element.classList.add(ClassName$a.SHOWING);
  5328. if (this._config.animation) {
  5329. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5330. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5331. } else {
  5332. complete();
  5333. }
  5334. };
  5335. _proto.hide = function hide() {
  5336. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5337. return;
  5338. }
  5339. var hideEvent = $.Event(Event$a.HIDE);
  5340. $(this._element).trigger(hideEvent);
  5341. if (hideEvent.isDefaultPrevented()) {
  5342. return;
  5343. }
  5344. this._close();
  5345. };
  5346. _proto.dispose = function dispose() {
  5347. clearTimeout(this._timeout);
  5348. this._timeout = null;
  5349. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5350. this._element.classList.remove(ClassName$a.SHOW);
  5351. }
  5352. $(this._element).off(Event$a.CLICK_DISMISS);
  5353. $.removeData(this._element, DATA_KEY$a);
  5354. this._element = null;
  5355. this._config = null;
  5356. } // Private
  5357. ;
  5358. _proto._getConfig = function _getConfig(config) {
  5359. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5360. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5361. return config;
  5362. };
  5363. _proto._setListeners = function _setListeners() {
  5364. var _this2 = this;
  5365. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5366. return _this2.hide();
  5367. });
  5368. };
  5369. _proto._close = function _close() {
  5370. var _this3 = this;
  5371. var complete = function complete() {
  5372. _this3._element.classList.add(ClassName$a.HIDE);
  5373. $(_this3._element).trigger(Event$a.HIDDEN);
  5374. };
  5375. this._element.classList.remove(ClassName$a.SHOW);
  5376. if (this._config.animation) {
  5377. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5378. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5379. } else {
  5380. complete();
  5381. }
  5382. } // Static
  5383. ;
  5384. Toast._jQueryInterface = function _jQueryInterface(config) {
  5385. return this.each(function () {
  5386. var $element = $(this);
  5387. var data = $element.data(DATA_KEY$a);
  5388. var _config = typeof config === 'object' && config;
  5389. if (!data) {
  5390. data = new Toast(this, _config);
  5391. $element.data(DATA_KEY$a, data);
  5392. }
  5393. if (typeof config === 'string') {
  5394. if (typeof data[config] === 'undefined') {
  5395. throw new TypeError("No method named \"" + config + "\"");
  5396. }
  5397. data[config](this);
  5398. }
  5399. });
  5400. };
  5401. _createClass(Toast, null, [{
  5402. key: "VERSION",
  5403. get: function get() {
  5404. return VERSION$a;
  5405. }
  5406. }, {
  5407. key: "DefaultType",
  5408. get: function get() {
  5409. return DefaultType$7;
  5410. }
  5411. }, {
  5412. key: "Default",
  5413. get: function get() {
  5414. return Default$7;
  5415. }
  5416. }]);
  5417. return Toast;
  5418. }();
  5419. /**
  5420. * ------------------------------------------------------------------------
  5421. * jQuery
  5422. * ------------------------------------------------------------------------
  5423. */
  5424. $.fn[NAME$a] = Toast._jQueryInterface;
  5425. $.fn[NAME$a].Constructor = Toast;
  5426. $.fn[NAME$a].noConflict = function () {
  5427. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5428. return Toast._jQueryInterface;
  5429. };
  5430. exports.Alert = Alert;
  5431. exports.Button = Button;
  5432. exports.Carousel = Carousel;
  5433. exports.Collapse = Collapse;
  5434. exports.Dropdown = Dropdown;
  5435. exports.Modal = Modal;
  5436. exports.Popover = Popover;
  5437. exports.Scrollspy = ScrollSpy;
  5438. exports.Tab = Tab;
  5439. exports.Toast = Toast;
  5440. exports.Tooltip = Tooltip;
  5441. exports.Util = Util;
  5442. Object.defineProperty(exports, '__esModule', { value: true });
  5443. })));
  5444. //# sourceMappingURL=bootstrap.js.map
  5445. /***/ }),
  5446. /***/ "./node_modules/buffer/index.js":
  5447. /*!**************************************!*\
  5448. !*** ./node_modules/buffer/index.js ***!
  5449. \**************************************/
  5450. /*! no static exports found */
  5451. /***/ (function(module, exports, __webpack_require__) {
  5452. "use strict";
  5453. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5454. * The buffer module from node.js, for the browser.
  5455. *
  5456. * @author Feross Aboukhadijeh <http://feross.org>
  5457. * @license MIT
  5458. */
  5459. /* eslint-disable no-proto */
  5460. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5461. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5462. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5463. exports.Buffer = Buffer
  5464. exports.SlowBuffer = SlowBuffer
  5465. exports.INSPECT_MAX_BYTES = 50
  5466. /**
  5467. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5468. * === true Use Uint8Array implementation (fastest)
  5469. * === false Use Object implementation (most compatible, even IE6)
  5470. *
  5471. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5472. * Opera 11.6+, iOS 4.2+.
  5473. *
  5474. * Due to various browser bugs, sometimes the Object implementation will be used even
  5475. * when the browser supports typed arrays.
  5476. *
  5477. * Note:
  5478. *
  5479. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5480. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5481. *
  5482. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5483. *
  5484. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5485. * incorrect length in some situations.
  5486. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5487. * get the Object implementation, which is slower but behaves correctly.
  5488. */
  5489. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5490. ? global.TYPED_ARRAY_SUPPORT
  5491. : typedArraySupport()
  5492. /*
  5493. * Export kMaxLength after typed array support is determined.
  5494. */
  5495. exports.kMaxLength = kMaxLength()
  5496. function typedArraySupport () {
  5497. try {
  5498. var arr = new Uint8Array(1)
  5499. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5500. return arr.foo() === 42 && // typed array instances can be augmented
  5501. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5502. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5503. } catch (e) {
  5504. return false
  5505. }
  5506. }
  5507. function kMaxLength () {
  5508. return Buffer.TYPED_ARRAY_SUPPORT
  5509. ? 0x7fffffff
  5510. : 0x3fffffff
  5511. }
  5512. function createBuffer (that, length) {
  5513. if (kMaxLength() < length) {
  5514. throw new RangeError('Invalid typed array length')
  5515. }
  5516. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5517. // Return an augmented `Uint8Array` instance, for best performance
  5518. that = new Uint8Array(length)
  5519. that.__proto__ = Buffer.prototype
  5520. } else {
  5521. // Fallback: Return an object instance of the Buffer class
  5522. if (that === null) {
  5523. that = new Buffer(length)
  5524. }
  5525. that.length = length
  5526. }
  5527. return that
  5528. }
  5529. /**
  5530. * The Buffer constructor returns instances of `Uint8Array` that have their
  5531. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5532. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5533. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5534. * returns a single octet.
  5535. *
  5536. * The `Uint8Array` prototype remains unmodified.
  5537. */
  5538. function Buffer (arg, encodingOrOffset, length) {
  5539. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5540. return new Buffer(arg, encodingOrOffset, length)
  5541. }
  5542. // Common case.
  5543. if (typeof arg === 'number') {
  5544. if (typeof encodingOrOffset === 'string') {
  5545. throw new Error(
  5546. 'If encoding is specified then the first argument must be a string'
  5547. )
  5548. }
  5549. return allocUnsafe(this, arg)
  5550. }
  5551. return from(this, arg, encodingOrOffset, length)
  5552. }
  5553. Buffer.poolSize = 8192 // not used by this implementation
  5554. // TODO: Legacy, not needed anymore. Remove in next major version.
  5555. Buffer._augment = function (arr) {
  5556. arr.__proto__ = Buffer.prototype
  5557. return arr
  5558. }
  5559. function from (that, value, encodingOrOffset, length) {
  5560. if (typeof value === 'number') {
  5561. throw new TypeError('"value" argument must not be a number')
  5562. }
  5563. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5564. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5565. }
  5566. if (typeof value === 'string') {
  5567. return fromString(that, value, encodingOrOffset)
  5568. }
  5569. return fromObject(that, value)
  5570. }
  5571. /**
  5572. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5573. * if value is a number.
  5574. * Buffer.from(str[, encoding])
  5575. * Buffer.from(array)
  5576. * Buffer.from(buffer)
  5577. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5578. **/
  5579. Buffer.from = function (value, encodingOrOffset, length) {
  5580. return from(null, value, encodingOrOffset, length)
  5581. }
  5582. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5583. Buffer.prototype.__proto__ = Uint8Array.prototype
  5584. Buffer.__proto__ = Uint8Array
  5585. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5586. Buffer[Symbol.species] === Buffer) {
  5587. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5588. Object.defineProperty(Buffer, Symbol.species, {
  5589. value: null,
  5590. configurable: true
  5591. })
  5592. }
  5593. }
  5594. function assertSize (size) {
  5595. if (typeof size !== 'number') {
  5596. throw new TypeError('"size" argument must be a number')
  5597. } else if (size < 0) {
  5598. throw new RangeError('"size" argument must not be negative')
  5599. }
  5600. }
  5601. function alloc (that, size, fill, encoding) {
  5602. assertSize(size)
  5603. if (size <= 0) {
  5604. return createBuffer(that, size)
  5605. }
  5606. if (fill !== undefined) {
  5607. // Only pay attention to encoding if it's a string. This
  5608. // prevents accidentally sending in a number that would
  5609. // be interpretted as a start offset.
  5610. return typeof encoding === 'string'
  5611. ? createBuffer(that, size).fill(fill, encoding)
  5612. : createBuffer(that, size).fill(fill)
  5613. }
  5614. return createBuffer(that, size)
  5615. }
  5616. /**
  5617. * Creates a new filled Buffer instance.
  5618. * alloc(size[, fill[, encoding]])
  5619. **/
  5620. Buffer.alloc = function (size, fill, encoding) {
  5621. return alloc(null, size, fill, encoding)
  5622. }
  5623. function allocUnsafe (that, size) {
  5624. assertSize(size)
  5625. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5626. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5627. for (var i = 0; i < size; ++i) {
  5628. that[i] = 0
  5629. }
  5630. }
  5631. return that
  5632. }
  5633. /**
  5634. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5635. * */
  5636. Buffer.allocUnsafe = function (size) {
  5637. return allocUnsafe(null, size)
  5638. }
  5639. /**
  5640. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5641. */
  5642. Buffer.allocUnsafeSlow = function (size) {
  5643. return allocUnsafe(null, size)
  5644. }
  5645. function fromString (that, string, encoding) {
  5646. if (typeof encoding !== 'string' || encoding === '') {
  5647. encoding = 'utf8'
  5648. }
  5649. if (!Buffer.isEncoding(encoding)) {
  5650. throw new TypeError('"encoding" must be a valid string encoding')
  5651. }
  5652. var length = byteLength(string, encoding) | 0
  5653. that = createBuffer(that, length)
  5654. var actual = that.write(string, encoding)
  5655. if (actual !== length) {
  5656. // Writing a hex string, for example, that contains invalid characters will
  5657. // cause everything after the first invalid character to be ignored. (e.g.
  5658. // 'abxxcd' will be treated as 'ab')
  5659. that = that.slice(0, actual)
  5660. }
  5661. return that
  5662. }
  5663. function fromArrayLike (that, array) {
  5664. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5665. that = createBuffer(that, length)
  5666. for (var i = 0; i < length; i += 1) {
  5667. that[i] = array[i] & 255
  5668. }
  5669. return that
  5670. }
  5671. function fromArrayBuffer (that, array, byteOffset, length) {
  5672. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5673. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5674. throw new RangeError('\'offset\' is out of bounds')
  5675. }
  5676. if (array.byteLength < byteOffset + (length || 0)) {
  5677. throw new RangeError('\'length\' is out of bounds')
  5678. }
  5679. if (byteOffset === undefined && length === undefined) {
  5680. array = new Uint8Array(array)
  5681. } else if (length === undefined) {
  5682. array = new Uint8Array(array, byteOffset)
  5683. } else {
  5684. array = new Uint8Array(array, byteOffset, length)
  5685. }
  5686. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5687. // Return an augmented `Uint8Array` instance, for best performance
  5688. that = array
  5689. that.__proto__ = Buffer.prototype
  5690. } else {
  5691. // Fallback: Return an object instance of the Buffer class
  5692. that = fromArrayLike(that, array)
  5693. }
  5694. return that
  5695. }
  5696. function fromObject (that, obj) {
  5697. if (Buffer.isBuffer(obj)) {
  5698. var len = checked(obj.length) | 0
  5699. that = createBuffer(that, len)
  5700. if (that.length === 0) {
  5701. return that
  5702. }
  5703. obj.copy(that, 0, 0, len)
  5704. return that
  5705. }
  5706. if (obj) {
  5707. if ((typeof ArrayBuffer !== 'undefined' &&
  5708. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5709. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5710. return createBuffer(that, 0)
  5711. }
  5712. return fromArrayLike(that, obj)
  5713. }
  5714. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5715. return fromArrayLike(that, obj.data)
  5716. }
  5717. }
  5718. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5719. }
  5720. function checked (length) {
  5721. // Note: cannot use `length < kMaxLength()` here because that fails when
  5722. // length is NaN (which is otherwise coerced to zero.)
  5723. if (length >= kMaxLength()) {
  5724. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5725. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5726. }
  5727. return length | 0
  5728. }
  5729. function SlowBuffer (length) {
  5730. if (+length != length) { // eslint-disable-line eqeqeq
  5731. length = 0
  5732. }
  5733. return Buffer.alloc(+length)
  5734. }
  5735. Buffer.isBuffer = function isBuffer (b) {
  5736. return !!(b != null && b._isBuffer)
  5737. }
  5738. Buffer.compare = function compare (a, b) {
  5739. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5740. throw new TypeError('Arguments must be Buffers')
  5741. }
  5742. if (a === b) return 0
  5743. var x = a.length
  5744. var y = b.length
  5745. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5746. if (a[i] !== b[i]) {
  5747. x = a[i]
  5748. y = b[i]
  5749. break
  5750. }
  5751. }
  5752. if (x < y) return -1
  5753. if (y < x) return 1
  5754. return 0
  5755. }
  5756. Buffer.isEncoding = function isEncoding (encoding) {
  5757. switch (String(encoding).toLowerCase()) {
  5758. case 'hex':
  5759. case 'utf8':
  5760. case 'utf-8':
  5761. case 'ascii':
  5762. case 'latin1':
  5763. case 'binary':
  5764. case 'base64':
  5765. case 'ucs2':
  5766. case 'ucs-2':
  5767. case 'utf16le':
  5768. case 'utf-16le':
  5769. return true
  5770. default:
  5771. return false
  5772. }
  5773. }
  5774. Buffer.concat = function concat (list, length) {
  5775. if (!isArray(list)) {
  5776. throw new TypeError('"list" argument must be an Array of Buffers')
  5777. }
  5778. if (list.length === 0) {
  5779. return Buffer.alloc(0)
  5780. }
  5781. var i
  5782. if (length === undefined) {
  5783. length = 0
  5784. for (i = 0; i < list.length; ++i) {
  5785. length += list[i].length
  5786. }
  5787. }
  5788. var buffer = Buffer.allocUnsafe(length)
  5789. var pos = 0
  5790. for (i = 0; i < list.length; ++i) {
  5791. var buf = list[i]
  5792. if (!Buffer.isBuffer(buf)) {
  5793. throw new TypeError('"list" argument must be an Array of Buffers')
  5794. }
  5795. buf.copy(buffer, pos)
  5796. pos += buf.length
  5797. }
  5798. return buffer
  5799. }
  5800. function byteLength (string, encoding) {
  5801. if (Buffer.isBuffer(string)) {
  5802. return string.length
  5803. }
  5804. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5805. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5806. return string.byteLength
  5807. }
  5808. if (typeof string !== 'string') {
  5809. string = '' + string
  5810. }
  5811. var len = string.length
  5812. if (len === 0) return 0
  5813. // Use a for loop to avoid recursion
  5814. var loweredCase = false
  5815. for (;;) {
  5816. switch (encoding) {
  5817. case 'ascii':
  5818. case 'latin1':
  5819. case 'binary':
  5820. return len
  5821. case 'utf8':
  5822. case 'utf-8':
  5823. case undefined:
  5824. return utf8ToBytes(string).length
  5825. case 'ucs2':
  5826. case 'ucs-2':
  5827. case 'utf16le':
  5828. case 'utf-16le':
  5829. return len * 2
  5830. case 'hex':
  5831. return len >>> 1
  5832. case 'base64':
  5833. return base64ToBytes(string).length
  5834. default:
  5835. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5836. encoding = ('' + encoding).toLowerCase()
  5837. loweredCase = true
  5838. }
  5839. }
  5840. }
  5841. Buffer.byteLength = byteLength
  5842. function slowToString (encoding, start, end) {
  5843. var loweredCase = false
  5844. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5845. // property of a typed array.
  5846. // This behaves neither like String nor Uint8Array in that we set start/end
  5847. // to their upper/lower bounds if the value passed is out of range.
  5848. // undefined is handled specially as per ECMA-262 6th Edition,
  5849. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5850. if (start === undefined || start < 0) {
  5851. start = 0
  5852. }
  5853. // Return early if start > this.length. Done here to prevent potential uint32
  5854. // coercion fail below.
  5855. if (start > this.length) {
  5856. return ''
  5857. }
  5858. if (end === undefined || end > this.length) {
  5859. end = this.length
  5860. }
  5861. if (end <= 0) {
  5862. return ''
  5863. }
  5864. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5865. end >>>= 0
  5866. start >>>= 0
  5867. if (end <= start) {
  5868. return ''
  5869. }
  5870. if (!encoding) encoding = 'utf8'
  5871. while (true) {
  5872. switch (encoding) {
  5873. case 'hex':
  5874. return hexSlice(this, start, end)
  5875. case 'utf8':
  5876. case 'utf-8':
  5877. return utf8Slice(this, start, end)
  5878. case 'ascii':
  5879. return asciiSlice(this, start, end)
  5880. case 'latin1':
  5881. case 'binary':
  5882. return latin1Slice(this, start, end)
  5883. case 'base64':
  5884. return base64Slice(this, start, end)
  5885. case 'ucs2':
  5886. case 'ucs-2':
  5887. case 'utf16le':
  5888. case 'utf-16le':
  5889. return utf16leSlice(this, start, end)
  5890. default:
  5891. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  5892. encoding = (encoding + '').toLowerCase()
  5893. loweredCase = true
  5894. }
  5895. }
  5896. }
  5897. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  5898. // Buffer instances.
  5899. Buffer.prototype._isBuffer = true
  5900. function swap (b, n, m) {
  5901. var i = b[n]
  5902. b[n] = b[m]
  5903. b[m] = i
  5904. }
  5905. Buffer.prototype.swap16 = function swap16 () {
  5906. var len = this.length
  5907. if (len % 2 !== 0) {
  5908. throw new RangeError('Buffer size must be a multiple of 16-bits')
  5909. }
  5910. for (var i = 0; i < len; i += 2) {
  5911. swap(this, i, i + 1)
  5912. }
  5913. return this
  5914. }
  5915. Buffer.prototype.swap32 = function swap32 () {
  5916. var len = this.length
  5917. if (len % 4 !== 0) {
  5918. throw new RangeError('Buffer size must be a multiple of 32-bits')
  5919. }
  5920. for (var i = 0; i < len; i += 4) {
  5921. swap(this, i, i + 3)
  5922. swap(this, i + 1, i + 2)
  5923. }
  5924. return this
  5925. }
  5926. Buffer.prototype.swap64 = function swap64 () {
  5927. var len = this.length
  5928. if (len % 8 !== 0) {
  5929. throw new RangeError('Buffer size must be a multiple of 64-bits')
  5930. }
  5931. for (var i = 0; i < len; i += 8) {
  5932. swap(this, i, i + 7)
  5933. swap(this, i + 1, i + 6)
  5934. swap(this, i + 2, i + 5)
  5935. swap(this, i + 3, i + 4)
  5936. }
  5937. return this
  5938. }
  5939. Buffer.prototype.toString = function toString () {
  5940. var length = this.length | 0
  5941. if (length === 0) return ''
  5942. if (arguments.length === 0) return utf8Slice(this, 0, length)
  5943. return slowToString.apply(this, arguments)
  5944. }
  5945. Buffer.prototype.equals = function equals (b) {
  5946. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  5947. if (this === b) return true
  5948. return Buffer.compare(this, b) === 0
  5949. }
  5950. Buffer.prototype.inspect = function inspect () {
  5951. var str = ''
  5952. var max = exports.INSPECT_MAX_BYTES
  5953. if (this.length > 0) {
  5954. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  5955. if (this.length > max) str += ' ... '
  5956. }
  5957. return '<Buffer ' + str + '>'
  5958. }
  5959. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  5960. if (!Buffer.isBuffer(target)) {
  5961. throw new TypeError('Argument must be a Buffer')
  5962. }
  5963. if (start === undefined) {
  5964. start = 0
  5965. }
  5966. if (end === undefined) {
  5967. end = target ? target.length : 0
  5968. }
  5969. if (thisStart === undefined) {
  5970. thisStart = 0
  5971. }
  5972. if (thisEnd === undefined) {
  5973. thisEnd = this.length
  5974. }
  5975. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  5976. throw new RangeError('out of range index')
  5977. }
  5978. if (thisStart >= thisEnd && start >= end) {
  5979. return 0
  5980. }
  5981. if (thisStart >= thisEnd) {
  5982. return -1
  5983. }
  5984. if (start >= end) {
  5985. return 1
  5986. }
  5987. start >>>= 0
  5988. end >>>= 0
  5989. thisStart >>>= 0
  5990. thisEnd >>>= 0
  5991. if (this === target) return 0
  5992. var x = thisEnd - thisStart
  5993. var y = end - start
  5994. var len = Math.min(x, y)
  5995. var thisCopy = this.slice(thisStart, thisEnd)
  5996. var targetCopy = target.slice(start, end)
  5997. for (var i = 0; i < len; ++i) {
  5998. if (thisCopy[i] !== targetCopy[i]) {
  5999. x = thisCopy[i]
  6000. y = targetCopy[i]
  6001. break
  6002. }
  6003. }
  6004. if (x < y) return -1
  6005. if (y < x) return 1
  6006. return 0
  6007. }
  6008. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6009. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6010. //
  6011. // Arguments:
  6012. // - buffer - a Buffer to search
  6013. // - val - a string, Buffer, or number
  6014. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6015. // - encoding - an optional encoding, relevant is val is a string
  6016. // - dir - true for indexOf, false for lastIndexOf
  6017. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6018. // Empty buffer means no match
  6019. if (buffer.length === 0) return -1
  6020. // Normalize byteOffset
  6021. if (typeof byteOffset === 'string') {
  6022. encoding = byteOffset
  6023. byteOffset = 0
  6024. } else if (byteOffset > 0x7fffffff) {
  6025. byteOffset = 0x7fffffff
  6026. } else if (byteOffset < -0x80000000) {
  6027. byteOffset = -0x80000000
  6028. }
  6029. byteOffset = +byteOffset // Coerce to Number.
  6030. if (isNaN(byteOffset)) {
  6031. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6032. byteOffset = dir ? 0 : (buffer.length - 1)
  6033. }
  6034. // Normalize byteOffset: negative offsets start from the end of the buffer
  6035. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6036. if (byteOffset >= buffer.length) {
  6037. if (dir) return -1
  6038. else byteOffset = buffer.length - 1
  6039. } else if (byteOffset < 0) {
  6040. if (dir) byteOffset = 0
  6041. else return -1
  6042. }
  6043. // Normalize val
  6044. if (typeof val === 'string') {
  6045. val = Buffer.from(val, encoding)
  6046. }
  6047. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6048. if (Buffer.isBuffer(val)) {
  6049. // Special case: looking for empty string/buffer always fails
  6050. if (val.length === 0) {
  6051. return -1
  6052. }
  6053. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6054. } else if (typeof val === 'number') {
  6055. val = val & 0xFF // Search for a byte value [0-255]
  6056. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6057. typeof Uint8Array.prototype.indexOf === 'function') {
  6058. if (dir) {
  6059. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6060. } else {
  6061. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6062. }
  6063. }
  6064. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6065. }
  6066. throw new TypeError('val must be string, number or Buffer')
  6067. }
  6068. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6069. var indexSize = 1
  6070. var arrLength = arr.length
  6071. var valLength = val.length
  6072. if (encoding !== undefined) {
  6073. encoding = String(encoding).toLowerCase()
  6074. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6075. encoding === 'utf16le' || encoding === 'utf-16le') {
  6076. if (arr.length < 2 || val.length < 2) {
  6077. return -1
  6078. }
  6079. indexSize = 2
  6080. arrLength /= 2
  6081. valLength /= 2
  6082. byteOffset /= 2
  6083. }
  6084. }
  6085. function read (buf, i) {
  6086. if (indexSize === 1) {
  6087. return buf[i]
  6088. } else {
  6089. return buf.readUInt16BE(i * indexSize)
  6090. }
  6091. }
  6092. var i
  6093. if (dir) {
  6094. var foundIndex = -1
  6095. for (i = byteOffset; i < arrLength; i++) {
  6096. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6097. if (foundIndex === -1) foundIndex = i
  6098. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6099. } else {
  6100. if (foundIndex !== -1) i -= i - foundIndex
  6101. foundIndex = -1
  6102. }
  6103. }
  6104. } else {
  6105. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6106. for (i = byteOffset; i >= 0; i--) {
  6107. var found = true
  6108. for (var j = 0; j < valLength; j++) {
  6109. if (read(arr, i + j) !== read(val, j)) {
  6110. found = false
  6111. break
  6112. }
  6113. }
  6114. if (found) return i
  6115. }
  6116. }
  6117. return -1
  6118. }
  6119. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6120. return this.indexOf(val, byteOffset, encoding) !== -1
  6121. }
  6122. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6123. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6124. }
  6125. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6126. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6127. }
  6128. function hexWrite (buf, string, offset, length) {
  6129. offset = Number(offset) || 0
  6130. var remaining = buf.length - offset
  6131. if (!length) {
  6132. length = remaining
  6133. } else {
  6134. length = Number(length)
  6135. if (length > remaining) {
  6136. length = remaining
  6137. }
  6138. }
  6139. // must be an even number of digits
  6140. var strLen = string.length
  6141. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6142. if (length > strLen / 2) {
  6143. length = strLen / 2
  6144. }
  6145. for (var i = 0; i < length; ++i) {
  6146. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6147. if (isNaN(parsed)) return i
  6148. buf[offset + i] = parsed
  6149. }
  6150. return i
  6151. }
  6152. function utf8Write (buf, string, offset, length) {
  6153. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6154. }
  6155. function asciiWrite (buf, string, offset, length) {
  6156. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6157. }
  6158. function latin1Write (buf, string, offset, length) {
  6159. return asciiWrite(buf, string, offset, length)
  6160. }
  6161. function base64Write (buf, string, offset, length) {
  6162. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6163. }
  6164. function ucs2Write (buf, string, offset, length) {
  6165. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6166. }
  6167. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6168. // Buffer#write(string)
  6169. if (offset === undefined) {
  6170. encoding = 'utf8'
  6171. length = this.length
  6172. offset = 0
  6173. // Buffer#write(string, encoding)
  6174. } else if (length === undefined && typeof offset === 'string') {
  6175. encoding = offset
  6176. length = this.length
  6177. offset = 0
  6178. // Buffer#write(string, offset[, length][, encoding])
  6179. } else if (isFinite(offset)) {
  6180. offset = offset | 0
  6181. if (isFinite(length)) {
  6182. length = length | 0
  6183. if (encoding === undefined) encoding = 'utf8'
  6184. } else {
  6185. encoding = length
  6186. length = undefined
  6187. }
  6188. // legacy write(string, encoding, offset, length) - remove in v0.13
  6189. } else {
  6190. throw new Error(
  6191. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6192. )
  6193. }
  6194. var remaining = this.length - offset
  6195. if (length === undefined || length > remaining) length = remaining
  6196. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6197. throw new RangeError('Attempt to write outside buffer bounds')
  6198. }
  6199. if (!encoding) encoding = 'utf8'
  6200. var loweredCase = false
  6201. for (;;) {
  6202. switch (encoding) {
  6203. case 'hex':
  6204. return hexWrite(this, string, offset, length)
  6205. case 'utf8':
  6206. case 'utf-8':
  6207. return utf8Write(this, string, offset, length)
  6208. case 'ascii':
  6209. return asciiWrite(this, string, offset, length)
  6210. case 'latin1':
  6211. case 'binary':
  6212. return latin1Write(this, string, offset, length)
  6213. case 'base64':
  6214. // Warning: maxLength not taken into account in base64Write
  6215. return base64Write(this, string, offset, length)
  6216. case 'ucs2':
  6217. case 'ucs-2':
  6218. case 'utf16le':
  6219. case 'utf-16le':
  6220. return ucs2Write(this, string, offset, length)
  6221. default:
  6222. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6223. encoding = ('' + encoding).toLowerCase()
  6224. loweredCase = true
  6225. }
  6226. }
  6227. }
  6228. Buffer.prototype.toJSON = function toJSON () {
  6229. return {
  6230. type: 'Buffer',
  6231. data: Array.prototype.slice.call(this._arr || this, 0)
  6232. }
  6233. }
  6234. function base64Slice (buf, start, end) {
  6235. if (start === 0 && end === buf.length) {
  6236. return base64.fromByteArray(buf)
  6237. } else {
  6238. return base64.fromByteArray(buf.slice(start, end))
  6239. }
  6240. }
  6241. function utf8Slice (buf, start, end) {
  6242. end = Math.min(buf.length, end)
  6243. var res = []
  6244. var i = start
  6245. while (i < end) {
  6246. var firstByte = buf[i]
  6247. var codePoint = null
  6248. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6249. : (firstByte > 0xDF) ? 3
  6250. : (firstByte > 0xBF) ? 2
  6251. : 1
  6252. if (i + bytesPerSequence <= end) {
  6253. var secondByte, thirdByte, fourthByte, tempCodePoint
  6254. switch (bytesPerSequence) {
  6255. case 1:
  6256. if (firstByte < 0x80) {
  6257. codePoint = firstByte
  6258. }
  6259. break
  6260. case 2:
  6261. secondByte = buf[i + 1]
  6262. if ((secondByte & 0xC0) === 0x80) {
  6263. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6264. if (tempCodePoint > 0x7F) {
  6265. codePoint = tempCodePoint
  6266. }
  6267. }
  6268. break
  6269. case 3:
  6270. secondByte = buf[i + 1]
  6271. thirdByte = buf[i + 2]
  6272. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6273. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6274. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6275. codePoint = tempCodePoint
  6276. }
  6277. }
  6278. break
  6279. case 4:
  6280. secondByte = buf[i + 1]
  6281. thirdByte = buf[i + 2]
  6282. fourthByte = buf[i + 3]
  6283. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6284. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6285. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6286. codePoint = tempCodePoint
  6287. }
  6288. }
  6289. }
  6290. }
  6291. if (codePoint === null) {
  6292. // we did not generate a valid codePoint so insert a
  6293. // replacement char (U+FFFD) and advance only 1 byte
  6294. codePoint = 0xFFFD
  6295. bytesPerSequence = 1
  6296. } else if (codePoint > 0xFFFF) {
  6297. // encode to utf16 (surrogate pair dance)
  6298. codePoint -= 0x10000
  6299. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6300. codePoint = 0xDC00 | codePoint & 0x3FF
  6301. }
  6302. res.push(codePoint)
  6303. i += bytesPerSequence
  6304. }
  6305. return decodeCodePointsArray(res)
  6306. }
  6307. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6308. // the lowest limit is Chrome, with 0x10000 args.
  6309. // We go 1 magnitude less, for safety
  6310. var MAX_ARGUMENTS_LENGTH = 0x1000
  6311. function decodeCodePointsArray (codePoints) {
  6312. var len = codePoints.length
  6313. if (len <= MAX_ARGUMENTS_LENGTH) {
  6314. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6315. }
  6316. // Decode in chunks to avoid "call stack size exceeded".
  6317. var res = ''
  6318. var i = 0
  6319. while (i < len) {
  6320. res += String.fromCharCode.apply(
  6321. String,
  6322. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6323. )
  6324. }
  6325. return res
  6326. }
  6327. function asciiSlice (buf, start, end) {
  6328. var ret = ''
  6329. end = Math.min(buf.length, end)
  6330. for (var i = start; i < end; ++i) {
  6331. ret += String.fromCharCode(buf[i] & 0x7F)
  6332. }
  6333. return ret
  6334. }
  6335. function latin1Slice (buf, start, end) {
  6336. var ret = ''
  6337. end = Math.min(buf.length, end)
  6338. for (var i = start; i < end; ++i) {
  6339. ret += String.fromCharCode(buf[i])
  6340. }
  6341. return ret
  6342. }
  6343. function hexSlice (buf, start, end) {
  6344. var len = buf.length
  6345. if (!start || start < 0) start = 0
  6346. if (!end || end < 0 || end > len) end = len
  6347. var out = ''
  6348. for (var i = start; i < end; ++i) {
  6349. out += toHex(buf[i])
  6350. }
  6351. return out
  6352. }
  6353. function utf16leSlice (buf, start, end) {
  6354. var bytes = buf.slice(start, end)
  6355. var res = ''
  6356. for (var i = 0; i < bytes.length; i += 2) {
  6357. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6358. }
  6359. return res
  6360. }
  6361. Buffer.prototype.slice = function slice (start, end) {
  6362. var len = this.length
  6363. start = ~~start
  6364. end = end === undefined ? len : ~~end
  6365. if (start < 0) {
  6366. start += len
  6367. if (start < 0) start = 0
  6368. } else if (start > len) {
  6369. start = len
  6370. }
  6371. if (end < 0) {
  6372. end += len
  6373. if (end < 0) end = 0
  6374. } else if (end > len) {
  6375. end = len
  6376. }
  6377. if (end < start) end = start
  6378. var newBuf
  6379. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6380. newBuf = this.subarray(start, end)
  6381. newBuf.__proto__ = Buffer.prototype
  6382. } else {
  6383. var sliceLen = end - start
  6384. newBuf = new Buffer(sliceLen, undefined)
  6385. for (var i = 0; i < sliceLen; ++i) {
  6386. newBuf[i] = this[i + start]
  6387. }
  6388. }
  6389. return newBuf
  6390. }
  6391. /*
  6392. * Need to make sure that buffer isn't trying to write out of bounds.
  6393. */
  6394. function checkOffset (offset, ext, length) {
  6395. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6396. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6397. }
  6398. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6399. offset = offset | 0
  6400. byteLength = byteLength | 0
  6401. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6402. var val = this[offset]
  6403. var mul = 1
  6404. var i = 0
  6405. while (++i < byteLength && (mul *= 0x100)) {
  6406. val += this[offset + i] * mul
  6407. }
  6408. return val
  6409. }
  6410. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6411. offset = offset | 0
  6412. byteLength = byteLength | 0
  6413. if (!noAssert) {
  6414. checkOffset(offset, byteLength, this.length)
  6415. }
  6416. var val = this[offset + --byteLength]
  6417. var mul = 1
  6418. while (byteLength > 0 && (mul *= 0x100)) {
  6419. val += this[offset + --byteLength] * mul
  6420. }
  6421. return val
  6422. }
  6423. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6424. if (!noAssert) checkOffset(offset, 1, this.length)
  6425. return this[offset]
  6426. }
  6427. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6428. if (!noAssert) checkOffset(offset, 2, this.length)
  6429. return this[offset] | (this[offset + 1] << 8)
  6430. }
  6431. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6432. if (!noAssert) checkOffset(offset, 2, this.length)
  6433. return (this[offset] << 8) | this[offset + 1]
  6434. }
  6435. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6436. if (!noAssert) checkOffset(offset, 4, this.length)
  6437. return ((this[offset]) |
  6438. (this[offset + 1] << 8) |
  6439. (this[offset + 2] << 16)) +
  6440. (this[offset + 3] * 0x1000000)
  6441. }
  6442. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6443. if (!noAssert) checkOffset(offset, 4, this.length)
  6444. return (this[offset] * 0x1000000) +
  6445. ((this[offset + 1] << 16) |
  6446. (this[offset + 2] << 8) |
  6447. this[offset + 3])
  6448. }
  6449. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6450. offset = offset | 0
  6451. byteLength = byteLength | 0
  6452. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6453. var val = this[offset]
  6454. var mul = 1
  6455. var i = 0
  6456. while (++i < byteLength && (mul *= 0x100)) {
  6457. val += this[offset + i] * mul
  6458. }
  6459. mul *= 0x80
  6460. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6461. return val
  6462. }
  6463. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6464. offset = offset | 0
  6465. byteLength = byteLength | 0
  6466. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6467. var i = byteLength
  6468. var mul = 1
  6469. var val = this[offset + --i]
  6470. while (i > 0 && (mul *= 0x100)) {
  6471. val += this[offset + --i] * mul
  6472. }
  6473. mul *= 0x80
  6474. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6475. return val
  6476. }
  6477. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6478. if (!noAssert) checkOffset(offset, 1, this.length)
  6479. if (!(this[offset] & 0x80)) return (this[offset])
  6480. return ((0xff - this[offset] + 1) * -1)
  6481. }
  6482. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6483. if (!noAssert) checkOffset(offset, 2, this.length)
  6484. var val = this[offset] | (this[offset + 1] << 8)
  6485. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6486. }
  6487. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6488. if (!noAssert) checkOffset(offset, 2, this.length)
  6489. var val = this[offset + 1] | (this[offset] << 8)
  6490. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6491. }
  6492. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6493. if (!noAssert) checkOffset(offset, 4, this.length)
  6494. return (this[offset]) |
  6495. (this[offset + 1] << 8) |
  6496. (this[offset + 2] << 16) |
  6497. (this[offset + 3] << 24)
  6498. }
  6499. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6500. if (!noAssert) checkOffset(offset, 4, this.length)
  6501. return (this[offset] << 24) |
  6502. (this[offset + 1] << 16) |
  6503. (this[offset + 2] << 8) |
  6504. (this[offset + 3])
  6505. }
  6506. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6507. if (!noAssert) checkOffset(offset, 4, this.length)
  6508. return ieee754.read(this, offset, true, 23, 4)
  6509. }
  6510. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6511. if (!noAssert) checkOffset(offset, 4, this.length)
  6512. return ieee754.read(this, offset, false, 23, 4)
  6513. }
  6514. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6515. if (!noAssert) checkOffset(offset, 8, this.length)
  6516. return ieee754.read(this, offset, true, 52, 8)
  6517. }
  6518. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6519. if (!noAssert) checkOffset(offset, 8, this.length)
  6520. return ieee754.read(this, offset, false, 52, 8)
  6521. }
  6522. function checkInt (buf, value, offset, ext, max, min) {
  6523. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6524. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6525. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6526. }
  6527. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6528. value = +value
  6529. offset = offset | 0
  6530. byteLength = byteLength | 0
  6531. if (!noAssert) {
  6532. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6533. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6534. }
  6535. var mul = 1
  6536. var i = 0
  6537. this[offset] = value & 0xFF
  6538. while (++i < byteLength && (mul *= 0x100)) {
  6539. this[offset + i] = (value / mul) & 0xFF
  6540. }
  6541. return offset + byteLength
  6542. }
  6543. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6544. value = +value
  6545. offset = offset | 0
  6546. byteLength = byteLength | 0
  6547. if (!noAssert) {
  6548. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6549. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6550. }
  6551. var i = byteLength - 1
  6552. var mul = 1
  6553. this[offset + i] = value & 0xFF
  6554. while (--i >= 0 && (mul *= 0x100)) {
  6555. this[offset + i] = (value / mul) & 0xFF
  6556. }
  6557. return offset + byteLength
  6558. }
  6559. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6560. value = +value
  6561. offset = offset | 0
  6562. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6563. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6564. this[offset] = (value & 0xff)
  6565. return offset + 1
  6566. }
  6567. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6568. if (value < 0) value = 0xffff + value + 1
  6569. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6570. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6571. (littleEndian ? i : 1 - i) * 8
  6572. }
  6573. }
  6574. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6575. value = +value
  6576. offset = offset | 0
  6577. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6578. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6579. this[offset] = (value & 0xff)
  6580. this[offset + 1] = (value >>> 8)
  6581. } else {
  6582. objectWriteUInt16(this, value, offset, true)
  6583. }
  6584. return offset + 2
  6585. }
  6586. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6587. value = +value
  6588. offset = offset | 0
  6589. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6590. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6591. this[offset] = (value >>> 8)
  6592. this[offset + 1] = (value & 0xff)
  6593. } else {
  6594. objectWriteUInt16(this, value, offset, false)
  6595. }
  6596. return offset + 2
  6597. }
  6598. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6599. if (value < 0) value = 0xffffffff + value + 1
  6600. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6601. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6602. }
  6603. }
  6604. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6605. value = +value
  6606. offset = offset | 0
  6607. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6608. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6609. this[offset + 3] = (value >>> 24)
  6610. this[offset + 2] = (value >>> 16)
  6611. this[offset + 1] = (value >>> 8)
  6612. this[offset] = (value & 0xff)
  6613. } else {
  6614. objectWriteUInt32(this, value, offset, true)
  6615. }
  6616. return offset + 4
  6617. }
  6618. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6619. value = +value
  6620. offset = offset | 0
  6621. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6622. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6623. this[offset] = (value >>> 24)
  6624. this[offset + 1] = (value >>> 16)
  6625. this[offset + 2] = (value >>> 8)
  6626. this[offset + 3] = (value & 0xff)
  6627. } else {
  6628. objectWriteUInt32(this, value, offset, false)
  6629. }
  6630. return offset + 4
  6631. }
  6632. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6633. value = +value
  6634. offset = offset | 0
  6635. if (!noAssert) {
  6636. var limit = Math.pow(2, 8 * byteLength - 1)
  6637. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6638. }
  6639. var i = 0
  6640. var mul = 1
  6641. var sub = 0
  6642. this[offset] = value & 0xFF
  6643. while (++i < byteLength && (mul *= 0x100)) {
  6644. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6645. sub = 1
  6646. }
  6647. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6648. }
  6649. return offset + byteLength
  6650. }
  6651. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6652. value = +value
  6653. offset = offset | 0
  6654. if (!noAssert) {
  6655. var limit = Math.pow(2, 8 * byteLength - 1)
  6656. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6657. }
  6658. var i = byteLength - 1
  6659. var mul = 1
  6660. var sub = 0
  6661. this[offset + i] = value & 0xFF
  6662. while (--i >= 0 && (mul *= 0x100)) {
  6663. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6664. sub = 1
  6665. }
  6666. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6667. }
  6668. return offset + byteLength
  6669. }
  6670. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6671. value = +value
  6672. offset = offset | 0
  6673. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6674. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6675. if (value < 0) value = 0xff + value + 1
  6676. this[offset] = (value & 0xff)
  6677. return offset + 1
  6678. }
  6679. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6680. value = +value
  6681. offset = offset | 0
  6682. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6683. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6684. this[offset] = (value & 0xff)
  6685. this[offset + 1] = (value >>> 8)
  6686. } else {
  6687. objectWriteUInt16(this, value, offset, true)
  6688. }
  6689. return offset + 2
  6690. }
  6691. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6692. value = +value
  6693. offset = offset | 0
  6694. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6695. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6696. this[offset] = (value >>> 8)
  6697. this[offset + 1] = (value & 0xff)
  6698. } else {
  6699. objectWriteUInt16(this, value, offset, false)
  6700. }
  6701. return offset + 2
  6702. }
  6703. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6704. value = +value
  6705. offset = offset | 0
  6706. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6707. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6708. this[offset] = (value & 0xff)
  6709. this[offset + 1] = (value >>> 8)
  6710. this[offset + 2] = (value >>> 16)
  6711. this[offset + 3] = (value >>> 24)
  6712. } else {
  6713. objectWriteUInt32(this, value, offset, true)
  6714. }
  6715. return offset + 4
  6716. }
  6717. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6718. value = +value
  6719. offset = offset | 0
  6720. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6721. if (value < 0) value = 0xffffffff + value + 1
  6722. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6723. this[offset] = (value >>> 24)
  6724. this[offset + 1] = (value >>> 16)
  6725. this[offset + 2] = (value >>> 8)
  6726. this[offset + 3] = (value & 0xff)
  6727. } else {
  6728. objectWriteUInt32(this, value, offset, false)
  6729. }
  6730. return offset + 4
  6731. }
  6732. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6733. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6734. if (offset < 0) throw new RangeError('Index out of range')
  6735. }
  6736. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6737. if (!noAssert) {
  6738. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6739. }
  6740. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6741. return offset + 4
  6742. }
  6743. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6744. return writeFloat(this, value, offset, true, noAssert)
  6745. }
  6746. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6747. return writeFloat(this, value, offset, false, noAssert)
  6748. }
  6749. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6750. if (!noAssert) {
  6751. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6752. }
  6753. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6754. return offset + 8
  6755. }
  6756. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6757. return writeDouble(this, value, offset, true, noAssert)
  6758. }
  6759. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6760. return writeDouble(this, value, offset, false, noAssert)
  6761. }
  6762. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6763. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6764. if (!start) start = 0
  6765. if (!end && end !== 0) end = this.length
  6766. if (targetStart >= target.length) targetStart = target.length
  6767. if (!targetStart) targetStart = 0
  6768. if (end > 0 && end < start) end = start
  6769. // Copy 0 bytes; we're done
  6770. if (end === start) return 0
  6771. if (target.length === 0 || this.length === 0) return 0
  6772. // Fatal error conditions
  6773. if (targetStart < 0) {
  6774. throw new RangeError('targetStart out of bounds')
  6775. }
  6776. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6777. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6778. // Are we oob?
  6779. if (end > this.length) end = this.length
  6780. if (target.length - targetStart < end - start) {
  6781. end = target.length - targetStart + start
  6782. }
  6783. var len = end - start
  6784. var i
  6785. if (this === target && start < targetStart && targetStart < end) {
  6786. // descending copy from end
  6787. for (i = len - 1; i >= 0; --i) {
  6788. target[i + targetStart] = this[i + start]
  6789. }
  6790. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6791. // ascending copy from start
  6792. for (i = 0; i < len; ++i) {
  6793. target[i + targetStart] = this[i + start]
  6794. }
  6795. } else {
  6796. Uint8Array.prototype.set.call(
  6797. target,
  6798. this.subarray(start, start + len),
  6799. targetStart
  6800. )
  6801. }
  6802. return len
  6803. }
  6804. // Usage:
  6805. // buffer.fill(number[, offset[, end]])
  6806. // buffer.fill(buffer[, offset[, end]])
  6807. // buffer.fill(string[, offset[, end]][, encoding])
  6808. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6809. // Handle string cases:
  6810. if (typeof val === 'string') {
  6811. if (typeof start === 'string') {
  6812. encoding = start
  6813. start = 0
  6814. end = this.length
  6815. } else if (typeof end === 'string') {
  6816. encoding = end
  6817. end = this.length
  6818. }
  6819. if (val.length === 1) {
  6820. var code = val.charCodeAt(0)
  6821. if (code < 256) {
  6822. val = code
  6823. }
  6824. }
  6825. if (encoding !== undefined && typeof encoding !== 'string') {
  6826. throw new TypeError('encoding must be a string')
  6827. }
  6828. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6829. throw new TypeError('Unknown encoding: ' + encoding)
  6830. }
  6831. } else if (typeof val === 'number') {
  6832. val = val & 255
  6833. }
  6834. // Invalid ranges are not set to a default, so can range check early.
  6835. if (start < 0 || this.length < start || this.length < end) {
  6836. throw new RangeError('Out of range index')
  6837. }
  6838. if (end <= start) {
  6839. return this
  6840. }
  6841. start = start >>> 0
  6842. end = end === undefined ? this.length : end >>> 0
  6843. if (!val) val = 0
  6844. var i
  6845. if (typeof val === 'number') {
  6846. for (i = start; i < end; ++i) {
  6847. this[i] = val
  6848. }
  6849. } else {
  6850. var bytes = Buffer.isBuffer(val)
  6851. ? val
  6852. : utf8ToBytes(new Buffer(val, encoding).toString())
  6853. var len = bytes.length
  6854. for (i = 0; i < end - start; ++i) {
  6855. this[i + start] = bytes[i % len]
  6856. }
  6857. }
  6858. return this
  6859. }
  6860. // HELPER FUNCTIONS
  6861. // ================
  6862. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6863. function base64clean (str) {
  6864. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6865. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6866. // Node converts strings with length < 2 to ''
  6867. if (str.length < 2) return ''
  6868. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6869. while (str.length % 4 !== 0) {
  6870. str = str + '='
  6871. }
  6872. return str
  6873. }
  6874. function stringtrim (str) {
  6875. if (str.trim) return str.trim()
  6876. return str.replace(/^\s+|\s+$/g, '')
  6877. }
  6878. function toHex (n) {
  6879. if (n < 16) return '0' + n.toString(16)
  6880. return n.toString(16)
  6881. }
  6882. function utf8ToBytes (string, units) {
  6883. units = units || Infinity
  6884. var codePoint
  6885. var length = string.length
  6886. var leadSurrogate = null
  6887. var bytes = []
  6888. for (var i = 0; i < length; ++i) {
  6889. codePoint = string.charCodeAt(i)
  6890. // is surrogate component
  6891. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  6892. // last char was a lead
  6893. if (!leadSurrogate) {
  6894. // no lead yet
  6895. if (codePoint > 0xDBFF) {
  6896. // unexpected trail
  6897. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6898. continue
  6899. } else if (i + 1 === length) {
  6900. // unpaired lead
  6901. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6902. continue
  6903. }
  6904. // valid lead
  6905. leadSurrogate = codePoint
  6906. continue
  6907. }
  6908. // 2 leads in a row
  6909. if (codePoint < 0xDC00) {
  6910. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6911. leadSurrogate = codePoint
  6912. continue
  6913. }
  6914. // valid surrogate pair
  6915. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  6916. } else if (leadSurrogate) {
  6917. // valid bmp char, but last char was a lead
  6918. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  6919. }
  6920. leadSurrogate = null
  6921. // encode utf8
  6922. if (codePoint < 0x80) {
  6923. if ((units -= 1) < 0) break
  6924. bytes.push(codePoint)
  6925. } else if (codePoint < 0x800) {
  6926. if ((units -= 2) < 0) break
  6927. bytes.push(
  6928. codePoint >> 0x6 | 0xC0,
  6929. codePoint & 0x3F | 0x80
  6930. )
  6931. } else if (codePoint < 0x10000) {
  6932. if ((units -= 3) < 0) break
  6933. bytes.push(
  6934. codePoint >> 0xC | 0xE0,
  6935. codePoint >> 0x6 & 0x3F | 0x80,
  6936. codePoint & 0x3F | 0x80
  6937. )
  6938. } else if (codePoint < 0x110000) {
  6939. if ((units -= 4) < 0) break
  6940. bytes.push(
  6941. codePoint >> 0x12 | 0xF0,
  6942. codePoint >> 0xC & 0x3F | 0x80,
  6943. codePoint >> 0x6 & 0x3F | 0x80,
  6944. codePoint & 0x3F | 0x80
  6945. )
  6946. } else {
  6947. throw new Error('Invalid code point')
  6948. }
  6949. }
  6950. return bytes
  6951. }
  6952. function asciiToBytes (str) {
  6953. var byteArray = []
  6954. for (var i = 0; i < str.length; ++i) {
  6955. // Node's code seems to be doing this and not & 0x7F..
  6956. byteArray.push(str.charCodeAt(i) & 0xFF)
  6957. }
  6958. return byteArray
  6959. }
  6960. function utf16leToBytes (str, units) {
  6961. var c, hi, lo
  6962. var byteArray = []
  6963. for (var i = 0; i < str.length; ++i) {
  6964. if ((units -= 2) < 0) break
  6965. c = str.charCodeAt(i)
  6966. hi = c >> 8
  6967. lo = c % 256
  6968. byteArray.push(lo)
  6969. byteArray.push(hi)
  6970. }
  6971. return byteArray
  6972. }
  6973. function base64ToBytes (str) {
  6974. return base64.toByteArray(base64clean(str))
  6975. }
  6976. function blitBuffer (src, dst, offset, length) {
  6977. for (var i = 0; i < length; ++i) {
  6978. if ((i + offset >= dst.length) || (i >= src.length)) break
  6979. dst[i + offset] = src[i]
  6980. }
  6981. return i
  6982. }
  6983. function isnan (val) {
  6984. return val !== val // eslint-disable-line no-self-compare
  6985. }
  6986. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  6987. /***/ }),
  6988. /***/ "./node_modules/ieee754/index.js":
  6989. /*!***************************************!*\
  6990. !*** ./node_modules/ieee754/index.js ***!
  6991. \***************************************/
  6992. /*! no static exports found */
  6993. /***/ (function(module, exports) {
  6994. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  6995. var e, m
  6996. var eLen = (nBytes * 8) - mLen - 1
  6997. var eMax = (1 << eLen) - 1
  6998. var eBias = eMax >> 1
  6999. var nBits = -7
  7000. var i = isLE ? (nBytes - 1) : 0
  7001. var d = isLE ? -1 : 1
  7002. var s = buffer[offset + i]
  7003. i += d
  7004. e = s & ((1 << (-nBits)) - 1)
  7005. s >>= (-nBits)
  7006. nBits += eLen
  7007. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7008. m = e & ((1 << (-nBits)) - 1)
  7009. e >>= (-nBits)
  7010. nBits += mLen
  7011. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7012. if (e === 0) {
  7013. e = 1 - eBias
  7014. } else if (e === eMax) {
  7015. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7016. } else {
  7017. m = m + Math.pow(2, mLen)
  7018. e = e - eBias
  7019. }
  7020. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7021. }
  7022. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7023. var e, m, c
  7024. var eLen = (nBytes * 8) - mLen - 1
  7025. var eMax = (1 << eLen) - 1
  7026. var eBias = eMax >> 1
  7027. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7028. var i = isLE ? 0 : (nBytes - 1)
  7029. var d = isLE ? 1 : -1
  7030. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7031. value = Math.abs(value)
  7032. if (isNaN(value) || value === Infinity) {
  7033. m = isNaN(value) ? 1 : 0
  7034. e = eMax
  7035. } else {
  7036. e = Math.floor(Math.log(value) / Math.LN2)
  7037. if (value * (c = Math.pow(2, -e)) < 1) {
  7038. e--
  7039. c *= 2
  7040. }
  7041. if (e + eBias >= 1) {
  7042. value += rt / c
  7043. } else {
  7044. value += rt * Math.pow(2, 1 - eBias)
  7045. }
  7046. if (value * c >= 2) {
  7047. e++
  7048. c /= 2
  7049. }
  7050. if (e + eBias >= eMax) {
  7051. m = 0
  7052. e = eMax
  7053. } else if (e + eBias >= 1) {
  7054. m = ((value * c) - 1) * Math.pow(2, mLen)
  7055. e = e + eBias
  7056. } else {
  7057. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7058. e = 0
  7059. }
  7060. }
  7061. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7062. e = (e << mLen) | m
  7063. eLen += mLen
  7064. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7065. buffer[offset + i - d] |= s * 128
  7066. }
  7067. /***/ }),
  7068. /***/ "./node_modules/isarray/index.js":
  7069. /*!***************************************!*\
  7070. !*** ./node_modules/isarray/index.js ***!
  7071. \***************************************/
  7072. /*! no static exports found */
  7073. /***/ (function(module, exports) {
  7074. var toString = {}.toString;
  7075. module.exports = Array.isArray || function (arr) {
  7076. return toString.call(arr) == '[object Array]';
  7077. };
  7078. /***/ }),
  7079. /***/ "./node_modules/jquery/dist/jquery.js":
  7080. /*!********************************************!*\
  7081. !*** ./node_modules/jquery/dist/jquery.js ***!
  7082. \********************************************/
  7083. /*! no static exports found */
  7084. /***/ (function(module, exports, __webpack_require__) {
  7085. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  7086. * jQuery JavaScript Library v3.4.1
  7087. * https://jquery.com/
  7088. *
  7089. * Includes Sizzle.js
  7090. * https://sizzlejs.com/
  7091. *
  7092. * Copyright JS Foundation and other contributors
  7093. * Released under the MIT license
  7094. * https://jquery.org/license
  7095. *
  7096. * Date: 2019-05-01T21:04Z
  7097. */
  7098. ( function( global, factory ) {
  7099. "use strict";
  7100. if ( true && typeof module.exports === "object" ) {
  7101. // For CommonJS and CommonJS-like environments where a proper `window`
  7102. // is present, execute the factory and get jQuery.
  7103. // For environments that do not have a `window` with a `document`
  7104. // (such as Node.js), expose a factory as module.exports.
  7105. // This accentuates the need for the creation of a real `window`.
  7106. // e.g. var jQuery = require("jquery")(window);
  7107. // See ticket #14549 for more info.
  7108. module.exports = global.document ?
  7109. factory( global, true ) :
  7110. function( w ) {
  7111. if ( !w.document ) {
  7112. throw new Error( "jQuery requires a window with a document" );
  7113. }
  7114. return factory( w );
  7115. };
  7116. } else {
  7117. factory( global );
  7118. }
  7119. // Pass this if window is not defined yet
  7120. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  7121. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  7122. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  7123. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  7124. // enough that all such attempts are guarded in a try block.
  7125. "use strict";
  7126. var arr = [];
  7127. var document = window.document;
  7128. var getProto = Object.getPrototypeOf;
  7129. var slice = arr.slice;
  7130. var concat = arr.concat;
  7131. var push = arr.push;
  7132. var indexOf = arr.indexOf;
  7133. var class2type = {};
  7134. var toString = class2type.toString;
  7135. var hasOwn = class2type.hasOwnProperty;
  7136. var fnToString = hasOwn.toString;
  7137. var ObjectFunctionString = fnToString.call( Object );
  7138. var support = {};
  7139. var isFunction = function isFunction( obj ) {
  7140. // Support: Chrome <=57, Firefox <=52
  7141. // In some browsers, typeof returns "function" for HTML <object> elements
  7142. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  7143. // We don't want to classify *any* DOM node as a function.
  7144. return typeof obj === "function" && typeof obj.nodeType !== "number";
  7145. };
  7146. var isWindow = function isWindow( obj ) {
  7147. return obj != null && obj === obj.window;
  7148. };
  7149. var preservedScriptAttributes = {
  7150. type: true,
  7151. src: true,
  7152. nonce: true,
  7153. noModule: true
  7154. };
  7155. function DOMEval( code, node, doc ) {
  7156. doc = doc || document;
  7157. var i, val,
  7158. script = doc.createElement( "script" );
  7159. script.text = code;
  7160. if ( node ) {
  7161. for ( i in preservedScriptAttributes ) {
  7162. // Support: Firefox 64+, Edge 18+
  7163. // Some browsers don't support the "nonce" property on scripts.
  7164. // On the other hand, just using `getAttribute` is not enough as
  7165. // the `nonce` attribute is reset to an empty string whenever it
  7166. // becomes browsing-context connected.
  7167. // See https://github.com/whatwg/html/issues/2369
  7168. // See https://html.spec.whatwg.org/#nonce-attributes
  7169. // The `node.getAttribute` check was added for the sake of
  7170. // `jQuery.globalEval` so that it can fake a nonce-containing node
  7171. // via an object.
  7172. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  7173. if ( val ) {
  7174. script.setAttribute( i, val );
  7175. }
  7176. }
  7177. }
  7178. doc.head.appendChild( script ).parentNode.removeChild( script );
  7179. }
  7180. function toType( obj ) {
  7181. if ( obj == null ) {
  7182. return obj + "";
  7183. }
  7184. // Support: Android <=2.3 only (functionish RegExp)
  7185. return typeof obj === "object" || typeof obj === "function" ?
  7186. class2type[ toString.call( obj ) ] || "object" :
  7187. typeof obj;
  7188. }
  7189. /* global Symbol */
  7190. // Defining this global in .eslintrc.json would create a danger of using the global
  7191. // unguarded in another place, it seems safer to define global only for this module
  7192. var
  7193. version = "3.4.1",
  7194. // Define a local copy of jQuery
  7195. jQuery = function( selector, context ) {
  7196. // The jQuery object is actually just the init constructor 'enhanced'
  7197. // Need init if jQuery is called (just allow error to be thrown if not included)
  7198. return new jQuery.fn.init( selector, context );
  7199. },
  7200. // Support: Android <=4.0 only
  7201. // Make sure we trim BOM and NBSP
  7202. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  7203. jQuery.fn = jQuery.prototype = {
  7204. // The current version of jQuery being used
  7205. jquery: version,
  7206. constructor: jQuery,
  7207. // The default length of a jQuery object is 0
  7208. length: 0,
  7209. toArray: function() {
  7210. return slice.call( this );
  7211. },
  7212. // Get the Nth element in the matched element set OR
  7213. // Get the whole matched element set as a clean array
  7214. get: function( num ) {
  7215. // Return all the elements in a clean array
  7216. if ( num == null ) {
  7217. return slice.call( this );
  7218. }
  7219. // Return just the one element from the set
  7220. return num < 0 ? this[ num + this.length ] : this[ num ];
  7221. },
  7222. // Take an array of elements and push it onto the stack
  7223. // (returning the new matched element set)
  7224. pushStack: function( elems ) {
  7225. // Build a new jQuery matched element set
  7226. var ret = jQuery.merge( this.constructor(), elems );
  7227. // Add the old object onto the stack (as a reference)
  7228. ret.prevObject = this;
  7229. // Return the newly-formed element set
  7230. return ret;
  7231. },
  7232. // Execute a callback for every element in the matched set.
  7233. each: function( callback ) {
  7234. return jQuery.each( this, callback );
  7235. },
  7236. map: function( callback ) {
  7237. return this.pushStack( jQuery.map( this, function( elem, i ) {
  7238. return callback.call( elem, i, elem );
  7239. } ) );
  7240. },
  7241. slice: function() {
  7242. return this.pushStack( slice.apply( this, arguments ) );
  7243. },
  7244. first: function() {
  7245. return this.eq( 0 );
  7246. },
  7247. last: function() {
  7248. return this.eq( -1 );
  7249. },
  7250. eq: function( i ) {
  7251. var len = this.length,
  7252. j = +i + ( i < 0 ? len : 0 );
  7253. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  7254. },
  7255. end: function() {
  7256. return this.prevObject || this.constructor();
  7257. },
  7258. // For internal use only.
  7259. // Behaves like an Array's method, not like a jQuery method.
  7260. push: push,
  7261. sort: arr.sort,
  7262. splice: arr.splice
  7263. };
  7264. jQuery.extend = jQuery.fn.extend = function() {
  7265. var options, name, src, copy, copyIsArray, clone,
  7266. target = arguments[ 0 ] || {},
  7267. i = 1,
  7268. length = arguments.length,
  7269. deep = false;
  7270. // Handle a deep copy situation
  7271. if ( typeof target === "boolean" ) {
  7272. deep = target;
  7273. // Skip the boolean and the target
  7274. target = arguments[ i ] || {};
  7275. i++;
  7276. }
  7277. // Handle case when target is a string or something (possible in deep copy)
  7278. if ( typeof target !== "object" && !isFunction( target ) ) {
  7279. target = {};
  7280. }
  7281. // Extend jQuery itself if only one argument is passed
  7282. if ( i === length ) {
  7283. target = this;
  7284. i--;
  7285. }
  7286. for ( ; i < length; i++ ) {
  7287. // Only deal with non-null/undefined values
  7288. if ( ( options = arguments[ i ] ) != null ) {
  7289. // Extend the base object
  7290. for ( name in options ) {
  7291. copy = options[ name ];
  7292. // Prevent Object.prototype pollution
  7293. // Prevent never-ending loop
  7294. if ( name === "__proto__" || target === copy ) {
  7295. continue;
  7296. }
  7297. // Recurse if we're merging plain objects or arrays
  7298. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  7299. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  7300. src = target[ name ];
  7301. // Ensure proper type for the source value
  7302. if ( copyIsArray && !Array.isArray( src ) ) {
  7303. clone = [];
  7304. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  7305. clone = {};
  7306. } else {
  7307. clone = src;
  7308. }
  7309. copyIsArray = false;
  7310. // Never move original objects, clone them
  7311. target[ name ] = jQuery.extend( deep, clone, copy );
  7312. // Don't bring in undefined values
  7313. } else if ( copy !== undefined ) {
  7314. target[ name ] = copy;
  7315. }
  7316. }
  7317. }
  7318. }
  7319. // Return the modified object
  7320. return target;
  7321. };
  7322. jQuery.extend( {
  7323. // Unique for each copy of jQuery on the page
  7324. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  7325. // Assume jQuery is ready without the ready module
  7326. isReady: true,
  7327. error: function( msg ) {
  7328. throw new Error( msg );
  7329. },
  7330. noop: function() {},
  7331. isPlainObject: function( obj ) {
  7332. var proto, Ctor;
  7333. // Detect obvious negatives
  7334. // Use toString instead of jQuery.type to catch host objects
  7335. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  7336. return false;
  7337. }
  7338. proto = getProto( obj );
  7339. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  7340. if ( !proto ) {
  7341. return true;
  7342. }
  7343. // Objects with prototype are plain iff they were constructed by a global Object function
  7344. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  7345. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  7346. },
  7347. isEmptyObject: function( obj ) {
  7348. var name;
  7349. for ( name in obj ) {
  7350. return false;
  7351. }
  7352. return true;
  7353. },
  7354. // Evaluates a script in a global context
  7355. globalEval: function( code, options ) {
  7356. DOMEval( code, { nonce: options && options.nonce } );
  7357. },
  7358. each: function( obj, callback ) {
  7359. var length, i = 0;
  7360. if ( isArrayLike( obj ) ) {
  7361. length = obj.length;
  7362. for ( ; i < length; i++ ) {
  7363. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7364. break;
  7365. }
  7366. }
  7367. } else {
  7368. for ( i in obj ) {
  7369. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  7370. break;
  7371. }
  7372. }
  7373. }
  7374. return obj;
  7375. },
  7376. // Support: Android <=4.0 only
  7377. trim: function( text ) {
  7378. return text == null ?
  7379. "" :
  7380. ( text + "" ).replace( rtrim, "" );
  7381. },
  7382. // results is for internal usage only
  7383. makeArray: function( arr, results ) {
  7384. var ret = results || [];
  7385. if ( arr != null ) {
  7386. if ( isArrayLike( Object( arr ) ) ) {
  7387. jQuery.merge( ret,
  7388. typeof arr === "string" ?
  7389. [ arr ] : arr
  7390. );
  7391. } else {
  7392. push.call( ret, arr );
  7393. }
  7394. }
  7395. return ret;
  7396. },
  7397. inArray: function( elem, arr, i ) {
  7398. return arr == null ? -1 : indexOf.call( arr, elem, i );
  7399. },
  7400. // Support: Android <=4.0 only, PhantomJS 1 only
  7401. // push.apply(_, arraylike) throws on ancient WebKit
  7402. merge: function( first, second ) {
  7403. var len = +second.length,
  7404. j = 0,
  7405. i = first.length;
  7406. for ( ; j < len; j++ ) {
  7407. first[ i++ ] = second[ j ];
  7408. }
  7409. first.length = i;
  7410. return first;
  7411. },
  7412. grep: function( elems, callback, invert ) {
  7413. var callbackInverse,
  7414. matches = [],
  7415. i = 0,
  7416. length = elems.length,
  7417. callbackExpect = !invert;
  7418. // Go through the array, only saving the items
  7419. // that pass the validator function
  7420. for ( ; i < length; i++ ) {
  7421. callbackInverse = !callback( elems[ i ], i );
  7422. if ( callbackInverse !== callbackExpect ) {
  7423. matches.push( elems[ i ] );
  7424. }
  7425. }
  7426. return matches;
  7427. },
  7428. // arg is for internal usage only
  7429. map: function( elems, callback, arg ) {
  7430. var length, value,
  7431. i = 0,
  7432. ret = [];
  7433. // Go through the array, translating each of the items to their new values
  7434. if ( isArrayLike( elems ) ) {
  7435. length = elems.length;
  7436. for ( ; i < length; i++ ) {
  7437. value = callback( elems[ i ], i, arg );
  7438. if ( value != null ) {
  7439. ret.push( value );
  7440. }
  7441. }
  7442. // Go through every key on the object,
  7443. } else {
  7444. for ( i in elems ) {
  7445. value = callback( elems[ i ], i, arg );
  7446. if ( value != null ) {
  7447. ret.push( value );
  7448. }
  7449. }
  7450. }
  7451. // Flatten any nested arrays
  7452. return concat.apply( [], ret );
  7453. },
  7454. // A global GUID counter for objects
  7455. guid: 1,
  7456. // jQuery.support is not used in Core but other projects attach their
  7457. // properties to it so it needs to exist.
  7458. support: support
  7459. } );
  7460. if ( typeof Symbol === "function" ) {
  7461. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  7462. }
  7463. // Populate the class2type map
  7464. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  7465. function( i, name ) {
  7466. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  7467. } );
  7468. function isArrayLike( obj ) {
  7469. // Support: real iOS 8.2 only (not reproducible in simulator)
  7470. // `in` check used to prevent JIT error (gh-2145)
  7471. // hasOwn isn't used here due to false negatives
  7472. // regarding Nodelist length in IE
  7473. var length = !!obj && "length" in obj && obj.length,
  7474. type = toType( obj );
  7475. if ( isFunction( obj ) || isWindow( obj ) ) {
  7476. return false;
  7477. }
  7478. return type === "array" || length === 0 ||
  7479. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  7480. }
  7481. var Sizzle =
  7482. /*!
  7483. * Sizzle CSS Selector Engine v2.3.4
  7484. * https://sizzlejs.com/
  7485. *
  7486. * Copyright JS Foundation and other contributors
  7487. * Released under the MIT license
  7488. * https://js.foundation/
  7489. *
  7490. * Date: 2019-04-08
  7491. */
  7492. (function( window ) {
  7493. var i,
  7494. support,
  7495. Expr,
  7496. getText,
  7497. isXML,
  7498. tokenize,
  7499. compile,
  7500. select,
  7501. outermostContext,
  7502. sortInput,
  7503. hasDuplicate,
  7504. // Local document vars
  7505. setDocument,
  7506. document,
  7507. docElem,
  7508. documentIsHTML,
  7509. rbuggyQSA,
  7510. rbuggyMatches,
  7511. matches,
  7512. contains,
  7513. // Instance-specific data
  7514. expando = "sizzle" + 1 * new Date(),
  7515. preferredDoc = window.document,
  7516. dirruns = 0,
  7517. done = 0,
  7518. classCache = createCache(),
  7519. tokenCache = createCache(),
  7520. compilerCache = createCache(),
  7521. nonnativeSelectorCache = createCache(),
  7522. sortOrder = function( a, b ) {
  7523. if ( a === b ) {
  7524. hasDuplicate = true;
  7525. }
  7526. return 0;
  7527. },
  7528. // Instance methods
  7529. hasOwn = ({}).hasOwnProperty,
  7530. arr = [],
  7531. pop = arr.pop,
  7532. push_native = arr.push,
  7533. push = arr.push,
  7534. slice = arr.slice,
  7535. // Use a stripped-down indexOf as it's faster than native
  7536. // https://jsperf.com/thor-indexof-vs-for/5
  7537. indexOf = function( list, elem ) {
  7538. var i = 0,
  7539. len = list.length;
  7540. for ( ; i < len; i++ ) {
  7541. if ( list[i] === elem ) {
  7542. return i;
  7543. }
  7544. }
  7545. return -1;
  7546. },
  7547. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  7548. // Regular expressions
  7549. // http://www.w3.org/TR/css3-selectors/#whitespace
  7550. whitespace = "[\\x20\\t\\r\\n\\f]",
  7551. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  7552. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  7553. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  7554. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  7555. // Operator (capture 2)
  7556. "*([*^$|!~]?=)" + whitespace +
  7557. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  7558. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  7559. "*\\]",
  7560. pseudos = ":(" + identifier + ")(?:\\((" +
  7561. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  7562. // 1. quoted (capture 3; capture 4 or capture 5)
  7563. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  7564. // 2. simple (capture 6)
  7565. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  7566. // 3. anything else (capture 2)
  7567. ".*" +
  7568. ")\\)|)",
  7569. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  7570. rwhitespace = new RegExp( whitespace + "+", "g" ),
  7571. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  7572. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  7573. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  7574. rdescend = new RegExp( whitespace + "|>" ),
  7575. rpseudo = new RegExp( pseudos ),
  7576. ridentifier = new RegExp( "^" + identifier + "$" ),
  7577. matchExpr = {
  7578. "ID": new RegExp( "^#(" + identifier + ")" ),
  7579. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  7580. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  7581. "ATTR": new RegExp( "^" + attributes ),
  7582. "PSEUDO": new RegExp( "^" + pseudos ),
  7583. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  7584. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  7585. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  7586. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  7587. // For use in libraries implementing .is()
  7588. // We use this for POS matching in `select`
  7589. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  7590. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  7591. },
  7592. rhtml = /HTML$/i,
  7593. rinputs = /^(?:input|select|textarea|button)$/i,
  7594. rheader = /^h\d$/i,
  7595. rnative = /^[^{]+\{\s*\[native \w/,
  7596. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  7597. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  7598. rsibling = /[+~]/,
  7599. // CSS escapes
  7600. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  7601. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  7602. funescape = function( _, escaped, escapedWhitespace ) {
  7603. var high = "0x" + escaped - 0x10000;
  7604. // NaN means non-codepoint
  7605. // Support: Firefox<24
  7606. // Workaround erroneous numeric interpretation of +"0x"
  7607. return high !== high || escapedWhitespace ?
  7608. escaped :
  7609. high < 0 ?
  7610. // BMP codepoint
  7611. String.fromCharCode( high + 0x10000 ) :
  7612. // Supplemental Plane codepoint (surrogate pair)
  7613. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  7614. },
  7615. // CSS string/identifier serialization
  7616. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  7617. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  7618. fcssescape = function( ch, asCodePoint ) {
  7619. if ( asCodePoint ) {
  7620. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  7621. if ( ch === "\0" ) {
  7622. return "\uFFFD";
  7623. }
  7624. // Control characters and (dependent upon position) numbers get escaped as code points
  7625. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  7626. }
  7627. // Other potentially-special ASCII characters get backslash-escaped
  7628. return "\\" + ch;
  7629. },
  7630. // Used for iframes
  7631. // See setDocument()
  7632. // Removing the function wrapper causes a "Permission Denied"
  7633. // error in IE
  7634. unloadHandler = function() {
  7635. setDocument();
  7636. },
  7637. inDisabledFieldset = addCombinator(
  7638. function( elem ) {
  7639. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  7640. },
  7641. { dir: "parentNode", next: "legend" }
  7642. );
  7643. // Optimize for push.apply( _, NodeList )
  7644. try {
  7645. push.apply(
  7646. (arr = slice.call( preferredDoc.childNodes )),
  7647. preferredDoc.childNodes
  7648. );
  7649. // Support: Android<4.0
  7650. // Detect silently failing push.apply
  7651. arr[ preferredDoc.childNodes.length ].nodeType;
  7652. } catch ( e ) {
  7653. push = { apply: arr.length ?
  7654. // Leverage slice if possible
  7655. function( target, els ) {
  7656. push_native.apply( target, slice.call(els) );
  7657. } :
  7658. // Support: IE<9
  7659. // Otherwise append directly
  7660. function( target, els ) {
  7661. var j = target.length,
  7662. i = 0;
  7663. // Can't trust NodeList.length
  7664. while ( (target[j++] = els[i++]) ) {}
  7665. target.length = j - 1;
  7666. }
  7667. };
  7668. }
  7669. function Sizzle( selector, context, results, seed ) {
  7670. var m, i, elem, nid, match, groups, newSelector,
  7671. newContext = context && context.ownerDocument,
  7672. // nodeType defaults to 9, since context defaults to document
  7673. nodeType = context ? context.nodeType : 9;
  7674. results = results || [];
  7675. // Return early from calls with invalid selector or context
  7676. if ( typeof selector !== "string" || !selector ||
  7677. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  7678. return results;
  7679. }
  7680. // Try to shortcut find operations (as opposed to filters) in HTML documents
  7681. if ( !seed ) {
  7682. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  7683. setDocument( context );
  7684. }
  7685. context = context || document;
  7686. if ( documentIsHTML ) {
  7687. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  7688. // (excepting DocumentFragment context, where the methods don't exist)
  7689. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  7690. // ID selector
  7691. if ( (m = match[1]) ) {
  7692. // Document context
  7693. if ( nodeType === 9 ) {
  7694. if ( (elem = context.getElementById( m )) ) {
  7695. // Support: IE, Opera, Webkit
  7696. // TODO: identify versions
  7697. // getElementById can match elements by name instead of ID
  7698. if ( elem.id === m ) {
  7699. results.push( elem );
  7700. return results;
  7701. }
  7702. } else {
  7703. return results;
  7704. }
  7705. // Element context
  7706. } else {
  7707. // Support: IE, Opera, Webkit
  7708. // TODO: identify versions
  7709. // getElementById can match elements by name instead of ID
  7710. if ( newContext && (elem = newContext.getElementById( m )) &&
  7711. contains( context, elem ) &&
  7712. elem.id === m ) {
  7713. results.push( elem );
  7714. return results;
  7715. }
  7716. }
  7717. // Type selector
  7718. } else if ( match[2] ) {
  7719. push.apply( results, context.getElementsByTagName( selector ) );
  7720. return results;
  7721. // Class selector
  7722. } else if ( (m = match[3]) && support.getElementsByClassName &&
  7723. context.getElementsByClassName ) {
  7724. push.apply( results, context.getElementsByClassName( m ) );
  7725. return results;
  7726. }
  7727. }
  7728. // Take advantage of querySelectorAll
  7729. if ( support.qsa &&
  7730. !nonnativeSelectorCache[ selector + " " ] &&
  7731. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  7732. // Support: IE 8 only
  7733. // Exclude object elements
  7734. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  7735. newSelector = selector;
  7736. newContext = context;
  7737. // qSA considers elements outside a scoping root when evaluating child or
  7738. // descendant combinators, which is not what we want.
  7739. // In such cases, we work around the behavior by prefixing every selector in the
  7740. // list with an ID selector referencing the scope context.
  7741. // Thanks to Andrew Dupont for this technique.
  7742. if ( nodeType === 1 && rdescend.test( selector ) ) {
  7743. // Capture the context ID, setting it first if necessary
  7744. if ( (nid = context.getAttribute( "id" )) ) {
  7745. nid = nid.replace( rcssescape, fcssescape );
  7746. } else {
  7747. context.setAttribute( "id", (nid = expando) );
  7748. }
  7749. // Prefix every selector in the list
  7750. groups = tokenize( selector );
  7751. i = groups.length;
  7752. while ( i-- ) {
  7753. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  7754. }
  7755. newSelector = groups.join( "," );
  7756. // Expand context for sibling selectors
  7757. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  7758. context;
  7759. }
  7760. try {
  7761. push.apply( results,
  7762. newContext.querySelectorAll( newSelector )
  7763. );
  7764. return results;
  7765. } catch ( qsaError ) {
  7766. nonnativeSelectorCache( selector, true );
  7767. } finally {
  7768. if ( nid === expando ) {
  7769. context.removeAttribute( "id" );
  7770. }
  7771. }
  7772. }
  7773. }
  7774. }
  7775. // All others
  7776. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  7777. }
  7778. /**
  7779. * Create key-value caches of limited size
  7780. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  7781. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  7782. * deleting the oldest entry
  7783. */
  7784. function createCache() {
  7785. var keys = [];
  7786. function cache( key, value ) {
  7787. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  7788. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  7789. // Only keep the most recent entries
  7790. delete cache[ keys.shift() ];
  7791. }
  7792. return (cache[ key + " " ] = value);
  7793. }
  7794. return cache;
  7795. }
  7796. /**
  7797. * Mark a function for special use by Sizzle
  7798. * @param {Function} fn The function to mark
  7799. */
  7800. function markFunction( fn ) {
  7801. fn[ expando ] = true;
  7802. return fn;
  7803. }
  7804. /**
  7805. * Support testing using an element
  7806. * @param {Function} fn Passed the created element and returns a boolean result
  7807. */
  7808. function assert( fn ) {
  7809. var el = document.createElement("fieldset");
  7810. try {
  7811. return !!fn( el );
  7812. } catch (e) {
  7813. return false;
  7814. } finally {
  7815. // Remove from its parent by default
  7816. if ( el.parentNode ) {
  7817. el.parentNode.removeChild( el );
  7818. }
  7819. // release memory in IE
  7820. el = null;
  7821. }
  7822. }
  7823. /**
  7824. * Adds the same handler for all of the specified attrs
  7825. * @param {String} attrs Pipe-separated list of attributes
  7826. * @param {Function} handler The method that will be applied
  7827. */
  7828. function addHandle( attrs, handler ) {
  7829. var arr = attrs.split("|"),
  7830. i = arr.length;
  7831. while ( i-- ) {
  7832. Expr.attrHandle[ arr[i] ] = handler;
  7833. }
  7834. }
  7835. /**
  7836. * Checks document order of two siblings
  7837. * @param {Element} a
  7838. * @param {Element} b
  7839. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  7840. */
  7841. function siblingCheck( a, b ) {
  7842. var cur = b && a,
  7843. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  7844. a.sourceIndex - b.sourceIndex;
  7845. // Use IE sourceIndex if available on both nodes
  7846. if ( diff ) {
  7847. return diff;
  7848. }
  7849. // Check if b follows a
  7850. if ( cur ) {
  7851. while ( (cur = cur.nextSibling) ) {
  7852. if ( cur === b ) {
  7853. return -1;
  7854. }
  7855. }
  7856. }
  7857. return a ? 1 : -1;
  7858. }
  7859. /**
  7860. * Returns a function to use in pseudos for input types
  7861. * @param {String} type
  7862. */
  7863. function createInputPseudo( type ) {
  7864. return function( elem ) {
  7865. var name = elem.nodeName.toLowerCase();
  7866. return name === "input" && elem.type === type;
  7867. };
  7868. }
  7869. /**
  7870. * Returns a function to use in pseudos for buttons
  7871. * @param {String} type
  7872. */
  7873. function createButtonPseudo( type ) {
  7874. return function( elem ) {
  7875. var name = elem.nodeName.toLowerCase();
  7876. return (name === "input" || name === "button") && elem.type === type;
  7877. };
  7878. }
  7879. /**
  7880. * Returns a function to use in pseudos for :enabled/:disabled
  7881. * @param {Boolean} disabled true for :disabled; false for :enabled
  7882. */
  7883. function createDisabledPseudo( disabled ) {
  7884. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  7885. return function( elem ) {
  7886. // Only certain elements can match :enabled or :disabled
  7887. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  7888. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  7889. if ( "form" in elem ) {
  7890. // Check for inherited disabledness on relevant non-disabled elements:
  7891. // * listed form-associated elements in a disabled fieldset
  7892. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  7893. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  7894. // * option elements in a disabled optgroup
  7895. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  7896. // All such elements have a "form" property.
  7897. if ( elem.parentNode && elem.disabled === false ) {
  7898. // Option elements defer to a parent optgroup if present
  7899. if ( "label" in elem ) {
  7900. if ( "label" in elem.parentNode ) {
  7901. return elem.parentNode.disabled === disabled;
  7902. } else {
  7903. return elem.disabled === disabled;
  7904. }
  7905. }
  7906. // Support: IE 6 - 11
  7907. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  7908. return elem.isDisabled === disabled ||
  7909. // Where there is no isDisabled, check manually
  7910. /* jshint -W018 */
  7911. elem.isDisabled !== !disabled &&
  7912. inDisabledFieldset( elem ) === disabled;
  7913. }
  7914. return elem.disabled === disabled;
  7915. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  7916. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  7917. // even exist on them, let alone have a boolean value.
  7918. } else if ( "label" in elem ) {
  7919. return elem.disabled === disabled;
  7920. }
  7921. // Remaining elements are neither :enabled nor :disabled
  7922. return false;
  7923. };
  7924. }
  7925. /**
  7926. * Returns a function to use in pseudos for positionals
  7927. * @param {Function} fn
  7928. */
  7929. function createPositionalPseudo( fn ) {
  7930. return markFunction(function( argument ) {
  7931. argument = +argument;
  7932. return markFunction(function( seed, matches ) {
  7933. var j,
  7934. matchIndexes = fn( [], seed.length, argument ),
  7935. i = matchIndexes.length;
  7936. // Match elements found at the specified indexes
  7937. while ( i-- ) {
  7938. if ( seed[ (j = matchIndexes[i]) ] ) {
  7939. seed[j] = !(matches[j] = seed[j]);
  7940. }
  7941. }
  7942. });
  7943. });
  7944. }
  7945. /**
  7946. * Checks a node for validity as a Sizzle context
  7947. * @param {Element|Object=} context
  7948. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  7949. */
  7950. function testContext( context ) {
  7951. return context && typeof context.getElementsByTagName !== "undefined" && context;
  7952. }
  7953. // Expose support vars for convenience
  7954. support = Sizzle.support = {};
  7955. /**
  7956. * Detects XML nodes
  7957. * @param {Element|Object} elem An element or a document
  7958. * @returns {Boolean} True iff elem is a non-HTML XML node
  7959. */
  7960. isXML = Sizzle.isXML = function( elem ) {
  7961. var namespace = elem.namespaceURI,
  7962. docElem = (elem.ownerDocument || elem).documentElement;
  7963. // Support: IE <=8
  7964. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  7965. // https://bugs.jquery.com/ticket/4833
  7966. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  7967. };
  7968. /**
  7969. * Sets document-related variables once based on the current document
  7970. * @param {Element|Object} [doc] An element or document object to use to set the document
  7971. * @returns {Object} Returns the current document
  7972. */
  7973. setDocument = Sizzle.setDocument = function( node ) {
  7974. var hasCompare, subWindow,
  7975. doc = node ? node.ownerDocument || node : preferredDoc;
  7976. // Return early if doc is invalid or already selected
  7977. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  7978. return document;
  7979. }
  7980. // Update global variables
  7981. document = doc;
  7982. docElem = document.documentElement;
  7983. documentIsHTML = !isXML( document );
  7984. // Support: IE 9-11, Edge
  7985. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  7986. if ( preferredDoc !== document &&
  7987. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  7988. // Support: IE 11, Edge
  7989. if ( subWindow.addEventListener ) {
  7990. subWindow.addEventListener( "unload", unloadHandler, false );
  7991. // Support: IE 9 - 10 only
  7992. } else if ( subWindow.attachEvent ) {
  7993. subWindow.attachEvent( "onunload", unloadHandler );
  7994. }
  7995. }
  7996. /* Attributes
  7997. ---------------------------------------------------------------------- */
  7998. // Support: IE<8
  7999. // Verify that getAttribute really returns attributes and not properties
  8000. // (excepting IE8 booleans)
  8001. support.attributes = assert(function( el ) {
  8002. el.className = "i";
  8003. return !el.getAttribute("className");
  8004. });
  8005. /* getElement(s)By*
  8006. ---------------------------------------------------------------------- */
  8007. // Check if getElementsByTagName("*") returns only elements
  8008. support.getElementsByTagName = assert(function( el ) {
  8009. el.appendChild( document.createComment("") );
  8010. return !el.getElementsByTagName("*").length;
  8011. });
  8012. // Support: IE<9
  8013. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8014. // Support: IE<10
  8015. // Check if getElementById returns elements by name
  8016. // The broken getElementById methods don't pick up programmatically-set names,
  8017. // so use a roundabout getElementsByName test
  8018. support.getById = assert(function( el ) {
  8019. docElem.appendChild( el ).id = expando;
  8020. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8021. });
  8022. // ID filter and find
  8023. if ( support.getById ) {
  8024. Expr.filter["ID"] = function( id ) {
  8025. var attrId = id.replace( runescape, funescape );
  8026. return function( elem ) {
  8027. return elem.getAttribute("id") === attrId;
  8028. };
  8029. };
  8030. Expr.find["ID"] = function( id, context ) {
  8031. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8032. var elem = context.getElementById( id );
  8033. return elem ? [ elem ] : [];
  8034. }
  8035. };
  8036. } else {
  8037. Expr.filter["ID"] = function( id ) {
  8038. var attrId = id.replace( runescape, funescape );
  8039. return function( elem ) {
  8040. var node = typeof elem.getAttributeNode !== "undefined" &&
  8041. elem.getAttributeNode("id");
  8042. return node && node.value === attrId;
  8043. };
  8044. };
  8045. // Support: IE 6 - 7 only
  8046. // getElementById is not reliable as a find shortcut
  8047. Expr.find["ID"] = function( id, context ) {
  8048. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8049. var node, i, elems,
  8050. elem = context.getElementById( id );
  8051. if ( elem ) {
  8052. // Verify the id attribute
  8053. node = elem.getAttributeNode("id");
  8054. if ( node && node.value === id ) {
  8055. return [ elem ];
  8056. }
  8057. // Fall back on getElementsByName
  8058. elems = context.getElementsByName( id );
  8059. i = 0;
  8060. while ( (elem = elems[i++]) ) {
  8061. node = elem.getAttributeNode("id");
  8062. if ( node && node.value === id ) {
  8063. return [ elem ];
  8064. }
  8065. }
  8066. }
  8067. return [];
  8068. }
  8069. };
  8070. }
  8071. // Tag
  8072. Expr.find["TAG"] = support.getElementsByTagName ?
  8073. function( tag, context ) {
  8074. if ( typeof context.getElementsByTagName !== "undefined" ) {
  8075. return context.getElementsByTagName( tag );
  8076. // DocumentFragment nodes don't have gEBTN
  8077. } else if ( support.qsa ) {
  8078. return context.querySelectorAll( tag );
  8079. }
  8080. } :
  8081. function( tag, context ) {
  8082. var elem,
  8083. tmp = [],
  8084. i = 0,
  8085. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  8086. results = context.getElementsByTagName( tag );
  8087. // Filter out possible comments
  8088. if ( tag === "*" ) {
  8089. while ( (elem = results[i++]) ) {
  8090. if ( elem.nodeType === 1 ) {
  8091. tmp.push( elem );
  8092. }
  8093. }
  8094. return tmp;
  8095. }
  8096. return results;
  8097. };
  8098. // Class
  8099. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  8100. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  8101. return context.getElementsByClassName( className );
  8102. }
  8103. };
  8104. /* QSA/matchesSelector
  8105. ---------------------------------------------------------------------- */
  8106. // QSA and matchesSelector support
  8107. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  8108. rbuggyMatches = [];
  8109. // qSa(:focus) reports false when true (Chrome 21)
  8110. // We allow this because of a bug in IE8/9 that throws an error
  8111. // whenever `document.activeElement` is accessed on an iframe
  8112. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  8113. // See https://bugs.jquery.com/ticket/13378
  8114. rbuggyQSA = [];
  8115. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  8116. // Build QSA regex
  8117. // Regex strategy adopted from Diego Perini
  8118. assert(function( el ) {
  8119. // Select is set to empty string on purpose
  8120. // This is to test IE's treatment of not explicitly
  8121. // setting a boolean content attribute,
  8122. // since its presence should be enough
  8123. // https://bugs.jquery.com/ticket/12359
  8124. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  8125. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  8126. "<option selected=''></option></select>";
  8127. // Support: IE8, Opera 11-12.16
  8128. // Nothing should be selected when empty strings follow ^= or $= or *=
  8129. // The test attribute must be unknown in Opera but "safe" for WinRT
  8130. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  8131. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  8132. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  8133. }
  8134. // Support: IE8
  8135. // Boolean attributes and "value" are not treated correctly
  8136. if ( !el.querySelectorAll("[selected]").length ) {
  8137. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  8138. }
  8139. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  8140. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  8141. rbuggyQSA.push("~=");
  8142. }
  8143. // Webkit/Opera - :checked should return selected option elements
  8144. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8145. // IE8 throws error here and will not see later tests
  8146. if ( !el.querySelectorAll(":checked").length ) {
  8147. rbuggyQSA.push(":checked");
  8148. }
  8149. // Support: Safari 8+, iOS 8+
  8150. // https://bugs.webkit.org/show_bug.cgi?id=136851
  8151. // In-page `selector#id sibling-combinator selector` fails
  8152. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  8153. rbuggyQSA.push(".#.+[+~]");
  8154. }
  8155. });
  8156. assert(function( el ) {
  8157. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  8158. "<select disabled='disabled'><option/></select>";
  8159. // Support: Windows 8 Native Apps
  8160. // The type and name attributes are restricted during .innerHTML assignment
  8161. var input = document.createElement("input");
  8162. input.setAttribute( "type", "hidden" );
  8163. el.appendChild( input ).setAttribute( "name", "D" );
  8164. // Support: IE8
  8165. // Enforce case-sensitivity of name attribute
  8166. if ( el.querySelectorAll("[name=d]").length ) {
  8167. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  8168. }
  8169. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  8170. // IE8 throws error here and will not see later tests
  8171. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  8172. rbuggyQSA.push( ":enabled", ":disabled" );
  8173. }
  8174. // Support: IE9-11+
  8175. // IE's :disabled selector does not pick up the children of disabled fieldsets
  8176. docElem.appendChild( el ).disabled = true;
  8177. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  8178. rbuggyQSA.push( ":enabled", ":disabled" );
  8179. }
  8180. // Opera 10-11 does not throw on post-comma invalid pseudos
  8181. el.querySelectorAll("*,:x");
  8182. rbuggyQSA.push(",.*:");
  8183. });
  8184. }
  8185. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  8186. docElem.webkitMatchesSelector ||
  8187. docElem.mozMatchesSelector ||
  8188. docElem.oMatchesSelector ||
  8189. docElem.msMatchesSelector) )) ) {
  8190. assert(function( el ) {
  8191. // Check to see if it's possible to do matchesSelector
  8192. // on a disconnected node (IE 9)
  8193. support.disconnectedMatch = matches.call( el, "*" );
  8194. // This should fail with an exception
  8195. // Gecko does not error, returns false instead
  8196. matches.call( el, "[s!='']:x" );
  8197. rbuggyMatches.push( "!=", pseudos );
  8198. });
  8199. }
  8200. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  8201. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  8202. /* Contains
  8203. ---------------------------------------------------------------------- */
  8204. hasCompare = rnative.test( docElem.compareDocumentPosition );
  8205. // Element contains another
  8206. // Purposefully self-exclusive
  8207. // As in, an element does not contain itself
  8208. contains = hasCompare || rnative.test( docElem.contains ) ?
  8209. function( a, b ) {
  8210. var adown = a.nodeType === 9 ? a.documentElement : a,
  8211. bup = b && b.parentNode;
  8212. return a === bup || !!( bup && bup.nodeType === 1 && (
  8213. adown.contains ?
  8214. adown.contains( bup ) :
  8215. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  8216. ));
  8217. } :
  8218. function( a, b ) {
  8219. if ( b ) {
  8220. while ( (b = b.parentNode) ) {
  8221. if ( b === a ) {
  8222. return true;
  8223. }
  8224. }
  8225. }
  8226. return false;
  8227. };
  8228. /* Sorting
  8229. ---------------------------------------------------------------------- */
  8230. // Document order sorting
  8231. sortOrder = hasCompare ?
  8232. function( a, b ) {
  8233. // Flag for duplicate removal
  8234. if ( a === b ) {
  8235. hasDuplicate = true;
  8236. return 0;
  8237. }
  8238. // Sort on method existence if only one input has compareDocumentPosition
  8239. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  8240. if ( compare ) {
  8241. return compare;
  8242. }
  8243. // Calculate position if both inputs belong to the same document
  8244. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  8245. a.compareDocumentPosition( b ) :
  8246. // Otherwise we know they are disconnected
  8247. 1;
  8248. // Disconnected nodes
  8249. if ( compare & 1 ||
  8250. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  8251. // Choose the first element that is related to our preferred document
  8252. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  8253. return -1;
  8254. }
  8255. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  8256. return 1;
  8257. }
  8258. // Maintain original order
  8259. return sortInput ?
  8260. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8261. 0;
  8262. }
  8263. return compare & 4 ? -1 : 1;
  8264. } :
  8265. function( a, b ) {
  8266. // Exit early if the nodes are identical
  8267. if ( a === b ) {
  8268. hasDuplicate = true;
  8269. return 0;
  8270. }
  8271. var cur,
  8272. i = 0,
  8273. aup = a.parentNode,
  8274. bup = b.parentNode,
  8275. ap = [ a ],
  8276. bp = [ b ];
  8277. // Parentless nodes are either documents or disconnected
  8278. if ( !aup || !bup ) {
  8279. return a === document ? -1 :
  8280. b === document ? 1 :
  8281. aup ? -1 :
  8282. bup ? 1 :
  8283. sortInput ?
  8284. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  8285. 0;
  8286. // If the nodes are siblings, we can do a quick check
  8287. } else if ( aup === bup ) {
  8288. return siblingCheck( a, b );
  8289. }
  8290. // Otherwise we need full lists of their ancestors for comparison
  8291. cur = a;
  8292. while ( (cur = cur.parentNode) ) {
  8293. ap.unshift( cur );
  8294. }
  8295. cur = b;
  8296. while ( (cur = cur.parentNode) ) {
  8297. bp.unshift( cur );
  8298. }
  8299. // Walk down the tree looking for a discrepancy
  8300. while ( ap[i] === bp[i] ) {
  8301. i++;
  8302. }
  8303. return i ?
  8304. // Do a sibling check if the nodes have a common ancestor
  8305. siblingCheck( ap[i], bp[i] ) :
  8306. // Otherwise nodes in our document sort first
  8307. ap[i] === preferredDoc ? -1 :
  8308. bp[i] === preferredDoc ? 1 :
  8309. 0;
  8310. };
  8311. return document;
  8312. };
  8313. Sizzle.matches = function( expr, elements ) {
  8314. return Sizzle( expr, null, null, elements );
  8315. };
  8316. Sizzle.matchesSelector = function( elem, expr ) {
  8317. // Set document vars if needed
  8318. if ( ( elem.ownerDocument || elem ) !== document ) {
  8319. setDocument( elem );
  8320. }
  8321. if ( support.matchesSelector && documentIsHTML &&
  8322. !nonnativeSelectorCache[ expr + " " ] &&
  8323. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  8324. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  8325. try {
  8326. var ret = matches.call( elem, expr );
  8327. // IE 9's matchesSelector returns false on disconnected nodes
  8328. if ( ret || support.disconnectedMatch ||
  8329. // As well, disconnected nodes are said to be in a document
  8330. // fragment in IE 9
  8331. elem.document && elem.document.nodeType !== 11 ) {
  8332. return ret;
  8333. }
  8334. } catch (e) {
  8335. nonnativeSelectorCache( expr, true );
  8336. }
  8337. }
  8338. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  8339. };
  8340. Sizzle.contains = function( context, elem ) {
  8341. // Set document vars if needed
  8342. if ( ( context.ownerDocument || context ) !== document ) {
  8343. setDocument( context );
  8344. }
  8345. return contains( context, elem );
  8346. };
  8347. Sizzle.attr = function( elem, name ) {
  8348. // Set document vars if needed
  8349. if ( ( elem.ownerDocument || elem ) !== document ) {
  8350. setDocument( elem );
  8351. }
  8352. var fn = Expr.attrHandle[ name.toLowerCase() ],
  8353. // Don't get fooled by Object.prototype properties (jQuery #13807)
  8354. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  8355. fn( elem, name, !documentIsHTML ) :
  8356. undefined;
  8357. return val !== undefined ?
  8358. val :
  8359. support.attributes || !documentIsHTML ?
  8360. elem.getAttribute( name ) :
  8361. (val = elem.getAttributeNode(name)) && val.specified ?
  8362. val.value :
  8363. null;
  8364. };
  8365. Sizzle.escape = function( sel ) {
  8366. return (sel + "").replace( rcssescape, fcssescape );
  8367. };
  8368. Sizzle.error = function( msg ) {
  8369. throw new Error( "Syntax error, unrecognized expression: " + msg );
  8370. };
  8371. /**
  8372. * Document sorting and removing duplicates
  8373. * @param {ArrayLike} results
  8374. */
  8375. Sizzle.uniqueSort = function( results ) {
  8376. var elem,
  8377. duplicates = [],
  8378. j = 0,
  8379. i = 0;
  8380. // Unless we *know* we can detect duplicates, assume their presence
  8381. hasDuplicate = !support.detectDuplicates;
  8382. sortInput = !support.sortStable && results.slice( 0 );
  8383. results.sort( sortOrder );
  8384. if ( hasDuplicate ) {
  8385. while ( (elem = results[i++]) ) {
  8386. if ( elem === results[ i ] ) {
  8387. j = duplicates.push( i );
  8388. }
  8389. }
  8390. while ( j-- ) {
  8391. results.splice( duplicates[ j ], 1 );
  8392. }
  8393. }
  8394. // Clear input after sorting to release objects
  8395. // See https://github.com/jquery/sizzle/pull/225
  8396. sortInput = null;
  8397. return results;
  8398. };
  8399. /**
  8400. * Utility function for retrieving the text value of an array of DOM nodes
  8401. * @param {Array|Element} elem
  8402. */
  8403. getText = Sizzle.getText = function( elem ) {
  8404. var node,
  8405. ret = "",
  8406. i = 0,
  8407. nodeType = elem.nodeType;
  8408. if ( !nodeType ) {
  8409. // If no nodeType, this is expected to be an array
  8410. while ( (node = elem[i++]) ) {
  8411. // Do not traverse comment nodes
  8412. ret += getText( node );
  8413. }
  8414. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  8415. // Use textContent for elements
  8416. // innerText usage removed for consistency of new lines (jQuery #11153)
  8417. if ( typeof elem.textContent === "string" ) {
  8418. return elem.textContent;
  8419. } else {
  8420. // Traverse its children
  8421. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8422. ret += getText( elem );
  8423. }
  8424. }
  8425. } else if ( nodeType === 3 || nodeType === 4 ) {
  8426. return elem.nodeValue;
  8427. }
  8428. // Do not include comment or processing instruction nodes
  8429. return ret;
  8430. };
  8431. Expr = Sizzle.selectors = {
  8432. // Can be adjusted by the user
  8433. cacheLength: 50,
  8434. createPseudo: markFunction,
  8435. match: matchExpr,
  8436. attrHandle: {},
  8437. find: {},
  8438. relative: {
  8439. ">": { dir: "parentNode", first: true },
  8440. " ": { dir: "parentNode" },
  8441. "+": { dir: "previousSibling", first: true },
  8442. "~": { dir: "previousSibling" }
  8443. },
  8444. preFilter: {
  8445. "ATTR": function( match ) {
  8446. match[1] = match[1].replace( runescape, funescape );
  8447. // Move the given value to match[3] whether quoted or unquoted
  8448. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  8449. if ( match[2] === "~=" ) {
  8450. match[3] = " " + match[3] + " ";
  8451. }
  8452. return match.slice( 0, 4 );
  8453. },
  8454. "CHILD": function( match ) {
  8455. /* matches from matchExpr["CHILD"]
  8456. 1 type (only|nth|...)
  8457. 2 what (child|of-type)
  8458. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  8459. 4 xn-component of xn+y argument ([+-]?\d*n|)
  8460. 5 sign of xn-component
  8461. 6 x of xn-component
  8462. 7 sign of y-component
  8463. 8 y of y-component
  8464. */
  8465. match[1] = match[1].toLowerCase();
  8466. if ( match[1].slice( 0, 3 ) === "nth" ) {
  8467. // nth-* requires argument
  8468. if ( !match[3] ) {
  8469. Sizzle.error( match[0] );
  8470. }
  8471. // numeric x and y parameters for Expr.filter.CHILD
  8472. // remember that false/true cast respectively to 0/1
  8473. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  8474. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  8475. // other types prohibit arguments
  8476. } else if ( match[3] ) {
  8477. Sizzle.error( match[0] );
  8478. }
  8479. return match;
  8480. },
  8481. "PSEUDO": function( match ) {
  8482. var excess,
  8483. unquoted = !match[6] && match[2];
  8484. if ( matchExpr["CHILD"].test( match[0] ) ) {
  8485. return null;
  8486. }
  8487. // Accept quoted arguments as-is
  8488. if ( match[3] ) {
  8489. match[2] = match[4] || match[5] || "";
  8490. // Strip excess characters from unquoted arguments
  8491. } else if ( unquoted && rpseudo.test( unquoted ) &&
  8492. // Get excess from tokenize (recursively)
  8493. (excess = tokenize( unquoted, true )) &&
  8494. // advance to the next closing parenthesis
  8495. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  8496. // excess is a negative index
  8497. match[0] = match[0].slice( 0, excess );
  8498. match[2] = unquoted.slice( 0, excess );
  8499. }
  8500. // Return only captures needed by the pseudo filter method (type and argument)
  8501. return match.slice( 0, 3 );
  8502. }
  8503. },
  8504. filter: {
  8505. "TAG": function( nodeNameSelector ) {
  8506. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  8507. return nodeNameSelector === "*" ?
  8508. function() { return true; } :
  8509. function( elem ) {
  8510. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  8511. };
  8512. },
  8513. "CLASS": function( className ) {
  8514. var pattern = classCache[ className + " " ];
  8515. return pattern ||
  8516. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  8517. classCache( className, function( elem ) {
  8518. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  8519. });
  8520. },
  8521. "ATTR": function( name, operator, check ) {
  8522. return function( elem ) {
  8523. var result = Sizzle.attr( elem, name );
  8524. if ( result == null ) {
  8525. return operator === "!=";
  8526. }
  8527. if ( !operator ) {
  8528. return true;
  8529. }
  8530. result += "";
  8531. return operator === "=" ? result === check :
  8532. operator === "!=" ? result !== check :
  8533. operator === "^=" ? check && result.indexOf( check ) === 0 :
  8534. operator === "*=" ? check && result.indexOf( check ) > -1 :
  8535. operator === "$=" ? check && result.slice( -check.length ) === check :
  8536. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  8537. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  8538. false;
  8539. };
  8540. },
  8541. "CHILD": function( type, what, argument, first, last ) {
  8542. var simple = type.slice( 0, 3 ) !== "nth",
  8543. forward = type.slice( -4 ) !== "last",
  8544. ofType = what === "of-type";
  8545. return first === 1 && last === 0 ?
  8546. // Shortcut for :nth-*(n)
  8547. function( elem ) {
  8548. return !!elem.parentNode;
  8549. } :
  8550. function( elem, context, xml ) {
  8551. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  8552. dir = simple !== forward ? "nextSibling" : "previousSibling",
  8553. parent = elem.parentNode,
  8554. name = ofType && elem.nodeName.toLowerCase(),
  8555. useCache = !xml && !ofType,
  8556. diff = false;
  8557. if ( parent ) {
  8558. // :(first|last|only)-(child|of-type)
  8559. if ( simple ) {
  8560. while ( dir ) {
  8561. node = elem;
  8562. while ( (node = node[ dir ]) ) {
  8563. if ( ofType ?
  8564. node.nodeName.toLowerCase() === name :
  8565. node.nodeType === 1 ) {
  8566. return false;
  8567. }
  8568. }
  8569. // Reverse direction for :only-* (if we haven't yet done so)
  8570. start = dir = type === "only" && !start && "nextSibling";
  8571. }
  8572. return true;
  8573. }
  8574. start = [ forward ? parent.firstChild : parent.lastChild ];
  8575. // non-xml :nth-child(...) stores cache data on `parent`
  8576. if ( forward && useCache ) {
  8577. // Seek `elem` from a previously-cached index
  8578. // ...in a gzip-friendly way
  8579. node = parent;
  8580. outerCache = node[ expando ] || (node[ expando ] = {});
  8581. // Support: IE <9 only
  8582. // Defend against cloned attroperties (jQuery gh-1709)
  8583. uniqueCache = outerCache[ node.uniqueID ] ||
  8584. (outerCache[ node.uniqueID ] = {});
  8585. cache = uniqueCache[ type ] || [];
  8586. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8587. diff = nodeIndex && cache[ 2 ];
  8588. node = nodeIndex && parent.childNodes[ nodeIndex ];
  8589. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8590. // Fallback to seeking `elem` from the start
  8591. (diff = nodeIndex = 0) || start.pop()) ) {
  8592. // When found, cache indexes on `parent` and break
  8593. if ( node.nodeType === 1 && ++diff && node === elem ) {
  8594. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  8595. break;
  8596. }
  8597. }
  8598. } else {
  8599. // Use previously-cached element index if available
  8600. if ( useCache ) {
  8601. // ...in a gzip-friendly way
  8602. node = elem;
  8603. outerCache = node[ expando ] || (node[ expando ] = {});
  8604. // Support: IE <9 only
  8605. // Defend against cloned attroperties (jQuery gh-1709)
  8606. uniqueCache = outerCache[ node.uniqueID ] ||
  8607. (outerCache[ node.uniqueID ] = {});
  8608. cache = uniqueCache[ type ] || [];
  8609. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  8610. diff = nodeIndex;
  8611. }
  8612. // xml :nth-child(...)
  8613. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  8614. if ( diff === false ) {
  8615. // Use the same loop as above to seek `elem` from the start
  8616. while ( (node = ++nodeIndex && node && node[ dir ] ||
  8617. (diff = nodeIndex = 0) || start.pop()) ) {
  8618. if ( ( ofType ?
  8619. node.nodeName.toLowerCase() === name :
  8620. node.nodeType === 1 ) &&
  8621. ++diff ) {
  8622. // Cache the index of each encountered element
  8623. if ( useCache ) {
  8624. outerCache = node[ expando ] || (node[ expando ] = {});
  8625. // Support: IE <9 only
  8626. // Defend against cloned attroperties (jQuery gh-1709)
  8627. uniqueCache = outerCache[ node.uniqueID ] ||
  8628. (outerCache[ node.uniqueID ] = {});
  8629. uniqueCache[ type ] = [ dirruns, diff ];
  8630. }
  8631. if ( node === elem ) {
  8632. break;
  8633. }
  8634. }
  8635. }
  8636. }
  8637. }
  8638. // Incorporate the offset, then check against cycle size
  8639. diff -= last;
  8640. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  8641. }
  8642. };
  8643. },
  8644. "PSEUDO": function( pseudo, argument ) {
  8645. // pseudo-class names are case-insensitive
  8646. // http://www.w3.org/TR/selectors/#pseudo-classes
  8647. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  8648. // Remember that setFilters inherits from pseudos
  8649. var args,
  8650. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  8651. Sizzle.error( "unsupported pseudo: " + pseudo );
  8652. // The user may use createPseudo to indicate that
  8653. // arguments are needed to create the filter function
  8654. // just as Sizzle does
  8655. if ( fn[ expando ] ) {
  8656. return fn( argument );
  8657. }
  8658. // But maintain support for old signatures
  8659. if ( fn.length > 1 ) {
  8660. args = [ pseudo, pseudo, "", argument ];
  8661. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  8662. markFunction(function( seed, matches ) {
  8663. var idx,
  8664. matched = fn( seed, argument ),
  8665. i = matched.length;
  8666. while ( i-- ) {
  8667. idx = indexOf( seed, matched[i] );
  8668. seed[ idx ] = !( matches[ idx ] = matched[i] );
  8669. }
  8670. }) :
  8671. function( elem ) {
  8672. return fn( elem, 0, args );
  8673. };
  8674. }
  8675. return fn;
  8676. }
  8677. },
  8678. pseudos: {
  8679. // Potentially complex pseudos
  8680. "not": markFunction(function( selector ) {
  8681. // Trim the selector passed to compile
  8682. // to avoid treating leading and trailing
  8683. // spaces as combinators
  8684. var input = [],
  8685. results = [],
  8686. matcher = compile( selector.replace( rtrim, "$1" ) );
  8687. return matcher[ expando ] ?
  8688. markFunction(function( seed, matches, context, xml ) {
  8689. var elem,
  8690. unmatched = matcher( seed, null, xml, [] ),
  8691. i = seed.length;
  8692. // Match elements unmatched by `matcher`
  8693. while ( i-- ) {
  8694. if ( (elem = unmatched[i]) ) {
  8695. seed[i] = !(matches[i] = elem);
  8696. }
  8697. }
  8698. }) :
  8699. function( elem, context, xml ) {
  8700. input[0] = elem;
  8701. matcher( input, null, xml, results );
  8702. // Don't keep the element (issue #299)
  8703. input[0] = null;
  8704. return !results.pop();
  8705. };
  8706. }),
  8707. "has": markFunction(function( selector ) {
  8708. return function( elem ) {
  8709. return Sizzle( selector, elem ).length > 0;
  8710. };
  8711. }),
  8712. "contains": markFunction(function( text ) {
  8713. text = text.replace( runescape, funescape );
  8714. return function( elem ) {
  8715. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  8716. };
  8717. }),
  8718. // "Whether an element is represented by a :lang() selector
  8719. // is based solely on the element's language value
  8720. // being equal to the identifier C,
  8721. // or beginning with the identifier C immediately followed by "-".
  8722. // The matching of C against the element's language value is performed case-insensitively.
  8723. // The identifier C does not have to be a valid language name."
  8724. // http://www.w3.org/TR/selectors/#lang-pseudo
  8725. "lang": markFunction( function( lang ) {
  8726. // lang value must be a valid identifier
  8727. if ( !ridentifier.test(lang || "") ) {
  8728. Sizzle.error( "unsupported lang: " + lang );
  8729. }
  8730. lang = lang.replace( runescape, funescape ).toLowerCase();
  8731. return function( elem ) {
  8732. var elemLang;
  8733. do {
  8734. if ( (elemLang = documentIsHTML ?
  8735. elem.lang :
  8736. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  8737. elemLang = elemLang.toLowerCase();
  8738. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  8739. }
  8740. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  8741. return false;
  8742. };
  8743. }),
  8744. // Miscellaneous
  8745. "target": function( elem ) {
  8746. var hash = window.location && window.location.hash;
  8747. return hash && hash.slice( 1 ) === elem.id;
  8748. },
  8749. "root": function( elem ) {
  8750. return elem === docElem;
  8751. },
  8752. "focus": function( elem ) {
  8753. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  8754. },
  8755. // Boolean properties
  8756. "enabled": createDisabledPseudo( false ),
  8757. "disabled": createDisabledPseudo( true ),
  8758. "checked": function( elem ) {
  8759. // In CSS3, :checked should return both checked and selected elements
  8760. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  8761. var nodeName = elem.nodeName.toLowerCase();
  8762. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  8763. },
  8764. "selected": function( elem ) {
  8765. // Accessing this property makes selected-by-default
  8766. // options in Safari work properly
  8767. if ( elem.parentNode ) {
  8768. elem.parentNode.selectedIndex;
  8769. }
  8770. return elem.selected === true;
  8771. },
  8772. // Contents
  8773. "empty": function( elem ) {
  8774. // http://www.w3.org/TR/selectors/#empty-pseudo
  8775. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  8776. // but not by others (comment: 8; processing instruction: 7; etc.)
  8777. // nodeType < 6 works because attributes (2) do not appear as children
  8778. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  8779. if ( elem.nodeType < 6 ) {
  8780. return false;
  8781. }
  8782. }
  8783. return true;
  8784. },
  8785. "parent": function( elem ) {
  8786. return !Expr.pseudos["empty"]( elem );
  8787. },
  8788. // Element/input types
  8789. "header": function( elem ) {
  8790. return rheader.test( elem.nodeName );
  8791. },
  8792. "input": function( elem ) {
  8793. return rinputs.test( elem.nodeName );
  8794. },
  8795. "button": function( elem ) {
  8796. var name = elem.nodeName.toLowerCase();
  8797. return name === "input" && elem.type === "button" || name === "button";
  8798. },
  8799. "text": function( elem ) {
  8800. var attr;
  8801. return elem.nodeName.toLowerCase() === "input" &&
  8802. elem.type === "text" &&
  8803. // Support: IE<8
  8804. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  8805. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  8806. },
  8807. // Position-in-collection
  8808. "first": createPositionalPseudo(function() {
  8809. return [ 0 ];
  8810. }),
  8811. "last": createPositionalPseudo(function( matchIndexes, length ) {
  8812. return [ length - 1 ];
  8813. }),
  8814. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8815. return [ argument < 0 ? argument + length : argument ];
  8816. }),
  8817. "even": createPositionalPseudo(function( matchIndexes, length ) {
  8818. var i = 0;
  8819. for ( ; i < length; i += 2 ) {
  8820. matchIndexes.push( i );
  8821. }
  8822. return matchIndexes;
  8823. }),
  8824. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  8825. var i = 1;
  8826. for ( ; i < length; i += 2 ) {
  8827. matchIndexes.push( i );
  8828. }
  8829. return matchIndexes;
  8830. }),
  8831. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8832. var i = argument < 0 ?
  8833. argument + length :
  8834. argument > length ?
  8835. length :
  8836. argument;
  8837. for ( ; --i >= 0; ) {
  8838. matchIndexes.push( i );
  8839. }
  8840. return matchIndexes;
  8841. }),
  8842. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  8843. var i = argument < 0 ? argument + length : argument;
  8844. for ( ; ++i < length; ) {
  8845. matchIndexes.push( i );
  8846. }
  8847. return matchIndexes;
  8848. })
  8849. }
  8850. };
  8851. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  8852. // Add button/input type pseudos
  8853. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  8854. Expr.pseudos[ i ] = createInputPseudo( i );
  8855. }
  8856. for ( i in { submit: true, reset: true } ) {
  8857. Expr.pseudos[ i ] = createButtonPseudo( i );
  8858. }
  8859. // Easy API for creating new setFilters
  8860. function setFilters() {}
  8861. setFilters.prototype = Expr.filters = Expr.pseudos;
  8862. Expr.setFilters = new setFilters();
  8863. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  8864. var matched, match, tokens, type,
  8865. soFar, groups, preFilters,
  8866. cached = tokenCache[ selector + " " ];
  8867. if ( cached ) {
  8868. return parseOnly ? 0 : cached.slice( 0 );
  8869. }
  8870. soFar = selector;
  8871. groups = [];
  8872. preFilters = Expr.preFilter;
  8873. while ( soFar ) {
  8874. // Comma and first run
  8875. if ( !matched || (match = rcomma.exec( soFar )) ) {
  8876. if ( match ) {
  8877. // Don't consume trailing commas as valid
  8878. soFar = soFar.slice( match[0].length ) || soFar;
  8879. }
  8880. groups.push( (tokens = []) );
  8881. }
  8882. matched = false;
  8883. // Combinators
  8884. if ( (match = rcombinators.exec( soFar )) ) {
  8885. matched = match.shift();
  8886. tokens.push({
  8887. value: matched,
  8888. // Cast descendant combinators to space
  8889. type: match[0].replace( rtrim, " " )
  8890. });
  8891. soFar = soFar.slice( matched.length );
  8892. }
  8893. // Filters
  8894. for ( type in Expr.filter ) {
  8895. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  8896. (match = preFilters[ type ]( match ))) ) {
  8897. matched = match.shift();
  8898. tokens.push({
  8899. value: matched,
  8900. type: type,
  8901. matches: match
  8902. });
  8903. soFar = soFar.slice( matched.length );
  8904. }
  8905. }
  8906. if ( !matched ) {
  8907. break;
  8908. }
  8909. }
  8910. // Return the length of the invalid excess
  8911. // if we're just parsing
  8912. // Otherwise, throw an error or return tokens
  8913. return parseOnly ?
  8914. soFar.length :
  8915. soFar ?
  8916. Sizzle.error( selector ) :
  8917. // Cache the tokens
  8918. tokenCache( selector, groups ).slice( 0 );
  8919. };
  8920. function toSelector( tokens ) {
  8921. var i = 0,
  8922. len = tokens.length,
  8923. selector = "";
  8924. for ( ; i < len; i++ ) {
  8925. selector += tokens[i].value;
  8926. }
  8927. return selector;
  8928. }
  8929. function addCombinator( matcher, combinator, base ) {
  8930. var dir = combinator.dir,
  8931. skip = combinator.next,
  8932. key = skip || dir,
  8933. checkNonElements = base && key === "parentNode",
  8934. doneName = done++;
  8935. return combinator.first ?
  8936. // Check against closest ancestor/preceding element
  8937. function( elem, context, xml ) {
  8938. while ( (elem = elem[ dir ]) ) {
  8939. if ( elem.nodeType === 1 || checkNonElements ) {
  8940. return matcher( elem, context, xml );
  8941. }
  8942. }
  8943. return false;
  8944. } :
  8945. // Check against all ancestor/preceding elements
  8946. function( elem, context, xml ) {
  8947. var oldCache, uniqueCache, outerCache,
  8948. newCache = [ dirruns, doneName ];
  8949. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  8950. if ( xml ) {
  8951. while ( (elem = elem[ dir ]) ) {
  8952. if ( elem.nodeType === 1 || checkNonElements ) {
  8953. if ( matcher( elem, context, xml ) ) {
  8954. return true;
  8955. }
  8956. }
  8957. }
  8958. } else {
  8959. while ( (elem = elem[ dir ]) ) {
  8960. if ( elem.nodeType === 1 || checkNonElements ) {
  8961. outerCache = elem[ expando ] || (elem[ expando ] = {});
  8962. // Support: IE <9 only
  8963. // Defend against cloned attroperties (jQuery gh-1709)
  8964. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  8965. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  8966. elem = elem[ dir ] || elem;
  8967. } else if ( (oldCache = uniqueCache[ key ]) &&
  8968. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  8969. // Assign to newCache so results back-propagate to previous elements
  8970. return (newCache[ 2 ] = oldCache[ 2 ]);
  8971. } else {
  8972. // Reuse newcache so results back-propagate to previous elements
  8973. uniqueCache[ key ] = newCache;
  8974. // A match means we're done; a fail means we have to keep checking
  8975. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  8976. return true;
  8977. }
  8978. }
  8979. }
  8980. }
  8981. }
  8982. return false;
  8983. };
  8984. }
  8985. function elementMatcher( matchers ) {
  8986. return matchers.length > 1 ?
  8987. function( elem, context, xml ) {
  8988. var i = matchers.length;
  8989. while ( i-- ) {
  8990. if ( !matchers[i]( elem, context, xml ) ) {
  8991. return false;
  8992. }
  8993. }
  8994. return true;
  8995. } :
  8996. matchers[0];
  8997. }
  8998. function multipleContexts( selector, contexts, results ) {
  8999. var i = 0,
  9000. len = contexts.length;
  9001. for ( ; i < len; i++ ) {
  9002. Sizzle( selector, contexts[i], results );
  9003. }
  9004. return results;
  9005. }
  9006. function condense( unmatched, map, filter, context, xml ) {
  9007. var elem,
  9008. newUnmatched = [],
  9009. i = 0,
  9010. len = unmatched.length,
  9011. mapped = map != null;
  9012. for ( ; i < len; i++ ) {
  9013. if ( (elem = unmatched[i]) ) {
  9014. if ( !filter || filter( elem, context, xml ) ) {
  9015. newUnmatched.push( elem );
  9016. if ( mapped ) {
  9017. map.push( i );
  9018. }
  9019. }
  9020. }
  9021. }
  9022. return newUnmatched;
  9023. }
  9024. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9025. if ( postFilter && !postFilter[ expando ] ) {
  9026. postFilter = setMatcher( postFilter );
  9027. }
  9028. if ( postFinder && !postFinder[ expando ] ) {
  9029. postFinder = setMatcher( postFinder, postSelector );
  9030. }
  9031. return markFunction(function( seed, results, context, xml ) {
  9032. var temp, i, elem,
  9033. preMap = [],
  9034. postMap = [],
  9035. preexisting = results.length,
  9036. // Get initial elements from seed or context
  9037. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9038. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9039. matcherIn = preFilter && ( seed || !selector ) ?
  9040. condense( elems, preMap, preFilter, context, xml ) :
  9041. elems,
  9042. matcherOut = matcher ?
  9043. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9044. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9045. // ...intermediate processing is necessary
  9046. [] :
  9047. // ...otherwise use results directly
  9048. results :
  9049. matcherIn;
  9050. // Find primary matches
  9051. if ( matcher ) {
  9052. matcher( matcherIn, matcherOut, context, xml );
  9053. }
  9054. // Apply postFilter
  9055. if ( postFilter ) {
  9056. temp = condense( matcherOut, postMap );
  9057. postFilter( temp, [], context, xml );
  9058. // Un-match failing elements by moving them back to matcherIn
  9059. i = temp.length;
  9060. while ( i-- ) {
  9061. if ( (elem = temp[i]) ) {
  9062. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9063. }
  9064. }
  9065. }
  9066. if ( seed ) {
  9067. if ( postFinder || preFilter ) {
  9068. if ( postFinder ) {
  9069. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  9070. temp = [];
  9071. i = matcherOut.length;
  9072. while ( i-- ) {
  9073. if ( (elem = matcherOut[i]) ) {
  9074. // Restore matcherIn since elem is not yet a final match
  9075. temp.push( (matcherIn[i] = elem) );
  9076. }
  9077. }
  9078. postFinder( null, (matcherOut = []), temp, xml );
  9079. }
  9080. // Move matched elements from seed to results to keep them synchronized
  9081. i = matcherOut.length;
  9082. while ( i-- ) {
  9083. if ( (elem = matcherOut[i]) &&
  9084. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  9085. seed[temp] = !(results[temp] = elem);
  9086. }
  9087. }
  9088. }
  9089. // Add elements to results, through postFinder if defined
  9090. } else {
  9091. matcherOut = condense(
  9092. matcherOut === results ?
  9093. matcherOut.splice( preexisting, matcherOut.length ) :
  9094. matcherOut
  9095. );
  9096. if ( postFinder ) {
  9097. postFinder( null, results, matcherOut, xml );
  9098. } else {
  9099. push.apply( results, matcherOut );
  9100. }
  9101. }
  9102. });
  9103. }
  9104. function matcherFromTokens( tokens ) {
  9105. var checkContext, matcher, j,
  9106. len = tokens.length,
  9107. leadingRelative = Expr.relative[ tokens[0].type ],
  9108. implicitRelative = leadingRelative || Expr.relative[" "],
  9109. i = leadingRelative ? 1 : 0,
  9110. // The foundational matcher ensures that elements are reachable from top-level context(s)
  9111. matchContext = addCombinator( function( elem ) {
  9112. return elem === checkContext;
  9113. }, implicitRelative, true ),
  9114. matchAnyContext = addCombinator( function( elem ) {
  9115. return indexOf( checkContext, elem ) > -1;
  9116. }, implicitRelative, true ),
  9117. matchers = [ function( elem, context, xml ) {
  9118. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  9119. (checkContext = context).nodeType ?
  9120. matchContext( elem, context, xml ) :
  9121. matchAnyContext( elem, context, xml ) );
  9122. // Avoid hanging onto element (issue #299)
  9123. checkContext = null;
  9124. return ret;
  9125. } ];
  9126. for ( ; i < len; i++ ) {
  9127. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  9128. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  9129. } else {
  9130. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  9131. // Return special upon seeing a positional matcher
  9132. if ( matcher[ expando ] ) {
  9133. // Find the next relative operator (if any) for proper handling
  9134. j = ++i;
  9135. for ( ; j < len; j++ ) {
  9136. if ( Expr.relative[ tokens[j].type ] ) {
  9137. break;
  9138. }
  9139. }
  9140. return setMatcher(
  9141. i > 1 && elementMatcher( matchers ),
  9142. i > 1 && toSelector(
  9143. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  9144. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  9145. ).replace( rtrim, "$1" ),
  9146. matcher,
  9147. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  9148. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  9149. j < len && toSelector( tokens )
  9150. );
  9151. }
  9152. matchers.push( matcher );
  9153. }
  9154. }
  9155. return elementMatcher( matchers );
  9156. }
  9157. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  9158. var bySet = setMatchers.length > 0,
  9159. byElement = elementMatchers.length > 0,
  9160. superMatcher = function( seed, context, xml, results, outermost ) {
  9161. var elem, j, matcher,
  9162. matchedCount = 0,
  9163. i = "0",
  9164. unmatched = seed && [],
  9165. setMatched = [],
  9166. contextBackup = outermostContext,
  9167. // We must always have either seed elements or outermost context
  9168. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  9169. // Use integer dirruns iff this is the outermost matcher
  9170. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  9171. len = elems.length;
  9172. if ( outermost ) {
  9173. outermostContext = context === document || context || outermost;
  9174. }
  9175. // Add elements passing elementMatchers directly to results
  9176. // Support: IE<9, Safari
  9177. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  9178. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  9179. if ( byElement && elem ) {
  9180. j = 0;
  9181. if ( !context && elem.ownerDocument !== document ) {
  9182. setDocument( elem );
  9183. xml = !documentIsHTML;
  9184. }
  9185. while ( (matcher = elementMatchers[j++]) ) {
  9186. if ( matcher( elem, context || document, xml) ) {
  9187. results.push( elem );
  9188. break;
  9189. }
  9190. }
  9191. if ( outermost ) {
  9192. dirruns = dirrunsUnique;
  9193. }
  9194. }
  9195. // Track unmatched elements for set filters
  9196. if ( bySet ) {
  9197. // They will have gone through all possible matchers
  9198. if ( (elem = !matcher && elem) ) {
  9199. matchedCount--;
  9200. }
  9201. // Lengthen the array for every element, matched or not
  9202. if ( seed ) {
  9203. unmatched.push( elem );
  9204. }
  9205. }
  9206. }
  9207. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  9208. // makes the latter nonnegative.
  9209. matchedCount += i;
  9210. // Apply set filters to unmatched elements
  9211. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  9212. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  9213. // no element matchers and no seed.
  9214. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  9215. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  9216. // numerically zero.
  9217. if ( bySet && i !== matchedCount ) {
  9218. j = 0;
  9219. while ( (matcher = setMatchers[j++]) ) {
  9220. matcher( unmatched, setMatched, context, xml );
  9221. }
  9222. if ( seed ) {
  9223. // Reintegrate element matches to eliminate the need for sorting
  9224. if ( matchedCount > 0 ) {
  9225. while ( i-- ) {
  9226. if ( !(unmatched[i] || setMatched[i]) ) {
  9227. setMatched[i] = pop.call( results );
  9228. }
  9229. }
  9230. }
  9231. // Discard index placeholder values to get only actual matches
  9232. setMatched = condense( setMatched );
  9233. }
  9234. // Add matches to results
  9235. push.apply( results, setMatched );
  9236. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  9237. if ( outermost && !seed && setMatched.length > 0 &&
  9238. ( matchedCount + setMatchers.length ) > 1 ) {
  9239. Sizzle.uniqueSort( results );
  9240. }
  9241. }
  9242. // Override manipulation of globals by nested matchers
  9243. if ( outermost ) {
  9244. dirruns = dirrunsUnique;
  9245. outermostContext = contextBackup;
  9246. }
  9247. return unmatched;
  9248. };
  9249. return bySet ?
  9250. markFunction( superMatcher ) :
  9251. superMatcher;
  9252. }
  9253. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  9254. var i,
  9255. setMatchers = [],
  9256. elementMatchers = [],
  9257. cached = compilerCache[ selector + " " ];
  9258. if ( !cached ) {
  9259. // Generate a function of recursive functions that can be used to check each element
  9260. if ( !match ) {
  9261. match = tokenize( selector );
  9262. }
  9263. i = match.length;
  9264. while ( i-- ) {
  9265. cached = matcherFromTokens( match[i] );
  9266. if ( cached[ expando ] ) {
  9267. setMatchers.push( cached );
  9268. } else {
  9269. elementMatchers.push( cached );
  9270. }
  9271. }
  9272. // Cache the compiled function
  9273. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  9274. // Save selector and tokenization
  9275. cached.selector = selector;
  9276. }
  9277. return cached;
  9278. };
  9279. /**
  9280. * A low-level selection function that works with Sizzle's compiled
  9281. * selector functions
  9282. * @param {String|Function} selector A selector or a pre-compiled
  9283. * selector function built with Sizzle.compile
  9284. * @param {Element} context
  9285. * @param {Array} [results]
  9286. * @param {Array} [seed] A set of elements to match against
  9287. */
  9288. select = Sizzle.select = function( selector, context, results, seed ) {
  9289. var i, tokens, token, type, find,
  9290. compiled = typeof selector === "function" && selector,
  9291. match = !seed && tokenize( (selector = compiled.selector || selector) );
  9292. results = results || [];
  9293. // Try to minimize operations if there is only one selector in the list and no seed
  9294. // (the latter of which guarantees us context)
  9295. if ( match.length === 1 ) {
  9296. // Reduce context if the leading compound selector is an ID
  9297. tokens = match[0] = match[0].slice( 0 );
  9298. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  9299. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  9300. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  9301. if ( !context ) {
  9302. return results;
  9303. // Precompiled matchers will still verify ancestry, so step up a level
  9304. } else if ( compiled ) {
  9305. context = context.parentNode;
  9306. }
  9307. selector = selector.slice( tokens.shift().value.length );
  9308. }
  9309. // Fetch a seed set for right-to-left matching
  9310. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  9311. while ( i-- ) {
  9312. token = tokens[i];
  9313. // Abort if we hit a combinator
  9314. if ( Expr.relative[ (type = token.type) ] ) {
  9315. break;
  9316. }
  9317. if ( (find = Expr.find[ type ]) ) {
  9318. // Search, expanding context for leading sibling combinators
  9319. if ( (seed = find(
  9320. token.matches[0].replace( runescape, funescape ),
  9321. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  9322. )) ) {
  9323. // If seed is empty or no tokens remain, we can return early
  9324. tokens.splice( i, 1 );
  9325. selector = seed.length && toSelector( tokens );
  9326. if ( !selector ) {
  9327. push.apply( results, seed );
  9328. return results;
  9329. }
  9330. break;
  9331. }
  9332. }
  9333. }
  9334. }
  9335. // Compile and execute a filtering function if one is not provided
  9336. // Provide `match` to avoid retokenization if we modified the selector above
  9337. ( compiled || compile( selector, match ) )(
  9338. seed,
  9339. context,
  9340. !documentIsHTML,
  9341. results,
  9342. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  9343. );
  9344. return results;
  9345. };
  9346. // One-time assignments
  9347. // Sort stability
  9348. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  9349. // Support: Chrome 14-35+
  9350. // Always assume duplicates if they aren't passed to the comparison function
  9351. support.detectDuplicates = !!hasDuplicate;
  9352. // Initialize against the default document
  9353. setDocument();
  9354. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  9355. // Detached nodes confoundingly follow *each other*
  9356. support.sortDetached = assert(function( el ) {
  9357. // Should return 1, but returns 4 (following)
  9358. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  9359. });
  9360. // Support: IE<8
  9361. // Prevent attribute/property "interpolation"
  9362. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  9363. if ( !assert(function( el ) {
  9364. el.innerHTML = "<a href='#'></a>";
  9365. return el.firstChild.getAttribute("href") === "#" ;
  9366. }) ) {
  9367. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  9368. if ( !isXML ) {
  9369. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  9370. }
  9371. });
  9372. }
  9373. // Support: IE<9
  9374. // Use defaultValue in place of getAttribute("value")
  9375. if ( !support.attributes || !assert(function( el ) {
  9376. el.innerHTML = "<input/>";
  9377. el.firstChild.setAttribute( "value", "" );
  9378. return el.firstChild.getAttribute( "value" ) === "";
  9379. }) ) {
  9380. addHandle( "value", function( elem, name, isXML ) {
  9381. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  9382. return elem.defaultValue;
  9383. }
  9384. });
  9385. }
  9386. // Support: IE<9
  9387. // Use getAttributeNode to fetch booleans when getAttribute lies
  9388. if ( !assert(function( el ) {
  9389. return el.getAttribute("disabled") == null;
  9390. }) ) {
  9391. addHandle( booleans, function( elem, name, isXML ) {
  9392. var val;
  9393. if ( !isXML ) {
  9394. return elem[ name ] === true ? name.toLowerCase() :
  9395. (val = elem.getAttributeNode( name )) && val.specified ?
  9396. val.value :
  9397. null;
  9398. }
  9399. });
  9400. }
  9401. return Sizzle;
  9402. })( window );
  9403. jQuery.find = Sizzle;
  9404. jQuery.expr = Sizzle.selectors;
  9405. // Deprecated
  9406. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  9407. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  9408. jQuery.text = Sizzle.getText;
  9409. jQuery.isXMLDoc = Sizzle.isXML;
  9410. jQuery.contains = Sizzle.contains;
  9411. jQuery.escapeSelector = Sizzle.escape;
  9412. var dir = function( elem, dir, until ) {
  9413. var matched = [],
  9414. truncate = until !== undefined;
  9415. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  9416. if ( elem.nodeType === 1 ) {
  9417. if ( truncate && jQuery( elem ).is( until ) ) {
  9418. break;
  9419. }
  9420. matched.push( elem );
  9421. }
  9422. }
  9423. return matched;
  9424. };
  9425. var siblings = function( n, elem ) {
  9426. var matched = [];
  9427. for ( ; n; n = n.nextSibling ) {
  9428. if ( n.nodeType === 1 && n !== elem ) {
  9429. matched.push( n );
  9430. }
  9431. }
  9432. return matched;
  9433. };
  9434. var rneedsContext = jQuery.expr.match.needsContext;
  9435. function nodeName( elem, name ) {
  9436. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  9437. };
  9438. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  9439. // Implement the identical functionality for filter and not
  9440. function winnow( elements, qualifier, not ) {
  9441. if ( isFunction( qualifier ) ) {
  9442. return jQuery.grep( elements, function( elem, i ) {
  9443. return !!qualifier.call( elem, i, elem ) !== not;
  9444. } );
  9445. }
  9446. // Single element
  9447. if ( qualifier.nodeType ) {
  9448. return jQuery.grep( elements, function( elem ) {
  9449. return ( elem === qualifier ) !== not;
  9450. } );
  9451. }
  9452. // Arraylike of elements (jQuery, arguments, Array)
  9453. if ( typeof qualifier !== "string" ) {
  9454. return jQuery.grep( elements, function( elem ) {
  9455. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  9456. } );
  9457. }
  9458. // Filtered directly for both simple and complex selectors
  9459. return jQuery.filter( qualifier, elements, not );
  9460. }
  9461. jQuery.filter = function( expr, elems, not ) {
  9462. var elem = elems[ 0 ];
  9463. if ( not ) {
  9464. expr = ":not(" + expr + ")";
  9465. }
  9466. if ( elems.length === 1 && elem.nodeType === 1 ) {
  9467. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  9468. }
  9469. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  9470. return elem.nodeType === 1;
  9471. } ) );
  9472. };
  9473. jQuery.fn.extend( {
  9474. find: function( selector ) {
  9475. var i, ret,
  9476. len = this.length,
  9477. self = this;
  9478. if ( typeof selector !== "string" ) {
  9479. return this.pushStack( jQuery( selector ).filter( function() {
  9480. for ( i = 0; i < len; i++ ) {
  9481. if ( jQuery.contains( self[ i ], this ) ) {
  9482. return true;
  9483. }
  9484. }
  9485. } ) );
  9486. }
  9487. ret = this.pushStack( [] );
  9488. for ( i = 0; i < len; i++ ) {
  9489. jQuery.find( selector, self[ i ], ret );
  9490. }
  9491. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  9492. },
  9493. filter: function( selector ) {
  9494. return this.pushStack( winnow( this, selector || [], false ) );
  9495. },
  9496. not: function( selector ) {
  9497. return this.pushStack( winnow( this, selector || [], true ) );
  9498. },
  9499. is: function( selector ) {
  9500. return !!winnow(
  9501. this,
  9502. // If this is a positional/relative selector, check membership in the returned set
  9503. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  9504. typeof selector === "string" && rneedsContext.test( selector ) ?
  9505. jQuery( selector ) :
  9506. selector || [],
  9507. false
  9508. ).length;
  9509. }
  9510. } );
  9511. // Initialize a jQuery object
  9512. // A central reference to the root jQuery(document)
  9513. var rootjQuery,
  9514. // A simple way to check for HTML strings
  9515. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  9516. // Strict HTML recognition (#11290: must start with <)
  9517. // Shortcut simple #id case for speed
  9518. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  9519. init = jQuery.fn.init = function( selector, context, root ) {
  9520. var match, elem;
  9521. // HANDLE: $(""), $(null), $(undefined), $(false)
  9522. if ( !selector ) {
  9523. return this;
  9524. }
  9525. // Method init() accepts an alternate rootjQuery
  9526. // so migrate can support jQuery.sub (gh-2101)
  9527. root = root || rootjQuery;
  9528. // Handle HTML strings
  9529. if ( typeof selector === "string" ) {
  9530. if ( selector[ 0 ] === "<" &&
  9531. selector[ selector.length - 1 ] === ">" &&
  9532. selector.length >= 3 ) {
  9533. // Assume that strings that start and end with <> are HTML and skip the regex check
  9534. match = [ null, selector, null ];
  9535. } else {
  9536. match = rquickExpr.exec( selector );
  9537. }
  9538. // Match html or make sure no context is specified for #id
  9539. if ( match && ( match[ 1 ] || !context ) ) {
  9540. // HANDLE: $(html) -> $(array)
  9541. if ( match[ 1 ] ) {
  9542. context = context instanceof jQuery ? context[ 0 ] : context;
  9543. // Option to run scripts is true for back-compat
  9544. // Intentionally let the error be thrown if parseHTML is not present
  9545. jQuery.merge( this, jQuery.parseHTML(
  9546. match[ 1 ],
  9547. context && context.nodeType ? context.ownerDocument || context : document,
  9548. true
  9549. ) );
  9550. // HANDLE: $(html, props)
  9551. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  9552. for ( match in context ) {
  9553. // Properties of context are called as methods if possible
  9554. if ( isFunction( this[ match ] ) ) {
  9555. this[ match ]( context[ match ] );
  9556. // ...and otherwise set as attributes
  9557. } else {
  9558. this.attr( match, context[ match ] );
  9559. }
  9560. }
  9561. }
  9562. return this;
  9563. // HANDLE: $(#id)
  9564. } else {
  9565. elem = document.getElementById( match[ 2 ] );
  9566. if ( elem ) {
  9567. // Inject the element directly into the jQuery object
  9568. this[ 0 ] = elem;
  9569. this.length = 1;
  9570. }
  9571. return this;
  9572. }
  9573. // HANDLE: $(expr, $(...))
  9574. } else if ( !context || context.jquery ) {
  9575. return ( context || root ).find( selector );
  9576. // HANDLE: $(expr, context)
  9577. // (which is just equivalent to: $(context).find(expr)
  9578. } else {
  9579. return this.constructor( context ).find( selector );
  9580. }
  9581. // HANDLE: $(DOMElement)
  9582. } else if ( selector.nodeType ) {
  9583. this[ 0 ] = selector;
  9584. this.length = 1;
  9585. return this;
  9586. // HANDLE: $(function)
  9587. // Shortcut for document ready
  9588. } else if ( isFunction( selector ) ) {
  9589. return root.ready !== undefined ?
  9590. root.ready( selector ) :
  9591. // Execute immediately if ready is not present
  9592. selector( jQuery );
  9593. }
  9594. return jQuery.makeArray( selector, this );
  9595. };
  9596. // Give the init function the jQuery prototype for later instantiation
  9597. init.prototype = jQuery.fn;
  9598. // Initialize central reference
  9599. rootjQuery = jQuery( document );
  9600. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  9601. // Methods guaranteed to produce a unique set when starting from a unique set
  9602. guaranteedUnique = {
  9603. children: true,
  9604. contents: true,
  9605. next: true,
  9606. prev: true
  9607. };
  9608. jQuery.fn.extend( {
  9609. has: function( target ) {
  9610. var targets = jQuery( target, this ),
  9611. l = targets.length;
  9612. return this.filter( function() {
  9613. var i = 0;
  9614. for ( ; i < l; i++ ) {
  9615. if ( jQuery.contains( this, targets[ i ] ) ) {
  9616. return true;
  9617. }
  9618. }
  9619. } );
  9620. },
  9621. closest: function( selectors, context ) {
  9622. var cur,
  9623. i = 0,
  9624. l = this.length,
  9625. matched = [],
  9626. targets = typeof selectors !== "string" && jQuery( selectors );
  9627. // Positional selectors never match, since there's no _selection_ context
  9628. if ( !rneedsContext.test( selectors ) ) {
  9629. for ( ; i < l; i++ ) {
  9630. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  9631. // Always skip document fragments
  9632. if ( cur.nodeType < 11 && ( targets ?
  9633. targets.index( cur ) > -1 :
  9634. // Don't pass non-elements to Sizzle
  9635. cur.nodeType === 1 &&
  9636. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  9637. matched.push( cur );
  9638. break;
  9639. }
  9640. }
  9641. }
  9642. }
  9643. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  9644. },
  9645. // Determine the position of an element within the set
  9646. index: function( elem ) {
  9647. // No argument, return index in parent
  9648. if ( !elem ) {
  9649. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  9650. }
  9651. // Index in selector
  9652. if ( typeof elem === "string" ) {
  9653. return indexOf.call( jQuery( elem ), this[ 0 ] );
  9654. }
  9655. // Locate the position of the desired element
  9656. return indexOf.call( this,
  9657. // If it receives a jQuery object, the first element is used
  9658. elem.jquery ? elem[ 0 ] : elem
  9659. );
  9660. },
  9661. add: function( selector, context ) {
  9662. return this.pushStack(
  9663. jQuery.uniqueSort(
  9664. jQuery.merge( this.get(), jQuery( selector, context ) )
  9665. )
  9666. );
  9667. },
  9668. addBack: function( selector ) {
  9669. return this.add( selector == null ?
  9670. this.prevObject : this.prevObject.filter( selector )
  9671. );
  9672. }
  9673. } );
  9674. function sibling( cur, dir ) {
  9675. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  9676. return cur;
  9677. }
  9678. jQuery.each( {
  9679. parent: function( elem ) {
  9680. var parent = elem.parentNode;
  9681. return parent && parent.nodeType !== 11 ? parent : null;
  9682. },
  9683. parents: function( elem ) {
  9684. return dir( elem, "parentNode" );
  9685. },
  9686. parentsUntil: function( elem, i, until ) {
  9687. return dir( elem, "parentNode", until );
  9688. },
  9689. next: function( elem ) {
  9690. return sibling( elem, "nextSibling" );
  9691. },
  9692. prev: function( elem ) {
  9693. return sibling( elem, "previousSibling" );
  9694. },
  9695. nextAll: function( elem ) {
  9696. return dir( elem, "nextSibling" );
  9697. },
  9698. prevAll: function( elem ) {
  9699. return dir( elem, "previousSibling" );
  9700. },
  9701. nextUntil: function( elem, i, until ) {
  9702. return dir( elem, "nextSibling", until );
  9703. },
  9704. prevUntil: function( elem, i, until ) {
  9705. return dir( elem, "previousSibling", until );
  9706. },
  9707. siblings: function( elem ) {
  9708. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  9709. },
  9710. children: function( elem ) {
  9711. return siblings( elem.firstChild );
  9712. },
  9713. contents: function( elem ) {
  9714. if ( typeof elem.contentDocument !== "undefined" ) {
  9715. return elem.contentDocument;
  9716. }
  9717. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  9718. // Treat the template element as a regular one in browsers that
  9719. // don't support it.
  9720. if ( nodeName( elem, "template" ) ) {
  9721. elem = elem.content || elem;
  9722. }
  9723. return jQuery.merge( [], elem.childNodes );
  9724. }
  9725. }, function( name, fn ) {
  9726. jQuery.fn[ name ] = function( until, selector ) {
  9727. var matched = jQuery.map( this, fn, until );
  9728. if ( name.slice( -5 ) !== "Until" ) {
  9729. selector = until;
  9730. }
  9731. if ( selector && typeof selector === "string" ) {
  9732. matched = jQuery.filter( selector, matched );
  9733. }
  9734. if ( this.length > 1 ) {
  9735. // Remove duplicates
  9736. if ( !guaranteedUnique[ name ] ) {
  9737. jQuery.uniqueSort( matched );
  9738. }
  9739. // Reverse order for parents* and prev-derivatives
  9740. if ( rparentsprev.test( name ) ) {
  9741. matched.reverse();
  9742. }
  9743. }
  9744. return this.pushStack( matched );
  9745. };
  9746. } );
  9747. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  9748. // Convert String-formatted options into Object-formatted ones
  9749. function createOptions( options ) {
  9750. var object = {};
  9751. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  9752. object[ flag ] = true;
  9753. } );
  9754. return object;
  9755. }
  9756. /*
  9757. * Create a callback list using the following parameters:
  9758. *
  9759. * options: an optional list of space-separated options that will change how
  9760. * the callback list behaves or a more traditional option object
  9761. *
  9762. * By default a callback list will act like an event callback list and can be
  9763. * "fired" multiple times.
  9764. *
  9765. * Possible options:
  9766. *
  9767. * once: will ensure the callback list can only be fired once (like a Deferred)
  9768. *
  9769. * memory: will keep track of previous values and will call any callback added
  9770. * after the list has been fired right away with the latest "memorized"
  9771. * values (like a Deferred)
  9772. *
  9773. * unique: will ensure a callback can only be added once (no duplicate in the list)
  9774. *
  9775. * stopOnFalse: interrupt callings when a callback returns false
  9776. *
  9777. */
  9778. jQuery.Callbacks = function( options ) {
  9779. // Convert options from String-formatted to Object-formatted if needed
  9780. // (we check in cache first)
  9781. options = typeof options === "string" ?
  9782. createOptions( options ) :
  9783. jQuery.extend( {}, options );
  9784. var // Flag to know if list is currently firing
  9785. firing,
  9786. // Last fire value for non-forgettable lists
  9787. memory,
  9788. // Flag to know if list was already fired
  9789. fired,
  9790. // Flag to prevent firing
  9791. locked,
  9792. // Actual callback list
  9793. list = [],
  9794. // Queue of execution data for repeatable lists
  9795. queue = [],
  9796. // Index of currently firing callback (modified by add/remove as needed)
  9797. firingIndex = -1,
  9798. // Fire callbacks
  9799. fire = function() {
  9800. // Enforce single-firing
  9801. locked = locked || options.once;
  9802. // Execute callbacks for all pending executions,
  9803. // respecting firingIndex overrides and runtime changes
  9804. fired = firing = true;
  9805. for ( ; queue.length; firingIndex = -1 ) {
  9806. memory = queue.shift();
  9807. while ( ++firingIndex < list.length ) {
  9808. // Run callback and check for early termination
  9809. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  9810. options.stopOnFalse ) {
  9811. // Jump to end and forget the data so .add doesn't re-fire
  9812. firingIndex = list.length;
  9813. memory = false;
  9814. }
  9815. }
  9816. }
  9817. // Forget the data if we're done with it
  9818. if ( !options.memory ) {
  9819. memory = false;
  9820. }
  9821. firing = false;
  9822. // Clean up if we're done firing for good
  9823. if ( locked ) {
  9824. // Keep an empty list if we have data for future add calls
  9825. if ( memory ) {
  9826. list = [];
  9827. // Otherwise, this object is spent
  9828. } else {
  9829. list = "";
  9830. }
  9831. }
  9832. },
  9833. // Actual Callbacks object
  9834. self = {
  9835. // Add a callback or a collection of callbacks to the list
  9836. add: function() {
  9837. if ( list ) {
  9838. // If we have memory from a past run, we should fire after adding
  9839. if ( memory && !firing ) {
  9840. firingIndex = list.length - 1;
  9841. queue.push( memory );
  9842. }
  9843. ( function add( args ) {
  9844. jQuery.each( args, function( _, arg ) {
  9845. if ( isFunction( arg ) ) {
  9846. if ( !options.unique || !self.has( arg ) ) {
  9847. list.push( arg );
  9848. }
  9849. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  9850. // Inspect recursively
  9851. add( arg );
  9852. }
  9853. } );
  9854. } )( arguments );
  9855. if ( memory && !firing ) {
  9856. fire();
  9857. }
  9858. }
  9859. return this;
  9860. },
  9861. // Remove a callback from the list
  9862. remove: function() {
  9863. jQuery.each( arguments, function( _, arg ) {
  9864. var index;
  9865. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  9866. list.splice( index, 1 );
  9867. // Handle firing indexes
  9868. if ( index <= firingIndex ) {
  9869. firingIndex--;
  9870. }
  9871. }
  9872. } );
  9873. return this;
  9874. },
  9875. // Check if a given callback is in the list.
  9876. // If no argument is given, return whether or not list has callbacks attached.
  9877. has: function( fn ) {
  9878. return fn ?
  9879. jQuery.inArray( fn, list ) > -1 :
  9880. list.length > 0;
  9881. },
  9882. // Remove all callbacks from the list
  9883. empty: function() {
  9884. if ( list ) {
  9885. list = [];
  9886. }
  9887. return this;
  9888. },
  9889. // Disable .fire and .add
  9890. // Abort any current/pending executions
  9891. // Clear all callbacks and values
  9892. disable: function() {
  9893. locked = queue = [];
  9894. list = memory = "";
  9895. return this;
  9896. },
  9897. disabled: function() {
  9898. return !list;
  9899. },
  9900. // Disable .fire
  9901. // Also disable .add unless we have memory (since it would have no effect)
  9902. // Abort any pending executions
  9903. lock: function() {
  9904. locked = queue = [];
  9905. if ( !memory && !firing ) {
  9906. list = memory = "";
  9907. }
  9908. return this;
  9909. },
  9910. locked: function() {
  9911. return !!locked;
  9912. },
  9913. // Call all callbacks with the given context and arguments
  9914. fireWith: function( context, args ) {
  9915. if ( !locked ) {
  9916. args = args || [];
  9917. args = [ context, args.slice ? args.slice() : args ];
  9918. queue.push( args );
  9919. if ( !firing ) {
  9920. fire();
  9921. }
  9922. }
  9923. return this;
  9924. },
  9925. // Call all the callbacks with the given arguments
  9926. fire: function() {
  9927. self.fireWith( this, arguments );
  9928. return this;
  9929. },
  9930. // To know if the callbacks have already been called at least once
  9931. fired: function() {
  9932. return !!fired;
  9933. }
  9934. };
  9935. return self;
  9936. };
  9937. function Identity( v ) {
  9938. return v;
  9939. }
  9940. function Thrower( ex ) {
  9941. throw ex;
  9942. }
  9943. function adoptValue( value, resolve, reject, noValue ) {
  9944. var method;
  9945. try {
  9946. // Check for promise aspect first to privilege synchronous behavior
  9947. if ( value && isFunction( ( method = value.promise ) ) ) {
  9948. method.call( value ).done( resolve ).fail( reject );
  9949. // Other thenables
  9950. } else if ( value && isFunction( ( method = value.then ) ) ) {
  9951. method.call( value, resolve, reject );
  9952. // Other non-thenables
  9953. } else {
  9954. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  9955. // * false: [ value ].slice( 0 ) => resolve( value )
  9956. // * true: [ value ].slice( 1 ) => resolve()
  9957. resolve.apply( undefined, [ value ].slice( noValue ) );
  9958. }
  9959. // For Promises/A+, convert exceptions into rejections
  9960. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  9961. // Deferred#then to conditionally suppress rejection.
  9962. } catch ( value ) {
  9963. // Support: Android 4.0 only
  9964. // Strict mode functions invoked without .call/.apply get global-object context
  9965. reject.apply( undefined, [ value ] );
  9966. }
  9967. }
  9968. jQuery.extend( {
  9969. Deferred: function( func ) {
  9970. var tuples = [
  9971. // action, add listener, callbacks,
  9972. // ... .then handlers, argument index, [final state]
  9973. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  9974. jQuery.Callbacks( "memory" ), 2 ],
  9975. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  9976. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  9977. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  9978. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  9979. ],
  9980. state = "pending",
  9981. promise = {
  9982. state: function() {
  9983. return state;
  9984. },
  9985. always: function() {
  9986. deferred.done( arguments ).fail( arguments );
  9987. return this;
  9988. },
  9989. "catch": function( fn ) {
  9990. return promise.then( null, fn );
  9991. },
  9992. // Keep pipe for back-compat
  9993. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  9994. var fns = arguments;
  9995. return jQuery.Deferred( function( newDefer ) {
  9996. jQuery.each( tuples, function( i, tuple ) {
  9997. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  9998. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  9999. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10000. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10001. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10002. deferred[ tuple[ 1 ] ]( function() {
  10003. var returned = fn && fn.apply( this, arguments );
  10004. if ( returned && isFunction( returned.promise ) ) {
  10005. returned.promise()
  10006. .progress( newDefer.notify )
  10007. .done( newDefer.resolve )
  10008. .fail( newDefer.reject );
  10009. } else {
  10010. newDefer[ tuple[ 0 ] + "With" ](
  10011. this,
  10012. fn ? [ returned ] : arguments
  10013. );
  10014. }
  10015. } );
  10016. } );
  10017. fns = null;
  10018. } ).promise();
  10019. },
  10020. then: function( onFulfilled, onRejected, onProgress ) {
  10021. var maxDepth = 0;
  10022. function resolve( depth, deferred, handler, special ) {
  10023. return function() {
  10024. var that = this,
  10025. args = arguments,
  10026. mightThrow = function() {
  10027. var returned, then;
  10028. // Support: Promises/A+ section 2.3.3.3.3
  10029. // https://promisesaplus.com/#point-59
  10030. // Ignore double-resolution attempts
  10031. if ( depth < maxDepth ) {
  10032. return;
  10033. }
  10034. returned = handler.apply( that, args );
  10035. // Support: Promises/A+ section 2.3.1
  10036. // https://promisesaplus.com/#point-48
  10037. if ( returned === deferred.promise() ) {
  10038. throw new TypeError( "Thenable self-resolution" );
  10039. }
  10040. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10041. // https://promisesaplus.com/#point-54
  10042. // https://promisesaplus.com/#point-75
  10043. // Retrieve `then` only once
  10044. then = returned &&
  10045. // Support: Promises/A+ section 2.3.4
  10046. // https://promisesaplus.com/#point-64
  10047. // Only check objects and functions for thenability
  10048. ( typeof returned === "object" ||
  10049. typeof returned === "function" ) &&
  10050. returned.then;
  10051. // Handle a returned thenable
  10052. if ( isFunction( then ) ) {
  10053. // Special processors (notify) just wait for resolution
  10054. if ( special ) {
  10055. then.call(
  10056. returned,
  10057. resolve( maxDepth, deferred, Identity, special ),
  10058. resolve( maxDepth, deferred, Thrower, special )
  10059. );
  10060. // Normal processors (resolve) also hook into progress
  10061. } else {
  10062. // ...and disregard older resolution values
  10063. maxDepth++;
  10064. then.call(
  10065. returned,
  10066. resolve( maxDepth, deferred, Identity, special ),
  10067. resolve( maxDepth, deferred, Thrower, special ),
  10068. resolve( maxDepth, deferred, Identity,
  10069. deferred.notifyWith )
  10070. );
  10071. }
  10072. // Handle all other returned values
  10073. } else {
  10074. // Only substitute handlers pass on context
  10075. // and multiple values (non-spec behavior)
  10076. if ( handler !== Identity ) {
  10077. that = undefined;
  10078. args = [ returned ];
  10079. }
  10080. // Process the value(s)
  10081. // Default process is resolve
  10082. ( special || deferred.resolveWith )( that, args );
  10083. }
  10084. },
  10085. // Only normal processors (resolve) catch and reject exceptions
  10086. process = special ?
  10087. mightThrow :
  10088. function() {
  10089. try {
  10090. mightThrow();
  10091. } catch ( e ) {
  10092. if ( jQuery.Deferred.exceptionHook ) {
  10093. jQuery.Deferred.exceptionHook( e,
  10094. process.stackTrace );
  10095. }
  10096. // Support: Promises/A+ section 2.3.3.3.4.1
  10097. // https://promisesaplus.com/#point-61
  10098. // Ignore post-resolution exceptions
  10099. if ( depth + 1 >= maxDepth ) {
  10100. // Only substitute handlers pass on context
  10101. // and multiple values (non-spec behavior)
  10102. if ( handler !== Thrower ) {
  10103. that = undefined;
  10104. args = [ e ];
  10105. }
  10106. deferred.rejectWith( that, args );
  10107. }
  10108. }
  10109. };
  10110. // Support: Promises/A+ section 2.3.3.3.1
  10111. // https://promisesaplus.com/#point-57
  10112. // Re-resolve promises immediately to dodge false rejection from
  10113. // subsequent errors
  10114. if ( depth ) {
  10115. process();
  10116. } else {
  10117. // Call an optional hook to record the stack, in case of exception
  10118. // since it's otherwise lost when execution goes async
  10119. if ( jQuery.Deferred.getStackHook ) {
  10120. process.stackTrace = jQuery.Deferred.getStackHook();
  10121. }
  10122. window.setTimeout( process );
  10123. }
  10124. };
  10125. }
  10126. return jQuery.Deferred( function( newDefer ) {
  10127. // progress_handlers.add( ... )
  10128. tuples[ 0 ][ 3 ].add(
  10129. resolve(
  10130. 0,
  10131. newDefer,
  10132. isFunction( onProgress ) ?
  10133. onProgress :
  10134. Identity,
  10135. newDefer.notifyWith
  10136. )
  10137. );
  10138. // fulfilled_handlers.add( ... )
  10139. tuples[ 1 ][ 3 ].add(
  10140. resolve(
  10141. 0,
  10142. newDefer,
  10143. isFunction( onFulfilled ) ?
  10144. onFulfilled :
  10145. Identity
  10146. )
  10147. );
  10148. // rejected_handlers.add( ... )
  10149. tuples[ 2 ][ 3 ].add(
  10150. resolve(
  10151. 0,
  10152. newDefer,
  10153. isFunction( onRejected ) ?
  10154. onRejected :
  10155. Thrower
  10156. )
  10157. );
  10158. } ).promise();
  10159. },
  10160. // Get a promise for this deferred
  10161. // If obj is provided, the promise aspect is added to the object
  10162. promise: function( obj ) {
  10163. return obj != null ? jQuery.extend( obj, promise ) : promise;
  10164. }
  10165. },
  10166. deferred = {};
  10167. // Add list-specific methods
  10168. jQuery.each( tuples, function( i, tuple ) {
  10169. var list = tuple[ 2 ],
  10170. stateString = tuple[ 5 ];
  10171. // promise.progress = list.add
  10172. // promise.done = list.add
  10173. // promise.fail = list.add
  10174. promise[ tuple[ 1 ] ] = list.add;
  10175. // Handle state
  10176. if ( stateString ) {
  10177. list.add(
  10178. function() {
  10179. // state = "resolved" (i.e., fulfilled)
  10180. // state = "rejected"
  10181. state = stateString;
  10182. },
  10183. // rejected_callbacks.disable
  10184. // fulfilled_callbacks.disable
  10185. tuples[ 3 - i ][ 2 ].disable,
  10186. // rejected_handlers.disable
  10187. // fulfilled_handlers.disable
  10188. tuples[ 3 - i ][ 3 ].disable,
  10189. // progress_callbacks.lock
  10190. tuples[ 0 ][ 2 ].lock,
  10191. // progress_handlers.lock
  10192. tuples[ 0 ][ 3 ].lock
  10193. );
  10194. }
  10195. // progress_handlers.fire
  10196. // fulfilled_handlers.fire
  10197. // rejected_handlers.fire
  10198. list.add( tuple[ 3 ].fire );
  10199. // deferred.notify = function() { deferred.notifyWith(...) }
  10200. // deferred.resolve = function() { deferred.resolveWith(...) }
  10201. // deferred.reject = function() { deferred.rejectWith(...) }
  10202. deferred[ tuple[ 0 ] ] = function() {
  10203. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  10204. return this;
  10205. };
  10206. // deferred.notifyWith = list.fireWith
  10207. // deferred.resolveWith = list.fireWith
  10208. // deferred.rejectWith = list.fireWith
  10209. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  10210. } );
  10211. // Make the deferred a promise
  10212. promise.promise( deferred );
  10213. // Call given func if any
  10214. if ( func ) {
  10215. func.call( deferred, deferred );
  10216. }
  10217. // All done!
  10218. return deferred;
  10219. },
  10220. // Deferred helper
  10221. when: function( singleValue ) {
  10222. var
  10223. // count of uncompleted subordinates
  10224. remaining = arguments.length,
  10225. // count of unprocessed arguments
  10226. i = remaining,
  10227. // subordinate fulfillment data
  10228. resolveContexts = Array( i ),
  10229. resolveValues = slice.call( arguments ),
  10230. // the master Deferred
  10231. master = jQuery.Deferred(),
  10232. // subordinate callback factory
  10233. updateFunc = function( i ) {
  10234. return function( value ) {
  10235. resolveContexts[ i ] = this;
  10236. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  10237. if ( !( --remaining ) ) {
  10238. master.resolveWith( resolveContexts, resolveValues );
  10239. }
  10240. };
  10241. };
  10242. // Single- and empty arguments are adopted like Promise.resolve
  10243. if ( remaining <= 1 ) {
  10244. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  10245. !remaining );
  10246. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  10247. if ( master.state() === "pending" ||
  10248. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  10249. return master.then();
  10250. }
  10251. }
  10252. // Multiple arguments are aggregated like Promise.all array elements
  10253. while ( i-- ) {
  10254. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  10255. }
  10256. return master.promise();
  10257. }
  10258. } );
  10259. // These usually indicate a programmer mistake during development,
  10260. // warn about them ASAP rather than swallowing them by default.
  10261. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  10262. jQuery.Deferred.exceptionHook = function( error, stack ) {
  10263. // Support: IE 8 - 9 only
  10264. // Console exists when dev tools are open, which can happen at any time
  10265. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  10266. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  10267. }
  10268. };
  10269. jQuery.readyException = function( error ) {
  10270. window.setTimeout( function() {
  10271. throw error;
  10272. } );
  10273. };
  10274. // The deferred used on DOM ready
  10275. var readyList = jQuery.Deferred();
  10276. jQuery.fn.ready = function( fn ) {
  10277. readyList
  10278. .then( fn )
  10279. // Wrap jQuery.readyException in a function so that the lookup
  10280. // happens at the time of error handling instead of callback
  10281. // registration.
  10282. .catch( function( error ) {
  10283. jQuery.readyException( error );
  10284. } );
  10285. return this;
  10286. };
  10287. jQuery.extend( {
  10288. // Is the DOM ready to be used? Set to true once it occurs.
  10289. isReady: false,
  10290. // A counter to track how many items to wait for before
  10291. // the ready event fires. See #6781
  10292. readyWait: 1,
  10293. // Handle when the DOM is ready
  10294. ready: function( wait ) {
  10295. // Abort if there are pending holds or we're already ready
  10296. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  10297. return;
  10298. }
  10299. // Remember that the DOM is ready
  10300. jQuery.isReady = true;
  10301. // If a normal DOM Ready event fired, decrement, and wait if need be
  10302. if ( wait !== true && --jQuery.readyWait > 0 ) {
  10303. return;
  10304. }
  10305. // If there are functions bound, to execute
  10306. readyList.resolveWith( document, [ jQuery ] );
  10307. }
  10308. } );
  10309. jQuery.ready.then = readyList.then;
  10310. // The ready event handler and self cleanup method
  10311. function completed() {
  10312. document.removeEventListener( "DOMContentLoaded", completed );
  10313. window.removeEventListener( "load", completed );
  10314. jQuery.ready();
  10315. }
  10316. // Catch cases where $(document).ready() is called
  10317. // after the browser event has already occurred.
  10318. // Support: IE <=9 - 10 only
  10319. // Older IE sometimes signals "interactive" too soon
  10320. if ( document.readyState === "complete" ||
  10321. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  10322. // Handle it asynchronously to allow scripts the opportunity to delay ready
  10323. window.setTimeout( jQuery.ready );
  10324. } else {
  10325. // Use the handy event callback
  10326. document.addEventListener( "DOMContentLoaded", completed );
  10327. // A fallback to window.onload, that will always work
  10328. window.addEventListener( "load", completed );
  10329. }
  10330. // Multifunctional method to get and set values of a collection
  10331. // The value/s can optionally be executed if it's a function
  10332. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  10333. var i = 0,
  10334. len = elems.length,
  10335. bulk = key == null;
  10336. // Sets many values
  10337. if ( toType( key ) === "object" ) {
  10338. chainable = true;
  10339. for ( i in key ) {
  10340. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  10341. }
  10342. // Sets one value
  10343. } else if ( value !== undefined ) {
  10344. chainable = true;
  10345. if ( !isFunction( value ) ) {
  10346. raw = true;
  10347. }
  10348. if ( bulk ) {
  10349. // Bulk operations run against the entire set
  10350. if ( raw ) {
  10351. fn.call( elems, value );
  10352. fn = null;
  10353. // ...except when executing function values
  10354. } else {
  10355. bulk = fn;
  10356. fn = function( elem, key, value ) {
  10357. return bulk.call( jQuery( elem ), value );
  10358. };
  10359. }
  10360. }
  10361. if ( fn ) {
  10362. for ( ; i < len; i++ ) {
  10363. fn(
  10364. elems[ i ], key, raw ?
  10365. value :
  10366. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  10367. );
  10368. }
  10369. }
  10370. }
  10371. if ( chainable ) {
  10372. return elems;
  10373. }
  10374. // Gets
  10375. if ( bulk ) {
  10376. return fn.call( elems );
  10377. }
  10378. return len ? fn( elems[ 0 ], key ) : emptyGet;
  10379. };
  10380. // Matches dashed string for camelizing
  10381. var rmsPrefix = /^-ms-/,
  10382. rdashAlpha = /-([a-z])/g;
  10383. // Used by camelCase as callback to replace()
  10384. function fcamelCase( all, letter ) {
  10385. return letter.toUpperCase();
  10386. }
  10387. // Convert dashed to camelCase; used by the css and data modules
  10388. // Support: IE <=9 - 11, Edge 12 - 15
  10389. // Microsoft forgot to hump their vendor prefix (#9572)
  10390. function camelCase( string ) {
  10391. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  10392. }
  10393. var acceptData = function( owner ) {
  10394. // Accepts only:
  10395. // - Node
  10396. // - Node.ELEMENT_NODE
  10397. // - Node.DOCUMENT_NODE
  10398. // - Object
  10399. // - Any
  10400. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  10401. };
  10402. function Data() {
  10403. this.expando = jQuery.expando + Data.uid++;
  10404. }
  10405. Data.uid = 1;
  10406. Data.prototype = {
  10407. cache: function( owner ) {
  10408. // Check if the owner object already has a cache
  10409. var value = owner[ this.expando ];
  10410. // If not, create one
  10411. if ( !value ) {
  10412. value = {};
  10413. // We can accept data for non-element nodes in modern browsers,
  10414. // but we should not, see #8335.
  10415. // Always return an empty object.
  10416. if ( acceptData( owner ) ) {
  10417. // If it is a node unlikely to be stringify-ed or looped over
  10418. // use plain assignment
  10419. if ( owner.nodeType ) {
  10420. owner[ this.expando ] = value;
  10421. // Otherwise secure it in a non-enumerable property
  10422. // configurable must be true to allow the property to be
  10423. // deleted when data is removed
  10424. } else {
  10425. Object.defineProperty( owner, this.expando, {
  10426. value: value,
  10427. configurable: true
  10428. } );
  10429. }
  10430. }
  10431. }
  10432. return value;
  10433. },
  10434. set: function( owner, data, value ) {
  10435. var prop,
  10436. cache = this.cache( owner );
  10437. // Handle: [ owner, key, value ] args
  10438. // Always use camelCase key (gh-2257)
  10439. if ( typeof data === "string" ) {
  10440. cache[ camelCase( data ) ] = value;
  10441. // Handle: [ owner, { properties } ] args
  10442. } else {
  10443. // Copy the properties one-by-one to the cache object
  10444. for ( prop in data ) {
  10445. cache[ camelCase( prop ) ] = data[ prop ];
  10446. }
  10447. }
  10448. return cache;
  10449. },
  10450. get: function( owner, key ) {
  10451. return key === undefined ?
  10452. this.cache( owner ) :
  10453. // Always use camelCase key (gh-2257)
  10454. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  10455. },
  10456. access: function( owner, key, value ) {
  10457. // In cases where either:
  10458. //
  10459. // 1. No key was specified
  10460. // 2. A string key was specified, but no value provided
  10461. //
  10462. // Take the "read" path and allow the get method to determine
  10463. // which value to return, respectively either:
  10464. //
  10465. // 1. The entire cache object
  10466. // 2. The data stored at the key
  10467. //
  10468. if ( key === undefined ||
  10469. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  10470. return this.get( owner, key );
  10471. }
  10472. // When the key is not a string, or both a key and value
  10473. // are specified, set or extend (existing objects) with either:
  10474. //
  10475. // 1. An object of properties
  10476. // 2. A key and value
  10477. //
  10478. this.set( owner, key, value );
  10479. // Since the "set" path can have two possible entry points
  10480. // return the expected data based on which path was taken[*]
  10481. return value !== undefined ? value : key;
  10482. },
  10483. remove: function( owner, key ) {
  10484. var i,
  10485. cache = owner[ this.expando ];
  10486. if ( cache === undefined ) {
  10487. return;
  10488. }
  10489. if ( key !== undefined ) {
  10490. // Support array or space separated string of keys
  10491. if ( Array.isArray( key ) ) {
  10492. // If key is an array of keys...
  10493. // We always set camelCase keys, so remove that.
  10494. key = key.map( camelCase );
  10495. } else {
  10496. key = camelCase( key );
  10497. // If a key with the spaces exists, use it.
  10498. // Otherwise, create an array by matching non-whitespace
  10499. key = key in cache ?
  10500. [ key ] :
  10501. ( key.match( rnothtmlwhite ) || [] );
  10502. }
  10503. i = key.length;
  10504. while ( i-- ) {
  10505. delete cache[ key[ i ] ];
  10506. }
  10507. }
  10508. // Remove the expando if there's no more data
  10509. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  10510. // Support: Chrome <=35 - 45
  10511. // Webkit & Blink performance suffers when deleting properties
  10512. // from DOM nodes, so set to undefined instead
  10513. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  10514. if ( owner.nodeType ) {
  10515. owner[ this.expando ] = undefined;
  10516. } else {
  10517. delete owner[ this.expando ];
  10518. }
  10519. }
  10520. },
  10521. hasData: function( owner ) {
  10522. var cache = owner[ this.expando ];
  10523. return cache !== undefined && !jQuery.isEmptyObject( cache );
  10524. }
  10525. };
  10526. var dataPriv = new Data();
  10527. var dataUser = new Data();
  10528. // Implementation Summary
  10529. //
  10530. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  10531. // 2. Improve the module's maintainability by reducing the storage
  10532. // paths to a single mechanism.
  10533. // 3. Use the same single mechanism to support "private" and "user" data.
  10534. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  10535. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  10536. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  10537. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  10538. rmultiDash = /[A-Z]/g;
  10539. function getData( data ) {
  10540. if ( data === "true" ) {
  10541. return true;
  10542. }
  10543. if ( data === "false" ) {
  10544. return false;
  10545. }
  10546. if ( data === "null" ) {
  10547. return null;
  10548. }
  10549. // Only convert to a number if it doesn't change the string
  10550. if ( data === +data + "" ) {
  10551. return +data;
  10552. }
  10553. if ( rbrace.test( data ) ) {
  10554. return JSON.parse( data );
  10555. }
  10556. return data;
  10557. }
  10558. function dataAttr( elem, key, data ) {
  10559. var name;
  10560. // If nothing was found internally, try to fetch any
  10561. // data from the HTML5 data-* attribute
  10562. if ( data === undefined && elem.nodeType === 1 ) {
  10563. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  10564. data = elem.getAttribute( name );
  10565. if ( typeof data === "string" ) {
  10566. try {
  10567. data = getData( data );
  10568. } catch ( e ) {}
  10569. // Make sure we set the data so it isn't changed later
  10570. dataUser.set( elem, key, data );
  10571. } else {
  10572. data = undefined;
  10573. }
  10574. }
  10575. return data;
  10576. }
  10577. jQuery.extend( {
  10578. hasData: function( elem ) {
  10579. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  10580. },
  10581. data: function( elem, name, data ) {
  10582. return dataUser.access( elem, name, data );
  10583. },
  10584. removeData: function( elem, name ) {
  10585. dataUser.remove( elem, name );
  10586. },
  10587. // TODO: Now that all calls to _data and _removeData have been replaced
  10588. // with direct calls to dataPriv methods, these can be deprecated.
  10589. _data: function( elem, name, data ) {
  10590. return dataPriv.access( elem, name, data );
  10591. },
  10592. _removeData: function( elem, name ) {
  10593. dataPriv.remove( elem, name );
  10594. }
  10595. } );
  10596. jQuery.fn.extend( {
  10597. data: function( key, value ) {
  10598. var i, name, data,
  10599. elem = this[ 0 ],
  10600. attrs = elem && elem.attributes;
  10601. // Gets all values
  10602. if ( key === undefined ) {
  10603. if ( this.length ) {
  10604. data = dataUser.get( elem );
  10605. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  10606. i = attrs.length;
  10607. while ( i-- ) {
  10608. // Support: IE 11 only
  10609. // The attrs elements can be null (#14894)
  10610. if ( attrs[ i ] ) {
  10611. name = attrs[ i ].name;
  10612. if ( name.indexOf( "data-" ) === 0 ) {
  10613. name = camelCase( name.slice( 5 ) );
  10614. dataAttr( elem, name, data[ name ] );
  10615. }
  10616. }
  10617. }
  10618. dataPriv.set( elem, "hasDataAttrs", true );
  10619. }
  10620. }
  10621. return data;
  10622. }
  10623. // Sets multiple values
  10624. if ( typeof key === "object" ) {
  10625. return this.each( function() {
  10626. dataUser.set( this, key );
  10627. } );
  10628. }
  10629. return access( this, function( value ) {
  10630. var data;
  10631. // The calling jQuery object (element matches) is not empty
  10632. // (and therefore has an element appears at this[ 0 ]) and the
  10633. // `value` parameter was not undefined. An empty jQuery object
  10634. // will result in `undefined` for elem = this[ 0 ] which will
  10635. // throw an exception if an attempt to read a data cache is made.
  10636. if ( elem && value === undefined ) {
  10637. // Attempt to get data from the cache
  10638. // The key will always be camelCased in Data
  10639. data = dataUser.get( elem, key );
  10640. if ( data !== undefined ) {
  10641. return data;
  10642. }
  10643. // Attempt to "discover" the data in
  10644. // HTML5 custom data-* attrs
  10645. data = dataAttr( elem, key );
  10646. if ( data !== undefined ) {
  10647. return data;
  10648. }
  10649. // We tried really hard, but the data doesn't exist.
  10650. return;
  10651. }
  10652. // Set the data...
  10653. this.each( function() {
  10654. // We always store the camelCased key
  10655. dataUser.set( this, key, value );
  10656. } );
  10657. }, null, value, arguments.length > 1, null, true );
  10658. },
  10659. removeData: function( key ) {
  10660. return this.each( function() {
  10661. dataUser.remove( this, key );
  10662. } );
  10663. }
  10664. } );
  10665. jQuery.extend( {
  10666. queue: function( elem, type, data ) {
  10667. var queue;
  10668. if ( elem ) {
  10669. type = ( type || "fx" ) + "queue";
  10670. queue = dataPriv.get( elem, type );
  10671. // Speed up dequeue by getting out quickly if this is just a lookup
  10672. if ( data ) {
  10673. if ( !queue || Array.isArray( data ) ) {
  10674. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  10675. } else {
  10676. queue.push( data );
  10677. }
  10678. }
  10679. return queue || [];
  10680. }
  10681. },
  10682. dequeue: function( elem, type ) {
  10683. type = type || "fx";
  10684. var queue = jQuery.queue( elem, type ),
  10685. startLength = queue.length,
  10686. fn = queue.shift(),
  10687. hooks = jQuery._queueHooks( elem, type ),
  10688. next = function() {
  10689. jQuery.dequeue( elem, type );
  10690. };
  10691. // If the fx queue is dequeued, always remove the progress sentinel
  10692. if ( fn === "inprogress" ) {
  10693. fn = queue.shift();
  10694. startLength--;
  10695. }
  10696. if ( fn ) {
  10697. // Add a progress sentinel to prevent the fx queue from being
  10698. // automatically dequeued
  10699. if ( type === "fx" ) {
  10700. queue.unshift( "inprogress" );
  10701. }
  10702. // Clear up the last queue stop function
  10703. delete hooks.stop;
  10704. fn.call( elem, next, hooks );
  10705. }
  10706. if ( !startLength && hooks ) {
  10707. hooks.empty.fire();
  10708. }
  10709. },
  10710. // Not public - generate a queueHooks object, or return the current one
  10711. _queueHooks: function( elem, type ) {
  10712. var key = type + "queueHooks";
  10713. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  10714. empty: jQuery.Callbacks( "once memory" ).add( function() {
  10715. dataPriv.remove( elem, [ type + "queue", key ] );
  10716. } )
  10717. } );
  10718. }
  10719. } );
  10720. jQuery.fn.extend( {
  10721. queue: function( type, data ) {
  10722. var setter = 2;
  10723. if ( typeof type !== "string" ) {
  10724. data = type;
  10725. type = "fx";
  10726. setter--;
  10727. }
  10728. if ( arguments.length < setter ) {
  10729. return jQuery.queue( this[ 0 ], type );
  10730. }
  10731. return data === undefined ?
  10732. this :
  10733. this.each( function() {
  10734. var queue = jQuery.queue( this, type, data );
  10735. // Ensure a hooks for this queue
  10736. jQuery._queueHooks( this, type );
  10737. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  10738. jQuery.dequeue( this, type );
  10739. }
  10740. } );
  10741. },
  10742. dequeue: function( type ) {
  10743. return this.each( function() {
  10744. jQuery.dequeue( this, type );
  10745. } );
  10746. },
  10747. clearQueue: function( type ) {
  10748. return this.queue( type || "fx", [] );
  10749. },
  10750. // Get a promise resolved when queues of a certain type
  10751. // are emptied (fx is the type by default)
  10752. promise: function( type, obj ) {
  10753. var tmp,
  10754. count = 1,
  10755. defer = jQuery.Deferred(),
  10756. elements = this,
  10757. i = this.length,
  10758. resolve = function() {
  10759. if ( !( --count ) ) {
  10760. defer.resolveWith( elements, [ elements ] );
  10761. }
  10762. };
  10763. if ( typeof type !== "string" ) {
  10764. obj = type;
  10765. type = undefined;
  10766. }
  10767. type = type || "fx";
  10768. while ( i-- ) {
  10769. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  10770. if ( tmp && tmp.empty ) {
  10771. count++;
  10772. tmp.empty.add( resolve );
  10773. }
  10774. }
  10775. resolve();
  10776. return defer.promise( obj );
  10777. }
  10778. } );
  10779. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  10780. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  10781. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  10782. var documentElement = document.documentElement;
  10783. var isAttached = function( elem ) {
  10784. return jQuery.contains( elem.ownerDocument, elem );
  10785. },
  10786. composed = { composed: true };
  10787. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  10788. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  10789. // Support: iOS 10.0-10.2 only
  10790. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  10791. // leading to errors. We need to check for `getRootNode`.
  10792. if ( documentElement.getRootNode ) {
  10793. isAttached = function( elem ) {
  10794. return jQuery.contains( elem.ownerDocument, elem ) ||
  10795. elem.getRootNode( composed ) === elem.ownerDocument;
  10796. };
  10797. }
  10798. var isHiddenWithinTree = function( elem, el ) {
  10799. // isHiddenWithinTree might be called from jQuery#filter function;
  10800. // in that case, element will be second argument
  10801. elem = el || elem;
  10802. // Inline style trumps all
  10803. return elem.style.display === "none" ||
  10804. elem.style.display === "" &&
  10805. // Otherwise, check computed style
  10806. // Support: Firefox <=43 - 45
  10807. // Disconnected elements can have computed display: none, so first confirm that elem is
  10808. // in the document.
  10809. isAttached( elem ) &&
  10810. jQuery.css( elem, "display" ) === "none";
  10811. };
  10812. var swap = function( elem, options, callback, args ) {
  10813. var ret, name,
  10814. old = {};
  10815. // Remember the old values, and insert the new ones
  10816. for ( name in options ) {
  10817. old[ name ] = elem.style[ name ];
  10818. elem.style[ name ] = options[ name ];
  10819. }
  10820. ret = callback.apply( elem, args || [] );
  10821. // Revert the old values
  10822. for ( name in options ) {
  10823. elem.style[ name ] = old[ name ];
  10824. }
  10825. return ret;
  10826. };
  10827. function adjustCSS( elem, prop, valueParts, tween ) {
  10828. var adjusted, scale,
  10829. maxIterations = 20,
  10830. currentValue = tween ?
  10831. function() {
  10832. return tween.cur();
  10833. } :
  10834. function() {
  10835. return jQuery.css( elem, prop, "" );
  10836. },
  10837. initial = currentValue(),
  10838. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  10839. // Starting value computation is required for potential unit mismatches
  10840. initialInUnit = elem.nodeType &&
  10841. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  10842. rcssNum.exec( jQuery.css( elem, prop ) );
  10843. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  10844. // Support: Firefox <=54
  10845. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  10846. initial = initial / 2;
  10847. // Trust units reported by jQuery.css
  10848. unit = unit || initialInUnit[ 3 ];
  10849. // Iteratively approximate from a nonzero starting point
  10850. initialInUnit = +initial || 1;
  10851. while ( maxIterations-- ) {
  10852. // Evaluate and update our best guess (doubling guesses that zero out).
  10853. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  10854. jQuery.style( elem, prop, initialInUnit + unit );
  10855. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  10856. maxIterations = 0;
  10857. }
  10858. initialInUnit = initialInUnit / scale;
  10859. }
  10860. initialInUnit = initialInUnit * 2;
  10861. jQuery.style( elem, prop, initialInUnit + unit );
  10862. // Make sure we update the tween properties later on
  10863. valueParts = valueParts || [];
  10864. }
  10865. if ( valueParts ) {
  10866. initialInUnit = +initialInUnit || +initial || 0;
  10867. // Apply relative offset (+=/-=) if specified
  10868. adjusted = valueParts[ 1 ] ?
  10869. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  10870. +valueParts[ 2 ];
  10871. if ( tween ) {
  10872. tween.unit = unit;
  10873. tween.start = initialInUnit;
  10874. tween.end = adjusted;
  10875. }
  10876. }
  10877. return adjusted;
  10878. }
  10879. var defaultDisplayMap = {};
  10880. function getDefaultDisplay( elem ) {
  10881. var temp,
  10882. doc = elem.ownerDocument,
  10883. nodeName = elem.nodeName,
  10884. display = defaultDisplayMap[ nodeName ];
  10885. if ( display ) {
  10886. return display;
  10887. }
  10888. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  10889. display = jQuery.css( temp, "display" );
  10890. temp.parentNode.removeChild( temp );
  10891. if ( display === "none" ) {
  10892. display = "block";
  10893. }
  10894. defaultDisplayMap[ nodeName ] = display;
  10895. return display;
  10896. }
  10897. function showHide( elements, show ) {
  10898. var display, elem,
  10899. values = [],
  10900. index = 0,
  10901. length = elements.length;
  10902. // Determine new display value for elements that need to change
  10903. for ( ; index < length; index++ ) {
  10904. elem = elements[ index ];
  10905. if ( !elem.style ) {
  10906. continue;
  10907. }
  10908. display = elem.style.display;
  10909. if ( show ) {
  10910. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  10911. // check is required in this first loop unless we have a nonempty display value (either
  10912. // inline or about-to-be-restored)
  10913. if ( display === "none" ) {
  10914. values[ index ] = dataPriv.get( elem, "display" ) || null;
  10915. if ( !values[ index ] ) {
  10916. elem.style.display = "";
  10917. }
  10918. }
  10919. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  10920. values[ index ] = getDefaultDisplay( elem );
  10921. }
  10922. } else {
  10923. if ( display !== "none" ) {
  10924. values[ index ] = "none";
  10925. // Remember what we're overwriting
  10926. dataPriv.set( elem, "display", display );
  10927. }
  10928. }
  10929. }
  10930. // Set the display of the elements in a second loop to avoid constant reflow
  10931. for ( index = 0; index < length; index++ ) {
  10932. if ( values[ index ] != null ) {
  10933. elements[ index ].style.display = values[ index ];
  10934. }
  10935. }
  10936. return elements;
  10937. }
  10938. jQuery.fn.extend( {
  10939. show: function() {
  10940. return showHide( this, true );
  10941. },
  10942. hide: function() {
  10943. return showHide( this );
  10944. },
  10945. toggle: function( state ) {
  10946. if ( typeof state === "boolean" ) {
  10947. return state ? this.show() : this.hide();
  10948. }
  10949. return this.each( function() {
  10950. if ( isHiddenWithinTree( this ) ) {
  10951. jQuery( this ).show();
  10952. } else {
  10953. jQuery( this ).hide();
  10954. }
  10955. } );
  10956. }
  10957. } );
  10958. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  10959. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  10960. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  10961. // We have to close these tags to support XHTML (#13200)
  10962. var wrapMap = {
  10963. // Support: IE <=9 only
  10964. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  10965. // XHTML parsers do not magically insert elements in the
  10966. // same way that tag soup parsers do. So we cannot shorten
  10967. // this by omitting <tbody> or other required elements.
  10968. thead: [ 1, "<table>", "</table>" ],
  10969. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  10970. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  10971. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  10972. _default: [ 0, "", "" ]
  10973. };
  10974. // Support: IE <=9 only
  10975. wrapMap.optgroup = wrapMap.option;
  10976. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  10977. wrapMap.th = wrapMap.td;
  10978. function getAll( context, tag ) {
  10979. // Support: IE <=9 - 11 only
  10980. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  10981. var ret;
  10982. if ( typeof context.getElementsByTagName !== "undefined" ) {
  10983. ret = context.getElementsByTagName( tag || "*" );
  10984. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  10985. ret = context.querySelectorAll( tag || "*" );
  10986. } else {
  10987. ret = [];
  10988. }
  10989. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  10990. return jQuery.merge( [ context ], ret );
  10991. }
  10992. return ret;
  10993. }
  10994. // Mark scripts as having already been evaluated
  10995. function setGlobalEval( elems, refElements ) {
  10996. var i = 0,
  10997. l = elems.length;
  10998. for ( ; i < l; i++ ) {
  10999. dataPriv.set(
  11000. elems[ i ],
  11001. "globalEval",
  11002. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11003. );
  11004. }
  11005. }
  11006. var rhtml = /<|&#?\w+;/;
  11007. function buildFragment( elems, context, scripts, selection, ignored ) {
  11008. var elem, tmp, tag, wrap, attached, j,
  11009. fragment = context.createDocumentFragment(),
  11010. nodes = [],
  11011. i = 0,
  11012. l = elems.length;
  11013. for ( ; i < l; i++ ) {
  11014. elem = elems[ i ];
  11015. if ( elem || elem === 0 ) {
  11016. // Add nodes directly
  11017. if ( toType( elem ) === "object" ) {
  11018. // Support: Android <=4.0 only, PhantomJS 1 only
  11019. // push.apply(_, arraylike) throws on ancient WebKit
  11020. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11021. // Convert non-html into a text node
  11022. } else if ( !rhtml.test( elem ) ) {
  11023. nodes.push( context.createTextNode( elem ) );
  11024. // Convert html into DOM nodes
  11025. } else {
  11026. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11027. // Deserialize a standard representation
  11028. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11029. wrap = wrapMap[ tag ] || wrapMap._default;
  11030. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11031. // Descend through wrappers to the right content
  11032. j = wrap[ 0 ];
  11033. while ( j-- ) {
  11034. tmp = tmp.lastChild;
  11035. }
  11036. // Support: Android <=4.0 only, PhantomJS 1 only
  11037. // push.apply(_, arraylike) throws on ancient WebKit
  11038. jQuery.merge( nodes, tmp.childNodes );
  11039. // Remember the top-level container
  11040. tmp = fragment.firstChild;
  11041. // Ensure the created nodes are orphaned (#12392)
  11042. tmp.textContent = "";
  11043. }
  11044. }
  11045. }
  11046. // Remove wrapper from fragment
  11047. fragment.textContent = "";
  11048. i = 0;
  11049. while ( ( elem = nodes[ i++ ] ) ) {
  11050. // Skip elements already in the context collection (trac-4087)
  11051. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11052. if ( ignored ) {
  11053. ignored.push( elem );
  11054. }
  11055. continue;
  11056. }
  11057. attached = isAttached( elem );
  11058. // Append to fragment
  11059. tmp = getAll( fragment.appendChild( elem ), "script" );
  11060. // Preserve script evaluation history
  11061. if ( attached ) {
  11062. setGlobalEval( tmp );
  11063. }
  11064. // Capture executables
  11065. if ( scripts ) {
  11066. j = 0;
  11067. while ( ( elem = tmp[ j++ ] ) ) {
  11068. if ( rscriptType.test( elem.type || "" ) ) {
  11069. scripts.push( elem );
  11070. }
  11071. }
  11072. }
  11073. }
  11074. return fragment;
  11075. }
  11076. ( function() {
  11077. var fragment = document.createDocumentFragment(),
  11078. div = fragment.appendChild( document.createElement( "div" ) ),
  11079. input = document.createElement( "input" );
  11080. // Support: Android 4.0 - 4.3 only
  11081. // Check state lost if the name is set (#11217)
  11082. // Support: Windows Web Apps (WWA)
  11083. // `name` and `type` must use .setAttribute for WWA (#14901)
  11084. input.setAttribute( "type", "radio" );
  11085. input.setAttribute( "checked", "checked" );
  11086. input.setAttribute( "name", "t" );
  11087. div.appendChild( input );
  11088. // Support: Android <=4.1 only
  11089. // Older WebKit doesn't clone checked state correctly in fragments
  11090. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  11091. // Support: IE <=11 only
  11092. // Make sure textarea (and checkbox) defaultValue is properly cloned
  11093. div.innerHTML = "<textarea>x</textarea>";
  11094. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  11095. } )();
  11096. var
  11097. rkeyEvent = /^key/,
  11098. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  11099. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  11100. function returnTrue() {
  11101. return true;
  11102. }
  11103. function returnFalse() {
  11104. return false;
  11105. }
  11106. // Support: IE <=9 - 11+
  11107. // focus() and blur() are asynchronous, except when they are no-op.
  11108. // So expect focus to be synchronous when the element is already active,
  11109. // and blur to be synchronous when the element is not already active.
  11110. // (focus and blur are always synchronous in other supported browsers,
  11111. // this just defines when we can count on it).
  11112. function expectSync( elem, type ) {
  11113. return ( elem === safeActiveElement() ) === ( type === "focus" );
  11114. }
  11115. // Support: IE <=9 only
  11116. // Accessing document.activeElement can throw unexpectedly
  11117. // https://bugs.jquery.com/ticket/13393
  11118. function safeActiveElement() {
  11119. try {
  11120. return document.activeElement;
  11121. } catch ( err ) { }
  11122. }
  11123. function on( elem, types, selector, data, fn, one ) {
  11124. var origFn, type;
  11125. // Types can be a map of types/handlers
  11126. if ( typeof types === "object" ) {
  11127. // ( types-Object, selector, data )
  11128. if ( typeof selector !== "string" ) {
  11129. // ( types-Object, data )
  11130. data = data || selector;
  11131. selector = undefined;
  11132. }
  11133. for ( type in types ) {
  11134. on( elem, type, selector, data, types[ type ], one );
  11135. }
  11136. return elem;
  11137. }
  11138. if ( data == null && fn == null ) {
  11139. // ( types, fn )
  11140. fn = selector;
  11141. data = selector = undefined;
  11142. } else if ( fn == null ) {
  11143. if ( typeof selector === "string" ) {
  11144. // ( types, selector, fn )
  11145. fn = data;
  11146. data = undefined;
  11147. } else {
  11148. // ( types, data, fn )
  11149. fn = data;
  11150. data = selector;
  11151. selector = undefined;
  11152. }
  11153. }
  11154. if ( fn === false ) {
  11155. fn = returnFalse;
  11156. } else if ( !fn ) {
  11157. return elem;
  11158. }
  11159. if ( one === 1 ) {
  11160. origFn = fn;
  11161. fn = function( event ) {
  11162. // Can use an empty set, since event contains the info
  11163. jQuery().off( event );
  11164. return origFn.apply( this, arguments );
  11165. };
  11166. // Use same guid so caller can remove using origFn
  11167. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  11168. }
  11169. return elem.each( function() {
  11170. jQuery.event.add( this, types, fn, data, selector );
  11171. } );
  11172. }
  11173. /*
  11174. * Helper functions for managing events -- not part of the public interface.
  11175. * Props to Dean Edwards' addEvent library for many of the ideas.
  11176. */
  11177. jQuery.event = {
  11178. global: {},
  11179. add: function( elem, types, handler, data, selector ) {
  11180. var handleObjIn, eventHandle, tmp,
  11181. events, t, handleObj,
  11182. special, handlers, type, namespaces, origType,
  11183. elemData = dataPriv.get( elem );
  11184. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  11185. if ( !elemData ) {
  11186. return;
  11187. }
  11188. // Caller can pass in an object of custom data in lieu of the handler
  11189. if ( handler.handler ) {
  11190. handleObjIn = handler;
  11191. handler = handleObjIn.handler;
  11192. selector = handleObjIn.selector;
  11193. }
  11194. // Ensure that invalid selectors throw exceptions at attach time
  11195. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  11196. if ( selector ) {
  11197. jQuery.find.matchesSelector( documentElement, selector );
  11198. }
  11199. // Make sure that the handler has a unique ID, used to find/remove it later
  11200. if ( !handler.guid ) {
  11201. handler.guid = jQuery.guid++;
  11202. }
  11203. // Init the element's event structure and main handler, if this is the first
  11204. if ( !( events = elemData.events ) ) {
  11205. events = elemData.events = {};
  11206. }
  11207. if ( !( eventHandle = elemData.handle ) ) {
  11208. eventHandle = elemData.handle = function( e ) {
  11209. // Discard the second event of a jQuery.event.trigger() and
  11210. // when an event is called after a page has unloaded
  11211. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  11212. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  11213. };
  11214. }
  11215. // Handle multiple events separated by a space
  11216. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11217. t = types.length;
  11218. while ( t-- ) {
  11219. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11220. type = origType = tmp[ 1 ];
  11221. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11222. // There *must* be a type, no attaching namespace-only handlers
  11223. if ( !type ) {
  11224. continue;
  11225. }
  11226. // If event changes its type, use the special event handlers for the changed type
  11227. special = jQuery.event.special[ type ] || {};
  11228. // If selector defined, determine special event api type, otherwise given type
  11229. type = ( selector ? special.delegateType : special.bindType ) || type;
  11230. // Update special based on newly reset type
  11231. special = jQuery.event.special[ type ] || {};
  11232. // handleObj is passed to all event handlers
  11233. handleObj = jQuery.extend( {
  11234. type: type,
  11235. origType: origType,
  11236. data: data,
  11237. handler: handler,
  11238. guid: handler.guid,
  11239. selector: selector,
  11240. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  11241. namespace: namespaces.join( "." )
  11242. }, handleObjIn );
  11243. // Init the event handler queue if we're the first
  11244. if ( !( handlers = events[ type ] ) ) {
  11245. handlers = events[ type ] = [];
  11246. handlers.delegateCount = 0;
  11247. // Only use addEventListener if the special events handler returns false
  11248. if ( !special.setup ||
  11249. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  11250. if ( elem.addEventListener ) {
  11251. elem.addEventListener( type, eventHandle );
  11252. }
  11253. }
  11254. }
  11255. if ( special.add ) {
  11256. special.add.call( elem, handleObj );
  11257. if ( !handleObj.handler.guid ) {
  11258. handleObj.handler.guid = handler.guid;
  11259. }
  11260. }
  11261. // Add to the element's handler list, delegates in front
  11262. if ( selector ) {
  11263. handlers.splice( handlers.delegateCount++, 0, handleObj );
  11264. } else {
  11265. handlers.push( handleObj );
  11266. }
  11267. // Keep track of which events have ever been used, for event optimization
  11268. jQuery.event.global[ type ] = true;
  11269. }
  11270. },
  11271. // Detach an event or set of events from an element
  11272. remove: function( elem, types, handler, selector, mappedTypes ) {
  11273. var j, origCount, tmp,
  11274. events, t, handleObj,
  11275. special, handlers, type, namespaces, origType,
  11276. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  11277. if ( !elemData || !( events = elemData.events ) ) {
  11278. return;
  11279. }
  11280. // Once for each type.namespace in types; type may be omitted
  11281. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  11282. t = types.length;
  11283. while ( t-- ) {
  11284. tmp = rtypenamespace.exec( types[ t ] ) || [];
  11285. type = origType = tmp[ 1 ];
  11286. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  11287. // Unbind all events (on this namespace, if provided) for the element
  11288. if ( !type ) {
  11289. for ( type in events ) {
  11290. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  11291. }
  11292. continue;
  11293. }
  11294. special = jQuery.event.special[ type ] || {};
  11295. type = ( selector ? special.delegateType : special.bindType ) || type;
  11296. handlers = events[ type ] || [];
  11297. tmp = tmp[ 2 ] &&
  11298. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  11299. // Remove matching events
  11300. origCount = j = handlers.length;
  11301. while ( j-- ) {
  11302. handleObj = handlers[ j ];
  11303. if ( ( mappedTypes || origType === handleObj.origType ) &&
  11304. ( !handler || handler.guid === handleObj.guid ) &&
  11305. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  11306. ( !selector || selector === handleObj.selector ||
  11307. selector === "**" && handleObj.selector ) ) {
  11308. handlers.splice( j, 1 );
  11309. if ( handleObj.selector ) {
  11310. handlers.delegateCount--;
  11311. }
  11312. if ( special.remove ) {
  11313. special.remove.call( elem, handleObj );
  11314. }
  11315. }
  11316. }
  11317. // Remove generic event handler if we removed something and no more handlers exist
  11318. // (avoids potential for endless recursion during removal of special event handlers)
  11319. if ( origCount && !handlers.length ) {
  11320. if ( !special.teardown ||
  11321. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  11322. jQuery.removeEvent( elem, type, elemData.handle );
  11323. }
  11324. delete events[ type ];
  11325. }
  11326. }
  11327. // Remove data and the expando if it's no longer used
  11328. if ( jQuery.isEmptyObject( events ) ) {
  11329. dataPriv.remove( elem, "handle events" );
  11330. }
  11331. },
  11332. dispatch: function( nativeEvent ) {
  11333. // Make a writable jQuery.Event from the native event object
  11334. var event = jQuery.event.fix( nativeEvent );
  11335. var i, j, ret, matched, handleObj, handlerQueue,
  11336. args = new Array( arguments.length ),
  11337. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  11338. special = jQuery.event.special[ event.type ] || {};
  11339. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  11340. args[ 0 ] = event;
  11341. for ( i = 1; i < arguments.length; i++ ) {
  11342. args[ i ] = arguments[ i ];
  11343. }
  11344. event.delegateTarget = this;
  11345. // Call the preDispatch hook for the mapped type, and let it bail if desired
  11346. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  11347. return;
  11348. }
  11349. // Determine handlers
  11350. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  11351. // Run delegates first; they may want to stop propagation beneath us
  11352. i = 0;
  11353. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  11354. event.currentTarget = matched.elem;
  11355. j = 0;
  11356. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  11357. !event.isImmediatePropagationStopped() ) {
  11358. // If the event is namespaced, then each handler is only invoked if it is
  11359. // specially universal or its namespaces are a superset of the event's.
  11360. if ( !event.rnamespace || handleObj.namespace === false ||
  11361. event.rnamespace.test( handleObj.namespace ) ) {
  11362. event.handleObj = handleObj;
  11363. event.data = handleObj.data;
  11364. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  11365. handleObj.handler ).apply( matched.elem, args );
  11366. if ( ret !== undefined ) {
  11367. if ( ( event.result = ret ) === false ) {
  11368. event.preventDefault();
  11369. event.stopPropagation();
  11370. }
  11371. }
  11372. }
  11373. }
  11374. }
  11375. // Call the postDispatch hook for the mapped type
  11376. if ( special.postDispatch ) {
  11377. special.postDispatch.call( this, event );
  11378. }
  11379. return event.result;
  11380. },
  11381. handlers: function( event, handlers ) {
  11382. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  11383. handlerQueue = [],
  11384. delegateCount = handlers.delegateCount,
  11385. cur = event.target;
  11386. // Find delegate handlers
  11387. if ( delegateCount &&
  11388. // Support: IE <=9
  11389. // Black-hole SVG <use> instance trees (trac-13180)
  11390. cur.nodeType &&
  11391. // Support: Firefox <=42
  11392. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  11393. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  11394. // Support: IE 11 only
  11395. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  11396. !( event.type === "click" && event.button >= 1 ) ) {
  11397. for ( ; cur !== this; cur = cur.parentNode || this ) {
  11398. // Don't check non-elements (#13208)
  11399. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  11400. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  11401. matchedHandlers = [];
  11402. matchedSelectors = {};
  11403. for ( i = 0; i < delegateCount; i++ ) {
  11404. handleObj = handlers[ i ];
  11405. // Don't conflict with Object.prototype properties (#13203)
  11406. sel = handleObj.selector + " ";
  11407. if ( matchedSelectors[ sel ] === undefined ) {
  11408. matchedSelectors[ sel ] = handleObj.needsContext ?
  11409. jQuery( sel, this ).index( cur ) > -1 :
  11410. jQuery.find( sel, this, null, [ cur ] ).length;
  11411. }
  11412. if ( matchedSelectors[ sel ] ) {
  11413. matchedHandlers.push( handleObj );
  11414. }
  11415. }
  11416. if ( matchedHandlers.length ) {
  11417. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  11418. }
  11419. }
  11420. }
  11421. }
  11422. // Add the remaining (directly-bound) handlers
  11423. cur = this;
  11424. if ( delegateCount < handlers.length ) {
  11425. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  11426. }
  11427. return handlerQueue;
  11428. },
  11429. addProp: function( name, hook ) {
  11430. Object.defineProperty( jQuery.Event.prototype, name, {
  11431. enumerable: true,
  11432. configurable: true,
  11433. get: isFunction( hook ) ?
  11434. function() {
  11435. if ( this.originalEvent ) {
  11436. return hook( this.originalEvent );
  11437. }
  11438. } :
  11439. function() {
  11440. if ( this.originalEvent ) {
  11441. return this.originalEvent[ name ];
  11442. }
  11443. },
  11444. set: function( value ) {
  11445. Object.defineProperty( this, name, {
  11446. enumerable: true,
  11447. configurable: true,
  11448. writable: true,
  11449. value: value
  11450. } );
  11451. }
  11452. } );
  11453. },
  11454. fix: function( originalEvent ) {
  11455. return originalEvent[ jQuery.expando ] ?
  11456. originalEvent :
  11457. new jQuery.Event( originalEvent );
  11458. },
  11459. special: {
  11460. load: {
  11461. // Prevent triggered image.load events from bubbling to window.load
  11462. noBubble: true
  11463. },
  11464. click: {
  11465. // Utilize native event to ensure correct state for checkable inputs
  11466. setup: function( data ) {
  11467. // For mutual compressibility with _default, replace `this` access with a local var.
  11468. // `|| data` is dead code meant only to preserve the variable through minification.
  11469. var el = this || data;
  11470. // Claim the first handler
  11471. if ( rcheckableType.test( el.type ) &&
  11472. el.click && nodeName( el, "input" ) ) {
  11473. // dataPriv.set( el, "click", ... )
  11474. leverageNative( el, "click", returnTrue );
  11475. }
  11476. // Return false to allow normal processing in the caller
  11477. return false;
  11478. },
  11479. trigger: function( data ) {
  11480. // For mutual compressibility with _default, replace `this` access with a local var.
  11481. // `|| data` is dead code meant only to preserve the variable through minification.
  11482. var el = this || data;
  11483. // Force setup before triggering a click
  11484. if ( rcheckableType.test( el.type ) &&
  11485. el.click && nodeName( el, "input" ) ) {
  11486. leverageNative( el, "click" );
  11487. }
  11488. // Return non-false to allow normal event-path propagation
  11489. return true;
  11490. },
  11491. // For cross-browser consistency, suppress native .click() on links
  11492. // Also prevent it if we're currently inside a leveraged native-event stack
  11493. _default: function( event ) {
  11494. var target = event.target;
  11495. return rcheckableType.test( target.type ) &&
  11496. target.click && nodeName( target, "input" ) &&
  11497. dataPriv.get( target, "click" ) ||
  11498. nodeName( target, "a" );
  11499. }
  11500. },
  11501. beforeunload: {
  11502. postDispatch: function( event ) {
  11503. // Support: Firefox 20+
  11504. // Firefox doesn't alert if the returnValue field is not set.
  11505. if ( event.result !== undefined && event.originalEvent ) {
  11506. event.originalEvent.returnValue = event.result;
  11507. }
  11508. }
  11509. }
  11510. }
  11511. };
  11512. // Ensure the presence of an event listener that handles manually-triggered
  11513. // synthetic events by interrupting progress until reinvoked in response to
  11514. // *native* events that it fires directly, ensuring that state changes have
  11515. // already occurred before other listeners are invoked.
  11516. function leverageNative( el, type, expectSync ) {
  11517. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  11518. if ( !expectSync ) {
  11519. if ( dataPriv.get( el, type ) === undefined ) {
  11520. jQuery.event.add( el, type, returnTrue );
  11521. }
  11522. return;
  11523. }
  11524. // Register the controller as a special universal handler for all event namespaces
  11525. dataPriv.set( el, type, false );
  11526. jQuery.event.add( el, type, {
  11527. namespace: false,
  11528. handler: function( event ) {
  11529. var notAsync, result,
  11530. saved = dataPriv.get( this, type );
  11531. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  11532. // Interrupt processing of the outer synthetic .trigger()ed event
  11533. // Saved data should be false in such cases, but might be a leftover capture object
  11534. // from an async native handler (gh-4350)
  11535. if ( !saved.length ) {
  11536. // Store arguments for use when handling the inner native event
  11537. // There will always be at least one argument (an event object), so this array
  11538. // will not be confused with a leftover capture object.
  11539. saved = slice.call( arguments );
  11540. dataPriv.set( this, type, saved );
  11541. // Trigger the native event and capture its result
  11542. // Support: IE <=9 - 11+
  11543. // focus() and blur() are asynchronous
  11544. notAsync = expectSync( this, type );
  11545. this[ type ]();
  11546. result = dataPriv.get( this, type );
  11547. if ( saved !== result || notAsync ) {
  11548. dataPriv.set( this, type, false );
  11549. } else {
  11550. result = {};
  11551. }
  11552. if ( saved !== result ) {
  11553. // Cancel the outer synthetic event
  11554. event.stopImmediatePropagation();
  11555. event.preventDefault();
  11556. return result.value;
  11557. }
  11558. // If this is an inner synthetic event for an event with a bubbling surrogate
  11559. // (focus or blur), assume that the surrogate already propagated from triggering the
  11560. // native event and prevent that from happening again here.
  11561. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  11562. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  11563. // less bad than duplication.
  11564. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  11565. event.stopPropagation();
  11566. }
  11567. // If this is a native event triggered above, everything is now in order
  11568. // Fire an inner synthetic event with the original arguments
  11569. } else if ( saved.length ) {
  11570. // ...and capture the result
  11571. dataPriv.set( this, type, {
  11572. value: jQuery.event.trigger(
  11573. // Support: IE <=9 - 11+
  11574. // Extend with the prototype to reset the above stopImmediatePropagation()
  11575. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  11576. saved.slice( 1 ),
  11577. this
  11578. )
  11579. } );
  11580. // Abort handling of the native event
  11581. event.stopImmediatePropagation();
  11582. }
  11583. }
  11584. } );
  11585. }
  11586. jQuery.removeEvent = function( elem, type, handle ) {
  11587. // This "if" is needed for plain objects
  11588. if ( elem.removeEventListener ) {
  11589. elem.removeEventListener( type, handle );
  11590. }
  11591. };
  11592. jQuery.Event = function( src, props ) {
  11593. // Allow instantiation without the 'new' keyword
  11594. if ( !( this instanceof jQuery.Event ) ) {
  11595. return new jQuery.Event( src, props );
  11596. }
  11597. // Event object
  11598. if ( src && src.type ) {
  11599. this.originalEvent = src;
  11600. this.type = src.type;
  11601. // Events bubbling up the document may have been marked as prevented
  11602. // by a handler lower down the tree; reflect the correct value.
  11603. this.isDefaultPrevented = src.defaultPrevented ||
  11604. src.defaultPrevented === undefined &&
  11605. // Support: Android <=2.3 only
  11606. src.returnValue === false ?
  11607. returnTrue :
  11608. returnFalse;
  11609. // Create target properties
  11610. // Support: Safari <=6 - 7 only
  11611. // Target should not be a text node (#504, #13143)
  11612. this.target = ( src.target && src.target.nodeType === 3 ) ?
  11613. src.target.parentNode :
  11614. src.target;
  11615. this.currentTarget = src.currentTarget;
  11616. this.relatedTarget = src.relatedTarget;
  11617. // Event type
  11618. } else {
  11619. this.type = src;
  11620. }
  11621. // Put explicitly provided properties onto the event object
  11622. if ( props ) {
  11623. jQuery.extend( this, props );
  11624. }
  11625. // Create a timestamp if incoming event doesn't have one
  11626. this.timeStamp = src && src.timeStamp || Date.now();
  11627. // Mark it as fixed
  11628. this[ jQuery.expando ] = true;
  11629. };
  11630. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  11631. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  11632. jQuery.Event.prototype = {
  11633. constructor: jQuery.Event,
  11634. isDefaultPrevented: returnFalse,
  11635. isPropagationStopped: returnFalse,
  11636. isImmediatePropagationStopped: returnFalse,
  11637. isSimulated: false,
  11638. preventDefault: function() {
  11639. var e = this.originalEvent;
  11640. this.isDefaultPrevented = returnTrue;
  11641. if ( e && !this.isSimulated ) {
  11642. e.preventDefault();
  11643. }
  11644. },
  11645. stopPropagation: function() {
  11646. var e = this.originalEvent;
  11647. this.isPropagationStopped = returnTrue;
  11648. if ( e && !this.isSimulated ) {
  11649. e.stopPropagation();
  11650. }
  11651. },
  11652. stopImmediatePropagation: function() {
  11653. var e = this.originalEvent;
  11654. this.isImmediatePropagationStopped = returnTrue;
  11655. if ( e && !this.isSimulated ) {
  11656. e.stopImmediatePropagation();
  11657. }
  11658. this.stopPropagation();
  11659. }
  11660. };
  11661. // Includes all common event props including KeyEvent and MouseEvent specific props
  11662. jQuery.each( {
  11663. altKey: true,
  11664. bubbles: true,
  11665. cancelable: true,
  11666. changedTouches: true,
  11667. ctrlKey: true,
  11668. detail: true,
  11669. eventPhase: true,
  11670. metaKey: true,
  11671. pageX: true,
  11672. pageY: true,
  11673. shiftKey: true,
  11674. view: true,
  11675. "char": true,
  11676. code: true,
  11677. charCode: true,
  11678. key: true,
  11679. keyCode: true,
  11680. button: true,
  11681. buttons: true,
  11682. clientX: true,
  11683. clientY: true,
  11684. offsetX: true,
  11685. offsetY: true,
  11686. pointerId: true,
  11687. pointerType: true,
  11688. screenX: true,
  11689. screenY: true,
  11690. targetTouches: true,
  11691. toElement: true,
  11692. touches: true,
  11693. which: function( event ) {
  11694. var button = event.button;
  11695. // Add which for key events
  11696. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  11697. return event.charCode != null ? event.charCode : event.keyCode;
  11698. }
  11699. // Add which for click: 1 === left; 2 === middle; 3 === right
  11700. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  11701. if ( button & 1 ) {
  11702. return 1;
  11703. }
  11704. if ( button & 2 ) {
  11705. return 3;
  11706. }
  11707. if ( button & 4 ) {
  11708. return 2;
  11709. }
  11710. return 0;
  11711. }
  11712. return event.which;
  11713. }
  11714. }, jQuery.event.addProp );
  11715. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  11716. jQuery.event.special[ type ] = {
  11717. // Utilize native event if possible so blur/focus sequence is correct
  11718. setup: function() {
  11719. // Claim the first handler
  11720. // dataPriv.set( this, "focus", ... )
  11721. // dataPriv.set( this, "blur", ... )
  11722. leverageNative( this, type, expectSync );
  11723. // Return false to allow normal processing in the caller
  11724. return false;
  11725. },
  11726. trigger: function() {
  11727. // Force setup before trigger
  11728. leverageNative( this, type );
  11729. // Return non-false to allow normal event-path propagation
  11730. return true;
  11731. },
  11732. delegateType: delegateType
  11733. };
  11734. } );
  11735. // Create mouseenter/leave events using mouseover/out and event-time checks
  11736. // so that event delegation works in jQuery.
  11737. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  11738. //
  11739. // Support: Safari 7 only
  11740. // Safari sends mouseenter too often; see:
  11741. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  11742. // for the description of the bug (it existed in older Chrome versions as well).
  11743. jQuery.each( {
  11744. mouseenter: "mouseover",
  11745. mouseleave: "mouseout",
  11746. pointerenter: "pointerover",
  11747. pointerleave: "pointerout"
  11748. }, function( orig, fix ) {
  11749. jQuery.event.special[ orig ] = {
  11750. delegateType: fix,
  11751. bindType: fix,
  11752. handle: function( event ) {
  11753. var ret,
  11754. target = this,
  11755. related = event.relatedTarget,
  11756. handleObj = event.handleObj;
  11757. // For mouseenter/leave call the handler if related is outside the target.
  11758. // NB: No relatedTarget if the mouse left/entered the browser window
  11759. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  11760. event.type = handleObj.origType;
  11761. ret = handleObj.handler.apply( this, arguments );
  11762. event.type = fix;
  11763. }
  11764. return ret;
  11765. }
  11766. };
  11767. } );
  11768. jQuery.fn.extend( {
  11769. on: function( types, selector, data, fn ) {
  11770. return on( this, types, selector, data, fn );
  11771. },
  11772. one: function( types, selector, data, fn ) {
  11773. return on( this, types, selector, data, fn, 1 );
  11774. },
  11775. off: function( types, selector, fn ) {
  11776. var handleObj, type;
  11777. if ( types && types.preventDefault && types.handleObj ) {
  11778. // ( event ) dispatched jQuery.Event
  11779. handleObj = types.handleObj;
  11780. jQuery( types.delegateTarget ).off(
  11781. handleObj.namespace ?
  11782. handleObj.origType + "." + handleObj.namespace :
  11783. handleObj.origType,
  11784. handleObj.selector,
  11785. handleObj.handler
  11786. );
  11787. return this;
  11788. }
  11789. if ( typeof types === "object" ) {
  11790. // ( types-object [, selector] )
  11791. for ( type in types ) {
  11792. this.off( type, selector, types[ type ] );
  11793. }
  11794. return this;
  11795. }
  11796. if ( selector === false || typeof selector === "function" ) {
  11797. // ( types [, fn] )
  11798. fn = selector;
  11799. selector = undefined;
  11800. }
  11801. if ( fn === false ) {
  11802. fn = returnFalse;
  11803. }
  11804. return this.each( function() {
  11805. jQuery.event.remove( this, types, fn, selector );
  11806. } );
  11807. }
  11808. } );
  11809. var
  11810. /* eslint-disable max-len */
  11811. // See https://github.com/eslint/eslint/issues/3229
  11812. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  11813. /* eslint-enable */
  11814. // Support: IE <=10 - 11, Edge 12 - 13 only
  11815. // In IE/Edge using regex groups here causes severe slowdowns.
  11816. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  11817. rnoInnerhtml = /<script|<style|<link/i,
  11818. // checked="checked" or checked
  11819. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  11820. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  11821. // Prefer a tbody over its parent table for containing new rows
  11822. function manipulationTarget( elem, content ) {
  11823. if ( nodeName( elem, "table" ) &&
  11824. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  11825. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  11826. }
  11827. return elem;
  11828. }
  11829. // Replace/restore the type attribute of script elements for safe DOM manipulation
  11830. function disableScript( elem ) {
  11831. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  11832. return elem;
  11833. }
  11834. function restoreScript( elem ) {
  11835. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  11836. elem.type = elem.type.slice( 5 );
  11837. } else {
  11838. elem.removeAttribute( "type" );
  11839. }
  11840. return elem;
  11841. }
  11842. function cloneCopyEvent( src, dest ) {
  11843. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  11844. if ( dest.nodeType !== 1 ) {
  11845. return;
  11846. }
  11847. // 1. Copy private data: events, handlers, etc.
  11848. if ( dataPriv.hasData( src ) ) {
  11849. pdataOld = dataPriv.access( src );
  11850. pdataCur = dataPriv.set( dest, pdataOld );
  11851. events = pdataOld.events;
  11852. if ( events ) {
  11853. delete pdataCur.handle;
  11854. pdataCur.events = {};
  11855. for ( type in events ) {
  11856. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  11857. jQuery.event.add( dest, type, events[ type ][ i ] );
  11858. }
  11859. }
  11860. }
  11861. }
  11862. // 2. Copy user data
  11863. if ( dataUser.hasData( src ) ) {
  11864. udataOld = dataUser.access( src );
  11865. udataCur = jQuery.extend( {}, udataOld );
  11866. dataUser.set( dest, udataCur );
  11867. }
  11868. }
  11869. // Fix IE bugs, see support tests
  11870. function fixInput( src, dest ) {
  11871. var nodeName = dest.nodeName.toLowerCase();
  11872. // Fails to persist the checked state of a cloned checkbox or radio button.
  11873. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  11874. dest.checked = src.checked;
  11875. // Fails to return the selected option to the default selected state when cloning options
  11876. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  11877. dest.defaultValue = src.defaultValue;
  11878. }
  11879. }
  11880. function domManip( collection, args, callback, ignored ) {
  11881. // Flatten any nested arrays
  11882. args = concat.apply( [], args );
  11883. var fragment, first, scripts, hasScripts, node, doc,
  11884. i = 0,
  11885. l = collection.length,
  11886. iNoClone = l - 1,
  11887. value = args[ 0 ],
  11888. valueIsFunction = isFunction( value );
  11889. // We can't cloneNode fragments that contain checked, in WebKit
  11890. if ( valueIsFunction ||
  11891. ( l > 1 && typeof value === "string" &&
  11892. !support.checkClone && rchecked.test( value ) ) ) {
  11893. return collection.each( function( index ) {
  11894. var self = collection.eq( index );
  11895. if ( valueIsFunction ) {
  11896. args[ 0 ] = value.call( this, index, self.html() );
  11897. }
  11898. domManip( self, args, callback, ignored );
  11899. } );
  11900. }
  11901. if ( l ) {
  11902. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  11903. first = fragment.firstChild;
  11904. if ( fragment.childNodes.length === 1 ) {
  11905. fragment = first;
  11906. }
  11907. // Require either new content or an interest in ignored elements to invoke the callback
  11908. if ( first || ignored ) {
  11909. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  11910. hasScripts = scripts.length;
  11911. // Use the original fragment for the last item
  11912. // instead of the first because it can end up
  11913. // being emptied incorrectly in certain situations (#8070).
  11914. for ( ; i < l; i++ ) {
  11915. node = fragment;
  11916. if ( i !== iNoClone ) {
  11917. node = jQuery.clone( node, true, true );
  11918. // Keep references to cloned scripts for later restoration
  11919. if ( hasScripts ) {
  11920. // Support: Android <=4.0 only, PhantomJS 1 only
  11921. // push.apply(_, arraylike) throws on ancient WebKit
  11922. jQuery.merge( scripts, getAll( node, "script" ) );
  11923. }
  11924. }
  11925. callback.call( collection[ i ], node, i );
  11926. }
  11927. if ( hasScripts ) {
  11928. doc = scripts[ scripts.length - 1 ].ownerDocument;
  11929. // Reenable scripts
  11930. jQuery.map( scripts, restoreScript );
  11931. // Evaluate executable scripts on first document insertion
  11932. for ( i = 0; i < hasScripts; i++ ) {
  11933. node = scripts[ i ];
  11934. if ( rscriptType.test( node.type || "" ) &&
  11935. !dataPriv.access( node, "globalEval" ) &&
  11936. jQuery.contains( doc, node ) ) {
  11937. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  11938. // Optional AJAX dependency, but won't run scripts if not present
  11939. if ( jQuery._evalUrl && !node.noModule ) {
  11940. jQuery._evalUrl( node.src, {
  11941. nonce: node.nonce || node.getAttribute( "nonce" )
  11942. } );
  11943. }
  11944. } else {
  11945. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  11946. }
  11947. }
  11948. }
  11949. }
  11950. }
  11951. }
  11952. return collection;
  11953. }
  11954. function remove( elem, selector, keepData ) {
  11955. var node,
  11956. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  11957. i = 0;
  11958. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  11959. if ( !keepData && node.nodeType === 1 ) {
  11960. jQuery.cleanData( getAll( node ) );
  11961. }
  11962. if ( node.parentNode ) {
  11963. if ( keepData && isAttached( node ) ) {
  11964. setGlobalEval( getAll( node, "script" ) );
  11965. }
  11966. node.parentNode.removeChild( node );
  11967. }
  11968. }
  11969. return elem;
  11970. }
  11971. jQuery.extend( {
  11972. htmlPrefilter: function( html ) {
  11973. return html.replace( rxhtmlTag, "<$1></$2>" );
  11974. },
  11975. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  11976. var i, l, srcElements, destElements,
  11977. clone = elem.cloneNode( true ),
  11978. inPage = isAttached( elem );
  11979. // Fix IE cloning issues
  11980. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  11981. !jQuery.isXMLDoc( elem ) ) {
  11982. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  11983. destElements = getAll( clone );
  11984. srcElements = getAll( elem );
  11985. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  11986. fixInput( srcElements[ i ], destElements[ i ] );
  11987. }
  11988. }
  11989. // Copy the events from the original to the clone
  11990. if ( dataAndEvents ) {
  11991. if ( deepDataAndEvents ) {
  11992. srcElements = srcElements || getAll( elem );
  11993. destElements = destElements || getAll( clone );
  11994. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  11995. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  11996. }
  11997. } else {
  11998. cloneCopyEvent( elem, clone );
  11999. }
  12000. }
  12001. // Preserve script evaluation history
  12002. destElements = getAll( clone, "script" );
  12003. if ( destElements.length > 0 ) {
  12004. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12005. }
  12006. // Return the cloned set
  12007. return clone;
  12008. },
  12009. cleanData: function( elems ) {
  12010. var data, elem, type,
  12011. special = jQuery.event.special,
  12012. i = 0;
  12013. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12014. if ( acceptData( elem ) ) {
  12015. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12016. if ( data.events ) {
  12017. for ( type in data.events ) {
  12018. if ( special[ type ] ) {
  12019. jQuery.event.remove( elem, type );
  12020. // This is a shortcut to avoid jQuery.event.remove's overhead
  12021. } else {
  12022. jQuery.removeEvent( elem, type, data.handle );
  12023. }
  12024. }
  12025. }
  12026. // Support: Chrome <=35 - 45+
  12027. // Assign undefined instead of using delete, see Data#remove
  12028. elem[ dataPriv.expando ] = undefined;
  12029. }
  12030. if ( elem[ dataUser.expando ] ) {
  12031. // Support: Chrome <=35 - 45+
  12032. // Assign undefined instead of using delete, see Data#remove
  12033. elem[ dataUser.expando ] = undefined;
  12034. }
  12035. }
  12036. }
  12037. }
  12038. } );
  12039. jQuery.fn.extend( {
  12040. detach: function( selector ) {
  12041. return remove( this, selector, true );
  12042. },
  12043. remove: function( selector ) {
  12044. return remove( this, selector );
  12045. },
  12046. text: function( value ) {
  12047. return access( this, function( value ) {
  12048. return value === undefined ?
  12049. jQuery.text( this ) :
  12050. this.empty().each( function() {
  12051. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12052. this.textContent = value;
  12053. }
  12054. } );
  12055. }, null, value, arguments.length );
  12056. },
  12057. append: function() {
  12058. return domManip( this, arguments, function( elem ) {
  12059. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12060. var target = manipulationTarget( this, elem );
  12061. target.appendChild( elem );
  12062. }
  12063. } );
  12064. },
  12065. prepend: function() {
  12066. return domManip( this, arguments, function( elem ) {
  12067. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12068. var target = manipulationTarget( this, elem );
  12069. target.insertBefore( elem, target.firstChild );
  12070. }
  12071. } );
  12072. },
  12073. before: function() {
  12074. return domManip( this, arguments, function( elem ) {
  12075. if ( this.parentNode ) {
  12076. this.parentNode.insertBefore( elem, this );
  12077. }
  12078. } );
  12079. },
  12080. after: function() {
  12081. return domManip( this, arguments, function( elem ) {
  12082. if ( this.parentNode ) {
  12083. this.parentNode.insertBefore( elem, this.nextSibling );
  12084. }
  12085. } );
  12086. },
  12087. empty: function() {
  12088. var elem,
  12089. i = 0;
  12090. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  12091. if ( elem.nodeType === 1 ) {
  12092. // Prevent memory leaks
  12093. jQuery.cleanData( getAll( elem, false ) );
  12094. // Remove any remaining nodes
  12095. elem.textContent = "";
  12096. }
  12097. }
  12098. return this;
  12099. },
  12100. clone: function( dataAndEvents, deepDataAndEvents ) {
  12101. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  12102. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  12103. return this.map( function() {
  12104. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  12105. } );
  12106. },
  12107. html: function( value ) {
  12108. return access( this, function( value ) {
  12109. var elem = this[ 0 ] || {},
  12110. i = 0,
  12111. l = this.length;
  12112. if ( value === undefined && elem.nodeType === 1 ) {
  12113. return elem.innerHTML;
  12114. }
  12115. // See if we can take a shortcut and just use innerHTML
  12116. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  12117. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  12118. value = jQuery.htmlPrefilter( value );
  12119. try {
  12120. for ( ; i < l; i++ ) {
  12121. elem = this[ i ] || {};
  12122. // Remove element nodes and prevent memory leaks
  12123. if ( elem.nodeType === 1 ) {
  12124. jQuery.cleanData( getAll( elem, false ) );
  12125. elem.innerHTML = value;
  12126. }
  12127. }
  12128. elem = 0;
  12129. // If using innerHTML throws an exception, use the fallback method
  12130. } catch ( e ) {}
  12131. }
  12132. if ( elem ) {
  12133. this.empty().append( value );
  12134. }
  12135. }, null, value, arguments.length );
  12136. },
  12137. replaceWith: function() {
  12138. var ignored = [];
  12139. // Make the changes, replacing each non-ignored context element with the new content
  12140. return domManip( this, arguments, function( elem ) {
  12141. var parent = this.parentNode;
  12142. if ( jQuery.inArray( this, ignored ) < 0 ) {
  12143. jQuery.cleanData( getAll( this ) );
  12144. if ( parent ) {
  12145. parent.replaceChild( elem, this );
  12146. }
  12147. }
  12148. // Force callback invocation
  12149. }, ignored );
  12150. }
  12151. } );
  12152. jQuery.each( {
  12153. appendTo: "append",
  12154. prependTo: "prepend",
  12155. insertBefore: "before",
  12156. insertAfter: "after",
  12157. replaceAll: "replaceWith"
  12158. }, function( name, original ) {
  12159. jQuery.fn[ name ] = function( selector ) {
  12160. var elems,
  12161. ret = [],
  12162. insert = jQuery( selector ),
  12163. last = insert.length - 1,
  12164. i = 0;
  12165. for ( ; i <= last; i++ ) {
  12166. elems = i === last ? this : this.clone( true );
  12167. jQuery( insert[ i ] )[ original ]( elems );
  12168. // Support: Android <=4.0 only, PhantomJS 1 only
  12169. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  12170. push.apply( ret, elems.get() );
  12171. }
  12172. return this.pushStack( ret );
  12173. };
  12174. } );
  12175. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  12176. var getStyles = function( elem ) {
  12177. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  12178. // IE throws on elements created in popups
  12179. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  12180. var view = elem.ownerDocument.defaultView;
  12181. if ( !view || !view.opener ) {
  12182. view = window;
  12183. }
  12184. return view.getComputedStyle( elem );
  12185. };
  12186. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  12187. ( function() {
  12188. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  12189. // so they're executed at the same time to save the second computation.
  12190. function computeStyleTests() {
  12191. // This is a singleton, we need to execute it only once
  12192. if ( !div ) {
  12193. return;
  12194. }
  12195. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  12196. "margin-top:1px;padding:0;border:0";
  12197. div.style.cssText =
  12198. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  12199. "margin:auto;border:1px;padding:1px;" +
  12200. "width:60%;top:1%";
  12201. documentElement.appendChild( container ).appendChild( div );
  12202. var divStyle = window.getComputedStyle( div );
  12203. pixelPositionVal = divStyle.top !== "1%";
  12204. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  12205. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  12206. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  12207. // Some styles come back with percentage values, even though they shouldn't
  12208. div.style.right = "60%";
  12209. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  12210. // Support: IE 9 - 11 only
  12211. // Detect misreporting of content dimensions for box-sizing:border-box elements
  12212. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  12213. // Support: IE 9 only
  12214. // Detect overflow:scroll screwiness (gh-3699)
  12215. // Support: Chrome <=64
  12216. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  12217. div.style.position = "absolute";
  12218. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  12219. documentElement.removeChild( container );
  12220. // Nullify the div so it wouldn't be stored in the memory and
  12221. // it will also be a sign that checks already performed
  12222. div = null;
  12223. }
  12224. function roundPixelMeasures( measure ) {
  12225. return Math.round( parseFloat( measure ) );
  12226. }
  12227. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  12228. reliableMarginLeftVal,
  12229. container = document.createElement( "div" ),
  12230. div = document.createElement( "div" );
  12231. // Finish early in limited (non-browser) environments
  12232. if ( !div.style ) {
  12233. return;
  12234. }
  12235. // Support: IE <=9 - 11 only
  12236. // Style of cloned element affects source element cloned (#8908)
  12237. div.style.backgroundClip = "content-box";
  12238. div.cloneNode( true ).style.backgroundClip = "";
  12239. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  12240. jQuery.extend( support, {
  12241. boxSizingReliable: function() {
  12242. computeStyleTests();
  12243. return boxSizingReliableVal;
  12244. },
  12245. pixelBoxStyles: function() {
  12246. computeStyleTests();
  12247. return pixelBoxStylesVal;
  12248. },
  12249. pixelPosition: function() {
  12250. computeStyleTests();
  12251. return pixelPositionVal;
  12252. },
  12253. reliableMarginLeft: function() {
  12254. computeStyleTests();
  12255. return reliableMarginLeftVal;
  12256. },
  12257. scrollboxSize: function() {
  12258. computeStyleTests();
  12259. return scrollboxSizeVal;
  12260. }
  12261. } );
  12262. } )();
  12263. function curCSS( elem, name, computed ) {
  12264. var width, minWidth, maxWidth, ret,
  12265. // Support: Firefox 51+
  12266. // Retrieving style before computed somehow
  12267. // fixes an issue with getting wrong values
  12268. // on detached elements
  12269. style = elem.style;
  12270. computed = computed || getStyles( elem );
  12271. // getPropertyValue is needed for:
  12272. // .css('filter') (IE 9 only, #12537)
  12273. // .css('--customProperty) (#3144)
  12274. if ( computed ) {
  12275. ret = computed.getPropertyValue( name ) || computed[ name ];
  12276. if ( ret === "" && !isAttached( elem ) ) {
  12277. ret = jQuery.style( elem, name );
  12278. }
  12279. // A tribute to the "awesome hack by Dean Edwards"
  12280. // Android Browser returns percentage for some values,
  12281. // but width seems to be reliably pixels.
  12282. // This is against the CSSOM draft spec:
  12283. // https://drafts.csswg.org/cssom/#resolved-values
  12284. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  12285. // Remember the original values
  12286. width = style.width;
  12287. minWidth = style.minWidth;
  12288. maxWidth = style.maxWidth;
  12289. // Put in the new values to get a computed value out
  12290. style.minWidth = style.maxWidth = style.width = ret;
  12291. ret = computed.width;
  12292. // Revert the changed values
  12293. style.width = width;
  12294. style.minWidth = minWidth;
  12295. style.maxWidth = maxWidth;
  12296. }
  12297. }
  12298. return ret !== undefined ?
  12299. // Support: IE <=9 - 11 only
  12300. // IE returns zIndex value as an integer.
  12301. ret + "" :
  12302. ret;
  12303. }
  12304. function addGetHookIf( conditionFn, hookFn ) {
  12305. // Define the hook, we'll check on the first run if it's really needed.
  12306. return {
  12307. get: function() {
  12308. if ( conditionFn() ) {
  12309. // Hook not needed (or it's not possible to use it due
  12310. // to missing dependency), remove it.
  12311. delete this.get;
  12312. return;
  12313. }
  12314. // Hook needed; redefine it so that the support test is not executed again.
  12315. return ( this.get = hookFn ).apply( this, arguments );
  12316. }
  12317. };
  12318. }
  12319. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  12320. emptyStyle = document.createElement( "div" ).style,
  12321. vendorProps = {};
  12322. // Return a vendor-prefixed property or undefined
  12323. function vendorPropName( name ) {
  12324. // Check for vendor prefixed names
  12325. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  12326. i = cssPrefixes.length;
  12327. while ( i-- ) {
  12328. name = cssPrefixes[ i ] + capName;
  12329. if ( name in emptyStyle ) {
  12330. return name;
  12331. }
  12332. }
  12333. }
  12334. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  12335. function finalPropName( name ) {
  12336. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  12337. if ( final ) {
  12338. return final;
  12339. }
  12340. if ( name in emptyStyle ) {
  12341. return name;
  12342. }
  12343. return vendorProps[ name ] = vendorPropName( name ) || name;
  12344. }
  12345. var
  12346. // Swappable if display is none or starts with table
  12347. // except "table", "table-cell", or "table-caption"
  12348. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  12349. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  12350. rcustomProp = /^--/,
  12351. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  12352. cssNormalTransform = {
  12353. letterSpacing: "0",
  12354. fontWeight: "400"
  12355. };
  12356. function setPositiveNumber( elem, value, subtract ) {
  12357. // Any relative (+/-) values have already been
  12358. // normalized at this point
  12359. var matches = rcssNum.exec( value );
  12360. return matches ?
  12361. // Guard against undefined "subtract", e.g., when used as in cssHooks
  12362. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  12363. value;
  12364. }
  12365. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  12366. var i = dimension === "width" ? 1 : 0,
  12367. extra = 0,
  12368. delta = 0;
  12369. // Adjustment may not be necessary
  12370. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  12371. return 0;
  12372. }
  12373. for ( ; i < 4; i += 2 ) {
  12374. // Both box models exclude margin
  12375. if ( box === "margin" ) {
  12376. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  12377. }
  12378. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  12379. if ( !isBorderBox ) {
  12380. // Add padding
  12381. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12382. // For "border" or "margin", add border
  12383. if ( box !== "padding" ) {
  12384. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12385. // But still keep track of it otherwise
  12386. } else {
  12387. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12388. }
  12389. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  12390. // "padding" or "margin"
  12391. } else {
  12392. // For "content", subtract padding
  12393. if ( box === "content" ) {
  12394. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  12395. }
  12396. // For "content" or "padding", subtract border
  12397. if ( box !== "margin" ) {
  12398. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  12399. }
  12400. }
  12401. }
  12402. // Account for positive content-box scroll gutter when requested by providing computedVal
  12403. if ( !isBorderBox && computedVal >= 0 ) {
  12404. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  12405. // Assuming integer scroll gutter, subtract the rest and round down
  12406. delta += Math.max( 0, Math.ceil(
  12407. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12408. computedVal -
  12409. delta -
  12410. extra -
  12411. 0.5
  12412. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  12413. // Use an explicit zero to avoid NaN (gh-3964)
  12414. ) ) || 0;
  12415. }
  12416. return delta;
  12417. }
  12418. function getWidthOrHeight( elem, dimension, extra ) {
  12419. // Start with computed style
  12420. var styles = getStyles( elem ),
  12421. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  12422. // Fake content-box until we know it's needed to know the true value.
  12423. boxSizingNeeded = !support.boxSizingReliable() || extra,
  12424. isBorderBox = boxSizingNeeded &&
  12425. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12426. valueIsBorderBox = isBorderBox,
  12427. val = curCSS( elem, dimension, styles ),
  12428. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  12429. // Support: Firefox <=54
  12430. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  12431. if ( rnumnonpx.test( val ) ) {
  12432. if ( !extra ) {
  12433. return val;
  12434. }
  12435. val = "auto";
  12436. }
  12437. // Fall back to offsetWidth/offsetHeight when value is "auto"
  12438. // This happens for inline elements with no explicit setting (gh-3571)
  12439. // Support: Android <=4.1 - 4.3 only
  12440. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  12441. // Support: IE 9-11 only
  12442. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  12443. // We use getClientRects() to check for hidden/disconnected.
  12444. // In those cases, the computed value can be trusted to be border-box
  12445. if ( ( !support.boxSizingReliable() && isBorderBox ||
  12446. val === "auto" ||
  12447. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  12448. elem.getClientRects().length ) {
  12449. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  12450. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  12451. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  12452. // retrieved value as a content box dimension.
  12453. valueIsBorderBox = offsetProp in elem;
  12454. if ( valueIsBorderBox ) {
  12455. val = elem[ offsetProp ];
  12456. }
  12457. }
  12458. // Normalize "" and auto
  12459. val = parseFloat( val ) || 0;
  12460. // Adjust for the element's box model
  12461. return ( val +
  12462. boxModelAdjustment(
  12463. elem,
  12464. dimension,
  12465. extra || ( isBorderBox ? "border" : "content" ),
  12466. valueIsBorderBox,
  12467. styles,
  12468. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  12469. val
  12470. )
  12471. ) + "px";
  12472. }
  12473. jQuery.extend( {
  12474. // Add in style property hooks for overriding the default
  12475. // behavior of getting and setting a style property
  12476. cssHooks: {
  12477. opacity: {
  12478. get: function( elem, computed ) {
  12479. if ( computed ) {
  12480. // We should always get a number back from opacity
  12481. var ret = curCSS( elem, "opacity" );
  12482. return ret === "" ? "1" : ret;
  12483. }
  12484. }
  12485. }
  12486. },
  12487. // Don't automatically add "px" to these possibly-unitless properties
  12488. cssNumber: {
  12489. "animationIterationCount": true,
  12490. "columnCount": true,
  12491. "fillOpacity": true,
  12492. "flexGrow": true,
  12493. "flexShrink": true,
  12494. "fontWeight": true,
  12495. "gridArea": true,
  12496. "gridColumn": true,
  12497. "gridColumnEnd": true,
  12498. "gridColumnStart": true,
  12499. "gridRow": true,
  12500. "gridRowEnd": true,
  12501. "gridRowStart": true,
  12502. "lineHeight": true,
  12503. "opacity": true,
  12504. "order": true,
  12505. "orphans": true,
  12506. "widows": true,
  12507. "zIndex": true,
  12508. "zoom": true
  12509. },
  12510. // Add in properties whose names you wish to fix before
  12511. // setting or getting the value
  12512. cssProps: {},
  12513. // Get and set the style property on a DOM Node
  12514. style: function( elem, name, value, extra ) {
  12515. // Don't set styles on text and comment nodes
  12516. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  12517. return;
  12518. }
  12519. // Make sure that we're working with the right name
  12520. var ret, type, hooks,
  12521. origName = camelCase( name ),
  12522. isCustomProp = rcustomProp.test( name ),
  12523. style = elem.style;
  12524. // Make sure that we're working with the right name. We don't
  12525. // want to query the value if it is a CSS custom property
  12526. // since they are user-defined.
  12527. if ( !isCustomProp ) {
  12528. name = finalPropName( origName );
  12529. }
  12530. // Gets hook for the prefixed version, then unprefixed version
  12531. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12532. // Check if we're setting a value
  12533. if ( value !== undefined ) {
  12534. type = typeof value;
  12535. // Convert "+=" or "-=" to relative numbers (#7345)
  12536. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  12537. value = adjustCSS( elem, name, ret );
  12538. // Fixes bug #9237
  12539. type = "number";
  12540. }
  12541. // Make sure that null and NaN values aren't set (#7116)
  12542. if ( value == null || value !== value ) {
  12543. return;
  12544. }
  12545. // If a number was passed in, add the unit (except for certain CSS properties)
  12546. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  12547. // "px" to a few hardcoded values.
  12548. if ( type === "number" && !isCustomProp ) {
  12549. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  12550. }
  12551. // background-* props affect original clone's values
  12552. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  12553. style[ name ] = "inherit";
  12554. }
  12555. // If a hook was provided, use that value, otherwise just set the specified value
  12556. if ( !hooks || !( "set" in hooks ) ||
  12557. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  12558. if ( isCustomProp ) {
  12559. style.setProperty( name, value );
  12560. } else {
  12561. style[ name ] = value;
  12562. }
  12563. }
  12564. } else {
  12565. // If a hook was provided get the non-computed value from there
  12566. if ( hooks && "get" in hooks &&
  12567. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  12568. return ret;
  12569. }
  12570. // Otherwise just get the value from the style object
  12571. return style[ name ];
  12572. }
  12573. },
  12574. css: function( elem, name, extra, styles ) {
  12575. var val, num, hooks,
  12576. origName = camelCase( name ),
  12577. isCustomProp = rcustomProp.test( name );
  12578. // Make sure that we're working with the right name. We don't
  12579. // want to modify the value if it is a CSS custom property
  12580. // since they are user-defined.
  12581. if ( !isCustomProp ) {
  12582. name = finalPropName( origName );
  12583. }
  12584. // Try prefixed name followed by the unprefixed name
  12585. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  12586. // If a hook was provided get the computed value from there
  12587. if ( hooks && "get" in hooks ) {
  12588. val = hooks.get( elem, true, extra );
  12589. }
  12590. // Otherwise, if a way to get the computed value exists, use that
  12591. if ( val === undefined ) {
  12592. val = curCSS( elem, name, styles );
  12593. }
  12594. // Convert "normal" to computed value
  12595. if ( val === "normal" && name in cssNormalTransform ) {
  12596. val = cssNormalTransform[ name ];
  12597. }
  12598. // Make numeric if forced or a qualifier was provided and val looks numeric
  12599. if ( extra === "" || extra ) {
  12600. num = parseFloat( val );
  12601. return extra === true || isFinite( num ) ? num || 0 : val;
  12602. }
  12603. return val;
  12604. }
  12605. } );
  12606. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  12607. jQuery.cssHooks[ dimension ] = {
  12608. get: function( elem, computed, extra ) {
  12609. if ( computed ) {
  12610. // Certain elements can have dimension info if we invisibly show them
  12611. // but it must have a current display style that would benefit
  12612. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  12613. // Support: Safari 8+
  12614. // Table columns in Safari have non-zero offsetWidth & zero
  12615. // getBoundingClientRect().width unless display is changed.
  12616. // Support: IE <=11 only
  12617. // Running getBoundingClientRect on a disconnected node
  12618. // in IE throws an error.
  12619. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  12620. swap( elem, cssShow, function() {
  12621. return getWidthOrHeight( elem, dimension, extra );
  12622. } ) :
  12623. getWidthOrHeight( elem, dimension, extra );
  12624. }
  12625. },
  12626. set: function( elem, value, extra ) {
  12627. var matches,
  12628. styles = getStyles( elem ),
  12629. // Only read styles.position if the test has a chance to fail
  12630. // to avoid forcing a reflow.
  12631. scrollboxSizeBuggy = !support.scrollboxSize() &&
  12632. styles.position === "absolute",
  12633. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  12634. boxSizingNeeded = scrollboxSizeBuggy || extra,
  12635. isBorderBox = boxSizingNeeded &&
  12636. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  12637. subtract = extra ?
  12638. boxModelAdjustment(
  12639. elem,
  12640. dimension,
  12641. extra,
  12642. isBorderBox,
  12643. styles
  12644. ) :
  12645. 0;
  12646. // Account for unreliable border-box dimensions by comparing offset* to computed and
  12647. // faking a content-box to get border and padding (gh-3699)
  12648. if ( isBorderBox && scrollboxSizeBuggy ) {
  12649. subtract -= Math.ceil(
  12650. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  12651. parseFloat( styles[ dimension ] ) -
  12652. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  12653. 0.5
  12654. );
  12655. }
  12656. // Convert to pixels if value adjustment is needed
  12657. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  12658. ( matches[ 3 ] || "px" ) !== "px" ) {
  12659. elem.style[ dimension ] = value;
  12660. value = jQuery.css( elem, dimension );
  12661. }
  12662. return setPositiveNumber( elem, value, subtract );
  12663. }
  12664. };
  12665. } );
  12666. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  12667. function( elem, computed ) {
  12668. if ( computed ) {
  12669. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  12670. elem.getBoundingClientRect().left -
  12671. swap( elem, { marginLeft: 0 }, function() {
  12672. return elem.getBoundingClientRect().left;
  12673. } )
  12674. ) + "px";
  12675. }
  12676. }
  12677. );
  12678. // These hooks are used by animate to expand properties
  12679. jQuery.each( {
  12680. margin: "",
  12681. padding: "",
  12682. border: "Width"
  12683. }, function( prefix, suffix ) {
  12684. jQuery.cssHooks[ prefix + suffix ] = {
  12685. expand: function( value ) {
  12686. var i = 0,
  12687. expanded = {},
  12688. // Assumes a single number if not a string
  12689. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  12690. for ( ; i < 4; i++ ) {
  12691. expanded[ prefix + cssExpand[ i ] + suffix ] =
  12692. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  12693. }
  12694. return expanded;
  12695. }
  12696. };
  12697. if ( prefix !== "margin" ) {
  12698. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  12699. }
  12700. } );
  12701. jQuery.fn.extend( {
  12702. css: function( name, value ) {
  12703. return access( this, function( elem, name, value ) {
  12704. var styles, len,
  12705. map = {},
  12706. i = 0;
  12707. if ( Array.isArray( name ) ) {
  12708. styles = getStyles( elem );
  12709. len = name.length;
  12710. for ( ; i < len; i++ ) {
  12711. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  12712. }
  12713. return map;
  12714. }
  12715. return value !== undefined ?
  12716. jQuery.style( elem, name, value ) :
  12717. jQuery.css( elem, name );
  12718. }, name, value, arguments.length > 1 );
  12719. }
  12720. } );
  12721. function Tween( elem, options, prop, end, easing ) {
  12722. return new Tween.prototype.init( elem, options, prop, end, easing );
  12723. }
  12724. jQuery.Tween = Tween;
  12725. Tween.prototype = {
  12726. constructor: Tween,
  12727. init: function( elem, options, prop, end, easing, unit ) {
  12728. this.elem = elem;
  12729. this.prop = prop;
  12730. this.easing = easing || jQuery.easing._default;
  12731. this.options = options;
  12732. this.start = this.now = this.cur();
  12733. this.end = end;
  12734. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  12735. },
  12736. cur: function() {
  12737. var hooks = Tween.propHooks[ this.prop ];
  12738. return hooks && hooks.get ?
  12739. hooks.get( this ) :
  12740. Tween.propHooks._default.get( this );
  12741. },
  12742. run: function( percent ) {
  12743. var eased,
  12744. hooks = Tween.propHooks[ this.prop ];
  12745. if ( this.options.duration ) {
  12746. this.pos = eased = jQuery.easing[ this.easing ](
  12747. percent, this.options.duration * percent, 0, 1, this.options.duration
  12748. );
  12749. } else {
  12750. this.pos = eased = percent;
  12751. }
  12752. this.now = ( this.end - this.start ) * eased + this.start;
  12753. if ( this.options.step ) {
  12754. this.options.step.call( this.elem, this.now, this );
  12755. }
  12756. if ( hooks && hooks.set ) {
  12757. hooks.set( this );
  12758. } else {
  12759. Tween.propHooks._default.set( this );
  12760. }
  12761. return this;
  12762. }
  12763. };
  12764. Tween.prototype.init.prototype = Tween.prototype;
  12765. Tween.propHooks = {
  12766. _default: {
  12767. get: function( tween ) {
  12768. var result;
  12769. // Use a property on the element directly when it is not a DOM element,
  12770. // or when there is no matching style property that exists.
  12771. if ( tween.elem.nodeType !== 1 ||
  12772. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  12773. return tween.elem[ tween.prop ];
  12774. }
  12775. // Passing an empty string as a 3rd parameter to .css will automatically
  12776. // attempt a parseFloat and fallback to a string if the parse fails.
  12777. // Simple values such as "10px" are parsed to Float;
  12778. // complex values such as "rotate(1rad)" are returned as-is.
  12779. result = jQuery.css( tween.elem, tween.prop, "" );
  12780. // Empty strings, null, undefined and "auto" are converted to 0.
  12781. return !result || result === "auto" ? 0 : result;
  12782. },
  12783. set: function( tween ) {
  12784. // Use step hook for back compat.
  12785. // Use cssHook if its there.
  12786. // Use .style if available and use plain properties where available.
  12787. if ( jQuery.fx.step[ tween.prop ] ) {
  12788. jQuery.fx.step[ tween.prop ]( tween );
  12789. } else if ( tween.elem.nodeType === 1 && (
  12790. jQuery.cssHooks[ tween.prop ] ||
  12791. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  12792. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  12793. } else {
  12794. tween.elem[ tween.prop ] = tween.now;
  12795. }
  12796. }
  12797. }
  12798. };
  12799. // Support: IE <=9 only
  12800. // Panic based approach to setting things on disconnected nodes
  12801. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  12802. set: function( tween ) {
  12803. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  12804. tween.elem[ tween.prop ] = tween.now;
  12805. }
  12806. }
  12807. };
  12808. jQuery.easing = {
  12809. linear: function( p ) {
  12810. return p;
  12811. },
  12812. swing: function( p ) {
  12813. return 0.5 - Math.cos( p * Math.PI ) / 2;
  12814. },
  12815. _default: "swing"
  12816. };
  12817. jQuery.fx = Tween.prototype.init;
  12818. // Back compat <1.8 extension point
  12819. jQuery.fx.step = {};
  12820. var
  12821. fxNow, inProgress,
  12822. rfxtypes = /^(?:toggle|show|hide)$/,
  12823. rrun = /queueHooks$/;
  12824. function schedule() {
  12825. if ( inProgress ) {
  12826. if ( document.hidden === false && window.requestAnimationFrame ) {
  12827. window.requestAnimationFrame( schedule );
  12828. } else {
  12829. window.setTimeout( schedule, jQuery.fx.interval );
  12830. }
  12831. jQuery.fx.tick();
  12832. }
  12833. }
  12834. // Animations created synchronously will run synchronously
  12835. function createFxNow() {
  12836. window.setTimeout( function() {
  12837. fxNow = undefined;
  12838. } );
  12839. return ( fxNow = Date.now() );
  12840. }
  12841. // Generate parameters to create a standard animation
  12842. function genFx( type, includeWidth ) {
  12843. var which,
  12844. i = 0,
  12845. attrs = { height: type };
  12846. // If we include width, step value is 1 to do all cssExpand values,
  12847. // otherwise step value is 2 to skip over Left and Right
  12848. includeWidth = includeWidth ? 1 : 0;
  12849. for ( ; i < 4; i += 2 - includeWidth ) {
  12850. which = cssExpand[ i ];
  12851. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  12852. }
  12853. if ( includeWidth ) {
  12854. attrs.opacity = attrs.width = type;
  12855. }
  12856. return attrs;
  12857. }
  12858. function createTween( value, prop, animation ) {
  12859. var tween,
  12860. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  12861. index = 0,
  12862. length = collection.length;
  12863. for ( ; index < length; index++ ) {
  12864. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  12865. // We're done with this property
  12866. return tween;
  12867. }
  12868. }
  12869. }
  12870. function defaultPrefilter( elem, props, opts ) {
  12871. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  12872. isBox = "width" in props || "height" in props,
  12873. anim = this,
  12874. orig = {},
  12875. style = elem.style,
  12876. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  12877. dataShow = dataPriv.get( elem, "fxshow" );
  12878. // Queue-skipping animations hijack the fx hooks
  12879. if ( !opts.queue ) {
  12880. hooks = jQuery._queueHooks( elem, "fx" );
  12881. if ( hooks.unqueued == null ) {
  12882. hooks.unqueued = 0;
  12883. oldfire = hooks.empty.fire;
  12884. hooks.empty.fire = function() {
  12885. if ( !hooks.unqueued ) {
  12886. oldfire();
  12887. }
  12888. };
  12889. }
  12890. hooks.unqueued++;
  12891. anim.always( function() {
  12892. // Ensure the complete handler is called before this completes
  12893. anim.always( function() {
  12894. hooks.unqueued--;
  12895. if ( !jQuery.queue( elem, "fx" ).length ) {
  12896. hooks.empty.fire();
  12897. }
  12898. } );
  12899. } );
  12900. }
  12901. // Detect show/hide animations
  12902. for ( prop in props ) {
  12903. value = props[ prop ];
  12904. if ( rfxtypes.test( value ) ) {
  12905. delete props[ prop ];
  12906. toggle = toggle || value === "toggle";
  12907. if ( value === ( hidden ? "hide" : "show" ) ) {
  12908. // Pretend to be hidden if this is a "show" and
  12909. // there is still data from a stopped show/hide
  12910. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  12911. hidden = true;
  12912. // Ignore all other no-op show/hide data
  12913. } else {
  12914. continue;
  12915. }
  12916. }
  12917. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  12918. }
  12919. }
  12920. // Bail out if this is a no-op like .hide().hide()
  12921. propTween = !jQuery.isEmptyObject( props );
  12922. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  12923. return;
  12924. }
  12925. // Restrict "overflow" and "display" styles during box animations
  12926. if ( isBox && elem.nodeType === 1 ) {
  12927. // Support: IE <=9 - 11, Edge 12 - 15
  12928. // Record all 3 overflow attributes because IE does not infer the shorthand
  12929. // from identically-valued overflowX and overflowY and Edge just mirrors
  12930. // the overflowX value there.
  12931. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  12932. // Identify a display type, preferring old show/hide data over the CSS cascade
  12933. restoreDisplay = dataShow && dataShow.display;
  12934. if ( restoreDisplay == null ) {
  12935. restoreDisplay = dataPriv.get( elem, "display" );
  12936. }
  12937. display = jQuery.css( elem, "display" );
  12938. if ( display === "none" ) {
  12939. if ( restoreDisplay ) {
  12940. display = restoreDisplay;
  12941. } else {
  12942. // Get nonempty value(s) by temporarily forcing visibility
  12943. showHide( [ elem ], true );
  12944. restoreDisplay = elem.style.display || restoreDisplay;
  12945. display = jQuery.css( elem, "display" );
  12946. showHide( [ elem ] );
  12947. }
  12948. }
  12949. // Animate inline elements as inline-block
  12950. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  12951. if ( jQuery.css( elem, "float" ) === "none" ) {
  12952. // Restore the original display value at the end of pure show/hide animations
  12953. if ( !propTween ) {
  12954. anim.done( function() {
  12955. style.display = restoreDisplay;
  12956. } );
  12957. if ( restoreDisplay == null ) {
  12958. display = style.display;
  12959. restoreDisplay = display === "none" ? "" : display;
  12960. }
  12961. }
  12962. style.display = "inline-block";
  12963. }
  12964. }
  12965. }
  12966. if ( opts.overflow ) {
  12967. style.overflow = "hidden";
  12968. anim.always( function() {
  12969. style.overflow = opts.overflow[ 0 ];
  12970. style.overflowX = opts.overflow[ 1 ];
  12971. style.overflowY = opts.overflow[ 2 ];
  12972. } );
  12973. }
  12974. // Implement show/hide animations
  12975. propTween = false;
  12976. for ( prop in orig ) {
  12977. // General show/hide setup for this element animation
  12978. if ( !propTween ) {
  12979. if ( dataShow ) {
  12980. if ( "hidden" in dataShow ) {
  12981. hidden = dataShow.hidden;
  12982. }
  12983. } else {
  12984. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  12985. }
  12986. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  12987. if ( toggle ) {
  12988. dataShow.hidden = !hidden;
  12989. }
  12990. // Show elements before animating them
  12991. if ( hidden ) {
  12992. showHide( [ elem ], true );
  12993. }
  12994. /* eslint-disable no-loop-func */
  12995. anim.done( function() {
  12996. /* eslint-enable no-loop-func */
  12997. // The final step of a "hide" animation is actually hiding the element
  12998. if ( !hidden ) {
  12999. showHide( [ elem ] );
  13000. }
  13001. dataPriv.remove( elem, "fxshow" );
  13002. for ( prop in orig ) {
  13003. jQuery.style( elem, prop, orig[ prop ] );
  13004. }
  13005. } );
  13006. }
  13007. // Per-property setup
  13008. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13009. if ( !( prop in dataShow ) ) {
  13010. dataShow[ prop ] = propTween.start;
  13011. if ( hidden ) {
  13012. propTween.end = propTween.start;
  13013. propTween.start = 0;
  13014. }
  13015. }
  13016. }
  13017. }
  13018. function propFilter( props, specialEasing ) {
  13019. var index, name, easing, value, hooks;
  13020. // camelCase, specialEasing and expand cssHook pass
  13021. for ( index in props ) {
  13022. name = camelCase( index );
  13023. easing = specialEasing[ name ];
  13024. value = props[ index ];
  13025. if ( Array.isArray( value ) ) {
  13026. easing = value[ 1 ];
  13027. value = props[ index ] = value[ 0 ];
  13028. }
  13029. if ( index !== name ) {
  13030. props[ name ] = value;
  13031. delete props[ index ];
  13032. }
  13033. hooks = jQuery.cssHooks[ name ];
  13034. if ( hooks && "expand" in hooks ) {
  13035. value = hooks.expand( value );
  13036. delete props[ name ];
  13037. // Not quite $.extend, this won't overwrite existing keys.
  13038. // Reusing 'index' because we have the correct "name"
  13039. for ( index in value ) {
  13040. if ( !( index in props ) ) {
  13041. props[ index ] = value[ index ];
  13042. specialEasing[ index ] = easing;
  13043. }
  13044. }
  13045. } else {
  13046. specialEasing[ name ] = easing;
  13047. }
  13048. }
  13049. }
  13050. function Animation( elem, properties, options ) {
  13051. var result,
  13052. stopped,
  13053. index = 0,
  13054. length = Animation.prefilters.length,
  13055. deferred = jQuery.Deferred().always( function() {
  13056. // Don't match elem in the :animated selector
  13057. delete tick.elem;
  13058. } ),
  13059. tick = function() {
  13060. if ( stopped ) {
  13061. return false;
  13062. }
  13063. var currentTime = fxNow || createFxNow(),
  13064. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13065. // Support: Android 2.3 only
  13066. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13067. temp = remaining / animation.duration || 0,
  13068. percent = 1 - temp,
  13069. index = 0,
  13070. length = animation.tweens.length;
  13071. for ( ; index < length; index++ ) {
  13072. animation.tweens[ index ].run( percent );
  13073. }
  13074. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  13075. // If there's more to do, yield
  13076. if ( percent < 1 && length ) {
  13077. return remaining;
  13078. }
  13079. // If this was an empty animation, synthesize a final progress notification
  13080. if ( !length ) {
  13081. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13082. }
  13083. // Resolve the animation and report its conclusion
  13084. deferred.resolveWith( elem, [ animation ] );
  13085. return false;
  13086. },
  13087. animation = deferred.promise( {
  13088. elem: elem,
  13089. props: jQuery.extend( {}, properties ),
  13090. opts: jQuery.extend( true, {
  13091. specialEasing: {},
  13092. easing: jQuery.easing._default
  13093. }, options ),
  13094. originalProperties: properties,
  13095. originalOptions: options,
  13096. startTime: fxNow || createFxNow(),
  13097. duration: options.duration,
  13098. tweens: [],
  13099. createTween: function( prop, end ) {
  13100. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  13101. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  13102. animation.tweens.push( tween );
  13103. return tween;
  13104. },
  13105. stop: function( gotoEnd ) {
  13106. var index = 0,
  13107. // If we are going to the end, we want to run all the tweens
  13108. // otherwise we skip this part
  13109. length = gotoEnd ? animation.tweens.length : 0;
  13110. if ( stopped ) {
  13111. return this;
  13112. }
  13113. stopped = true;
  13114. for ( ; index < length; index++ ) {
  13115. animation.tweens[ index ].run( 1 );
  13116. }
  13117. // Resolve when we played the last frame; otherwise, reject
  13118. if ( gotoEnd ) {
  13119. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  13120. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  13121. } else {
  13122. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  13123. }
  13124. return this;
  13125. }
  13126. } ),
  13127. props = animation.props;
  13128. propFilter( props, animation.opts.specialEasing );
  13129. for ( ; index < length; index++ ) {
  13130. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  13131. if ( result ) {
  13132. if ( isFunction( result.stop ) ) {
  13133. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  13134. result.stop.bind( result );
  13135. }
  13136. return result;
  13137. }
  13138. }
  13139. jQuery.map( props, createTween, animation );
  13140. if ( isFunction( animation.opts.start ) ) {
  13141. animation.opts.start.call( elem, animation );
  13142. }
  13143. // Attach callbacks from options
  13144. animation
  13145. .progress( animation.opts.progress )
  13146. .done( animation.opts.done, animation.opts.complete )
  13147. .fail( animation.opts.fail )
  13148. .always( animation.opts.always );
  13149. jQuery.fx.timer(
  13150. jQuery.extend( tick, {
  13151. elem: elem,
  13152. anim: animation,
  13153. queue: animation.opts.queue
  13154. } )
  13155. );
  13156. return animation;
  13157. }
  13158. jQuery.Animation = jQuery.extend( Animation, {
  13159. tweeners: {
  13160. "*": [ function( prop, value ) {
  13161. var tween = this.createTween( prop, value );
  13162. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  13163. return tween;
  13164. } ]
  13165. },
  13166. tweener: function( props, callback ) {
  13167. if ( isFunction( props ) ) {
  13168. callback = props;
  13169. props = [ "*" ];
  13170. } else {
  13171. props = props.match( rnothtmlwhite );
  13172. }
  13173. var prop,
  13174. index = 0,
  13175. length = props.length;
  13176. for ( ; index < length; index++ ) {
  13177. prop = props[ index ];
  13178. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  13179. Animation.tweeners[ prop ].unshift( callback );
  13180. }
  13181. },
  13182. prefilters: [ defaultPrefilter ],
  13183. prefilter: function( callback, prepend ) {
  13184. if ( prepend ) {
  13185. Animation.prefilters.unshift( callback );
  13186. } else {
  13187. Animation.prefilters.push( callback );
  13188. }
  13189. }
  13190. } );
  13191. jQuery.speed = function( speed, easing, fn ) {
  13192. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  13193. complete: fn || !fn && easing ||
  13194. isFunction( speed ) && speed,
  13195. duration: speed,
  13196. easing: fn && easing || easing && !isFunction( easing ) && easing
  13197. };
  13198. // Go to the end state if fx are off
  13199. if ( jQuery.fx.off ) {
  13200. opt.duration = 0;
  13201. } else {
  13202. if ( typeof opt.duration !== "number" ) {
  13203. if ( opt.duration in jQuery.fx.speeds ) {
  13204. opt.duration = jQuery.fx.speeds[ opt.duration ];
  13205. } else {
  13206. opt.duration = jQuery.fx.speeds._default;
  13207. }
  13208. }
  13209. }
  13210. // Normalize opt.queue - true/undefined/null -> "fx"
  13211. if ( opt.queue == null || opt.queue === true ) {
  13212. opt.queue = "fx";
  13213. }
  13214. // Queueing
  13215. opt.old = opt.complete;
  13216. opt.complete = function() {
  13217. if ( isFunction( opt.old ) ) {
  13218. opt.old.call( this );
  13219. }
  13220. if ( opt.queue ) {
  13221. jQuery.dequeue( this, opt.queue );
  13222. }
  13223. };
  13224. return opt;
  13225. };
  13226. jQuery.fn.extend( {
  13227. fadeTo: function( speed, to, easing, callback ) {
  13228. // Show any hidden elements after setting opacity to 0
  13229. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  13230. // Animate to the value specified
  13231. .end().animate( { opacity: to }, speed, easing, callback );
  13232. },
  13233. animate: function( prop, speed, easing, callback ) {
  13234. var empty = jQuery.isEmptyObject( prop ),
  13235. optall = jQuery.speed( speed, easing, callback ),
  13236. doAnimation = function() {
  13237. // Operate on a copy of prop so per-property easing won't be lost
  13238. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  13239. // Empty animations, or finishing resolves immediately
  13240. if ( empty || dataPriv.get( this, "finish" ) ) {
  13241. anim.stop( true );
  13242. }
  13243. };
  13244. doAnimation.finish = doAnimation;
  13245. return empty || optall.queue === false ?
  13246. this.each( doAnimation ) :
  13247. this.queue( optall.queue, doAnimation );
  13248. },
  13249. stop: function( type, clearQueue, gotoEnd ) {
  13250. var stopQueue = function( hooks ) {
  13251. var stop = hooks.stop;
  13252. delete hooks.stop;
  13253. stop( gotoEnd );
  13254. };
  13255. if ( typeof type !== "string" ) {
  13256. gotoEnd = clearQueue;
  13257. clearQueue = type;
  13258. type = undefined;
  13259. }
  13260. if ( clearQueue && type !== false ) {
  13261. this.queue( type || "fx", [] );
  13262. }
  13263. return this.each( function() {
  13264. var dequeue = true,
  13265. index = type != null && type + "queueHooks",
  13266. timers = jQuery.timers,
  13267. data = dataPriv.get( this );
  13268. if ( index ) {
  13269. if ( data[ index ] && data[ index ].stop ) {
  13270. stopQueue( data[ index ] );
  13271. }
  13272. } else {
  13273. for ( index in data ) {
  13274. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  13275. stopQueue( data[ index ] );
  13276. }
  13277. }
  13278. }
  13279. for ( index = timers.length; index--; ) {
  13280. if ( timers[ index ].elem === this &&
  13281. ( type == null || timers[ index ].queue === type ) ) {
  13282. timers[ index ].anim.stop( gotoEnd );
  13283. dequeue = false;
  13284. timers.splice( index, 1 );
  13285. }
  13286. }
  13287. // Start the next in the queue if the last step wasn't forced.
  13288. // Timers currently will call their complete callbacks, which
  13289. // will dequeue but only if they were gotoEnd.
  13290. if ( dequeue || !gotoEnd ) {
  13291. jQuery.dequeue( this, type );
  13292. }
  13293. } );
  13294. },
  13295. finish: function( type ) {
  13296. if ( type !== false ) {
  13297. type = type || "fx";
  13298. }
  13299. return this.each( function() {
  13300. var index,
  13301. data = dataPriv.get( this ),
  13302. queue = data[ type + "queue" ],
  13303. hooks = data[ type + "queueHooks" ],
  13304. timers = jQuery.timers,
  13305. length = queue ? queue.length : 0;
  13306. // Enable finishing flag on private data
  13307. data.finish = true;
  13308. // Empty the queue first
  13309. jQuery.queue( this, type, [] );
  13310. if ( hooks && hooks.stop ) {
  13311. hooks.stop.call( this, true );
  13312. }
  13313. // Look for any active animations, and finish them
  13314. for ( index = timers.length; index--; ) {
  13315. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  13316. timers[ index ].anim.stop( true );
  13317. timers.splice( index, 1 );
  13318. }
  13319. }
  13320. // Look for any animations in the old queue and finish them
  13321. for ( index = 0; index < length; index++ ) {
  13322. if ( queue[ index ] && queue[ index ].finish ) {
  13323. queue[ index ].finish.call( this );
  13324. }
  13325. }
  13326. // Turn off finishing flag
  13327. delete data.finish;
  13328. } );
  13329. }
  13330. } );
  13331. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  13332. var cssFn = jQuery.fn[ name ];
  13333. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13334. return speed == null || typeof speed === "boolean" ?
  13335. cssFn.apply( this, arguments ) :
  13336. this.animate( genFx( name, true ), speed, easing, callback );
  13337. };
  13338. } );
  13339. // Generate shortcuts for custom animations
  13340. jQuery.each( {
  13341. slideDown: genFx( "show" ),
  13342. slideUp: genFx( "hide" ),
  13343. slideToggle: genFx( "toggle" ),
  13344. fadeIn: { opacity: "show" },
  13345. fadeOut: { opacity: "hide" },
  13346. fadeToggle: { opacity: "toggle" }
  13347. }, function( name, props ) {
  13348. jQuery.fn[ name ] = function( speed, easing, callback ) {
  13349. return this.animate( props, speed, easing, callback );
  13350. };
  13351. } );
  13352. jQuery.timers = [];
  13353. jQuery.fx.tick = function() {
  13354. var timer,
  13355. i = 0,
  13356. timers = jQuery.timers;
  13357. fxNow = Date.now();
  13358. for ( ; i < timers.length; i++ ) {
  13359. timer = timers[ i ];
  13360. // Run the timer and safely remove it when done (allowing for external removal)
  13361. if ( !timer() && timers[ i ] === timer ) {
  13362. timers.splice( i--, 1 );
  13363. }
  13364. }
  13365. if ( !timers.length ) {
  13366. jQuery.fx.stop();
  13367. }
  13368. fxNow = undefined;
  13369. };
  13370. jQuery.fx.timer = function( timer ) {
  13371. jQuery.timers.push( timer );
  13372. jQuery.fx.start();
  13373. };
  13374. jQuery.fx.interval = 13;
  13375. jQuery.fx.start = function() {
  13376. if ( inProgress ) {
  13377. return;
  13378. }
  13379. inProgress = true;
  13380. schedule();
  13381. };
  13382. jQuery.fx.stop = function() {
  13383. inProgress = null;
  13384. };
  13385. jQuery.fx.speeds = {
  13386. slow: 600,
  13387. fast: 200,
  13388. // Default speed
  13389. _default: 400
  13390. };
  13391. // Based off of the plugin by Clint Helfers, with permission.
  13392. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  13393. jQuery.fn.delay = function( time, type ) {
  13394. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  13395. type = type || "fx";
  13396. return this.queue( type, function( next, hooks ) {
  13397. var timeout = window.setTimeout( next, time );
  13398. hooks.stop = function() {
  13399. window.clearTimeout( timeout );
  13400. };
  13401. } );
  13402. };
  13403. ( function() {
  13404. var input = document.createElement( "input" ),
  13405. select = document.createElement( "select" ),
  13406. opt = select.appendChild( document.createElement( "option" ) );
  13407. input.type = "checkbox";
  13408. // Support: Android <=4.3 only
  13409. // Default value for a checkbox should be "on"
  13410. support.checkOn = input.value !== "";
  13411. // Support: IE <=11 only
  13412. // Must access selectedIndex to make default options select
  13413. support.optSelected = opt.selected;
  13414. // Support: IE <=11 only
  13415. // An input loses its value after becoming a radio
  13416. input = document.createElement( "input" );
  13417. input.value = "t";
  13418. input.type = "radio";
  13419. support.radioValue = input.value === "t";
  13420. } )();
  13421. var boolHook,
  13422. attrHandle = jQuery.expr.attrHandle;
  13423. jQuery.fn.extend( {
  13424. attr: function( name, value ) {
  13425. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  13426. },
  13427. removeAttr: function( name ) {
  13428. return this.each( function() {
  13429. jQuery.removeAttr( this, name );
  13430. } );
  13431. }
  13432. } );
  13433. jQuery.extend( {
  13434. attr: function( elem, name, value ) {
  13435. var ret, hooks,
  13436. nType = elem.nodeType;
  13437. // Don't get/set attributes on text, comment and attribute nodes
  13438. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13439. return;
  13440. }
  13441. // Fallback to prop when attributes are not supported
  13442. if ( typeof elem.getAttribute === "undefined" ) {
  13443. return jQuery.prop( elem, name, value );
  13444. }
  13445. // Attribute hooks are determined by the lowercase version
  13446. // Grab necessary hook if one is defined
  13447. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13448. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  13449. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  13450. }
  13451. if ( value !== undefined ) {
  13452. if ( value === null ) {
  13453. jQuery.removeAttr( elem, name );
  13454. return;
  13455. }
  13456. if ( hooks && "set" in hooks &&
  13457. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13458. return ret;
  13459. }
  13460. elem.setAttribute( name, value + "" );
  13461. return value;
  13462. }
  13463. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13464. return ret;
  13465. }
  13466. ret = jQuery.find.attr( elem, name );
  13467. // Non-existent attributes return null, we normalize to undefined
  13468. return ret == null ? undefined : ret;
  13469. },
  13470. attrHooks: {
  13471. type: {
  13472. set: function( elem, value ) {
  13473. if ( !support.radioValue && value === "radio" &&
  13474. nodeName( elem, "input" ) ) {
  13475. var val = elem.value;
  13476. elem.setAttribute( "type", value );
  13477. if ( val ) {
  13478. elem.value = val;
  13479. }
  13480. return value;
  13481. }
  13482. }
  13483. }
  13484. },
  13485. removeAttr: function( elem, value ) {
  13486. var name,
  13487. i = 0,
  13488. // Attribute names can contain non-HTML whitespace characters
  13489. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  13490. attrNames = value && value.match( rnothtmlwhite );
  13491. if ( attrNames && elem.nodeType === 1 ) {
  13492. while ( ( name = attrNames[ i++ ] ) ) {
  13493. elem.removeAttribute( name );
  13494. }
  13495. }
  13496. }
  13497. } );
  13498. // Hooks for boolean attributes
  13499. boolHook = {
  13500. set: function( elem, value, name ) {
  13501. if ( value === false ) {
  13502. // Remove boolean attributes when set to false
  13503. jQuery.removeAttr( elem, name );
  13504. } else {
  13505. elem.setAttribute( name, name );
  13506. }
  13507. return name;
  13508. }
  13509. };
  13510. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  13511. var getter = attrHandle[ name ] || jQuery.find.attr;
  13512. attrHandle[ name ] = function( elem, name, isXML ) {
  13513. var ret, handle,
  13514. lowercaseName = name.toLowerCase();
  13515. if ( !isXML ) {
  13516. // Avoid an infinite loop by temporarily removing this function from the getter
  13517. handle = attrHandle[ lowercaseName ];
  13518. attrHandle[ lowercaseName ] = ret;
  13519. ret = getter( elem, name, isXML ) != null ?
  13520. lowercaseName :
  13521. null;
  13522. attrHandle[ lowercaseName ] = handle;
  13523. }
  13524. return ret;
  13525. };
  13526. } );
  13527. var rfocusable = /^(?:input|select|textarea|button)$/i,
  13528. rclickable = /^(?:a|area)$/i;
  13529. jQuery.fn.extend( {
  13530. prop: function( name, value ) {
  13531. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  13532. },
  13533. removeProp: function( name ) {
  13534. return this.each( function() {
  13535. delete this[ jQuery.propFix[ name ] || name ];
  13536. } );
  13537. }
  13538. } );
  13539. jQuery.extend( {
  13540. prop: function( elem, name, value ) {
  13541. var ret, hooks,
  13542. nType = elem.nodeType;
  13543. // Don't get/set properties on text, comment and attribute nodes
  13544. if ( nType === 3 || nType === 8 || nType === 2 ) {
  13545. return;
  13546. }
  13547. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  13548. // Fix name and attach hooks
  13549. name = jQuery.propFix[ name ] || name;
  13550. hooks = jQuery.propHooks[ name ];
  13551. }
  13552. if ( value !== undefined ) {
  13553. if ( hooks && "set" in hooks &&
  13554. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  13555. return ret;
  13556. }
  13557. return ( elem[ name ] = value );
  13558. }
  13559. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  13560. return ret;
  13561. }
  13562. return elem[ name ];
  13563. },
  13564. propHooks: {
  13565. tabIndex: {
  13566. get: function( elem ) {
  13567. // Support: IE <=9 - 11 only
  13568. // elem.tabIndex doesn't always return the
  13569. // correct value when it hasn't been explicitly set
  13570. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  13571. // Use proper attribute retrieval(#12072)
  13572. var tabindex = jQuery.find.attr( elem, "tabindex" );
  13573. if ( tabindex ) {
  13574. return parseInt( tabindex, 10 );
  13575. }
  13576. if (
  13577. rfocusable.test( elem.nodeName ) ||
  13578. rclickable.test( elem.nodeName ) &&
  13579. elem.href
  13580. ) {
  13581. return 0;
  13582. }
  13583. return -1;
  13584. }
  13585. }
  13586. },
  13587. propFix: {
  13588. "for": "htmlFor",
  13589. "class": "className"
  13590. }
  13591. } );
  13592. // Support: IE <=11 only
  13593. // Accessing the selectedIndex property
  13594. // forces the browser to respect setting selected
  13595. // on the option
  13596. // The getter ensures a default option is selected
  13597. // when in an optgroup
  13598. // eslint rule "no-unused-expressions" is disabled for this code
  13599. // since it considers such accessions noop
  13600. if ( !support.optSelected ) {
  13601. jQuery.propHooks.selected = {
  13602. get: function( elem ) {
  13603. /* eslint no-unused-expressions: "off" */
  13604. var parent = elem.parentNode;
  13605. if ( parent && parent.parentNode ) {
  13606. parent.parentNode.selectedIndex;
  13607. }
  13608. return null;
  13609. },
  13610. set: function( elem ) {
  13611. /* eslint no-unused-expressions: "off" */
  13612. var parent = elem.parentNode;
  13613. if ( parent ) {
  13614. parent.selectedIndex;
  13615. if ( parent.parentNode ) {
  13616. parent.parentNode.selectedIndex;
  13617. }
  13618. }
  13619. }
  13620. };
  13621. }
  13622. jQuery.each( [
  13623. "tabIndex",
  13624. "readOnly",
  13625. "maxLength",
  13626. "cellSpacing",
  13627. "cellPadding",
  13628. "rowSpan",
  13629. "colSpan",
  13630. "useMap",
  13631. "frameBorder",
  13632. "contentEditable"
  13633. ], function() {
  13634. jQuery.propFix[ this.toLowerCase() ] = this;
  13635. } );
  13636. // Strip and collapse whitespace according to HTML spec
  13637. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  13638. function stripAndCollapse( value ) {
  13639. var tokens = value.match( rnothtmlwhite ) || [];
  13640. return tokens.join( " " );
  13641. }
  13642. function getClass( elem ) {
  13643. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  13644. }
  13645. function classesToArray( value ) {
  13646. if ( Array.isArray( value ) ) {
  13647. return value;
  13648. }
  13649. if ( typeof value === "string" ) {
  13650. return value.match( rnothtmlwhite ) || [];
  13651. }
  13652. return [];
  13653. }
  13654. jQuery.fn.extend( {
  13655. addClass: function( value ) {
  13656. var classes, elem, cur, curValue, clazz, j, finalValue,
  13657. i = 0;
  13658. if ( isFunction( value ) ) {
  13659. return this.each( function( j ) {
  13660. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  13661. } );
  13662. }
  13663. classes = classesToArray( value );
  13664. if ( classes.length ) {
  13665. while ( ( elem = this[ i++ ] ) ) {
  13666. curValue = getClass( elem );
  13667. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13668. if ( cur ) {
  13669. j = 0;
  13670. while ( ( clazz = classes[ j++ ] ) ) {
  13671. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  13672. cur += clazz + " ";
  13673. }
  13674. }
  13675. // Only assign if different to avoid unneeded rendering.
  13676. finalValue = stripAndCollapse( cur );
  13677. if ( curValue !== finalValue ) {
  13678. elem.setAttribute( "class", finalValue );
  13679. }
  13680. }
  13681. }
  13682. }
  13683. return this;
  13684. },
  13685. removeClass: function( value ) {
  13686. var classes, elem, cur, curValue, clazz, j, finalValue,
  13687. i = 0;
  13688. if ( isFunction( value ) ) {
  13689. return this.each( function( j ) {
  13690. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  13691. } );
  13692. }
  13693. if ( !arguments.length ) {
  13694. return this.attr( "class", "" );
  13695. }
  13696. classes = classesToArray( value );
  13697. if ( classes.length ) {
  13698. while ( ( elem = this[ i++ ] ) ) {
  13699. curValue = getClass( elem );
  13700. // This expression is here for better compressibility (see addClass)
  13701. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  13702. if ( cur ) {
  13703. j = 0;
  13704. while ( ( clazz = classes[ j++ ] ) ) {
  13705. // Remove *all* instances
  13706. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  13707. cur = cur.replace( " " + clazz + " ", " " );
  13708. }
  13709. }
  13710. // Only assign if different to avoid unneeded rendering.
  13711. finalValue = stripAndCollapse( cur );
  13712. if ( curValue !== finalValue ) {
  13713. elem.setAttribute( "class", finalValue );
  13714. }
  13715. }
  13716. }
  13717. }
  13718. return this;
  13719. },
  13720. toggleClass: function( value, stateVal ) {
  13721. var type = typeof value,
  13722. isValidValue = type === "string" || Array.isArray( value );
  13723. if ( typeof stateVal === "boolean" && isValidValue ) {
  13724. return stateVal ? this.addClass( value ) : this.removeClass( value );
  13725. }
  13726. if ( isFunction( value ) ) {
  13727. return this.each( function( i ) {
  13728. jQuery( this ).toggleClass(
  13729. value.call( this, i, getClass( this ), stateVal ),
  13730. stateVal
  13731. );
  13732. } );
  13733. }
  13734. return this.each( function() {
  13735. var className, i, self, classNames;
  13736. if ( isValidValue ) {
  13737. // Toggle individual class names
  13738. i = 0;
  13739. self = jQuery( this );
  13740. classNames = classesToArray( value );
  13741. while ( ( className = classNames[ i++ ] ) ) {
  13742. // Check each className given, space separated list
  13743. if ( self.hasClass( className ) ) {
  13744. self.removeClass( className );
  13745. } else {
  13746. self.addClass( className );
  13747. }
  13748. }
  13749. // Toggle whole class name
  13750. } else if ( value === undefined || type === "boolean" ) {
  13751. className = getClass( this );
  13752. if ( className ) {
  13753. // Store className if set
  13754. dataPriv.set( this, "__className__", className );
  13755. }
  13756. // If the element has a class name or if we're passed `false`,
  13757. // then remove the whole classname (if there was one, the above saved it).
  13758. // Otherwise bring back whatever was previously saved (if anything),
  13759. // falling back to the empty string if nothing was stored.
  13760. if ( this.setAttribute ) {
  13761. this.setAttribute( "class",
  13762. className || value === false ?
  13763. "" :
  13764. dataPriv.get( this, "__className__" ) || ""
  13765. );
  13766. }
  13767. }
  13768. } );
  13769. },
  13770. hasClass: function( selector ) {
  13771. var className, elem,
  13772. i = 0;
  13773. className = " " + selector + " ";
  13774. while ( ( elem = this[ i++ ] ) ) {
  13775. if ( elem.nodeType === 1 &&
  13776. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  13777. return true;
  13778. }
  13779. }
  13780. return false;
  13781. }
  13782. } );
  13783. var rreturn = /\r/g;
  13784. jQuery.fn.extend( {
  13785. val: function( value ) {
  13786. var hooks, ret, valueIsFunction,
  13787. elem = this[ 0 ];
  13788. if ( !arguments.length ) {
  13789. if ( elem ) {
  13790. hooks = jQuery.valHooks[ elem.type ] ||
  13791. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  13792. if ( hooks &&
  13793. "get" in hooks &&
  13794. ( ret = hooks.get( elem, "value" ) ) !== undefined
  13795. ) {
  13796. return ret;
  13797. }
  13798. ret = elem.value;
  13799. // Handle most common string cases
  13800. if ( typeof ret === "string" ) {
  13801. return ret.replace( rreturn, "" );
  13802. }
  13803. // Handle cases where value is null/undef or number
  13804. return ret == null ? "" : ret;
  13805. }
  13806. return;
  13807. }
  13808. valueIsFunction = isFunction( value );
  13809. return this.each( function( i ) {
  13810. var val;
  13811. if ( this.nodeType !== 1 ) {
  13812. return;
  13813. }
  13814. if ( valueIsFunction ) {
  13815. val = value.call( this, i, jQuery( this ).val() );
  13816. } else {
  13817. val = value;
  13818. }
  13819. // Treat null/undefined as ""; convert numbers to string
  13820. if ( val == null ) {
  13821. val = "";
  13822. } else if ( typeof val === "number" ) {
  13823. val += "";
  13824. } else if ( Array.isArray( val ) ) {
  13825. val = jQuery.map( val, function( value ) {
  13826. return value == null ? "" : value + "";
  13827. } );
  13828. }
  13829. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  13830. // If set returns undefined, fall back to normal setting
  13831. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  13832. this.value = val;
  13833. }
  13834. } );
  13835. }
  13836. } );
  13837. jQuery.extend( {
  13838. valHooks: {
  13839. option: {
  13840. get: function( elem ) {
  13841. var val = jQuery.find.attr( elem, "value" );
  13842. return val != null ?
  13843. val :
  13844. // Support: IE <=10 - 11 only
  13845. // option.text throws exceptions (#14686, #14858)
  13846. // Strip and collapse whitespace
  13847. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  13848. stripAndCollapse( jQuery.text( elem ) );
  13849. }
  13850. },
  13851. select: {
  13852. get: function( elem ) {
  13853. var value, option, i,
  13854. options = elem.options,
  13855. index = elem.selectedIndex,
  13856. one = elem.type === "select-one",
  13857. values = one ? null : [],
  13858. max = one ? index + 1 : options.length;
  13859. if ( index < 0 ) {
  13860. i = max;
  13861. } else {
  13862. i = one ? index : 0;
  13863. }
  13864. // Loop through all the selected options
  13865. for ( ; i < max; i++ ) {
  13866. option = options[ i ];
  13867. // Support: IE <=9 only
  13868. // IE8-9 doesn't update selected after form reset (#2551)
  13869. if ( ( option.selected || i === index ) &&
  13870. // Don't return options that are disabled or in a disabled optgroup
  13871. !option.disabled &&
  13872. ( !option.parentNode.disabled ||
  13873. !nodeName( option.parentNode, "optgroup" ) ) ) {
  13874. // Get the specific value for the option
  13875. value = jQuery( option ).val();
  13876. // We don't need an array for one selects
  13877. if ( one ) {
  13878. return value;
  13879. }
  13880. // Multi-Selects return an array
  13881. values.push( value );
  13882. }
  13883. }
  13884. return values;
  13885. },
  13886. set: function( elem, value ) {
  13887. var optionSet, option,
  13888. options = elem.options,
  13889. values = jQuery.makeArray( value ),
  13890. i = options.length;
  13891. while ( i-- ) {
  13892. option = options[ i ];
  13893. /* eslint-disable no-cond-assign */
  13894. if ( option.selected =
  13895. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  13896. ) {
  13897. optionSet = true;
  13898. }
  13899. /* eslint-enable no-cond-assign */
  13900. }
  13901. // Force browsers to behave consistently when non-matching value is set
  13902. if ( !optionSet ) {
  13903. elem.selectedIndex = -1;
  13904. }
  13905. return values;
  13906. }
  13907. }
  13908. }
  13909. } );
  13910. // Radios and checkboxes getter/setter
  13911. jQuery.each( [ "radio", "checkbox" ], function() {
  13912. jQuery.valHooks[ this ] = {
  13913. set: function( elem, value ) {
  13914. if ( Array.isArray( value ) ) {
  13915. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  13916. }
  13917. }
  13918. };
  13919. if ( !support.checkOn ) {
  13920. jQuery.valHooks[ this ].get = function( elem ) {
  13921. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  13922. };
  13923. }
  13924. } );
  13925. // Return jQuery for attributes-only inclusion
  13926. support.focusin = "onfocusin" in window;
  13927. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  13928. stopPropagationCallback = function( e ) {
  13929. e.stopPropagation();
  13930. };
  13931. jQuery.extend( jQuery.event, {
  13932. trigger: function( event, data, elem, onlyHandlers ) {
  13933. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  13934. eventPath = [ elem || document ],
  13935. type = hasOwn.call( event, "type" ) ? event.type : event,
  13936. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  13937. cur = lastElement = tmp = elem = elem || document;
  13938. // Don't do events on text and comment nodes
  13939. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  13940. return;
  13941. }
  13942. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  13943. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  13944. return;
  13945. }
  13946. if ( type.indexOf( "." ) > -1 ) {
  13947. // Namespaced trigger; create a regexp to match event type in handle()
  13948. namespaces = type.split( "." );
  13949. type = namespaces.shift();
  13950. namespaces.sort();
  13951. }
  13952. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  13953. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  13954. event = event[ jQuery.expando ] ?
  13955. event :
  13956. new jQuery.Event( type, typeof event === "object" && event );
  13957. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  13958. event.isTrigger = onlyHandlers ? 2 : 3;
  13959. event.namespace = namespaces.join( "." );
  13960. event.rnamespace = event.namespace ?
  13961. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  13962. null;
  13963. // Clean up the event in case it is being reused
  13964. event.result = undefined;
  13965. if ( !event.target ) {
  13966. event.target = elem;
  13967. }
  13968. // Clone any incoming data and prepend the event, creating the handler arg list
  13969. data = data == null ?
  13970. [ event ] :
  13971. jQuery.makeArray( data, [ event ] );
  13972. // Allow special events to draw outside the lines
  13973. special = jQuery.event.special[ type ] || {};
  13974. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  13975. return;
  13976. }
  13977. // Determine event propagation path in advance, per W3C events spec (#9951)
  13978. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  13979. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  13980. bubbleType = special.delegateType || type;
  13981. if ( !rfocusMorph.test( bubbleType + type ) ) {
  13982. cur = cur.parentNode;
  13983. }
  13984. for ( ; cur; cur = cur.parentNode ) {
  13985. eventPath.push( cur );
  13986. tmp = cur;
  13987. }
  13988. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  13989. if ( tmp === ( elem.ownerDocument || document ) ) {
  13990. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  13991. }
  13992. }
  13993. // Fire handlers on the event path
  13994. i = 0;
  13995. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  13996. lastElement = cur;
  13997. event.type = i > 1 ?
  13998. bubbleType :
  13999. special.bindType || type;
  14000. // jQuery handler
  14001. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14002. dataPriv.get( cur, "handle" );
  14003. if ( handle ) {
  14004. handle.apply( cur, data );
  14005. }
  14006. // Native handler
  14007. handle = ontype && cur[ ontype ];
  14008. if ( handle && handle.apply && acceptData( cur ) ) {
  14009. event.result = handle.apply( cur, data );
  14010. if ( event.result === false ) {
  14011. event.preventDefault();
  14012. }
  14013. }
  14014. }
  14015. event.type = type;
  14016. // If nobody prevented the default action, do it now
  14017. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14018. if ( ( !special._default ||
  14019. special._default.apply( eventPath.pop(), data ) === false ) &&
  14020. acceptData( elem ) ) {
  14021. // Call a native DOM method on the target with the same name as the event.
  14022. // Don't do default actions on window, that's where global variables be (#6170)
  14023. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14024. // Don't re-trigger an onFOO event when we call its FOO() method
  14025. tmp = elem[ ontype ];
  14026. if ( tmp ) {
  14027. elem[ ontype ] = null;
  14028. }
  14029. // Prevent re-triggering of the same event, since we already bubbled it above
  14030. jQuery.event.triggered = type;
  14031. if ( event.isPropagationStopped() ) {
  14032. lastElement.addEventListener( type, stopPropagationCallback );
  14033. }
  14034. elem[ type ]();
  14035. if ( event.isPropagationStopped() ) {
  14036. lastElement.removeEventListener( type, stopPropagationCallback );
  14037. }
  14038. jQuery.event.triggered = undefined;
  14039. if ( tmp ) {
  14040. elem[ ontype ] = tmp;
  14041. }
  14042. }
  14043. }
  14044. }
  14045. return event.result;
  14046. },
  14047. // Piggyback on a donor event to simulate a different one
  14048. // Used only for `focus(in | out)` events
  14049. simulate: function( type, elem, event ) {
  14050. var e = jQuery.extend(
  14051. new jQuery.Event(),
  14052. event,
  14053. {
  14054. type: type,
  14055. isSimulated: true
  14056. }
  14057. );
  14058. jQuery.event.trigger( e, null, elem );
  14059. }
  14060. } );
  14061. jQuery.fn.extend( {
  14062. trigger: function( type, data ) {
  14063. return this.each( function() {
  14064. jQuery.event.trigger( type, data, this );
  14065. } );
  14066. },
  14067. triggerHandler: function( type, data ) {
  14068. var elem = this[ 0 ];
  14069. if ( elem ) {
  14070. return jQuery.event.trigger( type, data, elem, true );
  14071. }
  14072. }
  14073. } );
  14074. // Support: Firefox <=44
  14075. // Firefox doesn't have focus(in | out) events
  14076. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  14077. //
  14078. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  14079. // focus(in | out) events fire after focus & blur events,
  14080. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  14081. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  14082. if ( !support.focusin ) {
  14083. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  14084. // Attach a single capturing handler on the document while someone wants focusin/focusout
  14085. var handler = function( event ) {
  14086. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  14087. };
  14088. jQuery.event.special[ fix ] = {
  14089. setup: function() {
  14090. var doc = this.ownerDocument || this,
  14091. attaches = dataPriv.access( doc, fix );
  14092. if ( !attaches ) {
  14093. doc.addEventListener( orig, handler, true );
  14094. }
  14095. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  14096. },
  14097. teardown: function() {
  14098. var doc = this.ownerDocument || this,
  14099. attaches = dataPriv.access( doc, fix ) - 1;
  14100. if ( !attaches ) {
  14101. doc.removeEventListener( orig, handler, true );
  14102. dataPriv.remove( doc, fix );
  14103. } else {
  14104. dataPriv.access( doc, fix, attaches );
  14105. }
  14106. }
  14107. };
  14108. } );
  14109. }
  14110. var location = window.location;
  14111. var nonce = Date.now();
  14112. var rquery = ( /\?/ );
  14113. // Cross-browser xml parsing
  14114. jQuery.parseXML = function( data ) {
  14115. var xml;
  14116. if ( !data || typeof data !== "string" ) {
  14117. return null;
  14118. }
  14119. // Support: IE 9 - 11 only
  14120. // IE throws on parseFromString with invalid input.
  14121. try {
  14122. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  14123. } catch ( e ) {
  14124. xml = undefined;
  14125. }
  14126. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  14127. jQuery.error( "Invalid XML: " + data );
  14128. }
  14129. return xml;
  14130. };
  14131. var
  14132. rbracket = /\[\]$/,
  14133. rCRLF = /\r?\n/g,
  14134. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  14135. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  14136. function buildParams( prefix, obj, traditional, add ) {
  14137. var name;
  14138. if ( Array.isArray( obj ) ) {
  14139. // Serialize array item.
  14140. jQuery.each( obj, function( i, v ) {
  14141. if ( traditional || rbracket.test( prefix ) ) {
  14142. // Treat each array item as a scalar.
  14143. add( prefix, v );
  14144. } else {
  14145. // Item is non-scalar (array or object), encode its numeric index.
  14146. buildParams(
  14147. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  14148. v,
  14149. traditional,
  14150. add
  14151. );
  14152. }
  14153. } );
  14154. } else if ( !traditional && toType( obj ) === "object" ) {
  14155. // Serialize object item.
  14156. for ( name in obj ) {
  14157. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  14158. }
  14159. } else {
  14160. // Serialize scalar item.
  14161. add( prefix, obj );
  14162. }
  14163. }
  14164. // Serialize an array of form elements or a set of
  14165. // key/values into a query string
  14166. jQuery.param = function( a, traditional ) {
  14167. var prefix,
  14168. s = [],
  14169. add = function( key, valueOrFunction ) {
  14170. // If value is a function, invoke it and use its return value
  14171. var value = isFunction( valueOrFunction ) ?
  14172. valueOrFunction() :
  14173. valueOrFunction;
  14174. s[ s.length ] = encodeURIComponent( key ) + "=" +
  14175. encodeURIComponent( value == null ? "" : value );
  14176. };
  14177. if ( a == null ) {
  14178. return "";
  14179. }
  14180. // If an array was passed in, assume that it is an array of form elements.
  14181. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  14182. // Serialize the form elements
  14183. jQuery.each( a, function() {
  14184. add( this.name, this.value );
  14185. } );
  14186. } else {
  14187. // If traditional, encode the "old" way (the way 1.3.2 or older
  14188. // did it), otherwise encode params recursively.
  14189. for ( prefix in a ) {
  14190. buildParams( prefix, a[ prefix ], traditional, add );
  14191. }
  14192. }
  14193. // Return the resulting serialization
  14194. return s.join( "&" );
  14195. };
  14196. jQuery.fn.extend( {
  14197. serialize: function() {
  14198. return jQuery.param( this.serializeArray() );
  14199. },
  14200. serializeArray: function() {
  14201. return this.map( function() {
  14202. // Can add propHook for "elements" to filter or add form elements
  14203. var elements = jQuery.prop( this, "elements" );
  14204. return elements ? jQuery.makeArray( elements ) : this;
  14205. } )
  14206. .filter( function() {
  14207. var type = this.type;
  14208. // Use .is( ":disabled" ) so that fieldset[disabled] works
  14209. return this.name && !jQuery( this ).is( ":disabled" ) &&
  14210. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  14211. ( this.checked || !rcheckableType.test( type ) );
  14212. } )
  14213. .map( function( i, elem ) {
  14214. var val = jQuery( this ).val();
  14215. if ( val == null ) {
  14216. return null;
  14217. }
  14218. if ( Array.isArray( val ) ) {
  14219. return jQuery.map( val, function( val ) {
  14220. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14221. } );
  14222. }
  14223. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  14224. } ).get();
  14225. }
  14226. } );
  14227. var
  14228. r20 = /%20/g,
  14229. rhash = /#.*$/,
  14230. rantiCache = /([?&])_=[^&]*/,
  14231. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  14232. // #7653, #8125, #8152: local protocol detection
  14233. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  14234. rnoContent = /^(?:GET|HEAD)$/,
  14235. rprotocol = /^\/\//,
  14236. /* Prefilters
  14237. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  14238. * 2) These are called:
  14239. * - BEFORE asking for a transport
  14240. * - AFTER param serialization (s.data is a string if s.processData is true)
  14241. * 3) key is the dataType
  14242. * 4) the catchall symbol "*" can be used
  14243. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  14244. */
  14245. prefilters = {},
  14246. /* Transports bindings
  14247. * 1) key is the dataType
  14248. * 2) the catchall symbol "*" can be used
  14249. * 3) selection will start with transport dataType and THEN go to "*" if needed
  14250. */
  14251. transports = {},
  14252. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  14253. allTypes = "*/".concat( "*" ),
  14254. // Anchor tag for parsing the document origin
  14255. originAnchor = document.createElement( "a" );
  14256. originAnchor.href = location.href;
  14257. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  14258. function addToPrefiltersOrTransports( structure ) {
  14259. // dataTypeExpression is optional and defaults to "*"
  14260. return function( dataTypeExpression, func ) {
  14261. if ( typeof dataTypeExpression !== "string" ) {
  14262. func = dataTypeExpression;
  14263. dataTypeExpression = "*";
  14264. }
  14265. var dataType,
  14266. i = 0,
  14267. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  14268. if ( isFunction( func ) ) {
  14269. // For each dataType in the dataTypeExpression
  14270. while ( ( dataType = dataTypes[ i++ ] ) ) {
  14271. // Prepend if requested
  14272. if ( dataType[ 0 ] === "+" ) {
  14273. dataType = dataType.slice( 1 ) || "*";
  14274. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  14275. // Otherwise append
  14276. } else {
  14277. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  14278. }
  14279. }
  14280. }
  14281. };
  14282. }
  14283. // Base inspection function for prefilters and transports
  14284. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  14285. var inspected = {},
  14286. seekingTransport = ( structure === transports );
  14287. function inspect( dataType ) {
  14288. var selected;
  14289. inspected[ dataType ] = true;
  14290. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  14291. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  14292. if ( typeof dataTypeOrTransport === "string" &&
  14293. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  14294. options.dataTypes.unshift( dataTypeOrTransport );
  14295. inspect( dataTypeOrTransport );
  14296. return false;
  14297. } else if ( seekingTransport ) {
  14298. return !( selected = dataTypeOrTransport );
  14299. }
  14300. } );
  14301. return selected;
  14302. }
  14303. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  14304. }
  14305. // A special extend for ajax options
  14306. // that takes "flat" options (not to be deep extended)
  14307. // Fixes #9887
  14308. function ajaxExtend( target, src ) {
  14309. var key, deep,
  14310. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  14311. for ( key in src ) {
  14312. if ( src[ key ] !== undefined ) {
  14313. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  14314. }
  14315. }
  14316. if ( deep ) {
  14317. jQuery.extend( true, target, deep );
  14318. }
  14319. return target;
  14320. }
  14321. /* Handles responses to an ajax request:
  14322. * - finds the right dataType (mediates between content-type and expected dataType)
  14323. * - returns the corresponding response
  14324. */
  14325. function ajaxHandleResponses( s, jqXHR, responses ) {
  14326. var ct, type, finalDataType, firstDataType,
  14327. contents = s.contents,
  14328. dataTypes = s.dataTypes;
  14329. // Remove auto dataType and get content-type in the process
  14330. while ( dataTypes[ 0 ] === "*" ) {
  14331. dataTypes.shift();
  14332. if ( ct === undefined ) {
  14333. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  14334. }
  14335. }
  14336. // Check if we're dealing with a known content-type
  14337. if ( ct ) {
  14338. for ( type in contents ) {
  14339. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  14340. dataTypes.unshift( type );
  14341. break;
  14342. }
  14343. }
  14344. }
  14345. // Check to see if we have a response for the expected dataType
  14346. if ( dataTypes[ 0 ] in responses ) {
  14347. finalDataType = dataTypes[ 0 ];
  14348. } else {
  14349. // Try convertible dataTypes
  14350. for ( type in responses ) {
  14351. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  14352. finalDataType = type;
  14353. break;
  14354. }
  14355. if ( !firstDataType ) {
  14356. firstDataType = type;
  14357. }
  14358. }
  14359. // Or just use first one
  14360. finalDataType = finalDataType || firstDataType;
  14361. }
  14362. // If we found a dataType
  14363. // We add the dataType to the list if needed
  14364. // and return the corresponding response
  14365. if ( finalDataType ) {
  14366. if ( finalDataType !== dataTypes[ 0 ] ) {
  14367. dataTypes.unshift( finalDataType );
  14368. }
  14369. return responses[ finalDataType ];
  14370. }
  14371. }
  14372. /* Chain conversions given the request and the original response
  14373. * Also sets the responseXXX fields on the jqXHR instance
  14374. */
  14375. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  14376. var conv2, current, conv, tmp, prev,
  14377. converters = {},
  14378. // Work with a copy of dataTypes in case we need to modify it for conversion
  14379. dataTypes = s.dataTypes.slice();
  14380. // Create converters map with lowercased keys
  14381. if ( dataTypes[ 1 ] ) {
  14382. for ( conv in s.converters ) {
  14383. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  14384. }
  14385. }
  14386. current = dataTypes.shift();
  14387. // Convert to each sequential dataType
  14388. while ( current ) {
  14389. if ( s.responseFields[ current ] ) {
  14390. jqXHR[ s.responseFields[ current ] ] = response;
  14391. }
  14392. // Apply the dataFilter if provided
  14393. if ( !prev && isSuccess && s.dataFilter ) {
  14394. response = s.dataFilter( response, s.dataType );
  14395. }
  14396. prev = current;
  14397. current = dataTypes.shift();
  14398. if ( current ) {
  14399. // There's only work to do if current dataType is non-auto
  14400. if ( current === "*" ) {
  14401. current = prev;
  14402. // Convert response if prev dataType is non-auto and differs from current
  14403. } else if ( prev !== "*" && prev !== current ) {
  14404. // Seek a direct converter
  14405. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  14406. // If none found, seek a pair
  14407. if ( !conv ) {
  14408. for ( conv2 in converters ) {
  14409. // If conv2 outputs current
  14410. tmp = conv2.split( " " );
  14411. if ( tmp[ 1 ] === current ) {
  14412. // If prev can be converted to accepted input
  14413. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  14414. converters[ "* " + tmp[ 0 ] ];
  14415. if ( conv ) {
  14416. // Condense equivalence converters
  14417. if ( conv === true ) {
  14418. conv = converters[ conv2 ];
  14419. // Otherwise, insert the intermediate dataType
  14420. } else if ( converters[ conv2 ] !== true ) {
  14421. current = tmp[ 0 ];
  14422. dataTypes.unshift( tmp[ 1 ] );
  14423. }
  14424. break;
  14425. }
  14426. }
  14427. }
  14428. }
  14429. // Apply converter (if not an equivalence)
  14430. if ( conv !== true ) {
  14431. // Unless errors are allowed to bubble, catch and return them
  14432. if ( conv && s.throws ) {
  14433. response = conv( response );
  14434. } else {
  14435. try {
  14436. response = conv( response );
  14437. } catch ( e ) {
  14438. return {
  14439. state: "parsererror",
  14440. error: conv ? e : "No conversion from " + prev + " to " + current
  14441. };
  14442. }
  14443. }
  14444. }
  14445. }
  14446. }
  14447. }
  14448. return { state: "success", data: response };
  14449. }
  14450. jQuery.extend( {
  14451. // Counter for holding the number of active queries
  14452. active: 0,
  14453. // Last-Modified header cache for next request
  14454. lastModified: {},
  14455. etag: {},
  14456. ajaxSettings: {
  14457. url: location.href,
  14458. type: "GET",
  14459. isLocal: rlocalProtocol.test( location.protocol ),
  14460. global: true,
  14461. processData: true,
  14462. async: true,
  14463. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  14464. /*
  14465. timeout: 0,
  14466. data: null,
  14467. dataType: null,
  14468. username: null,
  14469. password: null,
  14470. cache: null,
  14471. throws: false,
  14472. traditional: false,
  14473. headers: {},
  14474. */
  14475. accepts: {
  14476. "*": allTypes,
  14477. text: "text/plain",
  14478. html: "text/html",
  14479. xml: "application/xml, text/xml",
  14480. json: "application/json, text/javascript"
  14481. },
  14482. contents: {
  14483. xml: /\bxml\b/,
  14484. html: /\bhtml/,
  14485. json: /\bjson\b/
  14486. },
  14487. responseFields: {
  14488. xml: "responseXML",
  14489. text: "responseText",
  14490. json: "responseJSON"
  14491. },
  14492. // Data converters
  14493. // Keys separate source (or catchall "*") and destination types with a single space
  14494. converters: {
  14495. // Convert anything to text
  14496. "* text": String,
  14497. // Text to html (true = no transformation)
  14498. "text html": true,
  14499. // Evaluate text as a json expression
  14500. "text json": JSON.parse,
  14501. // Parse text as xml
  14502. "text xml": jQuery.parseXML
  14503. },
  14504. // For options that shouldn't be deep extended:
  14505. // you can add your own custom options here if
  14506. // and when you create one that shouldn't be
  14507. // deep extended (see ajaxExtend)
  14508. flatOptions: {
  14509. url: true,
  14510. context: true
  14511. }
  14512. },
  14513. // Creates a full fledged settings object into target
  14514. // with both ajaxSettings and settings fields.
  14515. // If target is omitted, writes into ajaxSettings.
  14516. ajaxSetup: function( target, settings ) {
  14517. return settings ?
  14518. // Building a settings object
  14519. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  14520. // Extending ajaxSettings
  14521. ajaxExtend( jQuery.ajaxSettings, target );
  14522. },
  14523. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  14524. ajaxTransport: addToPrefiltersOrTransports( transports ),
  14525. // Main method
  14526. ajax: function( url, options ) {
  14527. // If url is an object, simulate pre-1.5 signature
  14528. if ( typeof url === "object" ) {
  14529. options = url;
  14530. url = undefined;
  14531. }
  14532. // Force options to be an object
  14533. options = options || {};
  14534. var transport,
  14535. // URL without anti-cache param
  14536. cacheURL,
  14537. // Response headers
  14538. responseHeadersString,
  14539. responseHeaders,
  14540. // timeout handle
  14541. timeoutTimer,
  14542. // Url cleanup var
  14543. urlAnchor,
  14544. // Request state (becomes false upon send and true upon completion)
  14545. completed,
  14546. // To know if global events are to be dispatched
  14547. fireGlobals,
  14548. // Loop variable
  14549. i,
  14550. // uncached part of the url
  14551. uncached,
  14552. // Create the final options object
  14553. s = jQuery.ajaxSetup( {}, options ),
  14554. // Callbacks context
  14555. callbackContext = s.context || s,
  14556. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  14557. globalEventContext = s.context &&
  14558. ( callbackContext.nodeType || callbackContext.jquery ) ?
  14559. jQuery( callbackContext ) :
  14560. jQuery.event,
  14561. // Deferreds
  14562. deferred = jQuery.Deferred(),
  14563. completeDeferred = jQuery.Callbacks( "once memory" ),
  14564. // Status-dependent callbacks
  14565. statusCode = s.statusCode || {},
  14566. // Headers (they are sent all at once)
  14567. requestHeaders = {},
  14568. requestHeadersNames = {},
  14569. // Default abort message
  14570. strAbort = "canceled",
  14571. // Fake xhr
  14572. jqXHR = {
  14573. readyState: 0,
  14574. // Builds headers hashtable if needed
  14575. getResponseHeader: function( key ) {
  14576. var match;
  14577. if ( completed ) {
  14578. if ( !responseHeaders ) {
  14579. responseHeaders = {};
  14580. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  14581. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  14582. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  14583. .concat( match[ 2 ] );
  14584. }
  14585. }
  14586. match = responseHeaders[ key.toLowerCase() + " " ];
  14587. }
  14588. return match == null ? null : match.join( ", " );
  14589. },
  14590. // Raw string
  14591. getAllResponseHeaders: function() {
  14592. return completed ? responseHeadersString : null;
  14593. },
  14594. // Caches the header
  14595. setRequestHeader: function( name, value ) {
  14596. if ( completed == null ) {
  14597. name = requestHeadersNames[ name.toLowerCase() ] =
  14598. requestHeadersNames[ name.toLowerCase() ] || name;
  14599. requestHeaders[ name ] = value;
  14600. }
  14601. return this;
  14602. },
  14603. // Overrides response content-type header
  14604. overrideMimeType: function( type ) {
  14605. if ( completed == null ) {
  14606. s.mimeType = type;
  14607. }
  14608. return this;
  14609. },
  14610. // Status-dependent callbacks
  14611. statusCode: function( map ) {
  14612. var code;
  14613. if ( map ) {
  14614. if ( completed ) {
  14615. // Execute the appropriate callbacks
  14616. jqXHR.always( map[ jqXHR.status ] );
  14617. } else {
  14618. // Lazy-add the new callbacks in a way that preserves old ones
  14619. for ( code in map ) {
  14620. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  14621. }
  14622. }
  14623. }
  14624. return this;
  14625. },
  14626. // Cancel the request
  14627. abort: function( statusText ) {
  14628. var finalText = statusText || strAbort;
  14629. if ( transport ) {
  14630. transport.abort( finalText );
  14631. }
  14632. done( 0, finalText );
  14633. return this;
  14634. }
  14635. };
  14636. // Attach deferreds
  14637. deferred.promise( jqXHR );
  14638. // Add protocol if not provided (prefilters might expect it)
  14639. // Handle falsy url in the settings object (#10093: consistency with old signature)
  14640. // We also use the url parameter if available
  14641. s.url = ( ( url || s.url || location.href ) + "" )
  14642. .replace( rprotocol, location.protocol + "//" );
  14643. // Alias method option to type as per ticket #12004
  14644. s.type = options.method || options.type || s.method || s.type;
  14645. // Extract dataTypes list
  14646. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  14647. // A cross-domain request is in order when the origin doesn't match the current origin.
  14648. if ( s.crossDomain == null ) {
  14649. urlAnchor = document.createElement( "a" );
  14650. // Support: IE <=8 - 11, Edge 12 - 15
  14651. // IE throws exception on accessing the href property if url is malformed,
  14652. // e.g. http://example.com:80x/
  14653. try {
  14654. urlAnchor.href = s.url;
  14655. // Support: IE <=8 - 11 only
  14656. // Anchor's host property isn't correctly set when s.url is relative
  14657. urlAnchor.href = urlAnchor.href;
  14658. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  14659. urlAnchor.protocol + "//" + urlAnchor.host;
  14660. } catch ( e ) {
  14661. // If there is an error parsing the URL, assume it is crossDomain,
  14662. // it can be rejected by the transport if it is invalid
  14663. s.crossDomain = true;
  14664. }
  14665. }
  14666. // Convert data if not already a string
  14667. if ( s.data && s.processData && typeof s.data !== "string" ) {
  14668. s.data = jQuery.param( s.data, s.traditional );
  14669. }
  14670. // Apply prefilters
  14671. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  14672. // If request was aborted inside a prefilter, stop there
  14673. if ( completed ) {
  14674. return jqXHR;
  14675. }
  14676. // We can fire global events as of now if asked to
  14677. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  14678. fireGlobals = jQuery.event && s.global;
  14679. // Watch for a new set of requests
  14680. if ( fireGlobals && jQuery.active++ === 0 ) {
  14681. jQuery.event.trigger( "ajaxStart" );
  14682. }
  14683. // Uppercase the type
  14684. s.type = s.type.toUpperCase();
  14685. // Determine if request has content
  14686. s.hasContent = !rnoContent.test( s.type );
  14687. // Save the URL in case we're toying with the If-Modified-Since
  14688. // and/or If-None-Match header later on
  14689. // Remove hash to simplify url manipulation
  14690. cacheURL = s.url.replace( rhash, "" );
  14691. // More options handling for requests with no content
  14692. if ( !s.hasContent ) {
  14693. // Remember the hash so we can put it back
  14694. uncached = s.url.slice( cacheURL.length );
  14695. // If data is available and should be processed, append data to url
  14696. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  14697. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  14698. // #9682: remove data so that it's not used in an eventual retry
  14699. delete s.data;
  14700. }
  14701. // Add or update anti-cache param if needed
  14702. if ( s.cache === false ) {
  14703. cacheURL = cacheURL.replace( rantiCache, "$1" );
  14704. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  14705. }
  14706. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  14707. s.url = cacheURL + uncached;
  14708. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  14709. } else if ( s.data && s.processData &&
  14710. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  14711. s.data = s.data.replace( r20, "+" );
  14712. }
  14713. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14714. if ( s.ifModified ) {
  14715. if ( jQuery.lastModified[ cacheURL ] ) {
  14716. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  14717. }
  14718. if ( jQuery.etag[ cacheURL ] ) {
  14719. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  14720. }
  14721. }
  14722. // Set the correct header, if data is being sent
  14723. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  14724. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  14725. }
  14726. // Set the Accepts header for the server, depending on the dataType
  14727. jqXHR.setRequestHeader(
  14728. "Accept",
  14729. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  14730. s.accepts[ s.dataTypes[ 0 ] ] +
  14731. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  14732. s.accepts[ "*" ]
  14733. );
  14734. // Check for headers option
  14735. for ( i in s.headers ) {
  14736. jqXHR.setRequestHeader( i, s.headers[ i ] );
  14737. }
  14738. // Allow custom headers/mimetypes and early abort
  14739. if ( s.beforeSend &&
  14740. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  14741. // Abort if not done already and return
  14742. return jqXHR.abort();
  14743. }
  14744. // Aborting is no longer a cancellation
  14745. strAbort = "abort";
  14746. // Install callbacks on deferreds
  14747. completeDeferred.add( s.complete );
  14748. jqXHR.done( s.success );
  14749. jqXHR.fail( s.error );
  14750. // Get transport
  14751. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  14752. // If no transport, we auto-abort
  14753. if ( !transport ) {
  14754. done( -1, "No Transport" );
  14755. } else {
  14756. jqXHR.readyState = 1;
  14757. // Send global event
  14758. if ( fireGlobals ) {
  14759. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  14760. }
  14761. // If request was aborted inside ajaxSend, stop there
  14762. if ( completed ) {
  14763. return jqXHR;
  14764. }
  14765. // Timeout
  14766. if ( s.async && s.timeout > 0 ) {
  14767. timeoutTimer = window.setTimeout( function() {
  14768. jqXHR.abort( "timeout" );
  14769. }, s.timeout );
  14770. }
  14771. try {
  14772. completed = false;
  14773. transport.send( requestHeaders, done );
  14774. } catch ( e ) {
  14775. // Rethrow post-completion exceptions
  14776. if ( completed ) {
  14777. throw e;
  14778. }
  14779. // Propagate others as results
  14780. done( -1, e );
  14781. }
  14782. }
  14783. // Callback for when everything is done
  14784. function done( status, nativeStatusText, responses, headers ) {
  14785. var isSuccess, success, error, response, modified,
  14786. statusText = nativeStatusText;
  14787. // Ignore repeat invocations
  14788. if ( completed ) {
  14789. return;
  14790. }
  14791. completed = true;
  14792. // Clear timeout if it exists
  14793. if ( timeoutTimer ) {
  14794. window.clearTimeout( timeoutTimer );
  14795. }
  14796. // Dereference transport for early garbage collection
  14797. // (no matter how long the jqXHR object will be used)
  14798. transport = undefined;
  14799. // Cache response headers
  14800. responseHeadersString = headers || "";
  14801. // Set readyState
  14802. jqXHR.readyState = status > 0 ? 4 : 0;
  14803. // Determine if successful
  14804. isSuccess = status >= 200 && status < 300 || status === 304;
  14805. // Get response data
  14806. if ( responses ) {
  14807. response = ajaxHandleResponses( s, jqXHR, responses );
  14808. }
  14809. // Convert no matter what (that way responseXXX fields are always set)
  14810. response = ajaxConvert( s, response, jqXHR, isSuccess );
  14811. // If successful, handle type chaining
  14812. if ( isSuccess ) {
  14813. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  14814. if ( s.ifModified ) {
  14815. modified = jqXHR.getResponseHeader( "Last-Modified" );
  14816. if ( modified ) {
  14817. jQuery.lastModified[ cacheURL ] = modified;
  14818. }
  14819. modified = jqXHR.getResponseHeader( "etag" );
  14820. if ( modified ) {
  14821. jQuery.etag[ cacheURL ] = modified;
  14822. }
  14823. }
  14824. // if no content
  14825. if ( status === 204 || s.type === "HEAD" ) {
  14826. statusText = "nocontent";
  14827. // if not modified
  14828. } else if ( status === 304 ) {
  14829. statusText = "notmodified";
  14830. // If we have data, let's convert it
  14831. } else {
  14832. statusText = response.state;
  14833. success = response.data;
  14834. error = response.error;
  14835. isSuccess = !error;
  14836. }
  14837. } else {
  14838. // Extract error from statusText and normalize for non-aborts
  14839. error = statusText;
  14840. if ( status || !statusText ) {
  14841. statusText = "error";
  14842. if ( status < 0 ) {
  14843. status = 0;
  14844. }
  14845. }
  14846. }
  14847. // Set data for the fake xhr object
  14848. jqXHR.status = status;
  14849. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  14850. // Success/Error
  14851. if ( isSuccess ) {
  14852. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  14853. } else {
  14854. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  14855. }
  14856. // Status-dependent callbacks
  14857. jqXHR.statusCode( statusCode );
  14858. statusCode = undefined;
  14859. if ( fireGlobals ) {
  14860. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  14861. [ jqXHR, s, isSuccess ? success : error ] );
  14862. }
  14863. // Complete
  14864. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  14865. if ( fireGlobals ) {
  14866. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  14867. // Handle the global AJAX counter
  14868. if ( !( --jQuery.active ) ) {
  14869. jQuery.event.trigger( "ajaxStop" );
  14870. }
  14871. }
  14872. }
  14873. return jqXHR;
  14874. },
  14875. getJSON: function( url, data, callback ) {
  14876. return jQuery.get( url, data, callback, "json" );
  14877. },
  14878. getScript: function( url, callback ) {
  14879. return jQuery.get( url, undefined, callback, "script" );
  14880. }
  14881. } );
  14882. jQuery.each( [ "get", "post" ], function( i, method ) {
  14883. jQuery[ method ] = function( url, data, callback, type ) {
  14884. // Shift arguments if data argument was omitted
  14885. if ( isFunction( data ) ) {
  14886. type = type || callback;
  14887. callback = data;
  14888. data = undefined;
  14889. }
  14890. // The url can be an options object (which then must have .url)
  14891. return jQuery.ajax( jQuery.extend( {
  14892. url: url,
  14893. type: method,
  14894. dataType: type,
  14895. data: data,
  14896. success: callback
  14897. }, jQuery.isPlainObject( url ) && url ) );
  14898. };
  14899. } );
  14900. jQuery._evalUrl = function( url, options ) {
  14901. return jQuery.ajax( {
  14902. url: url,
  14903. // Make this explicit, since user can override this through ajaxSetup (#11264)
  14904. type: "GET",
  14905. dataType: "script",
  14906. cache: true,
  14907. async: false,
  14908. global: false,
  14909. // Only evaluate the response if it is successful (gh-4126)
  14910. // dataFilter is not invoked for failure responses, so using it instead
  14911. // of the default converter is kludgy but it works.
  14912. converters: {
  14913. "text script": function() {}
  14914. },
  14915. dataFilter: function( response ) {
  14916. jQuery.globalEval( response, options );
  14917. }
  14918. } );
  14919. };
  14920. jQuery.fn.extend( {
  14921. wrapAll: function( html ) {
  14922. var wrap;
  14923. if ( this[ 0 ] ) {
  14924. if ( isFunction( html ) ) {
  14925. html = html.call( this[ 0 ] );
  14926. }
  14927. // The elements to wrap the target around
  14928. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  14929. if ( this[ 0 ].parentNode ) {
  14930. wrap.insertBefore( this[ 0 ] );
  14931. }
  14932. wrap.map( function() {
  14933. var elem = this;
  14934. while ( elem.firstElementChild ) {
  14935. elem = elem.firstElementChild;
  14936. }
  14937. return elem;
  14938. } ).append( this );
  14939. }
  14940. return this;
  14941. },
  14942. wrapInner: function( html ) {
  14943. if ( isFunction( html ) ) {
  14944. return this.each( function( i ) {
  14945. jQuery( this ).wrapInner( html.call( this, i ) );
  14946. } );
  14947. }
  14948. return this.each( function() {
  14949. var self = jQuery( this ),
  14950. contents = self.contents();
  14951. if ( contents.length ) {
  14952. contents.wrapAll( html );
  14953. } else {
  14954. self.append( html );
  14955. }
  14956. } );
  14957. },
  14958. wrap: function( html ) {
  14959. var htmlIsFunction = isFunction( html );
  14960. return this.each( function( i ) {
  14961. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  14962. } );
  14963. },
  14964. unwrap: function( selector ) {
  14965. this.parent( selector ).not( "body" ).each( function() {
  14966. jQuery( this ).replaceWith( this.childNodes );
  14967. } );
  14968. return this;
  14969. }
  14970. } );
  14971. jQuery.expr.pseudos.hidden = function( elem ) {
  14972. return !jQuery.expr.pseudos.visible( elem );
  14973. };
  14974. jQuery.expr.pseudos.visible = function( elem ) {
  14975. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  14976. };
  14977. jQuery.ajaxSettings.xhr = function() {
  14978. try {
  14979. return new window.XMLHttpRequest();
  14980. } catch ( e ) {}
  14981. };
  14982. var xhrSuccessStatus = {
  14983. // File protocol always yields status code 0, assume 200
  14984. 0: 200,
  14985. // Support: IE <=9 only
  14986. // #1450: sometimes IE returns 1223 when it should be 204
  14987. 1223: 204
  14988. },
  14989. xhrSupported = jQuery.ajaxSettings.xhr();
  14990. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  14991. support.ajax = xhrSupported = !!xhrSupported;
  14992. jQuery.ajaxTransport( function( options ) {
  14993. var callback, errorCallback;
  14994. // Cross domain only allowed if supported through XMLHttpRequest
  14995. if ( support.cors || xhrSupported && !options.crossDomain ) {
  14996. return {
  14997. send: function( headers, complete ) {
  14998. var i,
  14999. xhr = options.xhr();
  15000. xhr.open(
  15001. options.type,
  15002. options.url,
  15003. options.async,
  15004. options.username,
  15005. options.password
  15006. );
  15007. // Apply custom fields if provided
  15008. if ( options.xhrFields ) {
  15009. for ( i in options.xhrFields ) {
  15010. xhr[ i ] = options.xhrFields[ i ];
  15011. }
  15012. }
  15013. // Override mime type if needed
  15014. if ( options.mimeType && xhr.overrideMimeType ) {
  15015. xhr.overrideMimeType( options.mimeType );
  15016. }
  15017. // X-Requested-With header
  15018. // For cross-domain requests, seeing as conditions for a preflight are
  15019. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15020. // (it can always be set on a per-request basis or even using ajaxSetup)
  15021. // For same-domain requests, won't change header if already provided.
  15022. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15023. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15024. }
  15025. // Set headers
  15026. for ( i in headers ) {
  15027. xhr.setRequestHeader( i, headers[ i ] );
  15028. }
  15029. // Callback
  15030. callback = function( type ) {
  15031. return function() {
  15032. if ( callback ) {
  15033. callback = errorCallback = xhr.onload =
  15034. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15035. xhr.onreadystatechange = null;
  15036. if ( type === "abort" ) {
  15037. xhr.abort();
  15038. } else if ( type === "error" ) {
  15039. // Support: IE <=9 only
  15040. // On a manual native abort, IE9 throws
  15041. // errors on any property access that is not readyState
  15042. if ( typeof xhr.status !== "number" ) {
  15043. complete( 0, "error" );
  15044. } else {
  15045. complete(
  15046. // File: protocol always yields status 0; see #8605, #14207
  15047. xhr.status,
  15048. xhr.statusText
  15049. );
  15050. }
  15051. } else {
  15052. complete(
  15053. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15054. xhr.statusText,
  15055. // Support: IE <=9 only
  15056. // IE9 has no XHR2 but throws on binary (trac-11426)
  15057. // For XHR2 non-text, let the caller handle it (gh-2498)
  15058. ( xhr.responseType || "text" ) !== "text" ||
  15059. typeof xhr.responseText !== "string" ?
  15060. { binary: xhr.response } :
  15061. { text: xhr.responseText },
  15062. xhr.getAllResponseHeaders()
  15063. );
  15064. }
  15065. }
  15066. };
  15067. };
  15068. // Listen to events
  15069. xhr.onload = callback();
  15070. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  15071. // Support: IE 9 only
  15072. // Use onreadystatechange to replace onabort
  15073. // to handle uncaught aborts
  15074. if ( xhr.onabort !== undefined ) {
  15075. xhr.onabort = errorCallback;
  15076. } else {
  15077. xhr.onreadystatechange = function() {
  15078. // Check readyState before timeout as it changes
  15079. if ( xhr.readyState === 4 ) {
  15080. // Allow onerror to be called first,
  15081. // but that will not handle a native abort
  15082. // Also, save errorCallback to a variable
  15083. // as xhr.onerror cannot be accessed
  15084. window.setTimeout( function() {
  15085. if ( callback ) {
  15086. errorCallback();
  15087. }
  15088. } );
  15089. }
  15090. };
  15091. }
  15092. // Create the abort callback
  15093. callback = callback( "abort" );
  15094. try {
  15095. // Do send the request (this may raise an exception)
  15096. xhr.send( options.hasContent && options.data || null );
  15097. } catch ( e ) {
  15098. // #14683: Only rethrow if this hasn't been notified as an error yet
  15099. if ( callback ) {
  15100. throw e;
  15101. }
  15102. }
  15103. },
  15104. abort: function() {
  15105. if ( callback ) {
  15106. callback();
  15107. }
  15108. }
  15109. };
  15110. }
  15111. } );
  15112. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  15113. jQuery.ajaxPrefilter( function( s ) {
  15114. if ( s.crossDomain ) {
  15115. s.contents.script = false;
  15116. }
  15117. } );
  15118. // Install script dataType
  15119. jQuery.ajaxSetup( {
  15120. accepts: {
  15121. script: "text/javascript, application/javascript, " +
  15122. "application/ecmascript, application/x-ecmascript"
  15123. },
  15124. contents: {
  15125. script: /\b(?:java|ecma)script\b/
  15126. },
  15127. converters: {
  15128. "text script": function( text ) {
  15129. jQuery.globalEval( text );
  15130. return text;
  15131. }
  15132. }
  15133. } );
  15134. // Handle cache's special case and crossDomain
  15135. jQuery.ajaxPrefilter( "script", function( s ) {
  15136. if ( s.cache === undefined ) {
  15137. s.cache = false;
  15138. }
  15139. if ( s.crossDomain ) {
  15140. s.type = "GET";
  15141. }
  15142. } );
  15143. // Bind script tag hack transport
  15144. jQuery.ajaxTransport( "script", function( s ) {
  15145. // This transport only deals with cross domain or forced-by-attrs requests
  15146. if ( s.crossDomain || s.scriptAttrs ) {
  15147. var script, callback;
  15148. return {
  15149. send: function( _, complete ) {
  15150. script = jQuery( "<script>" )
  15151. .attr( s.scriptAttrs || {} )
  15152. .prop( { charset: s.scriptCharset, src: s.url } )
  15153. .on( "load error", callback = function( evt ) {
  15154. script.remove();
  15155. callback = null;
  15156. if ( evt ) {
  15157. complete( evt.type === "error" ? 404 : 200, evt.type );
  15158. }
  15159. } );
  15160. // Use native DOM manipulation to avoid our domManip AJAX trickery
  15161. document.head.appendChild( script[ 0 ] );
  15162. },
  15163. abort: function() {
  15164. if ( callback ) {
  15165. callback();
  15166. }
  15167. }
  15168. };
  15169. }
  15170. } );
  15171. var oldCallbacks = [],
  15172. rjsonp = /(=)\?(?=&|$)|\?\?/;
  15173. // Default jsonp settings
  15174. jQuery.ajaxSetup( {
  15175. jsonp: "callback",
  15176. jsonpCallback: function() {
  15177. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  15178. this[ callback ] = true;
  15179. return callback;
  15180. }
  15181. } );
  15182. // Detect, normalize options and install callbacks for jsonp requests
  15183. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  15184. var callbackName, overwritten, responseContainer,
  15185. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  15186. "url" :
  15187. typeof s.data === "string" &&
  15188. ( s.contentType || "" )
  15189. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  15190. rjsonp.test( s.data ) && "data"
  15191. );
  15192. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  15193. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  15194. // Get callback name, remembering preexisting value associated with it
  15195. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  15196. s.jsonpCallback() :
  15197. s.jsonpCallback;
  15198. // Insert callback into url or form data
  15199. if ( jsonProp ) {
  15200. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  15201. } else if ( s.jsonp !== false ) {
  15202. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  15203. }
  15204. // Use data converter to retrieve json after script execution
  15205. s.converters[ "script json" ] = function() {
  15206. if ( !responseContainer ) {
  15207. jQuery.error( callbackName + " was not called" );
  15208. }
  15209. return responseContainer[ 0 ];
  15210. };
  15211. // Force json dataType
  15212. s.dataTypes[ 0 ] = "json";
  15213. // Install callback
  15214. overwritten = window[ callbackName ];
  15215. window[ callbackName ] = function() {
  15216. responseContainer = arguments;
  15217. };
  15218. // Clean-up function (fires after converters)
  15219. jqXHR.always( function() {
  15220. // If previous value didn't exist - remove it
  15221. if ( overwritten === undefined ) {
  15222. jQuery( window ).removeProp( callbackName );
  15223. // Otherwise restore preexisting value
  15224. } else {
  15225. window[ callbackName ] = overwritten;
  15226. }
  15227. // Save back as free
  15228. if ( s[ callbackName ] ) {
  15229. // Make sure that re-using the options doesn't screw things around
  15230. s.jsonpCallback = originalSettings.jsonpCallback;
  15231. // Save the callback name for future use
  15232. oldCallbacks.push( callbackName );
  15233. }
  15234. // Call if it was a function and we have a response
  15235. if ( responseContainer && isFunction( overwritten ) ) {
  15236. overwritten( responseContainer[ 0 ] );
  15237. }
  15238. responseContainer = overwritten = undefined;
  15239. } );
  15240. // Delegate to script
  15241. return "script";
  15242. }
  15243. } );
  15244. // Support: Safari 8 only
  15245. // In Safari 8 documents created via document.implementation.createHTMLDocument
  15246. // collapse sibling forms: the second one becomes a child of the first one.
  15247. // Because of that, this security measure has to be disabled in Safari 8.
  15248. // https://bugs.webkit.org/show_bug.cgi?id=137337
  15249. support.createHTMLDocument = ( function() {
  15250. var body = document.implementation.createHTMLDocument( "" ).body;
  15251. body.innerHTML = "<form></form><form></form>";
  15252. return body.childNodes.length === 2;
  15253. } )();
  15254. // Argument "data" should be string of html
  15255. // context (optional): If specified, the fragment will be created in this context,
  15256. // defaults to document
  15257. // keepScripts (optional): If true, will include scripts passed in the html string
  15258. jQuery.parseHTML = function( data, context, keepScripts ) {
  15259. if ( typeof data !== "string" ) {
  15260. return [];
  15261. }
  15262. if ( typeof context === "boolean" ) {
  15263. keepScripts = context;
  15264. context = false;
  15265. }
  15266. var base, parsed, scripts;
  15267. if ( !context ) {
  15268. // Stop scripts or inline event handlers from being executed immediately
  15269. // by using document.implementation
  15270. if ( support.createHTMLDocument ) {
  15271. context = document.implementation.createHTMLDocument( "" );
  15272. // Set the base href for the created document
  15273. // so any parsed elements with URLs
  15274. // are based on the document's URL (gh-2965)
  15275. base = context.createElement( "base" );
  15276. base.href = document.location.href;
  15277. context.head.appendChild( base );
  15278. } else {
  15279. context = document;
  15280. }
  15281. }
  15282. parsed = rsingleTag.exec( data );
  15283. scripts = !keepScripts && [];
  15284. // Single tag
  15285. if ( parsed ) {
  15286. return [ context.createElement( parsed[ 1 ] ) ];
  15287. }
  15288. parsed = buildFragment( [ data ], context, scripts );
  15289. if ( scripts && scripts.length ) {
  15290. jQuery( scripts ).remove();
  15291. }
  15292. return jQuery.merge( [], parsed.childNodes );
  15293. };
  15294. /**
  15295. * Load a url into a page
  15296. */
  15297. jQuery.fn.load = function( url, params, callback ) {
  15298. var selector, type, response,
  15299. self = this,
  15300. off = url.indexOf( " " );
  15301. if ( off > -1 ) {
  15302. selector = stripAndCollapse( url.slice( off ) );
  15303. url = url.slice( 0, off );
  15304. }
  15305. // If it's a function
  15306. if ( isFunction( params ) ) {
  15307. // We assume that it's the callback
  15308. callback = params;
  15309. params = undefined;
  15310. // Otherwise, build a param string
  15311. } else if ( params && typeof params === "object" ) {
  15312. type = "POST";
  15313. }
  15314. // If we have elements to modify, make the request
  15315. if ( self.length > 0 ) {
  15316. jQuery.ajax( {
  15317. url: url,
  15318. // If "type" variable is undefined, then "GET" method will be used.
  15319. // Make value of this field explicit since
  15320. // user can override it through ajaxSetup method
  15321. type: type || "GET",
  15322. dataType: "html",
  15323. data: params
  15324. } ).done( function( responseText ) {
  15325. // Save response for use in complete callback
  15326. response = arguments;
  15327. self.html( selector ?
  15328. // If a selector was specified, locate the right elements in a dummy div
  15329. // Exclude scripts to avoid IE 'Permission Denied' errors
  15330. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  15331. // Otherwise use the full result
  15332. responseText );
  15333. // If the request succeeds, this function gets "data", "status", "jqXHR"
  15334. // but they are ignored because response was set above.
  15335. // If it fails, this function gets "jqXHR", "status", "error"
  15336. } ).always( callback && function( jqXHR, status ) {
  15337. self.each( function() {
  15338. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  15339. } );
  15340. } );
  15341. }
  15342. return this;
  15343. };
  15344. // Attach a bunch of functions for handling common AJAX events
  15345. jQuery.each( [
  15346. "ajaxStart",
  15347. "ajaxStop",
  15348. "ajaxComplete",
  15349. "ajaxError",
  15350. "ajaxSuccess",
  15351. "ajaxSend"
  15352. ], function( i, type ) {
  15353. jQuery.fn[ type ] = function( fn ) {
  15354. return this.on( type, fn );
  15355. };
  15356. } );
  15357. jQuery.expr.pseudos.animated = function( elem ) {
  15358. return jQuery.grep( jQuery.timers, function( fn ) {
  15359. return elem === fn.elem;
  15360. } ).length;
  15361. };
  15362. jQuery.offset = {
  15363. setOffset: function( elem, options, i ) {
  15364. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  15365. position = jQuery.css( elem, "position" ),
  15366. curElem = jQuery( elem ),
  15367. props = {};
  15368. // Set position first, in-case top/left are set even on static elem
  15369. if ( position === "static" ) {
  15370. elem.style.position = "relative";
  15371. }
  15372. curOffset = curElem.offset();
  15373. curCSSTop = jQuery.css( elem, "top" );
  15374. curCSSLeft = jQuery.css( elem, "left" );
  15375. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  15376. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  15377. // Need to be able to calculate position if either
  15378. // top or left is auto and position is either absolute or fixed
  15379. if ( calculatePosition ) {
  15380. curPosition = curElem.position();
  15381. curTop = curPosition.top;
  15382. curLeft = curPosition.left;
  15383. } else {
  15384. curTop = parseFloat( curCSSTop ) || 0;
  15385. curLeft = parseFloat( curCSSLeft ) || 0;
  15386. }
  15387. if ( isFunction( options ) ) {
  15388. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  15389. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  15390. }
  15391. if ( options.top != null ) {
  15392. props.top = ( options.top - curOffset.top ) + curTop;
  15393. }
  15394. if ( options.left != null ) {
  15395. props.left = ( options.left - curOffset.left ) + curLeft;
  15396. }
  15397. if ( "using" in options ) {
  15398. options.using.call( elem, props );
  15399. } else {
  15400. curElem.css( props );
  15401. }
  15402. }
  15403. };
  15404. jQuery.fn.extend( {
  15405. // offset() relates an element's border box to the document origin
  15406. offset: function( options ) {
  15407. // Preserve chaining for setter
  15408. if ( arguments.length ) {
  15409. return options === undefined ?
  15410. this :
  15411. this.each( function( i ) {
  15412. jQuery.offset.setOffset( this, options, i );
  15413. } );
  15414. }
  15415. var rect, win,
  15416. elem = this[ 0 ];
  15417. if ( !elem ) {
  15418. return;
  15419. }
  15420. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  15421. // Support: IE <=11 only
  15422. // Running getBoundingClientRect on a
  15423. // disconnected node in IE throws an error
  15424. if ( !elem.getClientRects().length ) {
  15425. return { top: 0, left: 0 };
  15426. }
  15427. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  15428. rect = elem.getBoundingClientRect();
  15429. win = elem.ownerDocument.defaultView;
  15430. return {
  15431. top: rect.top + win.pageYOffset,
  15432. left: rect.left + win.pageXOffset
  15433. };
  15434. },
  15435. // position() relates an element's margin box to its offset parent's padding box
  15436. // This corresponds to the behavior of CSS absolute positioning
  15437. position: function() {
  15438. if ( !this[ 0 ] ) {
  15439. return;
  15440. }
  15441. var offsetParent, offset, doc,
  15442. elem = this[ 0 ],
  15443. parentOffset = { top: 0, left: 0 };
  15444. // position:fixed elements are offset from the viewport, which itself always has zero offset
  15445. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  15446. // Assume position:fixed implies availability of getBoundingClientRect
  15447. offset = elem.getBoundingClientRect();
  15448. } else {
  15449. offset = this.offset();
  15450. // Account for the *real* offset parent, which can be the document or its root element
  15451. // when a statically positioned element is identified
  15452. doc = elem.ownerDocument;
  15453. offsetParent = elem.offsetParent || doc.documentElement;
  15454. while ( offsetParent &&
  15455. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  15456. jQuery.css( offsetParent, "position" ) === "static" ) {
  15457. offsetParent = offsetParent.parentNode;
  15458. }
  15459. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  15460. // Incorporate borders into its offset, since they are outside its content origin
  15461. parentOffset = jQuery( offsetParent ).offset();
  15462. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  15463. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  15464. }
  15465. }
  15466. // Subtract parent offsets and element margins
  15467. return {
  15468. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  15469. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  15470. };
  15471. },
  15472. // This method will return documentElement in the following cases:
  15473. // 1) For the element inside the iframe without offsetParent, this method will return
  15474. // documentElement of the parent window
  15475. // 2) For the hidden or detached element
  15476. // 3) For body or html element, i.e. in case of the html node - it will return itself
  15477. //
  15478. // but those exceptions were never presented as a real life use-cases
  15479. // and might be considered as more preferable results.
  15480. //
  15481. // This logic, however, is not guaranteed and can change at any point in the future
  15482. offsetParent: function() {
  15483. return this.map( function() {
  15484. var offsetParent = this.offsetParent;
  15485. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  15486. offsetParent = offsetParent.offsetParent;
  15487. }
  15488. return offsetParent || documentElement;
  15489. } );
  15490. }
  15491. } );
  15492. // Create scrollLeft and scrollTop methods
  15493. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  15494. var top = "pageYOffset" === prop;
  15495. jQuery.fn[ method ] = function( val ) {
  15496. return access( this, function( elem, method, val ) {
  15497. // Coalesce documents and windows
  15498. var win;
  15499. if ( isWindow( elem ) ) {
  15500. win = elem;
  15501. } else if ( elem.nodeType === 9 ) {
  15502. win = elem.defaultView;
  15503. }
  15504. if ( val === undefined ) {
  15505. return win ? win[ prop ] : elem[ method ];
  15506. }
  15507. if ( win ) {
  15508. win.scrollTo(
  15509. !top ? val : win.pageXOffset,
  15510. top ? val : win.pageYOffset
  15511. );
  15512. } else {
  15513. elem[ method ] = val;
  15514. }
  15515. }, method, val, arguments.length );
  15516. };
  15517. } );
  15518. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  15519. // Add the top/left cssHooks using jQuery.fn.position
  15520. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  15521. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  15522. // getComputedStyle returns percent when specified for top/left/bottom/right;
  15523. // rather than make the css module depend on the offset module, just check for it here
  15524. jQuery.each( [ "top", "left" ], function( i, prop ) {
  15525. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  15526. function( elem, computed ) {
  15527. if ( computed ) {
  15528. computed = curCSS( elem, prop );
  15529. // If curCSS returns percentage, fallback to offset
  15530. return rnumnonpx.test( computed ) ?
  15531. jQuery( elem ).position()[ prop ] + "px" :
  15532. computed;
  15533. }
  15534. }
  15535. );
  15536. } );
  15537. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  15538. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  15539. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  15540. function( defaultExtra, funcName ) {
  15541. // Margin is only for outerHeight, outerWidth
  15542. jQuery.fn[ funcName ] = function( margin, value ) {
  15543. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  15544. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  15545. return access( this, function( elem, type, value ) {
  15546. var doc;
  15547. if ( isWindow( elem ) ) {
  15548. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  15549. return funcName.indexOf( "outer" ) === 0 ?
  15550. elem[ "inner" + name ] :
  15551. elem.document.documentElement[ "client" + name ];
  15552. }
  15553. // Get document width or height
  15554. if ( elem.nodeType === 9 ) {
  15555. doc = elem.documentElement;
  15556. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  15557. // whichever is greatest
  15558. return Math.max(
  15559. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  15560. elem.body[ "offset" + name ], doc[ "offset" + name ],
  15561. doc[ "client" + name ]
  15562. );
  15563. }
  15564. return value === undefined ?
  15565. // Get width or height on the element, requesting but not forcing parseFloat
  15566. jQuery.css( elem, type, extra ) :
  15567. // Set width or height on the element
  15568. jQuery.style( elem, type, value, extra );
  15569. }, type, chainable ? margin : undefined, chainable );
  15570. };
  15571. } );
  15572. } );
  15573. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  15574. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  15575. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  15576. function( i, name ) {
  15577. // Handle event binding
  15578. jQuery.fn[ name ] = function( data, fn ) {
  15579. return arguments.length > 0 ?
  15580. this.on( name, null, data, fn ) :
  15581. this.trigger( name );
  15582. };
  15583. } );
  15584. jQuery.fn.extend( {
  15585. hover: function( fnOver, fnOut ) {
  15586. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  15587. }
  15588. } );
  15589. jQuery.fn.extend( {
  15590. bind: function( types, data, fn ) {
  15591. return this.on( types, null, data, fn );
  15592. },
  15593. unbind: function( types, fn ) {
  15594. return this.off( types, null, fn );
  15595. },
  15596. delegate: function( selector, types, data, fn ) {
  15597. return this.on( types, selector, data, fn );
  15598. },
  15599. undelegate: function( selector, types, fn ) {
  15600. // ( namespace ) or ( selector, types [, fn] )
  15601. return arguments.length === 1 ?
  15602. this.off( selector, "**" ) :
  15603. this.off( types, selector || "**", fn );
  15604. }
  15605. } );
  15606. // Bind a function to a context, optionally partially applying any
  15607. // arguments.
  15608. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  15609. // However, it is not slated for removal any time soon
  15610. jQuery.proxy = function( fn, context ) {
  15611. var tmp, args, proxy;
  15612. if ( typeof context === "string" ) {
  15613. tmp = fn[ context ];
  15614. context = fn;
  15615. fn = tmp;
  15616. }
  15617. // Quick check to determine if target is callable, in the spec
  15618. // this throws a TypeError, but we will just return undefined.
  15619. if ( !isFunction( fn ) ) {
  15620. return undefined;
  15621. }
  15622. // Simulated bind
  15623. args = slice.call( arguments, 2 );
  15624. proxy = function() {
  15625. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  15626. };
  15627. // Set the guid of unique handler to the same of original handler, so it can be removed
  15628. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  15629. return proxy;
  15630. };
  15631. jQuery.holdReady = function( hold ) {
  15632. if ( hold ) {
  15633. jQuery.readyWait++;
  15634. } else {
  15635. jQuery.ready( true );
  15636. }
  15637. };
  15638. jQuery.isArray = Array.isArray;
  15639. jQuery.parseJSON = JSON.parse;
  15640. jQuery.nodeName = nodeName;
  15641. jQuery.isFunction = isFunction;
  15642. jQuery.isWindow = isWindow;
  15643. jQuery.camelCase = camelCase;
  15644. jQuery.type = toType;
  15645. jQuery.now = Date.now;
  15646. jQuery.isNumeric = function( obj ) {
  15647. // As of jQuery 3.0, isNumeric is limited to
  15648. // strings and numbers (primitives or objects)
  15649. // that can be coerced to finite numbers (gh-2662)
  15650. var type = jQuery.type( obj );
  15651. return ( type === "number" || type === "string" ) &&
  15652. // parseFloat NaNs numeric-cast false positives ("")
  15653. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  15654. // subtraction forces infinities to NaN
  15655. !isNaN( obj - parseFloat( obj ) );
  15656. };
  15657. // Register as a named AMD module, since jQuery can be concatenated with other
  15658. // files that may use define, but not via a proper concatenation script that
  15659. // understands anonymous AMD modules. A named AMD is safest and most robust
  15660. // way to register. Lowercase jquery is used because AMD module names are
  15661. // derived from file names, and jQuery is normally delivered in a lowercase
  15662. // file name. Do this after creating the global so that if an AMD module wants
  15663. // to call noConflict to hide this version of jQuery, it will work.
  15664. // Note that for maximum portability, libraries that are not jQuery should
  15665. // declare themselves as anonymous modules, and avoid setting a global if an
  15666. // AMD loader is present. jQuery is a special case. For more information, see
  15667. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  15668. if ( true ) {
  15669. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  15670. return jQuery;
  15671. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  15672. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  15673. }
  15674. var
  15675. // Map over jQuery in case of overwrite
  15676. _jQuery = window.jQuery,
  15677. // Map over the $ in case of overwrite
  15678. _$ = window.$;
  15679. jQuery.noConflict = function( deep ) {
  15680. if ( window.$ === jQuery ) {
  15681. window.$ = _$;
  15682. }
  15683. if ( deep && window.jQuery === jQuery ) {
  15684. window.jQuery = _jQuery;
  15685. }
  15686. return jQuery;
  15687. };
  15688. // Expose jQuery and $ identifiers, even in AMD
  15689. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  15690. // and CommonJS for browser emulators (#13566)
  15691. if ( !noGlobal ) {
  15692. window.jQuery = window.$ = jQuery;
  15693. }
  15694. return jQuery;
  15695. } );
  15696. /***/ }),
  15697. /***/ "./node_modules/laravel-echo/dist/echo.js":
  15698. /*!************************************************!*\
  15699. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  15700. \************************************************/
  15701. /*! exports provided: default */
  15702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15703. "use strict";
  15704. __webpack_require__.r(__webpack_exports__);
  15705. var classCallCheck = function (instance, Constructor) {
  15706. if (!(instance instanceof Constructor)) {
  15707. throw new TypeError("Cannot call a class as a function");
  15708. }
  15709. };
  15710. var createClass = function () {
  15711. function defineProperties(target, props) {
  15712. for (var i = 0; i < props.length; i++) {
  15713. var descriptor = props[i];
  15714. descriptor.enumerable = descriptor.enumerable || false;
  15715. descriptor.configurable = true;
  15716. if ("value" in descriptor) descriptor.writable = true;
  15717. Object.defineProperty(target, descriptor.key, descriptor);
  15718. }
  15719. }
  15720. return function (Constructor, protoProps, staticProps) {
  15721. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15722. if (staticProps) defineProperties(Constructor, staticProps);
  15723. return Constructor;
  15724. };
  15725. }();
  15726. var _extends = Object.assign || function (target) {
  15727. for (var i = 1; i < arguments.length; i++) {
  15728. var source = arguments[i];
  15729. for (var key in source) {
  15730. if (Object.prototype.hasOwnProperty.call(source, key)) {
  15731. target[key] = source[key];
  15732. }
  15733. }
  15734. }
  15735. return target;
  15736. };
  15737. var inherits = function (subClass, superClass) {
  15738. if (typeof superClass !== "function" && superClass !== null) {
  15739. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  15740. }
  15741. subClass.prototype = Object.create(superClass && superClass.prototype, {
  15742. constructor: {
  15743. value: subClass,
  15744. enumerable: false,
  15745. writable: true,
  15746. configurable: true
  15747. }
  15748. });
  15749. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  15750. };
  15751. var possibleConstructorReturn = function (self, call) {
  15752. if (!self) {
  15753. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  15754. }
  15755. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  15756. };
  15757. var Connector = function () {
  15758. /**
  15759. * Create a new class instance.
  15760. */
  15761. function Connector(options) {
  15762. classCallCheck(this, Connector);
  15763. /**
  15764. * Default connector options.
  15765. */
  15766. this._defaultOptions = {
  15767. auth: {
  15768. headers: {}
  15769. },
  15770. authEndpoint: '/broadcasting/auth',
  15771. broadcaster: 'pusher',
  15772. csrfToken: null,
  15773. host: null,
  15774. key: null,
  15775. namespace: 'App.Events'
  15776. };
  15777. this.setOptions(options);
  15778. this.connect();
  15779. }
  15780. /**
  15781. * Merge the custom options with the defaults.
  15782. */
  15783. createClass(Connector, [{
  15784. key: 'setOptions',
  15785. value: function setOptions(options) {
  15786. this.options = _extends(this._defaultOptions, options);
  15787. if (this.csrfToken()) {
  15788. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  15789. }
  15790. return options;
  15791. }
  15792. /**
  15793. * Extract the CSRF token from the page.
  15794. */
  15795. }, {
  15796. key: 'csrfToken',
  15797. value: function csrfToken() {
  15798. var selector = void 0;
  15799. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  15800. return window['Laravel'].csrfToken;
  15801. } else if (this.options.csrfToken) {
  15802. return this.options.csrfToken;
  15803. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  15804. return selector.getAttribute('content');
  15805. }
  15806. return null;
  15807. }
  15808. }]);
  15809. return Connector;
  15810. }();
  15811. /**
  15812. * This class represents a basic channel.
  15813. */
  15814. var Channel = function () {
  15815. function Channel() {
  15816. classCallCheck(this, Channel);
  15817. }
  15818. createClass(Channel, [{
  15819. key: 'listenForWhisper',
  15820. /**
  15821. * Listen for a whisper event on the channel instance.
  15822. */
  15823. value: function listenForWhisper(event, callback) {
  15824. return this.listen('.client-' + event, callback);
  15825. }
  15826. /**
  15827. * Listen for an event on the channel instance.
  15828. */
  15829. }, {
  15830. key: 'notification',
  15831. value: function notification(callback) {
  15832. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  15833. }
  15834. /**
  15835. * Stop listening for a whispser event on the channel instance.
  15836. */
  15837. }, {
  15838. key: 'stopListeningForWhisper',
  15839. value: function stopListeningForWhisper(event) {
  15840. return this.stopListening('.client-' + event);
  15841. }
  15842. }]);
  15843. return Channel;
  15844. }();
  15845. /**
  15846. * Event name formatter
  15847. */
  15848. var EventFormatter = function () {
  15849. /**
  15850. * Create a new class instance.
  15851. */
  15852. function EventFormatter(namespace) {
  15853. classCallCheck(this, EventFormatter);
  15854. this.setNamespace(namespace);
  15855. }
  15856. /**
  15857. * Format the given event name.
  15858. */
  15859. createClass(EventFormatter, [{
  15860. key: 'format',
  15861. value: function format(event) {
  15862. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  15863. return event.substr(1);
  15864. } else if (this.namespace) {
  15865. event = this.namespace + '.' + event;
  15866. }
  15867. return event.replace(/\./g, '\\');
  15868. }
  15869. /**
  15870. * Set the event namespace.
  15871. */
  15872. }, {
  15873. key: 'setNamespace',
  15874. value: function setNamespace(value) {
  15875. this.namespace = value;
  15876. }
  15877. }]);
  15878. return EventFormatter;
  15879. }();
  15880. /**
  15881. * This class represents a Pusher channel.
  15882. */
  15883. var PusherChannel = function (_Channel) {
  15884. inherits(PusherChannel, _Channel);
  15885. /**
  15886. * Create a new class instance.
  15887. */
  15888. function PusherChannel(pusher, name, options) {
  15889. classCallCheck(this, PusherChannel);
  15890. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  15891. _this.name = name;
  15892. _this.pusher = pusher;
  15893. _this.options = options;
  15894. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  15895. _this.subscribe();
  15896. return _this;
  15897. }
  15898. /**
  15899. * Subscribe to a Pusher channel.
  15900. */
  15901. createClass(PusherChannel, [{
  15902. key: 'subscribe',
  15903. value: function subscribe() {
  15904. this.subscription = this.pusher.subscribe(this.name);
  15905. }
  15906. /**
  15907. * Unsubscribe from a Pusher channel.
  15908. */
  15909. }, {
  15910. key: 'unsubscribe',
  15911. value: function unsubscribe() {
  15912. this.pusher.unsubscribe(this.name);
  15913. }
  15914. /**
  15915. * Listen for an event on the channel instance.
  15916. */
  15917. }, {
  15918. key: 'listen',
  15919. value: function listen(event, callback) {
  15920. this.on(this.eventFormatter.format(event), callback);
  15921. return this;
  15922. }
  15923. /**
  15924. * Stop listening for an event on the channel instance.
  15925. */
  15926. }, {
  15927. key: 'stopListening',
  15928. value: function stopListening(event) {
  15929. this.subscription.unbind(this.eventFormatter.format(event));
  15930. return this;
  15931. }
  15932. /**
  15933. * Bind a channel to an event.
  15934. */
  15935. }, {
  15936. key: 'on',
  15937. value: function on(event, callback) {
  15938. this.subscription.bind(event, callback);
  15939. return this;
  15940. }
  15941. }]);
  15942. return PusherChannel;
  15943. }(Channel);
  15944. /**
  15945. * This class represents a Pusher private channel.
  15946. */
  15947. var PusherPrivateChannel = function (_PusherChannel) {
  15948. inherits(PusherPrivateChannel, _PusherChannel);
  15949. function PusherPrivateChannel() {
  15950. classCallCheck(this, PusherPrivateChannel);
  15951. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  15952. }
  15953. createClass(PusherPrivateChannel, [{
  15954. key: 'whisper',
  15955. /**
  15956. * Trigger client event on the channel.
  15957. */
  15958. value: function whisper(eventName, data) {
  15959. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  15960. return this;
  15961. }
  15962. }]);
  15963. return PusherPrivateChannel;
  15964. }(PusherChannel);
  15965. /**
  15966. * This class represents a Pusher presence channel.
  15967. */
  15968. var PusherPresenceChannel = function (_PusherChannel) {
  15969. inherits(PusherPresenceChannel, _PusherChannel);
  15970. function PusherPresenceChannel() {
  15971. classCallCheck(this, PusherPresenceChannel);
  15972. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  15973. }
  15974. createClass(PusherPresenceChannel, [{
  15975. key: 'here',
  15976. /**
  15977. * Register a callback to be called anytime the member list changes.
  15978. */
  15979. value: function here(callback) {
  15980. this.on('pusher:subscription_succeeded', function (data) {
  15981. callback(Object.keys(data.members).map(function (k) {
  15982. return data.members[k];
  15983. }));
  15984. });
  15985. return this;
  15986. }
  15987. /**
  15988. * Listen for someone joining the channel.
  15989. */
  15990. }, {
  15991. key: 'joining',
  15992. value: function joining(callback) {
  15993. this.on('pusher:member_added', function (member) {
  15994. callback(member.info);
  15995. });
  15996. return this;
  15997. }
  15998. /**
  15999. * Listen for someone leaving the channel.
  16000. */
  16001. }, {
  16002. key: 'leaving',
  16003. value: function leaving(callback) {
  16004. this.on('pusher:member_removed', function (member) {
  16005. callback(member.info);
  16006. });
  16007. return this;
  16008. }
  16009. /**
  16010. * Trigger client event on the channel.
  16011. */
  16012. }, {
  16013. key: 'whisper',
  16014. value: function whisper(eventName, data) {
  16015. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16016. return this;
  16017. }
  16018. }]);
  16019. return PusherPresenceChannel;
  16020. }(PusherChannel);
  16021. /**
  16022. * This class represents a Socket.io channel.
  16023. */
  16024. var SocketIoChannel = function (_Channel) {
  16025. inherits(SocketIoChannel, _Channel);
  16026. /**
  16027. * Create a new class instance.
  16028. */
  16029. function SocketIoChannel(socket, name, options) {
  16030. classCallCheck(this, SocketIoChannel);
  16031. /**
  16032. * The event callbacks applied to the channel.
  16033. */
  16034. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16035. _this.events = {};
  16036. _this.name = name;
  16037. _this.socket = socket;
  16038. _this.options = options;
  16039. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16040. _this.subscribe();
  16041. _this.configureReconnector();
  16042. return _this;
  16043. }
  16044. /**
  16045. * Subscribe to a Socket.io channel.
  16046. */
  16047. createClass(SocketIoChannel, [{
  16048. key: 'subscribe',
  16049. value: function subscribe() {
  16050. this.socket.emit('subscribe', {
  16051. channel: this.name,
  16052. auth: this.options.auth || {}
  16053. });
  16054. }
  16055. /**
  16056. * Unsubscribe from channel and ubind event callbacks.
  16057. */
  16058. }, {
  16059. key: 'unsubscribe',
  16060. value: function unsubscribe() {
  16061. this.unbind();
  16062. this.socket.emit('unsubscribe', {
  16063. channel: this.name,
  16064. auth: this.options.auth || {}
  16065. });
  16066. }
  16067. /**
  16068. * Listen for an event on the channel instance.
  16069. */
  16070. }, {
  16071. key: 'listen',
  16072. value: function listen(event, callback) {
  16073. this.on(this.eventFormatter.format(event), callback);
  16074. return this;
  16075. }
  16076. /**
  16077. * Stop listening for an event on the channel instance.
  16078. */
  16079. }, {
  16080. key: 'stopListening',
  16081. value: function stopListening(event) {
  16082. var name = this.eventFormatter.format(event);
  16083. this.socket.removeListener(name);
  16084. delete this.events[name];
  16085. return this;
  16086. }
  16087. /**
  16088. * Bind the channel's socket to an event and store the callback.
  16089. */
  16090. }, {
  16091. key: 'on',
  16092. value: function on(event, callback) {
  16093. var _this2 = this;
  16094. var listener = function listener(channel, data) {
  16095. if (_this2.name == channel) {
  16096. callback(data);
  16097. }
  16098. };
  16099. this.socket.on(event, listener);
  16100. this.bind(event, listener);
  16101. }
  16102. /**
  16103. * Attach a 'reconnect' listener and bind the event.
  16104. */
  16105. }, {
  16106. key: 'configureReconnector',
  16107. value: function configureReconnector() {
  16108. var _this3 = this;
  16109. var listener = function listener() {
  16110. _this3.subscribe();
  16111. };
  16112. this.socket.on('reconnect', listener);
  16113. this.bind('reconnect', listener);
  16114. }
  16115. /**
  16116. * Bind the channel's socket to an event and store the callback.
  16117. */
  16118. }, {
  16119. key: 'bind',
  16120. value: function bind(event, callback) {
  16121. this.events[event] = this.events[event] || [];
  16122. this.events[event].push(callback);
  16123. }
  16124. /**
  16125. * Unbind the channel's socket from all stored event callbacks.
  16126. */
  16127. }, {
  16128. key: 'unbind',
  16129. value: function unbind() {
  16130. var _this4 = this;
  16131. Object.keys(this.events).forEach(function (event) {
  16132. _this4.events[event].forEach(function (callback) {
  16133. _this4.socket.removeListener(event, callback);
  16134. });
  16135. delete _this4.events[event];
  16136. });
  16137. }
  16138. }]);
  16139. return SocketIoChannel;
  16140. }(Channel);
  16141. /**
  16142. * This class represents a Socket.io presence channel.
  16143. */
  16144. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  16145. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  16146. function SocketIoPrivateChannel() {
  16147. classCallCheck(this, SocketIoPrivateChannel);
  16148. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  16149. }
  16150. createClass(SocketIoPrivateChannel, [{
  16151. key: 'whisper',
  16152. /**
  16153. * Trigger client event on the channel.
  16154. */
  16155. value: function whisper(eventName, data) {
  16156. this.socket.emit('client event', {
  16157. channel: this.name,
  16158. event: 'client-' + eventName,
  16159. data: data
  16160. });
  16161. return this;
  16162. }
  16163. }]);
  16164. return SocketIoPrivateChannel;
  16165. }(SocketIoChannel);
  16166. /**
  16167. * This class represents a Socket.io presence channel.
  16168. */
  16169. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  16170. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  16171. function SocketIoPresenceChannel() {
  16172. classCallCheck(this, SocketIoPresenceChannel);
  16173. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  16174. }
  16175. createClass(SocketIoPresenceChannel, [{
  16176. key: 'here',
  16177. /**
  16178. * Register a callback to be called anytime the member list changes.
  16179. */
  16180. value: function here(callback) {
  16181. this.on('presence:subscribed', function (members) {
  16182. callback(members.map(function (m) {
  16183. return m.user_info;
  16184. }));
  16185. });
  16186. return this;
  16187. }
  16188. /**
  16189. * Listen for someone joining the channel.
  16190. */
  16191. }, {
  16192. key: 'joining',
  16193. value: function joining(callback) {
  16194. this.on('presence:joining', function (member) {
  16195. return callback(member.user_info);
  16196. });
  16197. return this;
  16198. }
  16199. /**
  16200. * Listen for someone leaving the channel.
  16201. */
  16202. }, {
  16203. key: 'leaving',
  16204. value: function leaving(callback) {
  16205. this.on('presence:leaving', function (member) {
  16206. return callback(member.user_info);
  16207. });
  16208. return this;
  16209. }
  16210. }]);
  16211. return SocketIoPresenceChannel;
  16212. }(SocketIoPrivateChannel);
  16213. /**
  16214. * This class represents a null channel.
  16215. */
  16216. var NullChannel = function (_Channel) {
  16217. inherits(NullChannel, _Channel);
  16218. function NullChannel() {
  16219. classCallCheck(this, NullChannel);
  16220. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  16221. }
  16222. createClass(NullChannel, [{
  16223. key: 'subscribe',
  16224. /**
  16225. * Subscribe to a channel.
  16226. */
  16227. value: function subscribe() {}
  16228. //
  16229. /**
  16230. * Unsubscribe from a channel.
  16231. */
  16232. }, {
  16233. key: 'unsubscribe',
  16234. value: function unsubscribe() {}
  16235. //
  16236. /**
  16237. * Listen for an event on the channel instance.
  16238. */
  16239. }, {
  16240. key: 'listen',
  16241. value: function listen(event, callback) {
  16242. return this;
  16243. }
  16244. /**
  16245. * Stop listening for an event on the channel instance.
  16246. */
  16247. }, {
  16248. key: 'stopListening',
  16249. value: function stopListening(event) {
  16250. return this;
  16251. }
  16252. /**
  16253. * Bind a channel to an event.
  16254. */
  16255. }, {
  16256. key: 'on',
  16257. value: function on(event, callback) {
  16258. return this;
  16259. }
  16260. }]);
  16261. return NullChannel;
  16262. }(Channel);
  16263. /**
  16264. * This class represents a null private channel.
  16265. */
  16266. var NullPrivateChannel = function (_NullChannel) {
  16267. inherits(NullPrivateChannel, _NullChannel);
  16268. function NullPrivateChannel() {
  16269. classCallCheck(this, NullPrivateChannel);
  16270. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  16271. }
  16272. createClass(NullPrivateChannel, [{
  16273. key: 'whisper',
  16274. /**
  16275. * Trigger client event on the channel.
  16276. */
  16277. value: function whisper(eventName, data) {
  16278. return this;
  16279. }
  16280. }]);
  16281. return NullPrivateChannel;
  16282. }(NullChannel);
  16283. /**
  16284. * This class represents a null presence channel.
  16285. */
  16286. var NullPresenceChannel = function (_NullChannel) {
  16287. inherits(NullPresenceChannel, _NullChannel);
  16288. function NullPresenceChannel() {
  16289. classCallCheck(this, NullPresenceChannel);
  16290. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  16291. }
  16292. createClass(NullPresenceChannel, [{
  16293. key: 'here',
  16294. /**
  16295. * Register a callback to be called anytime the member list changes.
  16296. */
  16297. value: function here(callback) {
  16298. return this;
  16299. }
  16300. /**
  16301. * Listen for someone joining the channel.
  16302. */
  16303. }, {
  16304. key: 'joining',
  16305. value: function joining(callback) {
  16306. return this;
  16307. }
  16308. /**
  16309. * Listen for someone leaving the channel.
  16310. */
  16311. }, {
  16312. key: 'leaving',
  16313. value: function leaving(callback) {
  16314. return this;
  16315. }
  16316. /**
  16317. * Trigger client event on the channel.
  16318. */
  16319. }, {
  16320. key: 'whisper',
  16321. value: function whisper(eventName, data) {
  16322. return this;
  16323. }
  16324. }]);
  16325. return NullPresenceChannel;
  16326. }(NullChannel);
  16327. /**
  16328. * This class creates a connector to Pusher.
  16329. */
  16330. var PusherConnector = function (_Connector) {
  16331. inherits(PusherConnector, _Connector);
  16332. function PusherConnector() {
  16333. classCallCheck(this, PusherConnector);
  16334. /**
  16335. * All of the subscribed channel names.
  16336. */
  16337. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  16338. _this.channels = {};
  16339. return _this;
  16340. }
  16341. /**
  16342. * Create a fresh Pusher connection.
  16343. */
  16344. createClass(PusherConnector, [{
  16345. key: 'connect',
  16346. value: function connect() {
  16347. if (typeof this.options.client !== 'undefined') {
  16348. this.pusher = this.options.client;
  16349. } else {
  16350. this.pusher = new Pusher(this.options.key, this.options);
  16351. }
  16352. }
  16353. /**
  16354. * Listen for an event on a channel instance.
  16355. */
  16356. }, {
  16357. key: 'listen',
  16358. value: function listen(name, event, callback) {
  16359. return this.channel(name).listen(event, callback);
  16360. }
  16361. /**
  16362. * Get a channel instance by name.
  16363. */
  16364. }, {
  16365. key: 'channel',
  16366. value: function channel(name) {
  16367. if (!this.channels[name]) {
  16368. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  16369. }
  16370. return this.channels[name];
  16371. }
  16372. /**
  16373. * Get a private channel instance by name.
  16374. */
  16375. }, {
  16376. key: 'privateChannel',
  16377. value: function privateChannel(name) {
  16378. if (!this.channels['private-' + name]) {
  16379. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  16380. }
  16381. return this.channels['private-' + name];
  16382. }
  16383. /**
  16384. * Get a presence channel instance by name.
  16385. */
  16386. }, {
  16387. key: 'presenceChannel',
  16388. value: function presenceChannel(name) {
  16389. if (!this.channels['presence-' + name]) {
  16390. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  16391. }
  16392. return this.channels['presence-' + name];
  16393. }
  16394. /**
  16395. * Leave the given channel, as well as its private and presence variants.
  16396. */
  16397. }, {
  16398. key: 'leave',
  16399. value: function leave(name) {
  16400. var _this2 = this;
  16401. var channels = [name, 'private-' + name, 'presence-' + name];
  16402. channels.forEach(function (name, index) {
  16403. _this2.leaveChannel(name);
  16404. });
  16405. }
  16406. /**
  16407. * Leave the given channel.
  16408. */
  16409. }, {
  16410. key: 'leaveChannel',
  16411. value: function leaveChannel(name) {
  16412. if (this.channels[name]) {
  16413. this.channels[name].unsubscribe();
  16414. delete this.channels[name];
  16415. }
  16416. }
  16417. /**
  16418. * Get the socket ID for the connection.
  16419. */
  16420. }, {
  16421. key: 'socketId',
  16422. value: function socketId() {
  16423. return this.pusher.connection.socket_id;
  16424. }
  16425. /**
  16426. * Disconnect Pusher connection.
  16427. */
  16428. }, {
  16429. key: 'disconnect',
  16430. value: function disconnect() {
  16431. this.pusher.disconnect();
  16432. }
  16433. }]);
  16434. return PusherConnector;
  16435. }(Connector);
  16436. /**
  16437. * This class creates a connnector to a Socket.io server.
  16438. */
  16439. var SocketIoConnector = function (_Connector) {
  16440. inherits(SocketIoConnector, _Connector);
  16441. function SocketIoConnector() {
  16442. classCallCheck(this, SocketIoConnector);
  16443. /**
  16444. * All of the subscribed channel names.
  16445. */
  16446. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  16447. _this.channels = {};
  16448. return _this;
  16449. }
  16450. /**
  16451. * Create a fresh Socket.io connection.
  16452. */
  16453. createClass(SocketIoConnector, [{
  16454. key: 'connect',
  16455. value: function connect() {
  16456. var io = this.getSocketIO();
  16457. this.socket = io(this.options.host, this.options);
  16458. return this.socket;
  16459. }
  16460. /**
  16461. * Get socket.io module from global scope or options.
  16462. */
  16463. }, {
  16464. key: 'getSocketIO',
  16465. value: function getSocketIO() {
  16466. if (typeof this.options.client !== 'undefined') {
  16467. return this.options.client;
  16468. }
  16469. if (typeof io !== 'undefined') {
  16470. return io;
  16471. }
  16472. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  16473. }
  16474. /**
  16475. * Listen for an event on a channel instance.
  16476. */
  16477. }, {
  16478. key: 'listen',
  16479. value: function listen(name, event, callback) {
  16480. return this.channel(name).listen(event, callback);
  16481. }
  16482. /**
  16483. * Get a channel instance by name.
  16484. */
  16485. }, {
  16486. key: 'channel',
  16487. value: function channel(name) {
  16488. if (!this.channels[name]) {
  16489. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  16490. }
  16491. return this.channels[name];
  16492. }
  16493. /**
  16494. * Get a private channel instance by name.
  16495. */
  16496. }, {
  16497. key: 'privateChannel',
  16498. value: function privateChannel(name) {
  16499. if (!this.channels['private-' + name]) {
  16500. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  16501. }
  16502. return this.channels['private-' + name];
  16503. }
  16504. /**
  16505. * Get a presence channel instance by name.
  16506. */
  16507. }, {
  16508. key: 'presenceChannel',
  16509. value: function presenceChannel(name) {
  16510. if (!this.channels['presence-' + name]) {
  16511. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  16512. }
  16513. return this.channels['presence-' + name];
  16514. }
  16515. /**
  16516. * Leave the given channel, as well as its private and presence variants.
  16517. */
  16518. }, {
  16519. key: 'leave',
  16520. value: function leave(name) {
  16521. var _this2 = this;
  16522. var channels = [name, 'private-' + name, 'presence-' + name];
  16523. channels.forEach(function (name) {
  16524. _this2.leaveChannel(name);
  16525. });
  16526. }
  16527. /**
  16528. * Leave the given channel.
  16529. */
  16530. }, {
  16531. key: 'leaveChannel',
  16532. value: function leaveChannel(name) {
  16533. if (this.channels[name]) {
  16534. this.channels[name].unsubscribe();
  16535. delete this.channels[name];
  16536. }
  16537. }
  16538. /**
  16539. * Get the socket ID for the connection.
  16540. */
  16541. }, {
  16542. key: 'socketId',
  16543. value: function socketId() {
  16544. return this.socket.id;
  16545. }
  16546. /**
  16547. * Disconnect Socketio connection.
  16548. */
  16549. }, {
  16550. key: 'disconnect',
  16551. value: function disconnect() {
  16552. this.socket.disconnect();
  16553. }
  16554. }]);
  16555. return SocketIoConnector;
  16556. }(Connector);
  16557. /**
  16558. * This class creates a null connector.
  16559. */
  16560. var NullConnector = function (_Connector) {
  16561. inherits(NullConnector, _Connector);
  16562. function NullConnector() {
  16563. classCallCheck(this, NullConnector);
  16564. /**
  16565. * All of the subscribed channel names.
  16566. */
  16567. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  16568. _this.channels = {};
  16569. return _this;
  16570. }
  16571. /**
  16572. * Create a fresh connection.
  16573. */
  16574. createClass(NullConnector, [{
  16575. key: 'connect',
  16576. value: function connect() {}
  16577. //
  16578. /**
  16579. * Listen for an event on a channel instance.
  16580. */
  16581. }, {
  16582. key: 'listen',
  16583. value: function listen(name, event, callback) {
  16584. return new NullChannel();
  16585. }
  16586. /**
  16587. * Get a channel instance by name.
  16588. */
  16589. }, {
  16590. key: 'channel',
  16591. value: function channel(name) {
  16592. return new NullChannel();
  16593. }
  16594. /**
  16595. * Get a private channel instance by name.
  16596. */
  16597. }, {
  16598. key: 'privateChannel',
  16599. value: function privateChannel(name) {
  16600. return new NullPrivateChannel();
  16601. }
  16602. /**
  16603. * Get a presence channel instance by name.
  16604. */
  16605. }, {
  16606. key: 'presenceChannel',
  16607. value: function presenceChannel(name) {
  16608. return new NullPresenceChannel();
  16609. }
  16610. /**
  16611. * Leave the given channel, as well as its private and presence variants.
  16612. */
  16613. }, {
  16614. key: 'leave',
  16615. value: function leave(name) {}
  16616. //
  16617. /**
  16618. * Leave the given channel.
  16619. */
  16620. }, {
  16621. key: 'leaveChannel',
  16622. value: function leaveChannel(name) {}
  16623. //
  16624. /**
  16625. * Get the socket ID for the connection.
  16626. */
  16627. }, {
  16628. key: 'socketId',
  16629. value: function socketId() {
  16630. return 'fake-socket-id';
  16631. }
  16632. /**
  16633. * Disconnect the connection.
  16634. */
  16635. }, {
  16636. key: 'disconnect',
  16637. value: function disconnect() {
  16638. //
  16639. }
  16640. }]);
  16641. return NullConnector;
  16642. }(Connector);
  16643. /**
  16644. * This class is the primary API for interacting with broadcasting.
  16645. */
  16646. var Echo = function () {
  16647. /**
  16648. * Create a new class instance.
  16649. */
  16650. function Echo(options) {
  16651. classCallCheck(this, Echo);
  16652. this.options = options;
  16653. this.connect();
  16654. if (!this.options.withoutInterceptors) {
  16655. this.registerInterceptors();
  16656. }
  16657. }
  16658. /**
  16659. * Get a channel instance by name.
  16660. */
  16661. createClass(Echo, [{
  16662. key: 'channel',
  16663. value: function channel(_channel) {
  16664. return this.connector.channel(_channel);
  16665. }
  16666. /**
  16667. * Create a new connection.
  16668. */
  16669. }, {
  16670. key: 'connect',
  16671. value: function connect() {
  16672. if (this.options.broadcaster == 'pusher') {
  16673. this.connector = new PusherConnector(this.options);
  16674. } else if (this.options.broadcaster == 'socket.io') {
  16675. this.connector = new SocketIoConnector(this.options);
  16676. } else if (this.options.broadcaster == 'null') {
  16677. this.connector = new NullConnector(this.options);
  16678. } else if (typeof this.options.broadcaster == 'function') {
  16679. this.connector = new this.options.broadcaster(this.options);
  16680. }
  16681. }
  16682. /**
  16683. * Disconnect from the Echo server.
  16684. */
  16685. }, {
  16686. key: 'disconnect',
  16687. value: function disconnect() {
  16688. this.connector.disconnect();
  16689. }
  16690. /**
  16691. * Get a presence channel instance by name.
  16692. */
  16693. }, {
  16694. key: 'join',
  16695. value: function join(channel) {
  16696. return this.connector.presenceChannel(channel);
  16697. }
  16698. /**
  16699. * Leave the given channel, as well as its private and presence variants.
  16700. */
  16701. }, {
  16702. key: 'leave',
  16703. value: function leave(channel) {
  16704. this.connector.leave(channel);
  16705. }
  16706. /**
  16707. * Leave the given channel.
  16708. */
  16709. }, {
  16710. key: 'leaveChannel',
  16711. value: function leaveChannel(channel) {
  16712. this.connector.leaveChannel(channel);
  16713. }
  16714. /**
  16715. * Listen for an event on a channel instance.
  16716. */
  16717. }, {
  16718. key: 'listen',
  16719. value: function listen(channel, event, callback) {
  16720. return this.connector.listen(channel, event, callback);
  16721. }
  16722. /**
  16723. * Get a private channel instance by name.
  16724. */
  16725. }, {
  16726. key: 'private',
  16727. value: function _private(channel) {
  16728. return this.connector.privateChannel(channel);
  16729. }
  16730. /**
  16731. * Get the Socket ID for the connection.
  16732. */
  16733. }, {
  16734. key: 'socketId',
  16735. value: function socketId() {
  16736. return this.connector.socketId();
  16737. }
  16738. /**
  16739. * Register 3rd party request interceptiors. These are used to automatically
  16740. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  16741. */
  16742. }, {
  16743. key: 'registerInterceptors',
  16744. value: function registerInterceptors() {
  16745. if (typeof Vue === 'function' && Vue.http) {
  16746. this.registerVueRequestInterceptor();
  16747. }
  16748. if (typeof axios === 'function') {
  16749. this.registerAxiosRequestInterceptor();
  16750. }
  16751. if (typeof jQuery === 'function') {
  16752. this.registerjQueryAjaxSetup();
  16753. }
  16754. }
  16755. /**
  16756. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  16757. */
  16758. }, {
  16759. key: 'registerVueRequestInterceptor',
  16760. value: function registerVueRequestInterceptor() {
  16761. var _this = this;
  16762. Vue.http.interceptors.push(function (request, next) {
  16763. if (_this.socketId()) {
  16764. request.headers.set('X-Socket-ID', _this.socketId());
  16765. }
  16766. next();
  16767. });
  16768. }
  16769. /**
  16770. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  16771. */
  16772. }, {
  16773. key: 'registerAxiosRequestInterceptor',
  16774. value: function registerAxiosRequestInterceptor() {
  16775. var _this2 = this;
  16776. axios.interceptors.request.use(function (config) {
  16777. if (_this2.socketId()) {
  16778. config.headers['X-Socket-Id'] = _this2.socketId();
  16779. }
  16780. return config;
  16781. });
  16782. }
  16783. /**
  16784. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  16785. */
  16786. }, {
  16787. key: 'registerjQueryAjaxSetup',
  16788. value: function registerjQueryAjaxSetup() {
  16789. var _this3 = this;
  16790. if (typeof jQuery.ajax != 'undefined') {
  16791. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  16792. if (_this3.socketId()) {
  16793. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  16794. }
  16795. });
  16796. }
  16797. }
  16798. }]);
  16799. return Echo;
  16800. }();
  16801. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  16802. /***/ }),
  16803. /***/ "./node_modules/lodash/lodash.js":
  16804. /*!***************************************!*\
  16805. !*** ./node_modules/lodash/lodash.js ***!
  16806. \***************************************/
  16807. /*! no static exports found */
  16808. /***/ (function(module, exports, __webpack_require__) {
  16809. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  16810. * @license
  16811. * Lodash <https://lodash.com/>
  16812. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  16813. * Released under MIT license <https://lodash.com/license>
  16814. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  16815. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  16816. */
  16817. ;(function() {
  16818. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  16819. var undefined;
  16820. /** Used as the semantic version number. */
  16821. var VERSION = '4.17.15';
  16822. /** Used as the size to enable large array optimizations. */
  16823. var LARGE_ARRAY_SIZE = 200;
  16824. /** Error message constants. */
  16825. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  16826. FUNC_ERROR_TEXT = 'Expected a function';
  16827. /** Used to stand-in for `undefined` hash values. */
  16828. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  16829. /** Used as the maximum memoize cache size. */
  16830. var MAX_MEMOIZE_SIZE = 500;
  16831. /** Used as the internal argument placeholder. */
  16832. var PLACEHOLDER = '__lodash_placeholder__';
  16833. /** Used to compose bitmasks for cloning. */
  16834. var CLONE_DEEP_FLAG = 1,
  16835. CLONE_FLAT_FLAG = 2,
  16836. CLONE_SYMBOLS_FLAG = 4;
  16837. /** Used to compose bitmasks for value comparisons. */
  16838. var COMPARE_PARTIAL_FLAG = 1,
  16839. COMPARE_UNORDERED_FLAG = 2;
  16840. /** Used to compose bitmasks for function metadata. */
  16841. var WRAP_BIND_FLAG = 1,
  16842. WRAP_BIND_KEY_FLAG = 2,
  16843. WRAP_CURRY_BOUND_FLAG = 4,
  16844. WRAP_CURRY_FLAG = 8,
  16845. WRAP_CURRY_RIGHT_FLAG = 16,
  16846. WRAP_PARTIAL_FLAG = 32,
  16847. WRAP_PARTIAL_RIGHT_FLAG = 64,
  16848. WRAP_ARY_FLAG = 128,
  16849. WRAP_REARG_FLAG = 256,
  16850. WRAP_FLIP_FLAG = 512;
  16851. /** Used as default options for `_.truncate`. */
  16852. var DEFAULT_TRUNC_LENGTH = 30,
  16853. DEFAULT_TRUNC_OMISSION = '...';
  16854. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  16855. var HOT_COUNT = 800,
  16856. HOT_SPAN = 16;
  16857. /** Used to indicate the type of lazy iteratees. */
  16858. var LAZY_FILTER_FLAG = 1,
  16859. LAZY_MAP_FLAG = 2,
  16860. LAZY_WHILE_FLAG = 3;
  16861. /** Used as references for various `Number` constants. */
  16862. var INFINITY = 1 / 0,
  16863. MAX_SAFE_INTEGER = 9007199254740991,
  16864. MAX_INTEGER = 1.7976931348623157e+308,
  16865. NAN = 0 / 0;
  16866. /** Used as references for the maximum length and index of an array. */
  16867. var MAX_ARRAY_LENGTH = 4294967295,
  16868. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  16869. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  16870. /** Used to associate wrap methods with their bit flags. */
  16871. var wrapFlags = [
  16872. ['ary', WRAP_ARY_FLAG],
  16873. ['bind', WRAP_BIND_FLAG],
  16874. ['bindKey', WRAP_BIND_KEY_FLAG],
  16875. ['curry', WRAP_CURRY_FLAG],
  16876. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  16877. ['flip', WRAP_FLIP_FLAG],
  16878. ['partial', WRAP_PARTIAL_FLAG],
  16879. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  16880. ['rearg', WRAP_REARG_FLAG]
  16881. ];
  16882. /** `Object#toString` result references. */
  16883. var argsTag = '[object Arguments]',
  16884. arrayTag = '[object Array]',
  16885. asyncTag = '[object AsyncFunction]',
  16886. boolTag = '[object Boolean]',
  16887. dateTag = '[object Date]',
  16888. domExcTag = '[object DOMException]',
  16889. errorTag = '[object Error]',
  16890. funcTag = '[object Function]',
  16891. genTag = '[object GeneratorFunction]',
  16892. mapTag = '[object Map]',
  16893. numberTag = '[object Number]',
  16894. nullTag = '[object Null]',
  16895. objectTag = '[object Object]',
  16896. promiseTag = '[object Promise]',
  16897. proxyTag = '[object Proxy]',
  16898. regexpTag = '[object RegExp]',
  16899. setTag = '[object Set]',
  16900. stringTag = '[object String]',
  16901. symbolTag = '[object Symbol]',
  16902. undefinedTag = '[object Undefined]',
  16903. weakMapTag = '[object WeakMap]',
  16904. weakSetTag = '[object WeakSet]';
  16905. var arrayBufferTag = '[object ArrayBuffer]',
  16906. dataViewTag = '[object DataView]',
  16907. float32Tag = '[object Float32Array]',
  16908. float64Tag = '[object Float64Array]',
  16909. int8Tag = '[object Int8Array]',
  16910. int16Tag = '[object Int16Array]',
  16911. int32Tag = '[object Int32Array]',
  16912. uint8Tag = '[object Uint8Array]',
  16913. uint8ClampedTag = '[object Uint8ClampedArray]',
  16914. uint16Tag = '[object Uint16Array]',
  16915. uint32Tag = '[object Uint32Array]';
  16916. /** Used to match empty string literals in compiled template source. */
  16917. var reEmptyStringLeading = /\b__p \+= '';/g,
  16918. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  16919. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  16920. /** Used to match HTML entities and HTML characters. */
  16921. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  16922. reUnescapedHtml = /[&<>"']/g,
  16923. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  16924. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  16925. /** Used to match template delimiters. */
  16926. var reEscape = /<%-([\s\S]+?)%>/g,
  16927. reEvaluate = /<%([\s\S]+?)%>/g,
  16928. reInterpolate = /<%=([\s\S]+?)%>/g;
  16929. /** Used to match property names within property paths. */
  16930. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  16931. reIsPlainProp = /^\w*$/,
  16932. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  16933. /**
  16934. * Used to match `RegExp`
  16935. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  16936. */
  16937. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  16938. reHasRegExpChar = RegExp(reRegExpChar.source);
  16939. /** Used to match leading and trailing whitespace. */
  16940. var reTrim = /^\s+|\s+$/g,
  16941. reTrimStart = /^\s+/,
  16942. reTrimEnd = /\s+$/;
  16943. /** Used to match wrap detail comments. */
  16944. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  16945. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  16946. reSplitDetails = /,? & /;
  16947. /** Used to match words composed of alphanumeric characters. */
  16948. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  16949. /** Used to match backslashes in property paths. */
  16950. var reEscapeChar = /\\(\\)?/g;
  16951. /**
  16952. * Used to match
  16953. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  16954. */
  16955. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  16956. /** Used to match `RegExp` flags from their coerced string values. */
  16957. var reFlags = /\w*$/;
  16958. /** Used to detect bad signed hexadecimal string values. */
  16959. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  16960. /** Used to detect binary string values. */
  16961. var reIsBinary = /^0b[01]+$/i;
  16962. /** Used to detect host constructors (Safari). */
  16963. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  16964. /** Used to detect octal string values. */
  16965. var reIsOctal = /^0o[0-7]+$/i;
  16966. /** Used to detect unsigned integer values. */
  16967. var reIsUint = /^(?:0|[1-9]\d*)$/;
  16968. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  16969. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  16970. /** Used to ensure capturing order of template delimiters. */
  16971. var reNoMatch = /($^)/;
  16972. /** Used to match unescaped characters in compiled string literals. */
  16973. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  16974. /** Used to compose unicode character classes. */
  16975. var rsAstralRange = '\\ud800-\\udfff',
  16976. rsComboMarksRange = '\\u0300-\\u036f',
  16977. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  16978. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  16979. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  16980. rsDingbatRange = '\\u2700-\\u27bf',
  16981. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  16982. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  16983. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  16984. rsPunctuationRange = '\\u2000-\\u206f',
  16985. 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',
  16986. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  16987. rsVarRange = '\\ufe0e\\ufe0f',
  16988. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  16989. /** Used to compose unicode capture groups. */
  16990. var rsApos = "['\u2019]",
  16991. rsAstral = '[' + rsAstralRange + ']',
  16992. rsBreak = '[' + rsBreakRange + ']',
  16993. rsCombo = '[' + rsComboRange + ']',
  16994. rsDigits = '\\d+',
  16995. rsDingbat = '[' + rsDingbatRange + ']',
  16996. rsLower = '[' + rsLowerRange + ']',
  16997. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  16998. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  16999. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17000. rsNonAstral = '[^' + rsAstralRange + ']',
  17001. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17002. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17003. rsUpper = '[' + rsUpperRange + ']',
  17004. rsZWJ = '\\u200d';
  17005. /** Used to compose unicode regexes. */
  17006. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17007. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17008. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17009. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17010. reOptMod = rsModifier + '?',
  17011. rsOptVar = '[' + rsVarRange + ']?',
  17012. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17013. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17014. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17015. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17016. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17017. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17018. /** Used to match apostrophes. */
  17019. var reApos = RegExp(rsApos, 'g');
  17020. /**
  17021. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17022. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17023. */
  17024. var reComboMark = RegExp(rsCombo, 'g');
  17025. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17026. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17027. /** Used to match complex or compound words. */
  17028. var reUnicodeWord = RegExp([
  17029. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17030. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17031. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17032. rsUpper + '+' + rsOptContrUpper,
  17033. rsOrdUpper,
  17034. rsOrdLower,
  17035. rsDigits,
  17036. rsEmoji
  17037. ].join('|'), 'g');
  17038. /** 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/). */
  17039. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17040. /** Used to detect strings that need a more robust regexp to match words. */
  17041. 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 ]/;
  17042. /** Used to assign default `context` object properties. */
  17043. var contextProps = [
  17044. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17045. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17046. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17047. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17048. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17049. ];
  17050. /** Used to make template sourceURLs easier to identify. */
  17051. var templateCounter = -1;
  17052. /** Used to identify `toStringTag` values of typed arrays. */
  17053. var typedArrayTags = {};
  17054. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17055. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17056. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17057. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17058. typedArrayTags[uint32Tag] = true;
  17059. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17060. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17061. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17062. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17063. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17064. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17065. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17066. typedArrayTags[weakMapTag] = false;
  17067. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17068. var cloneableTags = {};
  17069. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  17070. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  17071. cloneableTags[boolTag] = cloneableTags[dateTag] =
  17072. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  17073. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  17074. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  17075. cloneableTags[numberTag] = cloneableTags[objectTag] =
  17076. cloneableTags[regexpTag] = cloneableTags[setTag] =
  17077. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  17078. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  17079. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  17080. cloneableTags[errorTag] = cloneableTags[funcTag] =
  17081. cloneableTags[weakMapTag] = false;
  17082. /** Used to map Latin Unicode letters to basic Latin letters. */
  17083. var deburredLetters = {
  17084. // Latin-1 Supplement block.
  17085. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  17086. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  17087. '\xc7': 'C', '\xe7': 'c',
  17088. '\xd0': 'D', '\xf0': 'd',
  17089. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  17090. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  17091. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  17092. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  17093. '\xd1': 'N', '\xf1': 'n',
  17094. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  17095. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  17096. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  17097. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  17098. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  17099. '\xc6': 'Ae', '\xe6': 'ae',
  17100. '\xde': 'Th', '\xfe': 'th',
  17101. '\xdf': 'ss',
  17102. // Latin Extended-A block.
  17103. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  17104. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  17105. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  17106. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  17107. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  17108. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  17109. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  17110. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  17111. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  17112. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  17113. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  17114. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  17115. '\u0134': 'J', '\u0135': 'j',
  17116. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  17117. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  17118. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  17119. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  17120. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  17121. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  17122. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  17123. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  17124. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  17125. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  17126. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  17127. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  17128. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  17129. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  17130. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  17131. '\u0174': 'W', '\u0175': 'w',
  17132. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  17133. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  17134. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  17135. '\u0132': 'IJ', '\u0133': 'ij',
  17136. '\u0152': 'Oe', '\u0153': 'oe',
  17137. '\u0149': "'n", '\u017f': 's'
  17138. };
  17139. /** Used to map characters to HTML entities. */
  17140. var htmlEscapes = {
  17141. '&': '&amp;',
  17142. '<': '&lt;',
  17143. '>': '&gt;',
  17144. '"': '&quot;',
  17145. "'": '&#39;'
  17146. };
  17147. /** Used to map HTML entities to characters. */
  17148. var htmlUnescapes = {
  17149. '&amp;': '&',
  17150. '&lt;': '<',
  17151. '&gt;': '>',
  17152. '&quot;': '"',
  17153. '&#39;': "'"
  17154. };
  17155. /** Used to escape characters for inclusion in compiled string literals. */
  17156. var stringEscapes = {
  17157. '\\': '\\',
  17158. "'": "'",
  17159. '\n': 'n',
  17160. '\r': 'r',
  17161. '\u2028': 'u2028',
  17162. '\u2029': 'u2029'
  17163. };
  17164. /** Built-in method references without a dependency on `root`. */
  17165. var freeParseFloat = parseFloat,
  17166. freeParseInt = parseInt;
  17167. /** Detect free variable `global` from Node.js. */
  17168. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  17169. /** Detect free variable `self`. */
  17170. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  17171. /** Used as a reference to the global object. */
  17172. var root = freeGlobal || freeSelf || Function('return this')();
  17173. /** Detect free variable `exports`. */
  17174. var freeExports = true && exports && !exports.nodeType && exports;
  17175. /** Detect free variable `module`. */
  17176. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  17177. /** Detect the popular CommonJS extension `module.exports`. */
  17178. var moduleExports = freeModule && freeModule.exports === freeExports;
  17179. /** Detect free variable `process` from Node.js. */
  17180. var freeProcess = moduleExports && freeGlobal.process;
  17181. /** Used to access faster Node.js helpers. */
  17182. var nodeUtil = (function() {
  17183. try {
  17184. // Use `util.types` for Node.js 10+.
  17185. var types = freeModule && freeModule.require && freeModule.require('util').types;
  17186. if (types) {
  17187. return types;
  17188. }
  17189. // Legacy `process.binding('util')` for Node.js < 10.
  17190. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  17191. } catch (e) {}
  17192. }());
  17193. /* Node.js helper references. */
  17194. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  17195. nodeIsDate = nodeUtil && nodeUtil.isDate,
  17196. nodeIsMap = nodeUtil && nodeUtil.isMap,
  17197. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  17198. nodeIsSet = nodeUtil && nodeUtil.isSet,
  17199. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  17200. /*--------------------------------------------------------------------------*/
  17201. /**
  17202. * A faster alternative to `Function#apply`, this function invokes `func`
  17203. * with the `this` binding of `thisArg` and the arguments of `args`.
  17204. *
  17205. * @private
  17206. * @param {Function} func The function to invoke.
  17207. * @param {*} thisArg The `this` binding of `func`.
  17208. * @param {Array} args The arguments to invoke `func` with.
  17209. * @returns {*} Returns the result of `func`.
  17210. */
  17211. function apply(func, thisArg, args) {
  17212. switch (args.length) {
  17213. case 0: return func.call(thisArg);
  17214. case 1: return func.call(thisArg, args[0]);
  17215. case 2: return func.call(thisArg, args[0], args[1]);
  17216. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  17217. }
  17218. return func.apply(thisArg, args);
  17219. }
  17220. /**
  17221. * A specialized version of `baseAggregator` for arrays.
  17222. *
  17223. * @private
  17224. * @param {Array} [array] The array to iterate over.
  17225. * @param {Function} setter The function to set `accumulator` values.
  17226. * @param {Function} iteratee The iteratee to transform keys.
  17227. * @param {Object} accumulator The initial aggregated object.
  17228. * @returns {Function} Returns `accumulator`.
  17229. */
  17230. function arrayAggregator(array, setter, iteratee, accumulator) {
  17231. var index = -1,
  17232. length = array == null ? 0 : array.length;
  17233. while (++index < length) {
  17234. var value = array[index];
  17235. setter(accumulator, value, iteratee(value), array);
  17236. }
  17237. return accumulator;
  17238. }
  17239. /**
  17240. * A specialized version of `_.forEach` for arrays without support for
  17241. * iteratee shorthands.
  17242. *
  17243. * @private
  17244. * @param {Array} [array] The array to iterate over.
  17245. * @param {Function} iteratee The function invoked per iteration.
  17246. * @returns {Array} Returns `array`.
  17247. */
  17248. function arrayEach(array, iteratee) {
  17249. var index = -1,
  17250. length = array == null ? 0 : array.length;
  17251. while (++index < length) {
  17252. if (iteratee(array[index], index, array) === false) {
  17253. break;
  17254. }
  17255. }
  17256. return array;
  17257. }
  17258. /**
  17259. * A specialized version of `_.forEachRight` for arrays without support for
  17260. * iteratee shorthands.
  17261. *
  17262. * @private
  17263. * @param {Array} [array] The array to iterate over.
  17264. * @param {Function} iteratee The function invoked per iteration.
  17265. * @returns {Array} Returns `array`.
  17266. */
  17267. function arrayEachRight(array, iteratee) {
  17268. var length = array == null ? 0 : array.length;
  17269. while (length--) {
  17270. if (iteratee(array[length], length, array) === false) {
  17271. break;
  17272. }
  17273. }
  17274. return array;
  17275. }
  17276. /**
  17277. * A specialized version of `_.every` for arrays without support for
  17278. * iteratee shorthands.
  17279. *
  17280. * @private
  17281. * @param {Array} [array] The array to iterate over.
  17282. * @param {Function} predicate The function invoked per iteration.
  17283. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  17284. * else `false`.
  17285. */
  17286. function arrayEvery(array, predicate) {
  17287. var index = -1,
  17288. length = array == null ? 0 : array.length;
  17289. while (++index < length) {
  17290. if (!predicate(array[index], index, array)) {
  17291. return false;
  17292. }
  17293. }
  17294. return true;
  17295. }
  17296. /**
  17297. * A specialized version of `_.filter` for arrays without support for
  17298. * iteratee shorthands.
  17299. *
  17300. * @private
  17301. * @param {Array} [array] The array to iterate over.
  17302. * @param {Function} predicate The function invoked per iteration.
  17303. * @returns {Array} Returns the new filtered array.
  17304. */
  17305. function arrayFilter(array, predicate) {
  17306. var index = -1,
  17307. length = array == null ? 0 : array.length,
  17308. resIndex = 0,
  17309. result = [];
  17310. while (++index < length) {
  17311. var value = array[index];
  17312. if (predicate(value, index, array)) {
  17313. result[resIndex++] = value;
  17314. }
  17315. }
  17316. return result;
  17317. }
  17318. /**
  17319. * A specialized version of `_.includes` for arrays without support for
  17320. * specifying an index to search from.
  17321. *
  17322. * @private
  17323. * @param {Array} [array] The array to inspect.
  17324. * @param {*} target The value to search for.
  17325. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17326. */
  17327. function arrayIncludes(array, value) {
  17328. var length = array == null ? 0 : array.length;
  17329. return !!length && baseIndexOf(array, value, 0) > -1;
  17330. }
  17331. /**
  17332. * This function is like `arrayIncludes` except that it accepts a comparator.
  17333. *
  17334. * @private
  17335. * @param {Array} [array] The array to inspect.
  17336. * @param {*} target The value to search for.
  17337. * @param {Function} comparator The comparator invoked per element.
  17338. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  17339. */
  17340. function arrayIncludesWith(array, value, comparator) {
  17341. var index = -1,
  17342. length = array == null ? 0 : array.length;
  17343. while (++index < length) {
  17344. if (comparator(value, array[index])) {
  17345. return true;
  17346. }
  17347. }
  17348. return false;
  17349. }
  17350. /**
  17351. * A specialized version of `_.map` for arrays without support for iteratee
  17352. * shorthands.
  17353. *
  17354. * @private
  17355. * @param {Array} [array] The array to iterate over.
  17356. * @param {Function} iteratee The function invoked per iteration.
  17357. * @returns {Array} Returns the new mapped array.
  17358. */
  17359. function arrayMap(array, iteratee) {
  17360. var index = -1,
  17361. length = array == null ? 0 : array.length,
  17362. result = Array(length);
  17363. while (++index < length) {
  17364. result[index] = iteratee(array[index], index, array);
  17365. }
  17366. return result;
  17367. }
  17368. /**
  17369. * Appends the elements of `values` to `array`.
  17370. *
  17371. * @private
  17372. * @param {Array} array The array to modify.
  17373. * @param {Array} values The values to append.
  17374. * @returns {Array} Returns `array`.
  17375. */
  17376. function arrayPush(array, values) {
  17377. var index = -1,
  17378. length = values.length,
  17379. offset = array.length;
  17380. while (++index < length) {
  17381. array[offset + index] = values[index];
  17382. }
  17383. return array;
  17384. }
  17385. /**
  17386. * A specialized version of `_.reduce` for arrays without support for
  17387. * iteratee shorthands.
  17388. *
  17389. * @private
  17390. * @param {Array} [array] The array to iterate over.
  17391. * @param {Function} iteratee The function invoked per iteration.
  17392. * @param {*} [accumulator] The initial value.
  17393. * @param {boolean} [initAccum] Specify using the first element of `array` as
  17394. * the initial value.
  17395. * @returns {*} Returns the accumulated value.
  17396. */
  17397. function arrayReduce(array, iteratee, accumulator, initAccum) {
  17398. var index = -1,
  17399. length = array == null ? 0 : array.length;
  17400. if (initAccum && length) {
  17401. accumulator = array[++index];
  17402. }
  17403. while (++index < length) {
  17404. accumulator = iteratee(accumulator, array[index], index, array);
  17405. }
  17406. return accumulator;
  17407. }
  17408. /**
  17409. * A specialized version of `_.reduceRight` for arrays without support for
  17410. * iteratee shorthands.
  17411. *
  17412. * @private
  17413. * @param {Array} [array] The array to iterate over.
  17414. * @param {Function} iteratee The function invoked per iteration.
  17415. * @param {*} [accumulator] The initial value.
  17416. * @param {boolean} [initAccum] Specify using the last element of `array` as
  17417. * the initial value.
  17418. * @returns {*} Returns the accumulated value.
  17419. */
  17420. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  17421. var length = array == null ? 0 : array.length;
  17422. if (initAccum && length) {
  17423. accumulator = array[--length];
  17424. }
  17425. while (length--) {
  17426. accumulator = iteratee(accumulator, array[length], length, array);
  17427. }
  17428. return accumulator;
  17429. }
  17430. /**
  17431. * A specialized version of `_.some` for arrays without support for iteratee
  17432. * shorthands.
  17433. *
  17434. * @private
  17435. * @param {Array} [array] The array to iterate over.
  17436. * @param {Function} predicate The function invoked per iteration.
  17437. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17438. * else `false`.
  17439. */
  17440. function arraySome(array, predicate) {
  17441. var index = -1,
  17442. length = array == null ? 0 : array.length;
  17443. while (++index < length) {
  17444. if (predicate(array[index], index, array)) {
  17445. return true;
  17446. }
  17447. }
  17448. return false;
  17449. }
  17450. /**
  17451. * Gets the size of an ASCII `string`.
  17452. *
  17453. * @private
  17454. * @param {string} string The string inspect.
  17455. * @returns {number} Returns the string size.
  17456. */
  17457. var asciiSize = baseProperty('length');
  17458. /**
  17459. * Converts an ASCII `string` to an array.
  17460. *
  17461. * @private
  17462. * @param {string} string The string to convert.
  17463. * @returns {Array} Returns the converted array.
  17464. */
  17465. function asciiToArray(string) {
  17466. return string.split('');
  17467. }
  17468. /**
  17469. * Splits an ASCII `string` into an array of its words.
  17470. *
  17471. * @private
  17472. * @param {string} The string to inspect.
  17473. * @returns {Array} Returns the words of `string`.
  17474. */
  17475. function asciiWords(string) {
  17476. return string.match(reAsciiWord) || [];
  17477. }
  17478. /**
  17479. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  17480. * without support for iteratee shorthands, which iterates over `collection`
  17481. * using `eachFunc`.
  17482. *
  17483. * @private
  17484. * @param {Array|Object} collection The collection to inspect.
  17485. * @param {Function} predicate The function invoked per iteration.
  17486. * @param {Function} eachFunc The function to iterate over `collection`.
  17487. * @returns {*} Returns the found element or its key, else `undefined`.
  17488. */
  17489. function baseFindKey(collection, predicate, eachFunc) {
  17490. var result;
  17491. eachFunc(collection, function(value, key, collection) {
  17492. if (predicate(value, key, collection)) {
  17493. result = key;
  17494. return false;
  17495. }
  17496. });
  17497. return result;
  17498. }
  17499. /**
  17500. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  17501. * support for iteratee shorthands.
  17502. *
  17503. * @private
  17504. * @param {Array} array The array to inspect.
  17505. * @param {Function} predicate The function invoked per iteration.
  17506. * @param {number} fromIndex The index to search from.
  17507. * @param {boolean} [fromRight] Specify iterating from right to left.
  17508. * @returns {number} Returns the index of the matched value, else `-1`.
  17509. */
  17510. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  17511. var length = array.length,
  17512. index = fromIndex + (fromRight ? 1 : -1);
  17513. while ((fromRight ? index-- : ++index < length)) {
  17514. if (predicate(array[index], index, array)) {
  17515. return index;
  17516. }
  17517. }
  17518. return -1;
  17519. }
  17520. /**
  17521. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  17522. *
  17523. * @private
  17524. * @param {Array} array The array to inspect.
  17525. * @param {*} value The value to search for.
  17526. * @param {number} fromIndex The index to search from.
  17527. * @returns {number} Returns the index of the matched value, else `-1`.
  17528. */
  17529. function baseIndexOf(array, value, fromIndex) {
  17530. return value === value
  17531. ? strictIndexOf(array, value, fromIndex)
  17532. : baseFindIndex(array, baseIsNaN, fromIndex);
  17533. }
  17534. /**
  17535. * This function is like `baseIndexOf` except that it accepts a comparator.
  17536. *
  17537. * @private
  17538. * @param {Array} array The array to inspect.
  17539. * @param {*} value The value to search for.
  17540. * @param {number} fromIndex The index to search from.
  17541. * @param {Function} comparator The comparator invoked per element.
  17542. * @returns {number} Returns the index of the matched value, else `-1`.
  17543. */
  17544. function baseIndexOfWith(array, value, fromIndex, comparator) {
  17545. var index = fromIndex - 1,
  17546. length = array.length;
  17547. while (++index < length) {
  17548. if (comparator(array[index], value)) {
  17549. return index;
  17550. }
  17551. }
  17552. return -1;
  17553. }
  17554. /**
  17555. * The base implementation of `_.isNaN` without support for number objects.
  17556. *
  17557. * @private
  17558. * @param {*} value The value to check.
  17559. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  17560. */
  17561. function baseIsNaN(value) {
  17562. return value !== value;
  17563. }
  17564. /**
  17565. * The base implementation of `_.mean` and `_.meanBy` without support for
  17566. * iteratee shorthands.
  17567. *
  17568. * @private
  17569. * @param {Array} array The array to iterate over.
  17570. * @param {Function} iteratee The function invoked per iteration.
  17571. * @returns {number} Returns the mean.
  17572. */
  17573. function baseMean(array, iteratee) {
  17574. var length = array == null ? 0 : array.length;
  17575. return length ? (baseSum(array, iteratee) / length) : NAN;
  17576. }
  17577. /**
  17578. * The base implementation of `_.property` without support for deep paths.
  17579. *
  17580. * @private
  17581. * @param {string} key The key of the property to get.
  17582. * @returns {Function} Returns the new accessor function.
  17583. */
  17584. function baseProperty(key) {
  17585. return function(object) {
  17586. return object == null ? undefined : object[key];
  17587. };
  17588. }
  17589. /**
  17590. * The base implementation of `_.propertyOf` without support for deep paths.
  17591. *
  17592. * @private
  17593. * @param {Object} object The object to query.
  17594. * @returns {Function} Returns the new accessor function.
  17595. */
  17596. function basePropertyOf(object) {
  17597. return function(key) {
  17598. return object == null ? undefined : object[key];
  17599. };
  17600. }
  17601. /**
  17602. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  17603. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  17604. *
  17605. * @private
  17606. * @param {Array|Object} collection The collection to iterate over.
  17607. * @param {Function} iteratee The function invoked per iteration.
  17608. * @param {*} accumulator The initial value.
  17609. * @param {boolean} initAccum Specify using the first or last element of
  17610. * `collection` as the initial value.
  17611. * @param {Function} eachFunc The function to iterate over `collection`.
  17612. * @returns {*} Returns the accumulated value.
  17613. */
  17614. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  17615. eachFunc(collection, function(value, index, collection) {
  17616. accumulator = initAccum
  17617. ? (initAccum = false, value)
  17618. : iteratee(accumulator, value, index, collection);
  17619. });
  17620. return accumulator;
  17621. }
  17622. /**
  17623. * The base implementation of `_.sortBy` which uses `comparer` to define the
  17624. * sort order of `array` and replaces criteria objects with their corresponding
  17625. * values.
  17626. *
  17627. * @private
  17628. * @param {Array} array The array to sort.
  17629. * @param {Function} comparer The function to define sort order.
  17630. * @returns {Array} Returns `array`.
  17631. */
  17632. function baseSortBy(array, comparer) {
  17633. var length = array.length;
  17634. array.sort(comparer);
  17635. while (length--) {
  17636. array[length] = array[length].value;
  17637. }
  17638. return array;
  17639. }
  17640. /**
  17641. * The base implementation of `_.sum` and `_.sumBy` without support for
  17642. * iteratee shorthands.
  17643. *
  17644. * @private
  17645. * @param {Array} array The array to iterate over.
  17646. * @param {Function} iteratee The function invoked per iteration.
  17647. * @returns {number} Returns the sum.
  17648. */
  17649. function baseSum(array, iteratee) {
  17650. var result,
  17651. index = -1,
  17652. length = array.length;
  17653. while (++index < length) {
  17654. var current = iteratee(array[index]);
  17655. if (current !== undefined) {
  17656. result = result === undefined ? current : (result + current);
  17657. }
  17658. }
  17659. return result;
  17660. }
  17661. /**
  17662. * The base implementation of `_.times` without support for iteratee shorthands
  17663. * or max array length checks.
  17664. *
  17665. * @private
  17666. * @param {number} n The number of times to invoke `iteratee`.
  17667. * @param {Function} iteratee The function invoked per iteration.
  17668. * @returns {Array} Returns the array of results.
  17669. */
  17670. function baseTimes(n, iteratee) {
  17671. var index = -1,
  17672. result = Array(n);
  17673. while (++index < n) {
  17674. result[index] = iteratee(index);
  17675. }
  17676. return result;
  17677. }
  17678. /**
  17679. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  17680. * of key-value pairs for `object` corresponding to the property names of `props`.
  17681. *
  17682. * @private
  17683. * @param {Object} object The object to query.
  17684. * @param {Array} props The property names to get values for.
  17685. * @returns {Object} Returns the key-value pairs.
  17686. */
  17687. function baseToPairs(object, props) {
  17688. return arrayMap(props, function(key) {
  17689. return [key, object[key]];
  17690. });
  17691. }
  17692. /**
  17693. * The base implementation of `_.unary` without support for storing metadata.
  17694. *
  17695. * @private
  17696. * @param {Function} func The function to cap arguments for.
  17697. * @returns {Function} Returns the new capped function.
  17698. */
  17699. function baseUnary(func) {
  17700. return function(value) {
  17701. return func(value);
  17702. };
  17703. }
  17704. /**
  17705. * The base implementation of `_.values` and `_.valuesIn` which creates an
  17706. * array of `object` property values corresponding to the property names
  17707. * of `props`.
  17708. *
  17709. * @private
  17710. * @param {Object} object The object to query.
  17711. * @param {Array} props The property names to get values for.
  17712. * @returns {Object} Returns the array of property values.
  17713. */
  17714. function baseValues(object, props) {
  17715. return arrayMap(props, function(key) {
  17716. return object[key];
  17717. });
  17718. }
  17719. /**
  17720. * Checks if a `cache` value for `key` exists.
  17721. *
  17722. * @private
  17723. * @param {Object} cache The cache to query.
  17724. * @param {string} key The key of the entry to check.
  17725. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  17726. */
  17727. function cacheHas(cache, key) {
  17728. return cache.has(key);
  17729. }
  17730. /**
  17731. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  17732. * that is not found in the character symbols.
  17733. *
  17734. * @private
  17735. * @param {Array} strSymbols The string symbols to inspect.
  17736. * @param {Array} chrSymbols The character symbols to find.
  17737. * @returns {number} Returns the index of the first unmatched string symbol.
  17738. */
  17739. function charsStartIndex(strSymbols, chrSymbols) {
  17740. var index = -1,
  17741. length = strSymbols.length;
  17742. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17743. return index;
  17744. }
  17745. /**
  17746. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  17747. * that is not found in the character symbols.
  17748. *
  17749. * @private
  17750. * @param {Array} strSymbols The string symbols to inspect.
  17751. * @param {Array} chrSymbols The character symbols to find.
  17752. * @returns {number} Returns the index of the last unmatched string symbol.
  17753. */
  17754. function charsEndIndex(strSymbols, chrSymbols) {
  17755. var index = strSymbols.length;
  17756. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  17757. return index;
  17758. }
  17759. /**
  17760. * Gets the number of `placeholder` occurrences in `array`.
  17761. *
  17762. * @private
  17763. * @param {Array} array The array to inspect.
  17764. * @param {*} placeholder The placeholder to search for.
  17765. * @returns {number} Returns the placeholder count.
  17766. */
  17767. function countHolders(array, placeholder) {
  17768. var length = array.length,
  17769. result = 0;
  17770. while (length--) {
  17771. if (array[length] === placeholder) {
  17772. ++result;
  17773. }
  17774. }
  17775. return result;
  17776. }
  17777. /**
  17778. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  17779. * letters to basic Latin letters.
  17780. *
  17781. * @private
  17782. * @param {string} letter The matched letter to deburr.
  17783. * @returns {string} Returns the deburred letter.
  17784. */
  17785. var deburrLetter = basePropertyOf(deburredLetters);
  17786. /**
  17787. * Used by `_.escape` to convert characters to HTML entities.
  17788. *
  17789. * @private
  17790. * @param {string} chr The matched character to escape.
  17791. * @returns {string} Returns the escaped character.
  17792. */
  17793. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  17794. /**
  17795. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  17796. *
  17797. * @private
  17798. * @param {string} chr The matched character to escape.
  17799. * @returns {string} Returns the escaped character.
  17800. */
  17801. function escapeStringChar(chr) {
  17802. return '\\' + stringEscapes[chr];
  17803. }
  17804. /**
  17805. * Gets the value at `key` of `object`.
  17806. *
  17807. * @private
  17808. * @param {Object} [object] The object to query.
  17809. * @param {string} key The key of the property to get.
  17810. * @returns {*} Returns the property value.
  17811. */
  17812. function getValue(object, key) {
  17813. return object == null ? undefined : object[key];
  17814. }
  17815. /**
  17816. * Checks if `string` contains Unicode symbols.
  17817. *
  17818. * @private
  17819. * @param {string} string The string to inspect.
  17820. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  17821. */
  17822. function hasUnicode(string) {
  17823. return reHasUnicode.test(string);
  17824. }
  17825. /**
  17826. * Checks if `string` contains a word composed of Unicode symbols.
  17827. *
  17828. * @private
  17829. * @param {string} string The string to inspect.
  17830. * @returns {boolean} Returns `true` if a word is found, else `false`.
  17831. */
  17832. function hasUnicodeWord(string) {
  17833. return reHasUnicodeWord.test(string);
  17834. }
  17835. /**
  17836. * Converts `iterator` to an array.
  17837. *
  17838. * @private
  17839. * @param {Object} iterator The iterator to convert.
  17840. * @returns {Array} Returns the converted array.
  17841. */
  17842. function iteratorToArray(iterator) {
  17843. var data,
  17844. result = [];
  17845. while (!(data = iterator.next()).done) {
  17846. result.push(data.value);
  17847. }
  17848. return result;
  17849. }
  17850. /**
  17851. * Converts `map` to its key-value pairs.
  17852. *
  17853. * @private
  17854. * @param {Object} map The map to convert.
  17855. * @returns {Array} Returns the key-value pairs.
  17856. */
  17857. function mapToArray(map) {
  17858. var index = -1,
  17859. result = Array(map.size);
  17860. map.forEach(function(value, key) {
  17861. result[++index] = [key, value];
  17862. });
  17863. return result;
  17864. }
  17865. /**
  17866. * Creates a unary function that invokes `func` with its argument transformed.
  17867. *
  17868. * @private
  17869. * @param {Function} func The function to wrap.
  17870. * @param {Function} transform The argument transform.
  17871. * @returns {Function} Returns the new function.
  17872. */
  17873. function overArg(func, transform) {
  17874. return function(arg) {
  17875. return func(transform(arg));
  17876. };
  17877. }
  17878. /**
  17879. * Replaces all `placeholder` elements in `array` with an internal placeholder
  17880. * and returns an array of their indexes.
  17881. *
  17882. * @private
  17883. * @param {Array} array The array to modify.
  17884. * @param {*} placeholder The placeholder to replace.
  17885. * @returns {Array} Returns the new array of placeholder indexes.
  17886. */
  17887. function replaceHolders(array, placeholder) {
  17888. var index = -1,
  17889. length = array.length,
  17890. resIndex = 0,
  17891. result = [];
  17892. while (++index < length) {
  17893. var value = array[index];
  17894. if (value === placeholder || value === PLACEHOLDER) {
  17895. array[index] = PLACEHOLDER;
  17896. result[resIndex++] = index;
  17897. }
  17898. }
  17899. return result;
  17900. }
  17901. /**
  17902. * Converts `set` to an array of its values.
  17903. *
  17904. * @private
  17905. * @param {Object} set The set to convert.
  17906. * @returns {Array} Returns the values.
  17907. */
  17908. function setToArray(set) {
  17909. var index = -1,
  17910. result = Array(set.size);
  17911. set.forEach(function(value) {
  17912. result[++index] = value;
  17913. });
  17914. return result;
  17915. }
  17916. /**
  17917. * Converts `set` to its value-value pairs.
  17918. *
  17919. * @private
  17920. * @param {Object} set The set to convert.
  17921. * @returns {Array} Returns the value-value pairs.
  17922. */
  17923. function setToPairs(set) {
  17924. var index = -1,
  17925. result = Array(set.size);
  17926. set.forEach(function(value) {
  17927. result[++index] = [value, value];
  17928. });
  17929. return result;
  17930. }
  17931. /**
  17932. * A specialized version of `_.indexOf` which performs strict equality
  17933. * comparisons of values, i.e. `===`.
  17934. *
  17935. * @private
  17936. * @param {Array} array The array to inspect.
  17937. * @param {*} value The value to search for.
  17938. * @param {number} fromIndex The index to search from.
  17939. * @returns {number} Returns the index of the matched value, else `-1`.
  17940. */
  17941. function strictIndexOf(array, value, fromIndex) {
  17942. var index = fromIndex - 1,
  17943. length = array.length;
  17944. while (++index < length) {
  17945. if (array[index] === value) {
  17946. return index;
  17947. }
  17948. }
  17949. return -1;
  17950. }
  17951. /**
  17952. * A specialized version of `_.lastIndexOf` which performs strict equality
  17953. * comparisons of values, i.e. `===`.
  17954. *
  17955. * @private
  17956. * @param {Array} array The array to inspect.
  17957. * @param {*} value The value to search for.
  17958. * @param {number} fromIndex The index to search from.
  17959. * @returns {number} Returns the index of the matched value, else `-1`.
  17960. */
  17961. function strictLastIndexOf(array, value, fromIndex) {
  17962. var index = fromIndex + 1;
  17963. while (index--) {
  17964. if (array[index] === value) {
  17965. return index;
  17966. }
  17967. }
  17968. return index;
  17969. }
  17970. /**
  17971. * Gets the number of symbols in `string`.
  17972. *
  17973. * @private
  17974. * @param {string} string The string to inspect.
  17975. * @returns {number} Returns the string size.
  17976. */
  17977. function stringSize(string) {
  17978. return hasUnicode(string)
  17979. ? unicodeSize(string)
  17980. : asciiSize(string);
  17981. }
  17982. /**
  17983. * Converts `string` to an array.
  17984. *
  17985. * @private
  17986. * @param {string} string The string to convert.
  17987. * @returns {Array} Returns the converted array.
  17988. */
  17989. function stringToArray(string) {
  17990. return hasUnicode(string)
  17991. ? unicodeToArray(string)
  17992. : asciiToArray(string);
  17993. }
  17994. /**
  17995. * Used by `_.unescape` to convert HTML entities to characters.
  17996. *
  17997. * @private
  17998. * @param {string} chr The matched character to unescape.
  17999. * @returns {string} Returns the unescaped character.
  18000. */
  18001. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18002. /**
  18003. * Gets the size of a Unicode `string`.
  18004. *
  18005. * @private
  18006. * @param {string} string The string inspect.
  18007. * @returns {number} Returns the string size.
  18008. */
  18009. function unicodeSize(string) {
  18010. var result = reUnicode.lastIndex = 0;
  18011. while (reUnicode.test(string)) {
  18012. ++result;
  18013. }
  18014. return result;
  18015. }
  18016. /**
  18017. * Converts a Unicode `string` to an array.
  18018. *
  18019. * @private
  18020. * @param {string} string The string to convert.
  18021. * @returns {Array} Returns the converted array.
  18022. */
  18023. function unicodeToArray(string) {
  18024. return string.match(reUnicode) || [];
  18025. }
  18026. /**
  18027. * Splits a Unicode `string` into an array of its words.
  18028. *
  18029. * @private
  18030. * @param {string} The string to inspect.
  18031. * @returns {Array} Returns the words of `string`.
  18032. */
  18033. function unicodeWords(string) {
  18034. return string.match(reUnicodeWord) || [];
  18035. }
  18036. /*--------------------------------------------------------------------------*/
  18037. /**
  18038. * Create a new pristine `lodash` function using the `context` object.
  18039. *
  18040. * @static
  18041. * @memberOf _
  18042. * @since 1.1.0
  18043. * @category Util
  18044. * @param {Object} [context=root] The context object.
  18045. * @returns {Function} Returns a new `lodash` function.
  18046. * @example
  18047. *
  18048. * _.mixin({ 'foo': _.constant('foo') });
  18049. *
  18050. * var lodash = _.runInContext();
  18051. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18052. *
  18053. * _.isFunction(_.foo);
  18054. * // => true
  18055. * _.isFunction(_.bar);
  18056. * // => false
  18057. *
  18058. * lodash.isFunction(lodash.foo);
  18059. * // => false
  18060. * lodash.isFunction(lodash.bar);
  18061. * // => true
  18062. *
  18063. * // Create a suped-up `defer` in Node.js.
  18064. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18065. */
  18066. var runInContext = (function runInContext(context) {
  18067. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18068. /** Built-in constructor references. */
  18069. var Array = context.Array,
  18070. Date = context.Date,
  18071. Error = context.Error,
  18072. Function = context.Function,
  18073. Math = context.Math,
  18074. Object = context.Object,
  18075. RegExp = context.RegExp,
  18076. String = context.String,
  18077. TypeError = context.TypeError;
  18078. /** Used for built-in method references. */
  18079. var arrayProto = Array.prototype,
  18080. funcProto = Function.prototype,
  18081. objectProto = Object.prototype;
  18082. /** Used to detect overreaching core-js shims. */
  18083. var coreJsData = context['__core-js_shared__'];
  18084. /** Used to resolve the decompiled source of functions. */
  18085. var funcToString = funcProto.toString;
  18086. /** Used to check objects for own properties. */
  18087. var hasOwnProperty = objectProto.hasOwnProperty;
  18088. /** Used to generate unique IDs. */
  18089. var idCounter = 0;
  18090. /** Used to detect methods masquerading as native. */
  18091. var maskSrcKey = (function() {
  18092. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  18093. return uid ? ('Symbol(src)_1.' + uid) : '';
  18094. }());
  18095. /**
  18096. * Used to resolve the
  18097. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  18098. * of values.
  18099. */
  18100. var nativeObjectToString = objectProto.toString;
  18101. /** Used to infer the `Object` constructor. */
  18102. var objectCtorString = funcToString.call(Object);
  18103. /** Used to restore the original `_` reference in `_.noConflict`. */
  18104. var oldDash = root._;
  18105. /** Used to detect if a method is native. */
  18106. var reIsNative = RegExp('^' +
  18107. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  18108. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  18109. );
  18110. /** Built-in value references. */
  18111. var Buffer = moduleExports ? context.Buffer : undefined,
  18112. Symbol = context.Symbol,
  18113. Uint8Array = context.Uint8Array,
  18114. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  18115. getPrototype = overArg(Object.getPrototypeOf, Object),
  18116. objectCreate = Object.create,
  18117. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  18118. splice = arrayProto.splice,
  18119. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  18120. symIterator = Symbol ? Symbol.iterator : undefined,
  18121. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  18122. var defineProperty = (function() {
  18123. try {
  18124. var func = getNative(Object, 'defineProperty');
  18125. func({}, '', {});
  18126. return func;
  18127. } catch (e) {}
  18128. }());
  18129. /** Mocked built-ins. */
  18130. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  18131. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  18132. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  18133. /* Built-in method references for those with the same name as other `lodash` methods. */
  18134. var nativeCeil = Math.ceil,
  18135. nativeFloor = Math.floor,
  18136. nativeGetSymbols = Object.getOwnPropertySymbols,
  18137. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  18138. nativeIsFinite = context.isFinite,
  18139. nativeJoin = arrayProto.join,
  18140. nativeKeys = overArg(Object.keys, Object),
  18141. nativeMax = Math.max,
  18142. nativeMin = Math.min,
  18143. nativeNow = Date.now,
  18144. nativeParseInt = context.parseInt,
  18145. nativeRandom = Math.random,
  18146. nativeReverse = arrayProto.reverse;
  18147. /* Built-in method references that are verified to be native. */
  18148. var DataView = getNative(context, 'DataView'),
  18149. Map = getNative(context, 'Map'),
  18150. Promise = getNative(context, 'Promise'),
  18151. Set = getNative(context, 'Set'),
  18152. WeakMap = getNative(context, 'WeakMap'),
  18153. nativeCreate = getNative(Object, 'create');
  18154. /** Used to store function metadata. */
  18155. var metaMap = WeakMap && new WeakMap;
  18156. /** Used to lookup unminified function names. */
  18157. var realNames = {};
  18158. /** Used to detect maps, sets, and weakmaps. */
  18159. var dataViewCtorString = toSource(DataView),
  18160. mapCtorString = toSource(Map),
  18161. promiseCtorString = toSource(Promise),
  18162. setCtorString = toSource(Set),
  18163. weakMapCtorString = toSource(WeakMap);
  18164. /** Used to convert symbols to primitives and strings. */
  18165. var symbolProto = Symbol ? Symbol.prototype : undefined,
  18166. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  18167. symbolToString = symbolProto ? symbolProto.toString : undefined;
  18168. /*------------------------------------------------------------------------*/
  18169. /**
  18170. * Creates a `lodash` object which wraps `value` to enable implicit method
  18171. * chain sequences. Methods that operate on and return arrays, collections,
  18172. * and functions can be chained together. Methods that retrieve a single value
  18173. * or may return a primitive value will automatically end the chain sequence
  18174. * and return the unwrapped value. Otherwise, the value must be unwrapped
  18175. * with `_#value`.
  18176. *
  18177. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  18178. * enabled using `_.chain`.
  18179. *
  18180. * The execution of chained methods is lazy, that is, it's deferred until
  18181. * `_#value` is implicitly or explicitly called.
  18182. *
  18183. * Lazy evaluation allows several methods to support shortcut fusion.
  18184. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  18185. * the creation of intermediate arrays and can greatly reduce the number of
  18186. * iteratee executions. Sections of a chain sequence qualify for shortcut
  18187. * fusion if the section is applied to an array and iteratees accept only
  18188. * one argument. The heuristic for whether a section qualifies for shortcut
  18189. * fusion is subject to change.
  18190. *
  18191. * Chaining is supported in custom builds as long as the `_#value` method is
  18192. * directly or indirectly included in the build.
  18193. *
  18194. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  18195. *
  18196. * The wrapper `Array` methods are:
  18197. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  18198. *
  18199. * The wrapper `String` methods are:
  18200. * `replace` and `split`
  18201. *
  18202. * The wrapper methods that support shortcut fusion are:
  18203. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  18204. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  18205. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  18206. *
  18207. * The chainable wrapper methods are:
  18208. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  18209. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  18210. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  18211. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  18212. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  18213. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  18214. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  18215. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  18216. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  18217. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  18218. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  18219. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  18220. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  18221. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  18222. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  18223. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  18224. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  18225. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  18226. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  18227. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  18228. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  18229. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  18230. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  18231. * `zipObject`, `zipObjectDeep`, and `zipWith`
  18232. *
  18233. * The wrapper methods that are **not** chainable by default are:
  18234. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  18235. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  18236. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  18237. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  18238. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  18239. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  18240. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  18241. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  18242. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  18243. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  18244. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  18245. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  18246. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  18247. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  18248. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  18249. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  18250. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  18251. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  18252. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  18253. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  18254. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  18255. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  18256. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  18257. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  18258. * `upperFirst`, `value`, and `words`
  18259. *
  18260. * @name _
  18261. * @constructor
  18262. * @category Seq
  18263. * @param {*} value The value to wrap in a `lodash` instance.
  18264. * @returns {Object} Returns the new `lodash` wrapper instance.
  18265. * @example
  18266. *
  18267. * function square(n) {
  18268. * return n * n;
  18269. * }
  18270. *
  18271. * var wrapped = _([1, 2, 3]);
  18272. *
  18273. * // Returns an unwrapped value.
  18274. * wrapped.reduce(_.add);
  18275. * // => 6
  18276. *
  18277. * // Returns a wrapped value.
  18278. * var squares = wrapped.map(square);
  18279. *
  18280. * _.isArray(squares);
  18281. * // => false
  18282. *
  18283. * _.isArray(squares.value());
  18284. * // => true
  18285. */
  18286. function lodash(value) {
  18287. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  18288. if (value instanceof LodashWrapper) {
  18289. return value;
  18290. }
  18291. if (hasOwnProperty.call(value, '__wrapped__')) {
  18292. return wrapperClone(value);
  18293. }
  18294. }
  18295. return new LodashWrapper(value);
  18296. }
  18297. /**
  18298. * The base implementation of `_.create` without support for assigning
  18299. * properties to the created object.
  18300. *
  18301. * @private
  18302. * @param {Object} proto The object to inherit from.
  18303. * @returns {Object} Returns the new object.
  18304. */
  18305. var baseCreate = (function() {
  18306. function object() {}
  18307. return function(proto) {
  18308. if (!isObject(proto)) {
  18309. return {};
  18310. }
  18311. if (objectCreate) {
  18312. return objectCreate(proto);
  18313. }
  18314. object.prototype = proto;
  18315. var result = new object;
  18316. object.prototype = undefined;
  18317. return result;
  18318. };
  18319. }());
  18320. /**
  18321. * The function whose prototype chain sequence wrappers inherit from.
  18322. *
  18323. * @private
  18324. */
  18325. function baseLodash() {
  18326. // No operation performed.
  18327. }
  18328. /**
  18329. * The base constructor for creating `lodash` wrapper objects.
  18330. *
  18331. * @private
  18332. * @param {*} value The value to wrap.
  18333. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  18334. */
  18335. function LodashWrapper(value, chainAll) {
  18336. this.__wrapped__ = value;
  18337. this.__actions__ = [];
  18338. this.__chain__ = !!chainAll;
  18339. this.__index__ = 0;
  18340. this.__values__ = undefined;
  18341. }
  18342. /**
  18343. * By default, the template delimiters used by lodash are like those in
  18344. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  18345. * following template settings to use alternative delimiters.
  18346. *
  18347. * @static
  18348. * @memberOf _
  18349. * @type {Object}
  18350. */
  18351. lodash.templateSettings = {
  18352. /**
  18353. * Used to detect `data` property values to be HTML-escaped.
  18354. *
  18355. * @memberOf _.templateSettings
  18356. * @type {RegExp}
  18357. */
  18358. 'escape': reEscape,
  18359. /**
  18360. * Used to detect code to be evaluated.
  18361. *
  18362. * @memberOf _.templateSettings
  18363. * @type {RegExp}
  18364. */
  18365. 'evaluate': reEvaluate,
  18366. /**
  18367. * Used to detect `data` property values to inject.
  18368. *
  18369. * @memberOf _.templateSettings
  18370. * @type {RegExp}
  18371. */
  18372. 'interpolate': reInterpolate,
  18373. /**
  18374. * Used to reference the data object in the template text.
  18375. *
  18376. * @memberOf _.templateSettings
  18377. * @type {string}
  18378. */
  18379. 'variable': '',
  18380. /**
  18381. * Used to import variables into the compiled template.
  18382. *
  18383. * @memberOf _.templateSettings
  18384. * @type {Object}
  18385. */
  18386. 'imports': {
  18387. /**
  18388. * A reference to the `lodash` function.
  18389. *
  18390. * @memberOf _.templateSettings.imports
  18391. * @type {Function}
  18392. */
  18393. '_': lodash
  18394. }
  18395. };
  18396. // Ensure wrappers are instances of `baseLodash`.
  18397. lodash.prototype = baseLodash.prototype;
  18398. lodash.prototype.constructor = lodash;
  18399. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  18400. LodashWrapper.prototype.constructor = LodashWrapper;
  18401. /*------------------------------------------------------------------------*/
  18402. /**
  18403. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  18404. *
  18405. * @private
  18406. * @constructor
  18407. * @param {*} value The value to wrap.
  18408. */
  18409. function LazyWrapper(value) {
  18410. this.__wrapped__ = value;
  18411. this.__actions__ = [];
  18412. this.__dir__ = 1;
  18413. this.__filtered__ = false;
  18414. this.__iteratees__ = [];
  18415. this.__takeCount__ = MAX_ARRAY_LENGTH;
  18416. this.__views__ = [];
  18417. }
  18418. /**
  18419. * Creates a clone of the lazy wrapper object.
  18420. *
  18421. * @private
  18422. * @name clone
  18423. * @memberOf LazyWrapper
  18424. * @returns {Object} Returns the cloned `LazyWrapper` object.
  18425. */
  18426. function lazyClone() {
  18427. var result = new LazyWrapper(this.__wrapped__);
  18428. result.__actions__ = copyArray(this.__actions__);
  18429. result.__dir__ = this.__dir__;
  18430. result.__filtered__ = this.__filtered__;
  18431. result.__iteratees__ = copyArray(this.__iteratees__);
  18432. result.__takeCount__ = this.__takeCount__;
  18433. result.__views__ = copyArray(this.__views__);
  18434. return result;
  18435. }
  18436. /**
  18437. * Reverses the direction of lazy iteration.
  18438. *
  18439. * @private
  18440. * @name reverse
  18441. * @memberOf LazyWrapper
  18442. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  18443. */
  18444. function lazyReverse() {
  18445. if (this.__filtered__) {
  18446. var result = new LazyWrapper(this);
  18447. result.__dir__ = -1;
  18448. result.__filtered__ = true;
  18449. } else {
  18450. result = this.clone();
  18451. result.__dir__ *= -1;
  18452. }
  18453. return result;
  18454. }
  18455. /**
  18456. * Extracts the unwrapped value from its lazy wrapper.
  18457. *
  18458. * @private
  18459. * @name value
  18460. * @memberOf LazyWrapper
  18461. * @returns {*} Returns the unwrapped value.
  18462. */
  18463. function lazyValue() {
  18464. var array = this.__wrapped__.value(),
  18465. dir = this.__dir__,
  18466. isArr = isArray(array),
  18467. isRight = dir < 0,
  18468. arrLength = isArr ? array.length : 0,
  18469. view = getView(0, arrLength, this.__views__),
  18470. start = view.start,
  18471. end = view.end,
  18472. length = end - start,
  18473. index = isRight ? end : (start - 1),
  18474. iteratees = this.__iteratees__,
  18475. iterLength = iteratees.length,
  18476. resIndex = 0,
  18477. takeCount = nativeMin(length, this.__takeCount__);
  18478. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  18479. return baseWrapperValue(array, this.__actions__);
  18480. }
  18481. var result = [];
  18482. outer:
  18483. while (length-- && resIndex < takeCount) {
  18484. index += dir;
  18485. var iterIndex = -1,
  18486. value = array[index];
  18487. while (++iterIndex < iterLength) {
  18488. var data = iteratees[iterIndex],
  18489. iteratee = data.iteratee,
  18490. type = data.type,
  18491. computed = iteratee(value);
  18492. if (type == LAZY_MAP_FLAG) {
  18493. value = computed;
  18494. } else if (!computed) {
  18495. if (type == LAZY_FILTER_FLAG) {
  18496. continue outer;
  18497. } else {
  18498. break outer;
  18499. }
  18500. }
  18501. }
  18502. result[resIndex++] = value;
  18503. }
  18504. return result;
  18505. }
  18506. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  18507. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  18508. LazyWrapper.prototype.constructor = LazyWrapper;
  18509. /*------------------------------------------------------------------------*/
  18510. /**
  18511. * Creates a hash object.
  18512. *
  18513. * @private
  18514. * @constructor
  18515. * @param {Array} [entries] The key-value pairs to cache.
  18516. */
  18517. function Hash(entries) {
  18518. var index = -1,
  18519. length = entries == null ? 0 : entries.length;
  18520. this.clear();
  18521. while (++index < length) {
  18522. var entry = entries[index];
  18523. this.set(entry[0], entry[1]);
  18524. }
  18525. }
  18526. /**
  18527. * Removes all key-value entries from the hash.
  18528. *
  18529. * @private
  18530. * @name clear
  18531. * @memberOf Hash
  18532. */
  18533. function hashClear() {
  18534. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  18535. this.size = 0;
  18536. }
  18537. /**
  18538. * Removes `key` and its value from the hash.
  18539. *
  18540. * @private
  18541. * @name delete
  18542. * @memberOf Hash
  18543. * @param {Object} hash The hash to modify.
  18544. * @param {string} key The key of the value to remove.
  18545. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18546. */
  18547. function hashDelete(key) {
  18548. var result = this.has(key) && delete this.__data__[key];
  18549. this.size -= result ? 1 : 0;
  18550. return result;
  18551. }
  18552. /**
  18553. * Gets the hash value for `key`.
  18554. *
  18555. * @private
  18556. * @name get
  18557. * @memberOf Hash
  18558. * @param {string} key The key of the value to get.
  18559. * @returns {*} Returns the entry value.
  18560. */
  18561. function hashGet(key) {
  18562. var data = this.__data__;
  18563. if (nativeCreate) {
  18564. var result = data[key];
  18565. return result === HASH_UNDEFINED ? undefined : result;
  18566. }
  18567. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  18568. }
  18569. /**
  18570. * Checks if a hash value for `key` exists.
  18571. *
  18572. * @private
  18573. * @name has
  18574. * @memberOf Hash
  18575. * @param {string} key The key of the entry to check.
  18576. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18577. */
  18578. function hashHas(key) {
  18579. var data = this.__data__;
  18580. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  18581. }
  18582. /**
  18583. * Sets the hash `key` to `value`.
  18584. *
  18585. * @private
  18586. * @name set
  18587. * @memberOf Hash
  18588. * @param {string} key The key of the value to set.
  18589. * @param {*} value The value to set.
  18590. * @returns {Object} Returns the hash instance.
  18591. */
  18592. function hashSet(key, value) {
  18593. var data = this.__data__;
  18594. this.size += this.has(key) ? 0 : 1;
  18595. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  18596. return this;
  18597. }
  18598. // Add methods to `Hash`.
  18599. Hash.prototype.clear = hashClear;
  18600. Hash.prototype['delete'] = hashDelete;
  18601. Hash.prototype.get = hashGet;
  18602. Hash.prototype.has = hashHas;
  18603. Hash.prototype.set = hashSet;
  18604. /*------------------------------------------------------------------------*/
  18605. /**
  18606. * Creates an list cache object.
  18607. *
  18608. * @private
  18609. * @constructor
  18610. * @param {Array} [entries] The key-value pairs to cache.
  18611. */
  18612. function ListCache(entries) {
  18613. var index = -1,
  18614. length = entries == null ? 0 : entries.length;
  18615. this.clear();
  18616. while (++index < length) {
  18617. var entry = entries[index];
  18618. this.set(entry[0], entry[1]);
  18619. }
  18620. }
  18621. /**
  18622. * Removes all key-value entries from the list cache.
  18623. *
  18624. * @private
  18625. * @name clear
  18626. * @memberOf ListCache
  18627. */
  18628. function listCacheClear() {
  18629. this.__data__ = [];
  18630. this.size = 0;
  18631. }
  18632. /**
  18633. * Removes `key` and its value from the list cache.
  18634. *
  18635. * @private
  18636. * @name delete
  18637. * @memberOf ListCache
  18638. * @param {string} key The key of the value to remove.
  18639. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18640. */
  18641. function listCacheDelete(key) {
  18642. var data = this.__data__,
  18643. index = assocIndexOf(data, key);
  18644. if (index < 0) {
  18645. return false;
  18646. }
  18647. var lastIndex = data.length - 1;
  18648. if (index == lastIndex) {
  18649. data.pop();
  18650. } else {
  18651. splice.call(data, index, 1);
  18652. }
  18653. --this.size;
  18654. return true;
  18655. }
  18656. /**
  18657. * Gets the list cache value for `key`.
  18658. *
  18659. * @private
  18660. * @name get
  18661. * @memberOf ListCache
  18662. * @param {string} key The key of the value to get.
  18663. * @returns {*} Returns the entry value.
  18664. */
  18665. function listCacheGet(key) {
  18666. var data = this.__data__,
  18667. index = assocIndexOf(data, key);
  18668. return index < 0 ? undefined : data[index][1];
  18669. }
  18670. /**
  18671. * Checks if a list cache value for `key` exists.
  18672. *
  18673. * @private
  18674. * @name has
  18675. * @memberOf ListCache
  18676. * @param {string} key The key of the entry to check.
  18677. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18678. */
  18679. function listCacheHas(key) {
  18680. return assocIndexOf(this.__data__, key) > -1;
  18681. }
  18682. /**
  18683. * Sets the list cache `key` to `value`.
  18684. *
  18685. * @private
  18686. * @name set
  18687. * @memberOf ListCache
  18688. * @param {string} key The key of the value to set.
  18689. * @param {*} value The value to set.
  18690. * @returns {Object} Returns the list cache instance.
  18691. */
  18692. function listCacheSet(key, value) {
  18693. var data = this.__data__,
  18694. index = assocIndexOf(data, key);
  18695. if (index < 0) {
  18696. ++this.size;
  18697. data.push([key, value]);
  18698. } else {
  18699. data[index][1] = value;
  18700. }
  18701. return this;
  18702. }
  18703. // Add methods to `ListCache`.
  18704. ListCache.prototype.clear = listCacheClear;
  18705. ListCache.prototype['delete'] = listCacheDelete;
  18706. ListCache.prototype.get = listCacheGet;
  18707. ListCache.prototype.has = listCacheHas;
  18708. ListCache.prototype.set = listCacheSet;
  18709. /*------------------------------------------------------------------------*/
  18710. /**
  18711. * Creates a map cache object to store key-value pairs.
  18712. *
  18713. * @private
  18714. * @constructor
  18715. * @param {Array} [entries] The key-value pairs to cache.
  18716. */
  18717. function MapCache(entries) {
  18718. var index = -1,
  18719. length = entries == null ? 0 : entries.length;
  18720. this.clear();
  18721. while (++index < length) {
  18722. var entry = entries[index];
  18723. this.set(entry[0], entry[1]);
  18724. }
  18725. }
  18726. /**
  18727. * Removes all key-value entries from the map.
  18728. *
  18729. * @private
  18730. * @name clear
  18731. * @memberOf MapCache
  18732. */
  18733. function mapCacheClear() {
  18734. this.size = 0;
  18735. this.__data__ = {
  18736. 'hash': new Hash,
  18737. 'map': new (Map || ListCache),
  18738. 'string': new Hash
  18739. };
  18740. }
  18741. /**
  18742. * Removes `key` and its value from the map.
  18743. *
  18744. * @private
  18745. * @name delete
  18746. * @memberOf MapCache
  18747. * @param {string} key The key of the value to remove.
  18748. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18749. */
  18750. function mapCacheDelete(key) {
  18751. var result = getMapData(this, key)['delete'](key);
  18752. this.size -= result ? 1 : 0;
  18753. return result;
  18754. }
  18755. /**
  18756. * Gets the map value for `key`.
  18757. *
  18758. * @private
  18759. * @name get
  18760. * @memberOf MapCache
  18761. * @param {string} key The key of the value to get.
  18762. * @returns {*} Returns the entry value.
  18763. */
  18764. function mapCacheGet(key) {
  18765. return getMapData(this, key).get(key);
  18766. }
  18767. /**
  18768. * Checks if a map value for `key` exists.
  18769. *
  18770. * @private
  18771. * @name has
  18772. * @memberOf MapCache
  18773. * @param {string} key The key of the entry to check.
  18774. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18775. */
  18776. function mapCacheHas(key) {
  18777. return getMapData(this, key).has(key);
  18778. }
  18779. /**
  18780. * Sets the map `key` to `value`.
  18781. *
  18782. * @private
  18783. * @name set
  18784. * @memberOf MapCache
  18785. * @param {string} key The key of the value to set.
  18786. * @param {*} value The value to set.
  18787. * @returns {Object} Returns the map cache instance.
  18788. */
  18789. function mapCacheSet(key, value) {
  18790. var data = getMapData(this, key),
  18791. size = data.size;
  18792. data.set(key, value);
  18793. this.size += data.size == size ? 0 : 1;
  18794. return this;
  18795. }
  18796. // Add methods to `MapCache`.
  18797. MapCache.prototype.clear = mapCacheClear;
  18798. MapCache.prototype['delete'] = mapCacheDelete;
  18799. MapCache.prototype.get = mapCacheGet;
  18800. MapCache.prototype.has = mapCacheHas;
  18801. MapCache.prototype.set = mapCacheSet;
  18802. /*------------------------------------------------------------------------*/
  18803. /**
  18804. *
  18805. * Creates an array cache object to store unique values.
  18806. *
  18807. * @private
  18808. * @constructor
  18809. * @param {Array} [values] The values to cache.
  18810. */
  18811. function SetCache(values) {
  18812. var index = -1,
  18813. length = values == null ? 0 : values.length;
  18814. this.__data__ = new MapCache;
  18815. while (++index < length) {
  18816. this.add(values[index]);
  18817. }
  18818. }
  18819. /**
  18820. * Adds `value` to the array cache.
  18821. *
  18822. * @private
  18823. * @name add
  18824. * @memberOf SetCache
  18825. * @alias push
  18826. * @param {*} value The value to cache.
  18827. * @returns {Object} Returns the cache instance.
  18828. */
  18829. function setCacheAdd(value) {
  18830. this.__data__.set(value, HASH_UNDEFINED);
  18831. return this;
  18832. }
  18833. /**
  18834. * Checks if `value` is in the array cache.
  18835. *
  18836. * @private
  18837. * @name has
  18838. * @memberOf SetCache
  18839. * @param {*} value The value to search for.
  18840. * @returns {number} Returns `true` if `value` is found, else `false`.
  18841. */
  18842. function setCacheHas(value) {
  18843. return this.__data__.has(value);
  18844. }
  18845. // Add methods to `SetCache`.
  18846. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  18847. SetCache.prototype.has = setCacheHas;
  18848. /*------------------------------------------------------------------------*/
  18849. /**
  18850. * Creates a stack cache object to store key-value pairs.
  18851. *
  18852. * @private
  18853. * @constructor
  18854. * @param {Array} [entries] The key-value pairs to cache.
  18855. */
  18856. function Stack(entries) {
  18857. var data = this.__data__ = new ListCache(entries);
  18858. this.size = data.size;
  18859. }
  18860. /**
  18861. * Removes all key-value entries from the stack.
  18862. *
  18863. * @private
  18864. * @name clear
  18865. * @memberOf Stack
  18866. */
  18867. function stackClear() {
  18868. this.__data__ = new ListCache;
  18869. this.size = 0;
  18870. }
  18871. /**
  18872. * Removes `key` and its value from the stack.
  18873. *
  18874. * @private
  18875. * @name delete
  18876. * @memberOf Stack
  18877. * @param {string} key The key of the value to remove.
  18878. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  18879. */
  18880. function stackDelete(key) {
  18881. var data = this.__data__,
  18882. result = data['delete'](key);
  18883. this.size = data.size;
  18884. return result;
  18885. }
  18886. /**
  18887. * Gets the stack value for `key`.
  18888. *
  18889. * @private
  18890. * @name get
  18891. * @memberOf Stack
  18892. * @param {string} key The key of the value to get.
  18893. * @returns {*} Returns the entry value.
  18894. */
  18895. function stackGet(key) {
  18896. return this.__data__.get(key);
  18897. }
  18898. /**
  18899. * Checks if a stack value for `key` exists.
  18900. *
  18901. * @private
  18902. * @name has
  18903. * @memberOf Stack
  18904. * @param {string} key The key of the entry to check.
  18905. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18906. */
  18907. function stackHas(key) {
  18908. return this.__data__.has(key);
  18909. }
  18910. /**
  18911. * Sets the stack `key` to `value`.
  18912. *
  18913. * @private
  18914. * @name set
  18915. * @memberOf Stack
  18916. * @param {string} key The key of the value to set.
  18917. * @param {*} value The value to set.
  18918. * @returns {Object} Returns the stack cache instance.
  18919. */
  18920. function stackSet(key, value) {
  18921. var data = this.__data__;
  18922. if (data instanceof ListCache) {
  18923. var pairs = data.__data__;
  18924. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  18925. pairs.push([key, value]);
  18926. this.size = ++data.size;
  18927. return this;
  18928. }
  18929. data = this.__data__ = new MapCache(pairs);
  18930. }
  18931. data.set(key, value);
  18932. this.size = data.size;
  18933. return this;
  18934. }
  18935. // Add methods to `Stack`.
  18936. Stack.prototype.clear = stackClear;
  18937. Stack.prototype['delete'] = stackDelete;
  18938. Stack.prototype.get = stackGet;
  18939. Stack.prototype.has = stackHas;
  18940. Stack.prototype.set = stackSet;
  18941. /*------------------------------------------------------------------------*/
  18942. /**
  18943. * Creates an array of the enumerable property names of the array-like `value`.
  18944. *
  18945. * @private
  18946. * @param {*} value The value to query.
  18947. * @param {boolean} inherited Specify returning inherited property names.
  18948. * @returns {Array} Returns the array of property names.
  18949. */
  18950. function arrayLikeKeys(value, inherited) {
  18951. var isArr = isArray(value),
  18952. isArg = !isArr && isArguments(value),
  18953. isBuff = !isArr && !isArg && isBuffer(value),
  18954. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  18955. skipIndexes = isArr || isArg || isBuff || isType,
  18956. result = skipIndexes ? baseTimes(value.length, String) : [],
  18957. length = result.length;
  18958. for (var key in value) {
  18959. if ((inherited || hasOwnProperty.call(value, key)) &&
  18960. !(skipIndexes && (
  18961. // Safari 9 has enumerable `arguments.length` in strict mode.
  18962. key == 'length' ||
  18963. // Node.js 0.10 has enumerable non-index properties on buffers.
  18964. (isBuff && (key == 'offset' || key == 'parent')) ||
  18965. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  18966. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  18967. // Skip index properties.
  18968. isIndex(key, length)
  18969. ))) {
  18970. result.push(key);
  18971. }
  18972. }
  18973. return result;
  18974. }
  18975. /**
  18976. * A specialized version of `_.sample` for arrays.
  18977. *
  18978. * @private
  18979. * @param {Array} array The array to sample.
  18980. * @returns {*} Returns the random element.
  18981. */
  18982. function arraySample(array) {
  18983. var length = array.length;
  18984. return length ? array[baseRandom(0, length - 1)] : undefined;
  18985. }
  18986. /**
  18987. * A specialized version of `_.sampleSize` for arrays.
  18988. *
  18989. * @private
  18990. * @param {Array} array The array to sample.
  18991. * @param {number} n The number of elements to sample.
  18992. * @returns {Array} Returns the random elements.
  18993. */
  18994. function arraySampleSize(array, n) {
  18995. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  18996. }
  18997. /**
  18998. * A specialized version of `_.shuffle` for arrays.
  18999. *
  19000. * @private
  19001. * @param {Array} array The array to shuffle.
  19002. * @returns {Array} Returns the new shuffled array.
  19003. */
  19004. function arrayShuffle(array) {
  19005. return shuffleSelf(copyArray(array));
  19006. }
  19007. /**
  19008. * This function is like `assignValue` except that it doesn't assign
  19009. * `undefined` values.
  19010. *
  19011. * @private
  19012. * @param {Object} object The object to modify.
  19013. * @param {string} key The key of the property to assign.
  19014. * @param {*} value The value to assign.
  19015. */
  19016. function assignMergeValue(object, key, value) {
  19017. if ((value !== undefined && !eq(object[key], value)) ||
  19018. (value === undefined && !(key in object))) {
  19019. baseAssignValue(object, key, value);
  19020. }
  19021. }
  19022. /**
  19023. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19024. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19025. * for equality comparisons.
  19026. *
  19027. * @private
  19028. * @param {Object} object The object to modify.
  19029. * @param {string} key The key of the property to assign.
  19030. * @param {*} value The value to assign.
  19031. */
  19032. function assignValue(object, key, value) {
  19033. var objValue = object[key];
  19034. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19035. (value === undefined && !(key in object))) {
  19036. baseAssignValue(object, key, value);
  19037. }
  19038. }
  19039. /**
  19040. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19041. *
  19042. * @private
  19043. * @param {Array} array The array to inspect.
  19044. * @param {*} key The key to search for.
  19045. * @returns {number} Returns the index of the matched value, else `-1`.
  19046. */
  19047. function assocIndexOf(array, key) {
  19048. var length = array.length;
  19049. while (length--) {
  19050. if (eq(array[length][0], key)) {
  19051. return length;
  19052. }
  19053. }
  19054. return -1;
  19055. }
  19056. /**
  19057. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19058. * by `iteratee` and values set by `setter`.
  19059. *
  19060. * @private
  19061. * @param {Array|Object} collection The collection to iterate over.
  19062. * @param {Function} setter The function to set `accumulator` values.
  19063. * @param {Function} iteratee The iteratee to transform keys.
  19064. * @param {Object} accumulator The initial aggregated object.
  19065. * @returns {Function} Returns `accumulator`.
  19066. */
  19067. function baseAggregator(collection, setter, iteratee, accumulator) {
  19068. baseEach(collection, function(value, key, collection) {
  19069. setter(accumulator, value, iteratee(value), collection);
  19070. });
  19071. return accumulator;
  19072. }
  19073. /**
  19074. * The base implementation of `_.assign` without support for multiple sources
  19075. * or `customizer` functions.
  19076. *
  19077. * @private
  19078. * @param {Object} object The destination object.
  19079. * @param {Object} source The source object.
  19080. * @returns {Object} Returns `object`.
  19081. */
  19082. function baseAssign(object, source) {
  19083. return object && copyObject(source, keys(source), object);
  19084. }
  19085. /**
  19086. * The base implementation of `_.assignIn` without support for multiple sources
  19087. * or `customizer` functions.
  19088. *
  19089. * @private
  19090. * @param {Object} object The destination object.
  19091. * @param {Object} source The source object.
  19092. * @returns {Object} Returns `object`.
  19093. */
  19094. function baseAssignIn(object, source) {
  19095. return object && copyObject(source, keysIn(source), object);
  19096. }
  19097. /**
  19098. * The base implementation of `assignValue` and `assignMergeValue` without
  19099. * value checks.
  19100. *
  19101. * @private
  19102. * @param {Object} object The object to modify.
  19103. * @param {string} key The key of the property to assign.
  19104. * @param {*} value The value to assign.
  19105. */
  19106. function baseAssignValue(object, key, value) {
  19107. if (key == '__proto__' && defineProperty) {
  19108. defineProperty(object, key, {
  19109. 'configurable': true,
  19110. 'enumerable': true,
  19111. 'value': value,
  19112. 'writable': true
  19113. });
  19114. } else {
  19115. object[key] = value;
  19116. }
  19117. }
  19118. /**
  19119. * The base implementation of `_.at` without support for individual paths.
  19120. *
  19121. * @private
  19122. * @param {Object} object The object to iterate over.
  19123. * @param {string[]} paths The property paths to pick.
  19124. * @returns {Array} Returns the picked elements.
  19125. */
  19126. function baseAt(object, paths) {
  19127. var index = -1,
  19128. length = paths.length,
  19129. result = Array(length),
  19130. skip = object == null;
  19131. while (++index < length) {
  19132. result[index] = skip ? undefined : get(object, paths[index]);
  19133. }
  19134. return result;
  19135. }
  19136. /**
  19137. * The base implementation of `_.clamp` which doesn't coerce arguments.
  19138. *
  19139. * @private
  19140. * @param {number} number The number to clamp.
  19141. * @param {number} [lower] The lower bound.
  19142. * @param {number} upper The upper bound.
  19143. * @returns {number} Returns the clamped number.
  19144. */
  19145. function baseClamp(number, lower, upper) {
  19146. if (number === number) {
  19147. if (upper !== undefined) {
  19148. number = number <= upper ? number : upper;
  19149. }
  19150. if (lower !== undefined) {
  19151. number = number >= lower ? number : lower;
  19152. }
  19153. }
  19154. return number;
  19155. }
  19156. /**
  19157. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  19158. * traversed objects.
  19159. *
  19160. * @private
  19161. * @param {*} value The value to clone.
  19162. * @param {boolean} bitmask The bitmask flags.
  19163. * 1 - Deep clone
  19164. * 2 - Flatten inherited properties
  19165. * 4 - Clone symbols
  19166. * @param {Function} [customizer] The function to customize cloning.
  19167. * @param {string} [key] The key of `value`.
  19168. * @param {Object} [object] The parent object of `value`.
  19169. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  19170. * @returns {*} Returns the cloned value.
  19171. */
  19172. function baseClone(value, bitmask, customizer, key, object, stack) {
  19173. var result,
  19174. isDeep = bitmask & CLONE_DEEP_FLAG,
  19175. isFlat = bitmask & CLONE_FLAT_FLAG,
  19176. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  19177. if (customizer) {
  19178. result = object ? customizer(value, key, object, stack) : customizer(value);
  19179. }
  19180. if (result !== undefined) {
  19181. return result;
  19182. }
  19183. if (!isObject(value)) {
  19184. return value;
  19185. }
  19186. var isArr = isArray(value);
  19187. if (isArr) {
  19188. result = initCloneArray(value);
  19189. if (!isDeep) {
  19190. return copyArray(value, result);
  19191. }
  19192. } else {
  19193. var tag = getTag(value),
  19194. isFunc = tag == funcTag || tag == genTag;
  19195. if (isBuffer(value)) {
  19196. return cloneBuffer(value, isDeep);
  19197. }
  19198. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  19199. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  19200. if (!isDeep) {
  19201. return isFlat
  19202. ? copySymbolsIn(value, baseAssignIn(result, value))
  19203. : copySymbols(value, baseAssign(result, value));
  19204. }
  19205. } else {
  19206. if (!cloneableTags[tag]) {
  19207. return object ? value : {};
  19208. }
  19209. result = initCloneByTag(value, tag, isDeep);
  19210. }
  19211. }
  19212. // Check for circular references and return its corresponding clone.
  19213. stack || (stack = new Stack);
  19214. var stacked = stack.get(value);
  19215. if (stacked) {
  19216. return stacked;
  19217. }
  19218. stack.set(value, result);
  19219. if (isSet(value)) {
  19220. value.forEach(function(subValue) {
  19221. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  19222. });
  19223. } else if (isMap(value)) {
  19224. value.forEach(function(subValue, key) {
  19225. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19226. });
  19227. }
  19228. var keysFunc = isFull
  19229. ? (isFlat ? getAllKeysIn : getAllKeys)
  19230. : (isFlat ? keysIn : keys);
  19231. var props = isArr ? undefined : keysFunc(value);
  19232. arrayEach(props || value, function(subValue, key) {
  19233. if (props) {
  19234. key = subValue;
  19235. subValue = value[key];
  19236. }
  19237. // Recursively populate clone (susceptible to call stack limits).
  19238. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  19239. });
  19240. return result;
  19241. }
  19242. /**
  19243. * The base implementation of `_.conforms` which doesn't clone `source`.
  19244. *
  19245. * @private
  19246. * @param {Object} source The object of property predicates to conform to.
  19247. * @returns {Function} Returns the new spec function.
  19248. */
  19249. function baseConforms(source) {
  19250. var props = keys(source);
  19251. return function(object) {
  19252. return baseConformsTo(object, source, props);
  19253. };
  19254. }
  19255. /**
  19256. * The base implementation of `_.conformsTo` which accepts `props` to check.
  19257. *
  19258. * @private
  19259. * @param {Object} object The object to inspect.
  19260. * @param {Object} source The object of property predicates to conform to.
  19261. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  19262. */
  19263. function baseConformsTo(object, source, props) {
  19264. var length = props.length;
  19265. if (object == null) {
  19266. return !length;
  19267. }
  19268. object = Object(object);
  19269. while (length--) {
  19270. var key = props[length],
  19271. predicate = source[key],
  19272. value = object[key];
  19273. if ((value === undefined && !(key in object)) || !predicate(value)) {
  19274. return false;
  19275. }
  19276. }
  19277. return true;
  19278. }
  19279. /**
  19280. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  19281. * to provide to `func`.
  19282. *
  19283. * @private
  19284. * @param {Function} func The function to delay.
  19285. * @param {number} wait The number of milliseconds to delay invocation.
  19286. * @param {Array} args The arguments to provide to `func`.
  19287. * @returns {number|Object} Returns the timer id or timeout object.
  19288. */
  19289. function baseDelay(func, wait, args) {
  19290. if (typeof func != 'function') {
  19291. throw new TypeError(FUNC_ERROR_TEXT);
  19292. }
  19293. return setTimeout(function() { func.apply(undefined, args); }, wait);
  19294. }
  19295. /**
  19296. * The base implementation of methods like `_.difference` without support
  19297. * for excluding multiple arrays or iteratee shorthands.
  19298. *
  19299. * @private
  19300. * @param {Array} array The array to inspect.
  19301. * @param {Array} values The values to exclude.
  19302. * @param {Function} [iteratee] The iteratee invoked per element.
  19303. * @param {Function} [comparator] The comparator invoked per element.
  19304. * @returns {Array} Returns the new array of filtered values.
  19305. */
  19306. function baseDifference(array, values, iteratee, comparator) {
  19307. var index = -1,
  19308. includes = arrayIncludes,
  19309. isCommon = true,
  19310. length = array.length,
  19311. result = [],
  19312. valuesLength = values.length;
  19313. if (!length) {
  19314. return result;
  19315. }
  19316. if (iteratee) {
  19317. values = arrayMap(values, baseUnary(iteratee));
  19318. }
  19319. if (comparator) {
  19320. includes = arrayIncludesWith;
  19321. isCommon = false;
  19322. }
  19323. else if (values.length >= LARGE_ARRAY_SIZE) {
  19324. includes = cacheHas;
  19325. isCommon = false;
  19326. values = new SetCache(values);
  19327. }
  19328. outer:
  19329. while (++index < length) {
  19330. var value = array[index],
  19331. computed = iteratee == null ? value : iteratee(value);
  19332. value = (comparator || value !== 0) ? value : 0;
  19333. if (isCommon && computed === computed) {
  19334. var valuesIndex = valuesLength;
  19335. while (valuesIndex--) {
  19336. if (values[valuesIndex] === computed) {
  19337. continue outer;
  19338. }
  19339. }
  19340. result.push(value);
  19341. }
  19342. else if (!includes(values, computed, comparator)) {
  19343. result.push(value);
  19344. }
  19345. }
  19346. return result;
  19347. }
  19348. /**
  19349. * The base implementation of `_.forEach` without support for iteratee shorthands.
  19350. *
  19351. * @private
  19352. * @param {Array|Object} collection The collection to iterate over.
  19353. * @param {Function} iteratee The function invoked per iteration.
  19354. * @returns {Array|Object} Returns `collection`.
  19355. */
  19356. var baseEach = createBaseEach(baseForOwn);
  19357. /**
  19358. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  19359. *
  19360. * @private
  19361. * @param {Array|Object} collection The collection to iterate over.
  19362. * @param {Function} iteratee The function invoked per iteration.
  19363. * @returns {Array|Object} Returns `collection`.
  19364. */
  19365. var baseEachRight = createBaseEach(baseForOwnRight, true);
  19366. /**
  19367. * The base implementation of `_.every` without support for iteratee shorthands.
  19368. *
  19369. * @private
  19370. * @param {Array|Object} collection The collection to iterate over.
  19371. * @param {Function} predicate The function invoked per iteration.
  19372. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  19373. * else `false`
  19374. */
  19375. function baseEvery(collection, predicate) {
  19376. var result = true;
  19377. baseEach(collection, function(value, index, collection) {
  19378. result = !!predicate(value, index, collection);
  19379. return result;
  19380. });
  19381. return result;
  19382. }
  19383. /**
  19384. * The base implementation of methods like `_.max` and `_.min` which accepts a
  19385. * `comparator` to determine the extremum value.
  19386. *
  19387. * @private
  19388. * @param {Array} array The array to iterate over.
  19389. * @param {Function} iteratee The iteratee invoked per iteration.
  19390. * @param {Function} comparator The comparator used to compare values.
  19391. * @returns {*} Returns the extremum value.
  19392. */
  19393. function baseExtremum(array, iteratee, comparator) {
  19394. var index = -1,
  19395. length = array.length;
  19396. while (++index < length) {
  19397. var value = array[index],
  19398. current = iteratee(value);
  19399. if (current != null && (computed === undefined
  19400. ? (current === current && !isSymbol(current))
  19401. : comparator(current, computed)
  19402. )) {
  19403. var computed = current,
  19404. result = value;
  19405. }
  19406. }
  19407. return result;
  19408. }
  19409. /**
  19410. * The base implementation of `_.fill` without an iteratee call guard.
  19411. *
  19412. * @private
  19413. * @param {Array} array The array to fill.
  19414. * @param {*} value The value to fill `array` with.
  19415. * @param {number} [start=0] The start position.
  19416. * @param {number} [end=array.length] The end position.
  19417. * @returns {Array} Returns `array`.
  19418. */
  19419. function baseFill(array, value, start, end) {
  19420. var length = array.length;
  19421. start = toInteger(start);
  19422. if (start < 0) {
  19423. start = -start > length ? 0 : (length + start);
  19424. }
  19425. end = (end === undefined || end > length) ? length : toInteger(end);
  19426. if (end < 0) {
  19427. end += length;
  19428. }
  19429. end = start > end ? 0 : toLength(end);
  19430. while (start < end) {
  19431. array[start++] = value;
  19432. }
  19433. return array;
  19434. }
  19435. /**
  19436. * The base implementation of `_.filter` without support for iteratee shorthands.
  19437. *
  19438. * @private
  19439. * @param {Array|Object} collection The collection to iterate over.
  19440. * @param {Function} predicate The function invoked per iteration.
  19441. * @returns {Array} Returns the new filtered array.
  19442. */
  19443. function baseFilter(collection, predicate) {
  19444. var result = [];
  19445. baseEach(collection, function(value, index, collection) {
  19446. if (predicate(value, index, collection)) {
  19447. result.push(value);
  19448. }
  19449. });
  19450. return result;
  19451. }
  19452. /**
  19453. * The base implementation of `_.flatten` with support for restricting flattening.
  19454. *
  19455. * @private
  19456. * @param {Array} array The array to flatten.
  19457. * @param {number} depth The maximum recursion depth.
  19458. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  19459. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  19460. * @param {Array} [result=[]] The initial result value.
  19461. * @returns {Array} Returns the new flattened array.
  19462. */
  19463. function baseFlatten(array, depth, predicate, isStrict, result) {
  19464. var index = -1,
  19465. length = array.length;
  19466. predicate || (predicate = isFlattenable);
  19467. result || (result = []);
  19468. while (++index < length) {
  19469. var value = array[index];
  19470. if (depth > 0 && predicate(value)) {
  19471. if (depth > 1) {
  19472. // Recursively flatten arrays (susceptible to call stack limits).
  19473. baseFlatten(value, depth - 1, predicate, isStrict, result);
  19474. } else {
  19475. arrayPush(result, value);
  19476. }
  19477. } else if (!isStrict) {
  19478. result[result.length] = value;
  19479. }
  19480. }
  19481. return result;
  19482. }
  19483. /**
  19484. * The base implementation of `baseForOwn` which iterates over `object`
  19485. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  19486. * Iteratee functions may exit iteration early by explicitly returning `false`.
  19487. *
  19488. * @private
  19489. * @param {Object} object The object to iterate over.
  19490. * @param {Function} iteratee The function invoked per iteration.
  19491. * @param {Function} keysFunc The function to get the keys of `object`.
  19492. * @returns {Object} Returns `object`.
  19493. */
  19494. var baseFor = createBaseFor();
  19495. /**
  19496. * This function is like `baseFor` except that it iterates over properties
  19497. * in the opposite order.
  19498. *
  19499. * @private
  19500. * @param {Object} object The object to iterate over.
  19501. * @param {Function} iteratee The function invoked per iteration.
  19502. * @param {Function} keysFunc The function to get the keys of `object`.
  19503. * @returns {Object} Returns `object`.
  19504. */
  19505. var baseForRight = createBaseFor(true);
  19506. /**
  19507. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  19508. *
  19509. * @private
  19510. * @param {Object} object The object to iterate over.
  19511. * @param {Function} iteratee The function invoked per iteration.
  19512. * @returns {Object} Returns `object`.
  19513. */
  19514. function baseForOwn(object, iteratee) {
  19515. return object && baseFor(object, iteratee, keys);
  19516. }
  19517. /**
  19518. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  19519. *
  19520. * @private
  19521. * @param {Object} object The object to iterate over.
  19522. * @param {Function} iteratee The function invoked per iteration.
  19523. * @returns {Object} Returns `object`.
  19524. */
  19525. function baseForOwnRight(object, iteratee) {
  19526. return object && baseForRight(object, iteratee, keys);
  19527. }
  19528. /**
  19529. * The base implementation of `_.functions` which creates an array of
  19530. * `object` function property names filtered from `props`.
  19531. *
  19532. * @private
  19533. * @param {Object} object The object to inspect.
  19534. * @param {Array} props The property names to filter.
  19535. * @returns {Array} Returns the function names.
  19536. */
  19537. function baseFunctions(object, props) {
  19538. return arrayFilter(props, function(key) {
  19539. return isFunction(object[key]);
  19540. });
  19541. }
  19542. /**
  19543. * The base implementation of `_.get` without support for default values.
  19544. *
  19545. * @private
  19546. * @param {Object} object The object to query.
  19547. * @param {Array|string} path The path of the property to get.
  19548. * @returns {*} Returns the resolved value.
  19549. */
  19550. function baseGet(object, path) {
  19551. path = castPath(path, object);
  19552. var index = 0,
  19553. length = path.length;
  19554. while (object != null && index < length) {
  19555. object = object[toKey(path[index++])];
  19556. }
  19557. return (index && index == length) ? object : undefined;
  19558. }
  19559. /**
  19560. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  19561. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  19562. * symbols of `object`.
  19563. *
  19564. * @private
  19565. * @param {Object} object The object to query.
  19566. * @param {Function} keysFunc The function to get the keys of `object`.
  19567. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  19568. * @returns {Array} Returns the array of property names and symbols.
  19569. */
  19570. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  19571. var result = keysFunc(object);
  19572. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  19573. }
  19574. /**
  19575. * The base implementation of `getTag` without fallbacks for buggy environments.
  19576. *
  19577. * @private
  19578. * @param {*} value The value to query.
  19579. * @returns {string} Returns the `toStringTag`.
  19580. */
  19581. function baseGetTag(value) {
  19582. if (value == null) {
  19583. return value === undefined ? undefinedTag : nullTag;
  19584. }
  19585. return (symToStringTag && symToStringTag in Object(value))
  19586. ? getRawTag(value)
  19587. : objectToString(value);
  19588. }
  19589. /**
  19590. * The base implementation of `_.gt` which doesn't coerce arguments.
  19591. *
  19592. * @private
  19593. * @param {*} value The value to compare.
  19594. * @param {*} other The other value to compare.
  19595. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  19596. * else `false`.
  19597. */
  19598. function baseGt(value, other) {
  19599. return value > other;
  19600. }
  19601. /**
  19602. * The base implementation of `_.has` without support for deep paths.
  19603. *
  19604. * @private
  19605. * @param {Object} [object] The object to query.
  19606. * @param {Array|string} key The key to check.
  19607. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19608. */
  19609. function baseHas(object, key) {
  19610. return object != null && hasOwnProperty.call(object, key);
  19611. }
  19612. /**
  19613. * The base implementation of `_.hasIn` without support for deep paths.
  19614. *
  19615. * @private
  19616. * @param {Object} [object] The object to query.
  19617. * @param {Array|string} key The key to check.
  19618. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  19619. */
  19620. function baseHasIn(object, key) {
  19621. return object != null && key in Object(object);
  19622. }
  19623. /**
  19624. * The base implementation of `_.inRange` which doesn't coerce arguments.
  19625. *
  19626. * @private
  19627. * @param {number} number The number to check.
  19628. * @param {number} start The start of the range.
  19629. * @param {number} end The end of the range.
  19630. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  19631. */
  19632. function baseInRange(number, start, end) {
  19633. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  19634. }
  19635. /**
  19636. * The base implementation of methods like `_.intersection`, without support
  19637. * for iteratee shorthands, that accepts an array of arrays to inspect.
  19638. *
  19639. * @private
  19640. * @param {Array} arrays The arrays to inspect.
  19641. * @param {Function} [iteratee] The iteratee invoked per element.
  19642. * @param {Function} [comparator] The comparator invoked per element.
  19643. * @returns {Array} Returns the new array of shared values.
  19644. */
  19645. function baseIntersection(arrays, iteratee, comparator) {
  19646. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  19647. length = arrays[0].length,
  19648. othLength = arrays.length,
  19649. othIndex = othLength,
  19650. caches = Array(othLength),
  19651. maxLength = Infinity,
  19652. result = [];
  19653. while (othIndex--) {
  19654. var array = arrays[othIndex];
  19655. if (othIndex && iteratee) {
  19656. array = arrayMap(array, baseUnary(iteratee));
  19657. }
  19658. maxLength = nativeMin(array.length, maxLength);
  19659. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  19660. ? new SetCache(othIndex && array)
  19661. : undefined;
  19662. }
  19663. array = arrays[0];
  19664. var index = -1,
  19665. seen = caches[0];
  19666. outer:
  19667. while (++index < length && result.length < maxLength) {
  19668. var value = array[index],
  19669. computed = iteratee ? iteratee(value) : value;
  19670. value = (comparator || value !== 0) ? value : 0;
  19671. if (!(seen
  19672. ? cacheHas(seen, computed)
  19673. : includes(result, computed, comparator)
  19674. )) {
  19675. othIndex = othLength;
  19676. while (--othIndex) {
  19677. var cache = caches[othIndex];
  19678. if (!(cache
  19679. ? cacheHas(cache, computed)
  19680. : includes(arrays[othIndex], computed, comparator))
  19681. ) {
  19682. continue outer;
  19683. }
  19684. }
  19685. if (seen) {
  19686. seen.push(computed);
  19687. }
  19688. result.push(value);
  19689. }
  19690. }
  19691. return result;
  19692. }
  19693. /**
  19694. * The base implementation of `_.invert` and `_.invertBy` which inverts
  19695. * `object` with values transformed by `iteratee` and set by `setter`.
  19696. *
  19697. * @private
  19698. * @param {Object} object The object to iterate over.
  19699. * @param {Function} setter The function to set `accumulator` values.
  19700. * @param {Function} iteratee The iteratee to transform values.
  19701. * @param {Object} accumulator The initial inverted object.
  19702. * @returns {Function} Returns `accumulator`.
  19703. */
  19704. function baseInverter(object, setter, iteratee, accumulator) {
  19705. baseForOwn(object, function(value, key, object) {
  19706. setter(accumulator, iteratee(value), key, object);
  19707. });
  19708. return accumulator;
  19709. }
  19710. /**
  19711. * The base implementation of `_.invoke` without support for individual
  19712. * method arguments.
  19713. *
  19714. * @private
  19715. * @param {Object} object The object to query.
  19716. * @param {Array|string} path The path of the method to invoke.
  19717. * @param {Array} args The arguments to invoke the method with.
  19718. * @returns {*} Returns the result of the invoked method.
  19719. */
  19720. function baseInvoke(object, path, args) {
  19721. path = castPath(path, object);
  19722. object = parent(object, path);
  19723. var func = object == null ? object : object[toKey(last(path))];
  19724. return func == null ? undefined : apply(func, object, args);
  19725. }
  19726. /**
  19727. * The base implementation of `_.isArguments`.
  19728. *
  19729. * @private
  19730. * @param {*} value The value to check.
  19731. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  19732. */
  19733. function baseIsArguments(value) {
  19734. return isObjectLike(value) && baseGetTag(value) == argsTag;
  19735. }
  19736. /**
  19737. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  19738. *
  19739. * @private
  19740. * @param {*} value The value to check.
  19741. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  19742. */
  19743. function baseIsArrayBuffer(value) {
  19744. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  19745. }
  19746. /**
  19747. * The base implementation of `_.isDate` without Node.js optimizations.
  19748. *
  19749. * @private
  19750. * @param {*} value The value to check.
  19751. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  19752. */
  19753. function baseIsDate(value) {
  19754. return isObjectLike(value) && baseGetTag(value) == dateTag;
  19755. }
  19756. /**
  19757. * The base implementation of `_.isEqual` which supports partial comparisons
  19758. * and tracks traversed objects.
  19759. *
  19760. * @private
  19761. * @param {*} value The value to compare.
  19762. * @param {*} other The other value to compare.
  19763. * @param {boolean} bitmask The bitmask flags.
  19764. * 1 - Unordered comparison
  19765. * 2 - Partial comparison
  19766. * @param {Function} [customizer] The function to customize comparisons.
  19767. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  19768. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  19769. */
  19770. function baseIsEqual(value, other, bitmask, customizer, stack) {
  19771. if (value === other) {
  19772. return true;
  19773. }
  19774. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  19775. return value !== value && other !== other;
  19776. }
  19777. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  19778. }
  19779. /**
  19780. * A specialized version of `baseIsEqual` for arrays and objects which performs
  19781. * deep comparisons and tracks traversed objects enabling objects with circular
  19782. * references to be compared.
  19783. *
  19784. * @private
  19785. * @param {Object} object The object to compare.
  19786. * @param {Object} other The other object to compare.
  19787. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19788. * @param {Function} customizer The function to customize comparisons.
  19789. * @param {Function} equalFunc The function to determine equivalents of values.
  19790. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  19791. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19792. */
  19793. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  19794. var objIsArr = isArray(object),
  19795. othIsArr = isArray(other),
  19796. objTag = objIsArr ? arrayTag : getTag(object),
  19797. othTag = othIsArr ? arrayTag : getTag(other);
  19798. objTag = objTag == argsTag ? objectTag : objTag;
  19799. othTag = othTag == argsTag ? objectTag : othTag;
  19800. var objIsObj = objTag == objectTag,
  19801. othIsObj = othTag == objectTag,
  19802. isSameTag = objTag == othTag;
  19803. if (isSameTag && isBuffer(object)) {
  19804. if (!isBuffer(other)) {
  19805. return false;
  19806. }
  19807. objIsArr = true;
  19808. objIsObj = false;
  19809. }
  19810. if (isSameTag && !objIsObj) {
  19811. stack || (stack = new Stack);
  19812. return (objIsArr || isTypedArray(object))
  19813. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  19814. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  19815. }
  19816. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  19817. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  19818. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  19819. if (objIsWrapped || othIsWrapped) {
  19820. var objUnwrapped = objIsWrapped ? object.value() : object,
  19821. othUnwrapped = othIsWrapped ? other.value() : other;
  19822. stack || (stack = new Stack);
  19823. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  19824. }
  19825. }
  19826. if (!isSameTag) {
  19827. return false;
  19828. }
  19829. stack || (stack = new Stack);
  19830. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  19831. }
  19832. /**
  19833. * The base implementation of `_.isMap` without Node.js optimizations.
  19834. *
  19835. * @private
  19836. * @param {*} value The value to check.
  19837. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  19838. */
  19839. function baseIsMap(value) {
  19840. return isObjectLike(value) && getTag(value) == mapTag;
  19841. }
  19842. /**
  19843. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  19844. *
  19845. * @private
  19846. * @param {Object} object The object to inspect.
  19847. * @param {Object} source The object of property values to match.
  19848. * @param {Array} matchData The property names, values, and compare flags to match.
  19849. * @param {Function} [customizer] The function to customize comparisons.
  19850. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  19851. */
  19852. function baseIsMatch(object, source, matchData, customizer) {
  19853. var index = matchData.length,
  19854. length = index,
  19855. noCustomizer = !customizer;
  19856. if (object == null) {
  19857. return !length;
  19858. }
  19859. object = Object(object);
  19860. while (index--) {
  19861. var data = matchData[index];
  19862. if ((noCustomizer && data[2])
  19863. ? data[1] !== object[data[0]]
  19864. : !(data[0] in object)
  19865. ) {
  19866. return false;
  19867. }
  19868. }
  19869. while (++index < length) {
  19870. data = matchData[index];
  19871. var key = data[0],
  19872. objValue = object[key],
  19873. srcValue = data[1];
  19874. if (noCustomizer && data[2]) {
  19875. if (objValue === undefined && !(key in object)) {
  19876. return false;
  19877. }
  19878. } else {
  19879. var stack = new Stack;
  19880. if (customizer) {
  19881. var result = customizer(objValue, srcValue, key, object, source, stack);
  19882. }
  19883. if (!(result === undefined
  19884. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  19885. : result
  19886. )) {
  19887. return false;
  19888. }
  19889. }
  19890. }
  19891. return true;
  19892. }
  19893. /**
  19894. * The base implementation of `_.isNative` without bad shim checks.
  19895. *
  19896. * @private
  19897. * @param {*} value The value to check.
  19898. * @returns {boolean} Returns `true` if `value` is a native function,
  19899. * else `false`.
  19900. */
  19901. function baseIsNative(value) {
  19902. if (!isObject(value) || isMasked(value)) {
  19903. return false;
  19904. }
  19905. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  19906. return pattern.test(toSource(value));
  19907. }
  19908. /**
  19909. * The base implementation of `_.isRegExp` without Node.js optimizations.
  19910. *
  19911. * @private
  19912. * @param {*} value The value to check.
  19913. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  19914. */
  19915. function baseIsRegExp(value) {
  19916. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  19917. }
  19918. /**
  19919. * The base implementation of `_.isSet` without Node.js optimizations.
  19920. *
  19921. * @private
  19922. * @param {*} value The value to check.
  19923. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  19924. */
  19925. function baseIsSet(value) {
  19926. return isObjectLike(value) && getTag(value) == setTag;
  19927. }
  19928. /**
  19929. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  19930. *
  19931. * @private
  19932. * @param {*} value The value to check.
  19933. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  19934. */
  19935. function baseIsTypedArray(value) {
  19936. return isObjectLike(value) &&
  19937. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  19938. }
  19939. /**
  19940. * The base implementation of `_.iteratee`.
  19941. *
  19942. * @private
  19943. * @param {*} [value=_.identity] The value to convert to an iteratee.
  19944. * @returns {Function} Returns the iteratee.
  19945. */
  19946. function baseIteratee(value) {
  19947. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  19948. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  19949. if (typeof value == 'function') {
  19950. return value;
  19951. }
  19952. if (value == null) {
  19953. return identity;
  19954. }
  19955. if (typeof value == 'object') {
  19956. return isArray(value)
  19957. ? baseMatchesProperty(value[0], value[1])
  19958. : baseMatches(value);
  19959. }
  19960. return property(value);
  19961. }
  19962. /**
  19963. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  19964. *
  19965. * @private
  19966. * @param {Object} object The object to query.
  19967. * @returns {Array} Returns the array of property names.
  19968. */
  19969. function baseKeys(object) {
  19970. if (!isPrototype(object)) {
  19971. return nativeKeys(object);
  19972. }
  19973. var result = [];
  19974. for (var key in Object(object)) {
  19975. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  19976. result.push(key);
  19977. }
  19978. }
  19979. return result;
  19980. }
  19981. /**
  19982. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  19983. *
  19984. * @private
  19985. * @param {Object} object The object to query.
  19986. * @returns {Array} Returns the array of property names.
  19987. */
  19988. function baseKeysIn(object) {
  19989. if (!isObject(object)) {
  19990. return nativeKeysIn(object);
  19991. }
  19992. var isProto = isPrototype(object),
  19993. result = [];
  19994. for (var key in object) {
  19995. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  19996. result.push(key);
  19997. }
  19998. }
  19999. return result;
  20000. }
  20001. /**
  20002. * The base implementation of `_.lt` which doesn't coerce arguments.
  20003. *
  20004. * @private
  20005. * @param {*} value The value to compare.
  20006. * @param {*} other The other value to compare.
  20007. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20008. * else `false`.
  20009. */
  20010. function baseLt(value, other) {
  20011. return value < other;
  20012. }
  20013. /**
  20014. * The base implementation of `_.map` without support for iteratee shorthands.
  20015. *
  20016. * @private
  20017. * @param {Array|Object} collection The collection to iterate over.
  20018. * @param {Function} iteratee The function invoked per iteration.
  20019. * @returns {Array} Returns the new mapped array.
  20020. */
  20021. function baseMap(collection, iteratee) {
  20022. var index = -1,
  20023. result = isArrayLike(collection) ? Array(collection.length) : [];
  20024. baseEach(collection, function(value, key, collection) {
  20025. result[++index] = iteratee(value, key, collection);
  20026. });
  20027. return result;
  20028. }
  20029. /**
  20030. * The base implementation of `_.matches` which doesn't clone `source`.
  20031. *
  20032. * @private
  20033. * @param {Object} source The object of property values to match.
  20034. * @returns {Function} Returns the new spec function.
  20035. */
  20036. function baseMatches(source) {
  20037. var matchData = getMatchData(source);
  20038. if (matchData.length == 1 && matchData[0][2]) {
  20039. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20040. }
  20041. return function(object) {
  20042. return object === source || baseIsMatch(object, source, matchData);
  20043. };
  20044. }
  20045. /**
  20046. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20047. *
  20048. * @private
  20049. * @param {string} path The path of the property to get.
  20050. * @param {*} srcValue The value to match.
  20051. * @returns {Function} Returns the new spec function.
  20052. */
  20053. function baseMatchesProperty(path, srcValue) {
  20054. if (isKey(path) && isStrictComparable(srcValue)) {
  20055. return matchesStrictComparable(toKey(path), srcValue);
  20056. }
  20057. return function(object) {
  20058. var objValue = get(object, path);
  20059. return (objValue === undefined && objValue === srcValue)
  20060. ? hasIn(object, path)
  20061. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20062. };
  20063. }
  20064. /**
  20065. * The base implementation of `_.merge` without support for multiple sources.
  20066. *
  20067. * @private
  20068. * @param {Object} object The destination object.
  20069. * @param {Object} source The source object.
  20070. * @param {number} srcIndex The index of `source`.
  20071. * @param {Function} [customizer] The function to customize merged values.
  20072. * @param {Object} [stack] Tracks traversed source values and their merged
  20073. * counterparts.
  20074. */
  20075. function baseMerge(object, source, srcIndex, customizer, stack) {
  20076. if (object === source) {
  20077. return;
  20078. }
  20079. baseFor(source, function(srcValue, key) {
  20080. stack || (stack = new Stack);
  20081. if (isObject(srcValue)) {
  20082. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  20083. }
  20084. else {
  20085. var newValue = customizer
  20086. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  20087. : undefined;
  20088. if (newValue === undefined) {
  20089. newValue = srcValue;
  20090. }
  20091. assignMergeValue(object, key, newValue);
  20092. }
  20093. }, keysIn);
  20094. }
  20095. /**
  20096. * A specialized version of `baseMerge` for arrays and objects which performs
  20097. * deep merges and tracks traversed objects enabling objects with circular
  20098. * references to be merged.
  20099. *
  20100. * @private
  20101. * @param {Object} object The destination object.
  20102. * @param {Object} source The source object.
  20103. * @param {string} key The key of the value to merge.
  20104. * @param {number} srcIndex The index of `source`.
  20105. * @param {Function} mergeFunc The function to merge values.
  20106. * @param {Function} [customizer] The function to customize assigned values.
  20107. * @param {Object} [stack] Tracks traversed source values and their merged
  20108. * counterparts.
  20109. */
  20110. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  20111. var objValue = safeGet(object, key),
  20112. srcValue = safeGet(source, key),
  20113. stacked = stack.get(srcValue);
  20114. if (stacked) {
  20115. assignMergeValue(object, key, stacked);
  20116. return;
  20117. }
  20118. var newValue = customizer
  20119. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  20120. : undefined;
  20121. var isCommon = newValue === undefined;
  20122. if (isCommon) {
  20123. var isArr = isArray(srcValue),
  20124. isBuff = !isArr && isBuffer(srcValue),
  20125. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  20126. newValue = srcValue;
  20127. if (isArr || isBuff || isTyped) {
  20128. if (isArray(objValue)) {
  20129. newValue = objValue;
  20130. }
  20131. else if (isArrayLikeObject(objValue)) {
  20132. newValue = copyArray(objValue);
  20133. }
  20134. else if (isBuff) {
  20135. isCommon = false;
  20136. newValue = cloneBuffer(srcValue, true);
  20137. }
  20138. else if (isTyped) {
  20139. isCommon = false;
  20140. newValue = cloneTypedArray(srcValue, true);
  20141. }
  20142. else {
  20143. newValue = [];
  20144. }
  20145. }
  20146. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  20147. newValue = objValue;
  20148. if (isArguments(objValue)) {
  20149. newValue = toPlainObject(objValue);
  20150. }
  20151. else if (!isObject(objValue) || isFunction(objValue)) {
  20152. newValue = initCloneObject(srcValue);
  20153. }
  20154. }
  20155. else {
  20156. isCommon = false;
  20157. }
  20158. }
  20159. if (isCommon) {
  20160. // Recursively merge objects and arrays (susceptible to call stack limits).
  20161. stack.set(srcValue, newValue);
  20162. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  20163. stack['delete'](srcValue);
  20164. }
  20165. assignMergeValue(object, key, newValue);
  20166. }
  20167. /**
  20168. * The base implementation of `_.nth` which doesn't coerce arguments.
  20169. *
  20170. * @private
  20171. * @param {Array} array The array to query.
  20172. * @param {number} n The index of the element to return.
  20173. * @returns {*} Returns the nth element of `array`.
  20174. */
  20175. function baseNth(array, n) {
  20176. var length = array.length;
  20177. if (!length) {
  20178. return;
  20179. }
  20180. n += n < 0 ? length : 0;
  20181. return isIndex(n, length) ? array[n] : undefined;
  20182. }
  20183. /**
  20184. * The base implementation of `_.orderBy` without param guards.
  20185. *
  20186. * @private
  20187. * @param {Array|Object} collection The collection to iterate over.
  20188. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  20189. * @param {string[]} orders The sort orders of `iteratees`.
  20190. * @returns {Array} Returns the new sorted array.
  20191. */
  20192. function baseOrderBy(collection, iteratees, orders) {
  20193. var index = -1;
  20194. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  20195. var result = baseMap(collection, function(value, key, collection) {
  20196. var criteria = arrayMap(iteratees, function(iteratee) {
  20197. return iteratee(value);
  20198. });
  20199. return { 'criteria': criteria, 'index': ++index, 'value': value };
  20200. });
  20201. return baseSortBy(result, function(object, other) {
  20202. return compareMultiple(object, other, orders);
  20203. });
  20204. }
  20205. /**
  20206. * The base implementation of `_.pick` without support for individual
  20207. * property identifiers.
  20208. *
  20209. * @private
  20210. * @param {Object} object The source object.
  20211. * @param {string[]} paths The property paths to pick.
  20212. * @returns {Object} Returns the new object.
  20213. */
  20214. function basePick(object, paths) {
  20215. return basePickBy(object, paths, function(value, path) {
  20216. return hasIn(object, path);
  20217. });
  20218. }
  20219. /**
  20220. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  20221. *
  20222. * @private
  20223. * @param {Object} object The source object.
  20224. * @param {string[]} paths The property paths to pick.
  20225. * @param {Function} predicate The function invoked per property.
  20226. * @returns {Object} Returns the new object.
  20227. */
  20228. function basePickBy(object, paths, predicate) {
  20229. var index = -1,
  20230. length = paths.length,
  20231. result = {};
  20232. while (++index < length) {
  20233. var path = paths[index],
  20234. value = baseGet(object, path);
  20235. if (predicate(value, path)) {
  20236. baseSet(result, castPath(path, object), value);
  20237. }
  20238. }
  20239. return result;
  20240. }
  20241. /**
  20242. * A specialized version of `baseProperty` which supports deep paths.
  20243. *
  20244. * @private
  20245. * @param {Array|string} path The path of the property to get.
  20246. * @returns {Function} Returns the new accessor function.
  20247. */
  20248. function basePropertyDeep(path) {
  20249. return function(object) {
  20250. return baseGet(object, path);
  20251. };
  20252. }
  20253. /**
  20254. * The base implementation of `_.pullAllBy` without support for iteratee
  20255. * shorthands.
  20256. *
  20257. * @private
  20258. * @param {Array} array The array to modify.
  20259. * @param {Array} values The values to remove.
  20260. * @param {Function} [iteratee] The iteratee invoked per element.
  20261. * @param {Function} [comparator] The comparator invoked per element.
  20262. * @returns {Array} Returns `array`.
  20263. */
  20264. function basePullAll(array, values, iteratee, comparator) {
  20265. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  20266. index = -1,
  20267. length = values.length,
  20268. seen = array;
  20269. if (array === values) {
  20270. values = copyArray(values);
  20271. }
  20272. if (iteratee) {
  20273. seen = arrayMap(array, baseUnary(iteratee));
  20274. }
  20275. while (++index < length) {
  20276. var fromIndex = 0,
  20277. value = values[index],
  20278. computed = iteratee ? iteratee(value) : value;
  20279. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  20280. if (seen !== array) {
  20281. splice.call(seen, fromIndex, 1);
  20282. }
  20283. splice.call(array, fromIndex, 1);
  20284. }
  20285. }
  20286. return array;
  20287. }
  20288. /**
  20289. * The base implementation of `_.pullAt` without support for individual
  20290. * indexes or capturing the removed elements.
  20291. *
  20292. * @private
  20293. * @param {Array} array The array to modify.
  20294. * @param {number[]} indexes The indexes of elements to remove.
  20295. * @returns {Array} Returns `array`.
  20296. */
  20297. function basePullAt(array, indexes) {
  20298. var length = array ? indexes.length : 0,
  20299. lastIndex = length - 1;
  20300. while (length--) {
  20301. var index = indexes[length];
  20302. if (length == lastIndex || index !== previous) {
  20303. var previous = index;
  20304. if (isIndex(index)) {
  20305. splice.call(array, index, 1);
  20306. } else {
  20307. baseUnset(array, index);
  20308. }
  20309. }
  20310. }
  20311. return array;
  20312. }
  20313. /**
  20314. * The base implementation of `_.random` without support for returning
  20315. * floating-point numbers.
  20316. *
  20317. * @private
  20318. * @param {number} lower The lower bound.
  20319. * @param {number} upper The upper bound.
  20320. * @returns {number} Returns the random number.
  20321. */
  20322. function baseRandom(lower, upper) {
  20323. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  20324. }
  20325. /**
  20326. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  20327. * coerce arguments.
  20328. *
  20329. * @private
  20330. * @param {number} start The start of the range.
  20331. * @param {number} end The end of the range.
  20332. * @param {number} step The value to increment or decrement by.
  20333. * @param {boolean} [fromRight] Specify iterating from right to left.
  20334. * @returns {Array} Returns the range of numbers.
  20335. */
  20336. function baseRange(start, end, step, fromRight) {
  20337. var index = -1,
  20338. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  20339. result = Array(length);
  20340. while (length--) {
  20341. result[fromRight ? length : ++index] = start;
  20342. start += step;
  20343. }
  20344. return result;
  20345. }
  20346. /**
  20347. * The base implementation of `_.repeat` which doesn't coerce arguments.
  20348. *
  20349. * @private
  20350. * @param {string} string The string to repeat.
  20351. * @param {number} n The number of times to repeat the string.
  20352. * @returns {string} Returns the repeated string.
  20353. */
  20354. function baseRepeat(string, n) {
  20355. var result = '';
  20356. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  20357. return result;
  20358. }
  20359. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  20360. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  20361. do {
  20362. if (n % 2) {
  20363. result += string;
  20364. }
  20365. n = nativeFloor(n / 2);
  20366. if (n) {
  20367. string += string;
  20368. }
  20369. } while (n);
  20370. return result;
  20371. }
  20372. /**
  20373. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  20374. *
  20375. * @private
  20376. * @param {Function} func The function to apply a rest parameter to.
  20377. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20378. * @returns {Function} Returns the new function.
  20379. */
  20380. function baseRest(func, start) {
  20381. return setToString(overRest(func, start, identity), func + '');
  20382. }
  20383. /**
  20384. * The base implementation of `_.sample`.
  20385. *
  20386. * @private
  20387. * @param {Array|Object} collection The collection to sample.
  20388. * @returns {*} Returns the random element.
  20389. */
  20390. function baseSample(collection) {
  20391. return arraySample(values(collection));
  20392. }
  20393. /**
  20394. * The base implementation of `_.sampleSize` without param guards.
  20395. *
  20396. * @private
  20397. * @param {Array|Object} collection The collection to sample.
  20398. * @param {number} n The number of elements to sample.
  20399. * @returns {Array} Returns the random elements.
  20400. */
  20401. function baseSampleSize(collection, n) {
  20402. var array = values(collection);
  20403. return shuffleSelf(array, baseClamp(n, 0, array.length));
  20404. }
  20405. /**
  20406. * The base implementation of `_.set`.
  20407. *
  20408. * @private
  20409. * @param {Object} object The object to modify.
  20410. * @param {Array|string} path The path of the property to set.
  20411. * @param {*} value The value to set.
  20412. * @param {Function} [customizer] The function to customize path creation.
  20413. * @returns {Object} Returns `object`.
  20414. */
  20415. function baseSet(object, path, value, customizer) {
  20416. if (!isObject(object)) {
  20417. return object;
  20418. }
  20419. path = castPath(path, object);
  20420. var index = -1,
  20421. length = path.length,
  20422. lastIndex = length - 1,
  20423. nested = object;
  20424. while (nested != null && ++index < length) {
  20425. var key = toKey(path[index]),
  20426. newValue = value;
  20427. if (index != lastIndex) {
  20428. var objValue = nested[key];
  20429. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  20430. if (newValue === undefined) {
  20431. newValue = isObject(objValue)
  20432. ? objValue
  20433. : (isIndex(path[index + 1]) ? [] : {});
  20434. }
  20435. }
  20436. assignValue(nested, key, newValue);
  20437. nested = nested[key];
  20438. }
  20439. return object;
  20440. }
  20441. /**
  20442. * The base implementation of `setData` without support for hot loop shorting.
  20443. *
  20444. * @private
  20445. * @param {Function} func The function to associate metadata with.
  20446. * @param {*} data The metadata.
  20447. * @returns {Function} Returns `func`.
  20448. */
  20449. var baseSetData = !metaMap ? identity : function(func, data) {
  20450. metaMap.set(func, data);
  20451. return func;
  20452. };
  20453. /**
  20454. * The base implementation of `setToString` without support for hot loop shorting.
  20455. *
  20456. * @private
  20457. * @param {Function} func The function to modify.
  20458. * @param {Function} string The `toString` result.
  20459. * @returns {Function} Returns `func`.
  20460. */
  20461. var baseSetToString = !defineProperty ? identity : function(func, string) {
  20462. return defineProperty(func, 'toString', {
  20463. 'configurable': true,
  20464. 'enumerable': false,
  20465. 'value': constant(string),
  20466. 'writable': true
  20467. });
  20468. };
  20469. /**
  20470. * The base implementation of `_.shuffle`.
  20471. *
  20472. * @private
  20473. * @param {Array|Object} collection The collection to shuffle.
  20474. * @returns {Array} Returns the new shuffled array.
  20475. */
  20476. function baseShuffle(collection) {
  20477. return shuffleSelf(values(collection));
  20478. }
  20479. /**
  20480. * The base implementation of `_.slice` without an iteratee call guard.
  20481. *
  20482. * @private
  20483. * @param {Array} array The array to slice.
  20484. * @param {number} [start=0] The start position.
  20485. * @param {number} [end=array.length] The end position.
  20486. * @returns {Array} Returns the slice of `array`.
  20487. */
  20488. function baseSlice(array, start, end) {
  20489. var index = -1,
  20490. length = array.length;
  20491. if (start < 0) {
  20492. start = -start > length ? 0 : (length + start);
  20493. }
  20494. end = end > length ? length : end;
  20495. if (end < 0) {
  20496. end += length;
  20497. }
  20498. length = start > end ? 0 : ((end - start) >>> 0);
  20499. start >>>= 0;
  20500. var result = Array(length);
  20501. while (++index < length) {
  20502. result[index] = array[index + start];
  20503. }
  20504. return result;
  20505. }
  20506. /**
  20507. * The base implementation of `_.some` without support for iteratee shorthands.
  20508. *
  20509. * @private
  20510. * @param {Array|Object} collection The collection to iterate over.
  20511. * @param {Function} predicate The function invoked per iteration.
  20512. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20513. * else `false`.
  20514. */
  20515. function baseSome(collection, predicate) {
  20516. var result;
  20517. baseEach(collection, function(value, index, collection) {
  20518. result = predicate(value, index, collection);
  20519. return !result;
  20520. });
  20521. return !!result;
  20522. }
  20523. /**
  20524. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  20525. * performs a binary search of `array` to determine the index at which `value`
  20526. * should be inserted into `array` in order to maintain its sort order.
  20527. *
  20528. * @private
  20529. * @param {Array} array The sorted array to inspect.
  20530. * @param {*} value The value to evaluate.
  20531. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20532. * @returns {number} Returns the index at which `value` should be inserted
  20533. * into `array`.
  20534. */
  20535. function baseSortedIndex(array, value, retHighest) {
  20536. var low = 0,
  20537. high = array == null ? low : array.length;
  20538. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  20539. while (low < high) {
  20540. var mid = (low + high) >>> 1,
  20541. computed = array[mid];
  20542. if (computed !== null && !isSymbol(computed) &&
  20543. (retHighest ? (computed <= value) : (computed < value))) {
  20544. low = mid + 1;
  20545. } else {
  20546. high = mid;
  20547. }
  20548. }
  20549. return high;
  20550. }
  20551. return baseSortedIndexBy(array, value, identity, retHighest);
  20552. }
  20553. /**
  20554. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  20555. * which invokes `iteratee` for `value` and each element of `array` to compute
  20556. * their sort ranking. The iteratee is invoked with one argument; (value).
  20557. *
  20558. * @private
  20559. * @param {Array} array The sorted array to inspect.
  20560. * @param {*} value The value to evaluate.
  20561. * @param {Function} iteratee The iteratee invoked per element.
  20562. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  20563. * @returns {number} Returns the index at which `value` should be inserted
  20564. * into `array`.
  20565. */
  20566. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  20567. value = iteratee(value);
  20568. var low = 0,
  20569. high = array == null ? 0 : array.length,
  20570. valIsNaN = value !== value,
  20571. valIsNull = value === null,
  20572. valIsSymbol = isSymbol(value),
  20573. valIsUndefined = value === undefined;
  20574. while (low < high) {
  20575. var mid = nativeFloor((low + high) / 2),
  20576. computed = iteratee(array[mid]),
  20577. othIsDefined = computed !== undefined,
  20578. othIsNull = computed === null,
  20579. othIsReflexive = computed === computed,
  20580. othIsSymbol = isSymbol(computed);
  20581. if (valIsNaN) {
  20582. var setLow = retHighest || othIsReflexive;
  20583. } else if (valIsUndefined) {
  20584. setLow = othIsReflexive && (retHighest || othIsDefined);
  20585. } else if (valIsNull) {
  20586. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  20587. } else if (valIsSymbol) {
  20588. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  20589. } else if (othIsNull || othIsSymbol) {
  20590. setLow = false;
  20591. } else {
  20592. setLow = retHighest ? (computed <= value) : (computed < value);
  20593. }
  20594. if (setLow) {
  20595. low = mid + 1;
  20596. } else {
  20597. high = mid;
  20598. }
  20599. }
  20600. return nativeMin(high, MAX_ARRAY_INDEX);
  20601. }
  20602. /**
  20603. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  20604. * support for iteratee shorthands.
  20605. *
  20606. * @private
  20607. * @param {Array} array The array to inspect.
  20608. * @param {Function} [iteratee] The iteratee invoked per element.
  20609. * @returns {Array} Returns the new duplicate free array.
  20610. */
  20611. function baseSortedUniq(array, iteratee) {
  20612. var index = -1,
  20613. length = array.length,
  20614. resIndex = 0,
  20615. result = [];
  20616. while (++index < length) {
  20617. var value = array[index],
  20618. computed = iteratee ? iteratee(value) : value;
  20619. if (!index || !eq(computed, seen)) {
  20620. var seen = computed;
  20621. result[resIndex++] = value === 0 ? 0 : value;
  20622. }
  20623. }
  20624. return result;
  20625. }
  20626. /**
  20627. * The base implementation of `_.toNumber` which doesn't ensure correct
  20628. * conversions of binary, hexadecimal, or octal string values.
  20629. *
  20630. * @private
  20631. * @param {*} value The value to process.
  20632. * @returns {number} Returns the number.
  20633. */
  20634. function baseToNumber(value) {
  20635. if (typeof value == 'number') {
  20636. return value;
  20637. }
  20638. if (isSymbol(value)) {
  20639. return NAN;
  20640. }
  20641. return +value;
  20642. }
  20643. /**
  20644. * The base implementation of `_.toString` which doesn't convert nullish
  20645. * values to empty strings.
  20646. *
  20647. * @private
  20648. * @param {*} value The value to process.
  20649. * @returns {string} Returns the string.
  20650. */
  20651. function baseToString(value) {
  20652. // Exit early for strings to avoid a performance hit in some environments.
  20653. if (typeof value == 'string') {
  20654. return value;
  20655. }
  20656. if (isArray(value)) {
  20657. // Recursively convert values (susceptible to call stack limits).
  20658. return arrayMap(value, baseToString) + '';
  20659. }
  20660. if (isSymbol(value)) {
  20661. return symbolToString ? symbolToString.call(value) : '';
  20662. }
  20663. var result = (value + '');
  20664. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20665. }
  20666. /**
  20667. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  20668. *
  20669. * @private
  20670. * @param {Array} array The array to inspect.
  20671. * @param {Function} [iteratee] The iteratee invoked per element.
  20672. * @param {Function} [comparator] The comparator invoked per element.
  20673. * @returns {Array} Returns the new duplicate free array.
  20674. */
  20675. function baseUniq(array, iteratee, comparator) {
  20676. var index = -1,
  20677. includes = arrayIncludes,
  20678. length = array.length,
  20679. isCommon = true,
  20680. result = [],
  20681. seen = result;
  20682. if (comparator) {
  20683. isCommon = false;
  20684. includes = arrayIncludesWith;
  20685. }
  20686. else if (length >= LARGE_ARRAY_SIZE) {
  20687. var set = iteratee ? null : createSet(array);
  20688. if (set) {
  20689. return setToArray(set);
  20690. }
  20691. isCommon = false;
  20692. includes = cacheHas;
  20693. seen = new SetCache;
  20694. }
  20695. else {
  20696. seen = iteratee ? [] : result;
  20697. }
  20698. outer:
  20699. while (++index < length) {
  20700. var value = array[index],
  20701. computed = iteratee ? iteratee(value) : value;
  20702. value = (comparator || value !== 0) ? value : 0;
  20703. if (isCommon && computed === computed) {
  20704. var seenIndex = seen.length;
  20705. while (seenIndex--) {
  20706. if (seen[seenIndex] === computed) {
  20707. continue outer;
  20708. }
  20709. }
  20710. if (iteratee) {
  20711. seen.push(computed);
  20712. }
  20713. result.push(value);
  20714. }
  20715. else if (!includes(seen, computed, comparator)) {
  20716. if (seen !== result) {
  20717. seen.push(computed);
  20718. }
  20719. result.push(value);
  20720. }
  20721. }
  20722. return result;
  20723. }
  20724. /**
  20725. * The base implementation of `_.unset`.
  20726. *
  20727. * @private
  20728. * @param {Object} object The object to modify.
  20729. * @param {Array|string} path The property path to unset.
  20730. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  20731. */
  20732. function baseUnset(object, path) {
  20733. path = castPath(path, object);
  20734. object = parent(object, path);
  20735. return object == null || delete object[toKey(last(path))];
  20736. }
  20737. /**
  20738. * The base implementation of `_.update`.
  20739. *
  20740. * @private
  20741. * @param {Object} object The object to modify.
  20742. * @param {Array|string} path The path of the property to update.
  20743. * @param {Function} updater The function to produce the updated value.
  20744. * @param {Function} [customizer] The function to customize path creation.
  20745. * @returns {Object} Returns `object`.
  20746. */
  20747. function baseUpdate(object, path, updater, customizer) {
  20748. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  20749. }
  20750. /**
  20751. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  20752. * without support for iteratee shorthands.
  20753. *
  20754. * @private
  20755. * @param {Array} array The array to query.
  20756. * @param {Function} predicate The function invoked per iteration.
  20757. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  20758. * @param {boolean} [fromRight] Specify iterating from right to left.
  20759. * @returns {Array} Returns the slice of `array`.
  20760. */
  20761. function baseWhile(array, predicate, isDrop, fromRight) {
  20762. var length = array.length,
  20763. index = fromRight ? length : -1;
  20764. while ((fromRight ? index-- : ++index < length) &&
  20765. predicate(array[index], index, array)) {}
  20766. return isDrop
  20767. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  20768. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  20769. }
  20770. /**
  20771. * The base implementation of `wrapperValue` which returns the result of
  20772. * performing a sequence of actions on the unwrapped `value`, where each
  20773. * successive action is supplied the return value of the previous.
  20774. *
  20775. * @private
  20776. * @param {*} value The unwrapped value.
  20777. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  20778. * @returns {*} Returns the resolved value.
  20779. */
  20780. function baseWrapperValue(value, actions) {
  20781. var result = value;
  20782. if (result instanceof LazyWrapper) {
  20783. result = result.value();
  20784. }
  20785. return arrayReduce(actions, function(result, action) {
  20786. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  20787. }, result);
  20788. }
  20789. /**
  20790. * The base implementation of methods like `_.xor`, without support for
  20791. * iteratee shorthands, that accepts an array of arrays to inspect.
  20792. *
  20793. * @private
  20794. * @param {Array} arrays The arrays to inspect.
  20795. * @param {Function} [iteratee] The iteratee invoked per element.
  20796. * @param {Function} [comparator] The comparator invoked per element.
  20797. * @returns {Array} Returns the new array of values.
  20798. */
  20799. function baseXor(arrays, iteratee, comparator) {
  20800. var length = arrays.length;
  20801. if (length < 2) {
  20802. return length ? baseUniq(arrays[0]) : [];
  20803. }
  20804. var index = -1,
  20805. result = Array(length);
  20806. while (++index < length) {
  20807. var array = arrays[index],
  20808. othIndex = -1;
  20809. while (++othIndex < length) {
  20810. if (othIndex != index) {
  20811. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  20812. }
  20813. }
  20814. }
  20815. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  20816. }
  20817. /**
  20818. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  20819. *
  20820. * @private
  20821. * @param {Array} props The property identifiers.
  20822. * @param {Array} values The property values.
  20823. * @param {Function} assignFunc The function to assign values.
  20824. * @returns {Object} Returns the new object.
  20825. */
  20826. function baseZipObject(props, values, assignFunc) {
  20827. var index = -1,
  20828. length = props.length,
  20829. valsLength = values.length,
  20830. result = {};
  20831. while (++index < length) {
  20832. var value = index < valsLength ? values[index] : undefined;
  20833. assignFunc(result, props[index], value);
  20834. }
  20835. return result;
  20836. }
  20837. /**
  20838. * Casts `value` to an empty array if it's not an array like object.
  20839. *
  20840. * @private
  20841. * @param {*} value The value to inspect.
  20842. * @returns {Array|Object} Returns the cast array-like object.
  20843. */
  20844. function castArrayLikeObject(value) {
  20845. return isArrayLikeObject(value) ? value : [];
  20846. }
  20847. /**
  20848. * Casts `value` to `identity` if it's not a function.
  20849. *
  20850. * @private
  20851. * @param {*} value The value to inspect.
  20852. * @returns {Function} Returns cast function.
  20853. */
  20854. function castFunction(value) {
  20855. return typeof value == 'function' ? value : identity;
  20856. }
  20857. /**
  20858. * Casts `value` to a path array if it's not one.
  20859. *
  20860. * @private
  20861. * @param {*} value The value to inspect.
  20862. * @param {Object} [object] The object to query keys on.
  20863. * @returns {Array} Returns the cast property path array.
  20864. */
  20865. function castPath(value, object) {
  20866. if (isArray(value)) {
  20867. return value;
  20868. }
  20869. return isKey(value, object) ? [value] : stringToPath(toString(value));
  20870. }
  20871. /**
  20872. * A `baseRest` alias which can be replaced with `identity` by module
  20873. * replacement plugins.
  20874. *
  20875. * @private
  20876. * @type {Function}
  20877. * @param {Function} func The function to apply a rest parameter to.
  20878. * @returns {Function} Returns the new function.
  20879. */
  20880. var castRest = baseRest;
  20881. /**
  20882. * Casts `array` to a slice if it's needed.
  20883. *
  20884. * @private
  20885. * @param {Array} array The array to inspect.
  20886. * @param {number} start The start position.
  20887. * @param {number} [end=array.length] The end position.
  20888. * @returns {Array} Returns the cast slice.
  20889. */
  20890. function castSlice(array, start, end) {
  20891. var length = array.length;
  20892. end = end === undefined ? length : end;
  20893. return (!start && end >= length) ? array : baseSlice(array, start, end);
  20894. }
  20895. /**
  20896. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  20897. *
  20898. * @private
  20899. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  20900. */
  20901. var clearTimeout = ctxClearTimeout || function(id) {
  20902. return root.clearTimeout(id);
  20903. };
  20904. /**
  20905. * Creates a clone of `buffer`.
  20906. *
  20907. * @private
  20908. * @param {Buffer} buffer The buffer to clone.
  20909. * @param {boolean} [isDeep] Specify a deep clone.
  20910. * @returns {Buffer} Returns the cloned buffer.
  20911. */
  20912. function cloneBuffer(buffer, isDeep) {
  20913. if (isDeep) {
  20914. return buffer.slice();
  20915. }
  20916. var length = buffer.length,
  20917. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  20918. buffer.copy(result);
  20919. return result;
  20920. }
  20921. /**
  20922. * Creates a clone of `arrayBuffer`.
  20923. *
  20924. * @private
  20925. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  20926. * @returns {ArrayBuffer} Returns the cloned array buffer.
  20927. */
  20928. function cloneArrayBuffer(arrayBuffer) {
  20929. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  20930. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  20931. return result;
  20932. }
  20933. /**
  20934. * Creates a clone of `dataView`.
  20935. *
  20936. * @private
  20937. * @param {Object} dataView The data view to clone.
  20938. * @param {boolean} [isDeep] Specify a deep clone.
  20939. * @returns {Object} Returns the cloned data view.
  20940. */
  20941. function cloneDataView(dataView, isDeep) {
  20942. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  20943. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  20944. }
  20945. /**
  20946. * Creates a clone of `regexp`.
  20947. *
  20948. * @private
  20949. * @param {Object} regexp The regexp to clone.
  20950. * @returns {Object} Returns the cloned regexp.
  20951. */
  20952. function cloneRegExp(regexp) {
  20953. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  20954. result.lastIndex = regexp.lastIndex;
  20955. return result;
  20956. }
  20957. /**
  20958. * Creates a clone of the `symbol` object.
  20959. *
  20960. * @private
  20961. * @param {Object} symbol The symbol object to clone.
  20962. * @returns {Object} Returns the cloned symbol object.
  20963. */
  20964. function cloneSymbol(symbol) {
  20965. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  20966. }
  20967. /**
  20968. * Creates a clone of `typedArray`.
  20969. *
  20970. * @private
  20971. * @param {Object} typedArray The typed array to clone.
  20972. * @param {boolean} [isDeep] Specify a deep clone.
  20973. * @returns {Object} Returns the cloned typed array.
  20974. */
  20975. function cloneTypedArray(typedArray, isDeep) {
  20976. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  20977. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  20978. }
  20979. /**
  20980. * Compares values to sort them in ascending order.
  20981. *
  20982. * @private
  20983. * @param {*} value The value to compare.
  20984. * @param {*} other The other value to compare.
  20985. * @returns {number} Returns the sort order indicator for `value`.
  20986. */
  20987. function compareAscending(value, other) {
  20988. if (value !== other) {
  20989. var valIsDefined = value !== undefined,
  20990. valIsNull = value === null,
  20991. valIsReflexive = value === value,
  20992. valIsSymbol = isSymbol(value);
  20993. var othIsDefined = other !== undefined,
  20994. othIsNull = other === null,
  20995. othIsReflexive = other === other,
  20996. othIsSymbol = isSymbol(other);
  20997. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  20998. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  20999. (valIsNull && othIsDefined && othIsReflexive) ||
  21000. (!valIsDefined && othIsReflexive) ||
  21001. !valIsReflexive) {
  21002. return 1;
  21003. }
  21004. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21005. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21006. (othIsNull && valIsDefined && valIsReflexive) ||
  21007. (!othIsDefined && valIsReflexive) ||
  21008. !othIsReflexive) {
  21009. return -1;
  21010. }
  21011. }
  21012. return 0;
  21013. }
  21014. /**
  21015. * Used by `_.orderBy` to compare multiple properties of a value to another
  21016. * and stable sort them.
  21017. *
  21018. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21019. * specify an order of "desc" for descending or "asc" for ascending sort order
  21020. * of corresponding values.
  21021. *
  21022. * @private
  21023. * @param {Object} object The object to compare.
  21024. * @param {Object} other The other object to compare.
  21025. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21026. * @returns {number} Returns the sort order indicator for `object`.
  21027. */
  21028. function compareMultiple(object, other, orders) {
  21029. var index = -1,
  21030. objCriteria = object.criteria,
  21031. othCriteria = other.criteria,
  21032. length = objCriteria.length,
  21033. ordersLength = orders.length;
  21034. while (++index < length) {
  21035. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21036. if (result) {
  21037. if (index >= ordersLength) {
  21038. return result;
  21039. }
  21040. var order = orders[index];
  21041. return result * (order == 'desc' ? -1 : 1);
  21042. }
  21043. }
  21044. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21045. // that causes it, under certain circumstances, to provide the same value for
  21046. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21047. // for more details.
  21048. //
  21049. // This also ensures a stable sort in V8 and other engines.
  21050. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21051. return object.index - other.index;
  21052. }
  21053. /**
  21054. * Creates an array that is the composition of partially applied arguments,
  21055. * placeholders, and provided arguments into a single array of arguments.
  21056. *
  21057. * @private
  21058. * @param {Array} args The provided arguments.
  21059. * @param {Array} partials The arguments to prepend to those provided.
  21060. * @param {Array} holders The `partials` placeholder indexes.
  21061. * @params {boolean} [isCurried] Specify composing for a curried function.
  21062. * @returns {Array} Returns the new array of composed arguments.
  21063. */
  21064. function composeArgs(args, partials, holders, isCurried) {
  21065. var argsIndex = -1,
  21066. argsLength = args.length,
  21067. holdersLength = holders.length,
  21068. leftIndex = -1,
  21069. leftLength = partials.length,
  21070. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21071. result = Array(leftLength + rangeLength),
  21072. isUncurried = !isCurried;
  21073. while (++leftIndex < leftLength) {
  21074. result[leftIndex] = partials[leftIndex];
  21075. }
  21076. while (++argsIndex < holdersLength) {
  21077. if (isUncurried || argsIndex < argsLength) {
  21078. result[holders[argsIndex]] = args[argsIndex];
  21079. }
  21080. }
  21081. while (rangeLength--) {
  21082. result[leftIndex++] = args[argsIndex++];
  21083. }
  21084. return result;
  21085. }
  21086. /**
  21087. * This function is like `composeArgs` except that the arguments composition
  21088. * is tailored for `_.partialRight`.
  21089. *
  21090. * @private
  21091. * @param {Array} args The provided arguments.
  21092. * @param {Array} partials The arguments to append to those provided.
  21093. * @param {Array} holders The `partials` placeholder indexes.
  21094. * @params {boolean} [isCurried] Specify composing for a curried function.
  21095. * @returns {Array} Returns the new array of composed arguments.
  21096. */
  21097. function composeArgsRight(args, partials, holders, isCurried) {
  21098. var argsIndex = -1,
  21099. argsLength = args.length,
  21100. holdersIndex = -1,
  21101. holdersLength = holders.length,
  21102. rightIndex = -1,
  21103. rightLength = partials.length,
  21104. rangeLength = nativeMax(argsLength - holdersLength, 0),
  21105. result = Array(rangeLength + rightLength),
  21106. isUncurried = !isCurried;
  21107. while (++argsIndex < rangeLength) {
  21108. result[argsIndex] = args[argsIndex];
  21109. }
  21110. var offset = argsIndex;
  21111. while (++rightIndex < rightLength) {
  21112. result[offset + rightIndex] = partials[rightIndex];
  21113. }
  21114. while (++holdersIndex < holdersLength) {
  21115. if (isUncurried || argsIndex < argsLength) {
  21116. result[offset + holders[holdersIndex]] = args[argsIndex++];
  21117. }
  21118. }
  21119. return result;
  21120. }
  21121. /**
  21122. * Copies the values of `source` to `array`.
  21123. *
  21124. * @private
  21125. * @param {Array} source The array to copy values from.
  21126. * @param {Array} [array=[]] The array to copy values to.
  21127. * @returns {Array} Returns `array`.
  21128. */
  21129. function copyArray(source, array) {
  21130. var index = -1,
  21131. length = source.length;
  21132. array || (array = Array(length));
  21133. while (++index < length) {
  21134. array[index] = source[index];
  21135. }
  21136. return array;
  21137. }
  21138. /**
  21139. * Copies properties of `source` to `object`.
  21140. *
  21141. * @private
  21142. * @param {Object} source The object to copy properties from.
  21143. * @param {Array} props The property identifiers to copy.
  21144. * @param {Object} [object={}] The object to copy properties to.
  21145. * @param {Function} [customizer] The function to customize copied values.
  21146. * @returns {Object} Returns `object`.
  21147. */
  21148. function copyObject(source, props, object, customizer) {
  21149. var isNew = !object;
  21150. object || (object = {});
  21151. var index = -1,
  21152. length = props.length;
  21153. while (++index < length) {
  21154. var key = props[index];
  21155. var newValue = customizer
  21156. ? customizer(object[key], source[key], key, object, source)
  21157. : undefined;
  21158. if (newValue === undefined) {
  21159. newValue = source[key];
  21160. }
  21161. if (isNew) {
  21162. baseAssignValue(object, key, newValue);
  21163. } else {
  21164. assignValue(object, key, newValue);
  21165. }
  21166. }
  21167. return object;
  21168. }
  21169. /**
  21170. * Copies own symbols of `source` to `object`.
  21171. *
  21172. * @private
  21173. * @param {Object} source The object to copy symbols from.
  21174. * @param {Object} [object={}] The object to copy symbols to.
  21175. * @returns {Object} Returns `object`.
  21176. */
  21177. function copySymbols(source, object) {
  21178. return copyObject(source, getSymbols(source), object);
  21179. }
  21180. /**
  21181. * Copies own and inherited symbols of `source` to `object`.
  21182. *
  21183. * @private
  21184. * @param {Object} source The object to copy symbols from.
  21185. * @param {Object} [object={}] The object to copy symbols to.
  21186. * @returns {Object} Returns `object`.
  21187. */
  21188. function copySymbolsIn(source, object) {
  21189. return copyObject(source, getSymbolsIn(source), object);
  21190. }
  21191. /**
  21192. * Creates a function like `_.groupBy`.
  21193. *
  21194. * @private
  21195. * @param {Function} setter The function to set accumulator values.
  21196. * @param {Function} [initializer] The accumulator object initializer.
  21197. * @returns {Function} Returns the new aggregator function.
  21198. */
  21199. function createAggregator(setter, initializer) {
  21200. return function(collection, iteratee) {
  21201. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  21202. accumulator = initializer ? initializer() : {};
  21203. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  21204. };
  21205. }
  21206. /**
  21207. * Creates a function like `_.assign`.
  21208. *
  21209. * @private
  21210. * @param {Function} assigner The function to assign values.
  21211. * @returns {Function} Returns the new assigner function.
  21212. */
  21213. function createAssigner(assigner) {
  21214. return baseRest(function(object, sources) {
  21215. var index = -1,
  21216. length = sources.length,
  21217. customizer = length > 1 ? sources[length - 1] : undefined,
  21218. guard = length > 2 ? sources[2] : undefined;
  21219. customizer = (assigner.length > 3 && typeof customizer == 'function')
  21220. ? (length--, customizer)
  21221. : undefined;
  21222. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  21223. customizer = length < 3 ? undefined : customizer;
  21224. length = 1;
  21225. }
  21226. object = Object(object);
  21227. while (++index < length) {
  21228. var source = sources[index];
  21229. if (source) {
  21230. assigner(object, source, index, customizer);
  21231. }
  21232. }
  21233. return object;
  21234. });
  21235. }
  21236. /**
  21237. * Creates a `baseEach` or `baseEachRight` function.
  21238. *
  21239. * @private
  21240. * @param {Function} eachFunc The function to iterate over a collection.
  21241. * @param {boolean} [fromRight] Specify iterating from right to left.
  21242. * @returns {Function} Returns the new base function.
  21243. */
  21244. function createBaseEach(eachFunc, fromRight) {
  21245. return function(collection, iteratee) {
  21246. if (collection == null) {
  21247. return collection;
  21248. }
  21249. if (!isArrayLike(collection)) {
  21250. return eachFunc(collection, iteratee);
  21251. }
  21252. var length = collection.length,
  21253. index = fromRight ? length : -1,
  21254. iterable = Object(collection);
  21255. while ((fromRight ? index-- : ++index < length)) {
  21256. if (iteratee(iterable[index], index, iterable) === false) {
  21257. break;
  21258. }
  21259. }
  21260. return collection;
  21261. };
  21262. }
  21263. /**
  21264. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  21265. *
  21266. * @private
  21267. * @param {boolean} [fromRight] Specify iterating from right to left.
  21268. * @returns {Function} Returns the new base function.
  21269. */
  21270. function createBaseFor(fromRight) {
  21271. return function(object, iteratee, keysFunc) {
  21272. var index = -1,
  21273. iterable = Object(object),
  21274. props = keysFunc(object),
  21275. length = props.length;
  21276. while (length--) {
  21277. var key = props[fromRight ? length : ++index];
  21278. if (iteratee(iterable[key], key, iterable) === false) {
  21279. break;
  21280. }
  21281. }
  21282. return object;
  21283. };
  21284. }
  21285. /**
  21286. * Creates a function that wraps `func` to invoke it with the optional `this`
  21287. * binding of `thisArg`.
  21288. *
  21289. * @private
  21290. * @param {Function} func The function to wrap.
  21291. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21292. * @param {*} [thisArg] The `this` binding of `func`.
  21293. * @returns {Function} Returns the new wrapped function.
  21294. */
  21295. function createBind(func, bitmask, thisArg) {
  21296. var isBind = bitmask & WRAP_BIND_FLAG,
  21297. Ctor = createCtor(func);
  21298. function wrapper() {
  21299. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21300. return fn.apply(isBind ? thisArg : this, arguments);
  21301. }
  21302. return wrapper;
  21303. }
  21304. /**
  21305. * Creates a function like `_.lowerFirst`.
  21306. *
  21307. * @private
  21308. * @param {string} methodName The name of the `String` case method to use.
  21309. * @returns {Function} Returns the new case function.
  21310. */
  21311. function createCaseFirst(methodName) {
  21312. return function(string) {
  21313. string = toString(string);
  21314. var strSymbols = hasUnicode(string)
  21315. ? stringToArray(string)
  21316. : undefined;
  21317. var chr = strSymbols
  21318. ? strSymbols[0]
  21319. : string.charAt(0);
  21320. var trailing = strSymbols
  21321. ? castSlice(strSymbols, 1).join('')
  21322. : string.slice(1);
  21323. return chr[methodName]() + trailing;
  21324. };
  21325. }
  21326. /**
  21327. * Creates a function like `_.camelCase`.
  21328. *
  21329. * @private
  21330. * @param {Function} callback The function to combine each word.
  21331. * @returns {Function} Returns the new compounder function.
  21332. */
  21333. function createCompounder(callback) {
  21334. return function(string) {
  21335. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  21336. };
  21337. }
  21338. /**
  21339. * Creates a function that produces an instance of `Ctor` regardless of
  21340. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  21341. *
  21342. * @private
  21343. * @param {Function} Ctor The constructor to wrap.
  21344. * @returns {Function} Returns the new wrapped function.
  21345. */
  21346. function createCtor(Ctor) {
  21347. return function() {
  21348. // Use a `switch` statement to work with class constructors. See
  21349. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  21350. // for more details.
  21351. var args = arguments;
  21352. switch (args.length) {
  21353. case 0: return new Ctor;
  21354. case 1: return new Ctor(args[0]);
  21355. case 2: return new Ctor(args[0], args[1]);
  21356. case 3: return new Ctor(args[0], args[1], args[2]);
  21357. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  21358. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  21359. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  21360. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  21361. }
  21362. var thisBinding = baseCreate(Ctor.prototype),
  21363. result = Ctor.apply(thisBinding, args);
  21364. // Mimic the constructor's `return` behavior.
  21365. // See https://es5.github.io/#x13.2.2 for more details.
  21366. return isObject(result) ? result : thisBinding;
  21367. };
  21368. }
  21369. /**
  21370. * Creates a function that wraps `func` to enable currying.
  21371. *
  21372. * @private
  21373. * @param {Function} func The function to wrap.
  21374. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21375. * @param {number} arity The arity of `func`.
  21376. * @returns {Function} Returns the new wrapped function.
  21377. */
  21378. function createCurry(func, bitmask, arity) {
  21379. var Ctor = createCtor(func);
  21380. function wrapper() {
  21381. var length = arguments.length,
  21382. args = Array(length),
  21383. index = length,
  21384. placeholder = getHolder(wrapper);
  21385. while (index--) {
  21386. args[index] = arguments[index];
  21387. }
  21388. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  21389. ? []
  21390. : replaceHolders(args, placeholder);
  21391. length -= holders.length;
  21392. if (length < arity) {
  21393. return createRecurry(
  21394. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  21395. args, holders, undefined, undefined, arity - length);
  21396. }
  21397. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21398. return apply(fn, this, args);
  21399. }
  21400. return wrapper;
  21401. }
  21402. /**
  21403. * Creates a `_.find` or `_.findLast` function.
  21404. *
  21405. * @private
  21406. * @param {Function} findIndexFunc The function to find the collection index.
  21407. * @returns {Function} Returns the new find function.
  21408. */
  21409. function createFind(findIndexFunc) {
  21410. return function(collection, predicate, fromIndex) {
  21411. var iterable = Object(collection);
  21412. if (!isArrayLike(collection)) {
  21413. var iteratee = getIteratee(predicate, 3);
  21414. collection = keys(collection);
  21415. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  21416. }
  21417. var index = findIndexFunc(collection, predicate, fromIndex);
  21418. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  21419. };
  21420. }
  21421. /**
  21422. * Creates a `_.flow` or `_.flowRight` function.
  21423. *
  21424. * @private
  21425. * @param {boolean} [fromRight] Specify iterating from right to left.
  21426. * @returns {Function} Returns the new flow function.
  21427. */
  21428. function createFlow(fromRight) {
  21429. return flatRest(function(funcs) {
  21430. var length = funcs.length,
  21431. index = length,
  21432. prereq = LodashWrapper.prototype.thru;
  21433. if (fromRight) {
  21434. funcs.reverse();
  21435. }
  21436. while (index--) {
  21437. var func = funcs[index];
  21438. if (typeof func != 'function') {
  21439. throw new TypeError(FUNC_ERROR_TEXT);
  21440. }
  21441. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  21442. var wrapper = new LodashWrapper([], true);
  21443. }
  21444. }
  21445. index = wrapper ? index : length;
  21446. while (++index < length) {
  21447. func = funcs[index];
  21448. var funcName = getFuncName(func),
  21449. data = funcName == 'wrapper' ? getData(func) : undefined;
  21450. if (data && isLaziable(data[0]) &&
  21451. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  21452. !data[4].length && data[9] == 1
  21453. ) {
  21454. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  21455. } else {
  21456. wrapper = (func.length == 1 && isLaziable(func))
  21457. ? wrapper[funcName]()
  21458. : wrapper.thru(func);
  21459. }
  21460. }
  21461. return function() {
  21462. var args = arguments,
  21463. value = args[0];
  21464. if (wrapper && args.length == 1 && isArray(value)) {
  21465. return wrapper.plant(value).value();
  21466. }
  21467. var index = 0,
  21468. result = length ? funcs[index].apply(this, args) : value;
  21469. while (++index < length) {
  21470. result = funcs[index].call(this, result);
  21471. }
  21472. return result;
  21473. };
  21474. });
  21475. }
  21476. /**
  21477. * Creates a function that wraps `func` to invoke it with optional `this`
  21478. * binding of `thisArg`, partial application, and currying.
  21479. *
  21480. * @private
  21481. * @param {Function|string} func The function or method name to wrap.
  21482. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21483. * @param {*} [thisArg] The `this` binding of `func`.
  21484. * @param {Array} [partials] The arguments to prepend to those provided to
  21485. * the new function.
  21486. * @param {Array} [holders] The `partials` placeholder indexes.
  21487. * @param {Array} [partialsRight] The arguments to append to those provided
  21488. * to the new function.
  21489. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  21490. * @param {Array} [argPos] The argument positions of the new function.
  21491. * @param {number} [ary] The arity cap of `func`.
  21492. * @param {number} [arity] The arity of `func`.
  21493. * @returns {Function} Returns the new wrapped function.
  21494. */
  21495. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  21496. var isAry = bitmask & WRAP_ARY_FLAG,
  21497. isBind = bitmask & WRAP_BIND_FLAG,
  21498. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  21499. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  21500. isFlip = bitmask & WRAP_FLIP_FLAG,
  21501. Ctor = isBindKey ? undefined : createCtor(func);
  21502. function wrapper() {
  21503. var length = arguments.length,
  21504. args = Array(length),
  21505. index = length;
  21506. while (index--) {
  21507. args[index] = arguments[index];
  21508. }
  21509. if (isCurried) {
  21510. var placeholder = getHolder(wrapper),
  21511. holdersCount = countHolders(args, placeholder);
  21512. }
  21513. if (partials) {
  21514. args = composeArgs(args, partials, holders, isCurried);
  21515. }
  21516. if (partialsRight) {
  21517. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  21518. }
  21519. length -= holdersCount;
  21520. if (isCurried && length < arity) {
  21521. var newHolders = replaceHolders(args, placeholder);
  21522. return createRecurry(
  21523. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  21524. args, newHolders, argPos, ary, arity - length
  21525. );
  21526. }
  21527. var thisBinding = isBind ? thisArg : this,
  21528. fn = isBindKey ? thisBinding[func] : func;
  21529. length = args.length;
  21530. if (argPos) {
  21531. args = reorder(args, argPos);
  21532. } else if (isFlip && length > 1) {
  21533. args.reverse();
  21534. }
  21535. if (isAry && ary < length) {
  21536. args.length = ary;
  21537. }
  21538. if (this && this !== root && this instanceof wrapper) {
  21539. fn = Ctor || createCtor(fn);
  21540. }
  21541. return fn.apply(thisBinding, args);
  21542. }
  21543. return wrapper;
  21544. }
  21545. /**
  21546. * Creates a function like `_.invertBy`.
  21547. *
  21548. * @private
  21549. * @param {Function} setter The function to set accumulator values.
  21550. * @param {Function} toIteratee The function to resolve iteratees.
  21551. * @returns {Function} Returns the new inverter function.
  21552. */
  21553. function createInverter(setter, toIteratee) {
  21554. return function(object, iteratee) {
  21555. return baseInverter(object, setter, toIteratee(iteratee), {});
  21556. };
  21557. }
  21558. /**
  21559. * Creates a function that performs a mathematical operation on two values.
  21560. *
  21561. * @private
  21562. * @param {Function} operator The function to perform the operation.
  21563. * @param {number} [defaultValue] The value used for `undefined` arguments.
  21564. * @returns {Function} Returns the new mathematical operation function.
  21565. */
  21566. function createMathOperation(operator, defaultValue) {
  21567. return function(value, other) {
  21568. var result;
  21569. if (value === undefined && other === undefined) {
  21570. return defaultValue;
  21571. }
  21572. if (value !== undefined) {
  21573. result = value;
  21574. }
  21575. if (other !== undefined) {
  21576. if (result === undefined) {
  21577. return other;
  21578. }
  21579. if (typeof value == 'string' || typeof other == 'string') {
  21580. value = baseToString(value);
  21581. other = baseToString(other);
  21582. } else {
  21583. value = baseToNumber(value);
  21584. other = baseToNumber(other);
  21585. }
  21586. result = operator(value, other);
  21587. }
  21588. return result;
  21589. };
  21590. }
  21591. /**
  21592. * Creates a function like `_.over`.
  21593. *
  21594. * @private
  21595. * @param {Function} arrayFunc The function to iterate over iteratees.
  21596. * @returns {Function} Returns the new over function.
  21597. */
  21598. function createOver(arrayFunc) {
  21599. return flatRest(function(iteratees) {
  21600. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  21601. return baseRest(function(args) {
  21602. var thisArg = this;
  21603. return arrayFunc(iteratees, function(iteratee) {
  21604. return apply(iteratee, thisArg, args);
  21605. });
  21606. });
  21607. });
  21608. }
  21609. /**
  21610. * Creates the padding for `string` based on `length`. The `chars` string
  21611. * is truncated if the number of characters exceeds `length`.
  21612. *
  21613. * @private
  21614. * @param {number} length The padding length.
  21615. * @param {string} [chars=' '] The string used as padding.
  21616. * @returns {string} Returns the padding for `string`.
  21617. */
  21618. function createPadding(length, chars) {
  21619. chars = chars === undefined ? ' ' : baseToString(chars);
  21620. var charsLength = chars.length;
  21621. if (charsLength < 2) {
  21622. return charsLength ? baseRepeat(chars, length) : chars;
  21623. }
  21624. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  21625. return hasUnicode(chars)
  21626. ? castSlice(stringToArray(result), 0, length).join('')
  21627. : result.slice(0, length);
  21628. }
  21629. /**
  21630. * Creates a function that wraps `func` to invoke it with the `this` binding
  21631. * of `thisArg` and `partials` prepended to the arguments it receives.
  21632. *
  21633. * @private
  21634. * @param {Function} func The function to wrap.
  21635. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21636. * @param {*} thisArg The `this` binding of `func`.
  21637. * @param {Array} partials The arguments to prepend to those provided to
  21638. * the new function.
  21639. * @returns {Function} Returns the new wrapped function.
  21640. */
  21641. function createPartial(func, bitmask, thisArg, partials) {
  21642. var isBind = bitmask & WRAP_BIND_FLAG,
  21643. Ctor = createCtor(func);
  21644. function wrapper() {
  21645. var argsIndex = -1,
  21646. argsLength = arguments.length,
  21647. leftIndex = -1,
  21648. leftLength = partials.length,
  21649. args = Array(leftLength + argsLength),
  21650. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  21651. while (++leftIndex < leftLength) {
  21652. args[leftIndex] = partials[leftIndex];
  21653. }
  21654. while (argsLength--) {
  21655. args[leftIndex++] = arguments[++argsIndex];
  21656. }
  21657. return apply(fn, isBind ? thisArg : this, args);
  21658. }
  21659. return wrapper;
  21660. }
  21661. /**
  21662. * Creates a `_.range` or `_.rangeRight` function.
  21663. *
  21664. * @private
  21665. * @param {boolean} [fromRight] Specify iterating from right to left.
  21666. * @returns {Function} Returns the new range function.
  21667. */
  21668. function createRange(fromRight) {
  21669. return function(start, end, step) {
  21670. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  21671. end = step = undefined;
  21672. }
  21673. // Ensure the sign of `-0` is preserved.
  21674. start = toFinite(start);
  21675. if (end === undefined) {
  21676. end = start;
  21677. start = 0;
  21678. } else {
  21679. end = toFinite(end);
  21680. }
  21681. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  21682. return baseRange(start, end, step, fromRight);
  21683. };
  21684. }
  21685. /**
  21686. * Creates a function that performs a relational operation on two values.
  21687. *
  21688. * @private
  21689. * @param {Function} operator The function to perform the operation.
  21690. * @returns {Function} Returns the new relational operation function.
  21691. */
  21692. function createRelationalOperation(operator) {
  21693. return function(value, other) {
  21694. if (!(typeof value == 'string' && typeof other == 'string')) {
  21695. value = toNumber(value);
  21696. other = toNumber(other);
  21697. }
  21698. return operator(value, other);
  21699. };
  21700. }
  21701. /**
  21702. * Creates a function that wraps `func` to continue currying.
  21703. *
  21704. * @private
  21705. * @param {Function} func The function to wrap.
  21706. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  21707. * @param {Function} wrapFunc The function to create the `func` wrapper.
  21708. * @param {*} placeholder The placeholder value.
  21709. * @param {*} [thisArg] The `this` binding of `func`.
  21710. * @param {Array} [partials] The arguments to prepend to those provided to
  21711. * the new function.
  21712. * @param {Array} [holders] The `partials` placeholder indexes.
  21713. * @param {Array} [argPos] The argument positions of the new function.
  21714. * @param {number} [ary] The arity cap of `func`.
  21715. * @param {number} [arity] The arity of `func`.
  21716. * @returns {Function} Returns the new wrapped function.
  21717. */
  21718. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  21719. var isCurry = bitmask & WRAP_CURRY_FLAG,
  21720. newHolders = isCurry ? holders : undefined,
  21721. newHoldersRight = isCurry ? undefined : holders,
  21722. newPartials = isCurry ? partials : undefined,
  21723. newPartialsRight = isCurry ? undefined : partials;
  21724. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  21725. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  21726. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  21727. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  21728. }
  21729. var newData = [
  21730. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  21731. newHoldersRight, argPos, ary, arity
  21732. ];
  21733. var result = wrapFunc.apply(undefined, newData);
  21734. if (isLaziable(func)) {
  21735. setData(result, newData);
  21736. }
  21737. result.placeholder = placeholder;
  21738. return setWrapToString(result, func, bitmask);
  21739. }
  21740. /**
  21741. * Creates a function like `_.round`.
  21742. *
  21743. * @private
  21744. * @param {string} methodName The name of the `Math` method to use when rounding.
  21745. * @returns {Function} Returns the new round function.
  21746. */
  21747. function createRound(methodName) {
  21748. var func = Math[methodName];
  21749. return function(number, precision) {
  21750. number = toNumber(number);
  21751. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  21752. if (precision && nativeIsFinite(number)) {
  21753. // Shift with exponential notation to avoid floating-point issues.
  21754. // See [MDN](https://mdn.io/round#Examples) for more details.
  21755. var pair = (toString(number) + 'e').split('e'),
  21756. value = func(pair[0] + 'e' + (+pair[1] + precision));
  21757. pair = (toString(value) + 'e').split('e');
  21758. return +(pair[0] + 'e' + (+pair[1] - precision));
  21759. }
  21760. return func(number);
  21761. };
  21762. }
  21763. /**
  21764. * Creates a set object of `values`.
  21765. *
  21766. * @private
  21767. * @param {Array} values The values to add to the set.
  21768. * @returns {Object} Returns the new set.
  21769. */
  21770. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  21771. return new Set(values);
  21772. };
  21773. /**
  21774. * Creates a `_.toPairs` or `_.toPairsIn` function.
  21775. *
  21776. * @private
  21777. * @param {Function} keysFunc The function to get the keys of a given object.
  21778. * @returns {Function} Returns the new pairs function.
  21779. */
  21780. function createToPairs(keysFunc) {
  21781. return function(object) {
  21782. var tag = getTag(object);
  21783. if (tag == mapTag) {
  21784. return mapToArray(object);
  21785. }
  21786. if (tag == setTag) {
  21787. return setToPairs(object);
  21788. }
  21789. return baseToPairs(object, keysFunc(object));
  21790. };
  21791. }
  21792. /**
  21793. * Creates a function that either curries or invokes `func` with optional
  21794. * `this` binding and partially applied arguments.
  21795. *
  21796. * @private
  21797. * @param {Function|string} func The function or method name to wrap.
  21798. * @param {number} bitmask The bitmask flags.
  21799. * 1 - `_.bind`
  21800. * 2 - `_.bindKey`
  21801. * 4 - `_.curry` or `_.curryRight` of a bound function
  21802. * 8 - `_.curry`
  21803. * 16 - `_.curryRight`
  21804. * 32 - `_.partial`
  21805. * 64 - `_.partialRight`
  21806. * 128 - `_.rearg`
  21807. * 256 - `_.ary`
  21808. * 512 - `_.flip`
  21809. * @param {*} [thisArg] The `this` binding of `func`.
  21810. * @param {Array} [partials] The arguments to be partially applied.
  21811. * @param {Array} [holders] The `partials` placeholder indexes.
  21812. * @param {Array} [argPos] The argument positions of the new function.
  21813. * @param {number} [ary] The arity cap of `func`.
  21814. * @param {number} [arity] The arity of `func`.
  21815. * @returns {Function} Returns the new wrapped function.
  21816. */
  21817. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  21818. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  21819. if (!isBindKey && typeof func != 'function') {
  21820. throw new TypeError(FUNC_ERROR_TEXT);
  21821. }
  21822. var length = partials ? partials.length : 0;
  21823. if (!length) {
  21824. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  21825. partials = holders = undefined;
  21826. }
  21827. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  21828. arity = arity === undefined ? arity : toInteger(arity);
  21829. length -= holders ? holders.length : 0;
  21830. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  21831. var partialsRight = partials,
  21832. holdersRight = holders;
  21833. partials = holders = undefined;
  21834. }
  21835. var data = isBindKey ? undefined : getData(func);
  21836. var newData = [
  21837. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  21838. argPos, ary, arity
  21839. ];
  21840. if (data) {
  21841. mergeData(newData, data);
  21842. }
  21843. func = newData[0];
  21844. bitmask = newData[1];
  21845. thisArg = newData[2];
  21846. partials = newData[3];
  21847. holders = newData[4];
  21848. arity = newData[9] = newData[9] === undefined
  21849. ? (isBindKey ? 0 : func.length)
  21850. : nativeMax(newData[9] - length, 0);
  21851. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  21852. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  21853. }
  21854. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  21855. var result = createBind(func, bitmask, thisArg);
  21856. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  21857. result = createCurry(func, bitmask, arity);
  21858. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  21859. result = createPartial(func, bitmask, thisArg, partials);
  21860. } else {
  21861. result = createHybrid.apply(undefined, newData);
  21862. }
  21863. var setter = data ? baseSetData : setData;
  21864. return setWrapToString(setter(result, newData), func, bitmask);
  21865. }
  21866. /**
  21867. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  21868. * of source objects to the destination object for all destination properties
  21869. * that resolve to `undefined`.
  21870. *
  21871. * @private
  21872. * @param {*} objValue The destination value.
  21873. * @param {*} srcValue The source value.
  21874. * @param {string} key The key of the property to assign.
  21875. * @param {Object} object The parent object of `objValue`.
  21876. * @returns {*} Returns the value to assign.
  21877. */
  21878. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  21879. if (objValue === undefined ||
  21880. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  21881. return srcValue;
  21882. }
  21883. return objValue;
  21884. }
  21885. /**
  21886. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  21887. * objects into destination objects that are passed thru.
  21888. *
  21889. * @private
  21890. * @param {*} objValue The destination value.
  21891. * @param {*} srcValue The source value.
  21892. * @param {string} key The key of the property to merge.
  21893. * @param {Object} object The parent object of `objValue`.
  21894. * @param {Object} source The parent object of `srcValue`.
  21895. * @param {Object} [stack] Tracks traversed source values and their merged
  21896. * counterparts.
  21897. * @returns {*} Returns the value to assign.
  21898. */
  21899. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  21900. if (isObject(objValue) && isObject(srcValue)) {
  21901. // Recursively merge objects and arrays (susceptible to call stack limits).
  21902. stack.set(srcValue, objValue);
  21903. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  21904. stack['delete'](srcValue);
  21905. }
  21906. return objValue;
  21907. }
  21908. /**
  21909. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  21910. * objects.
  21911. *
  21912. * @private
  21913. * @param {*} value The value to inspect.
  21914. * @param {string} key The key of the property to inspect.
  21915. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  21916. */
  21917. function customOmitClone(value) {
  21918. return isPlainObject(value) ? undefined : value;
  21919. }
  21920. /**
  21921. * A specialized version of `baseIsEqualDeep` for arrays with support for
  21922. * partial deep comparisons.
  21923. *
  21924. * @private
  21925. * @param {Array} array The array to compare.
  21926. * @param {Array} other The other array to compare.
  21927. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  21928. * @param {Function} customizer The function to customize comparisons.
  21929. * @param {Function} equalFunc The function to determine equivalents of values.
  21930. * @param {Object} stack Tracks traversed `array` and `other` objects.
  21931. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  21932. */
  21933. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  21934. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  21935. arrLength = array.length,
  21936. othLength = other.length;
  21937. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  21938. return false;
  21939. }
  21940. // Assume cyclic values are equal.
  21941. var stacked = stack.get(array);
  21942. if (stacked && stack.get(other)) {
  21943. return stacked == other;
  21944. }
  21945. var index = -1,
  21946. result = true,
  21947. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  21948. stack.set(array, other);
  21949. stack.set(other, array);
  21950. // Ignore non-index properties.
  21951. while (++index < arrLength) {
  21952. var arrValue = array[index],
  21953. othValue = other[index];
  21954. if (customizer) {
  21955. var compared = isPartial
  21956. ? customizer(othValue, arrValue, index, other, array, stack)
  21957. : customizer(arrValue, othValue, index, array, other, stack);
  21958. }
  21959. if (compared !== undefined) {
  21960. if (compared) {
  21961. continue;
  21962. }
  21963. result = false;
  21964. break;
  21965. }
  21966. // Recursively compare arrays (susceptible to call stack limits).
  21967. if (seen) {
  21968. if (!arraySome(other, function(othValue, othIndex) {
  21969. if (!cacheHas(seen, othIndex) &&
  21970. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  21971. return seen.push(othIndex);
  21972. }
  21973. })) {
  21974. result = false;
  21975. break;
  21976. }
  21977. } else if (!(
  21978. arrValue === othValue ||
  21979. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  21980. )) {
  21981. result = false;
  21982. break;
  21983. }
  21984. }
  21985. stack['delete'](array);
  21986. stack['delete'](other);
  21987. return result;
  21988. }
  21989. /**
  21990. * A specialized version of `baseIsEqualDeep` for comparing objects of
  21991. * the same `toStringTag`.
  21992. *
  21993. * **Note:** This function only supports comparing values with tags of
  21994. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  21995. *
  21996. * @private
  21997. * @param {Object} object The object to compare.
  21998. * @param {Object} other The other object to compare.
  21999. * @param {string} tag The `toStringTag` of the objects to compare.
  22000. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22001. * @param {Function} customizer The function to customize comparisons.
  22002. * @param {Function} equalFunc The function to determine equivalents of values.
  22003. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22004. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22005. */
  22006. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22007. switch (tag) {
  22008. case dataViewTag:
  22009. if ((object.byteLength != other.byteLength) ||
  22010. (object.byteOffset != other.byteOffset)) {
  22011. return false;
  22012. }
  22013. object = object.buffer;
  22014. other = other.buffer;
  22015. case arrayBufferTag:
  22016. if ((object.byteLength != other.byteLength) ||
  22017. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22018. return false;
  22019. }
  22020. return true;
  22021. case boolTag:
  22022. case dateTag:
  22023. case numberTag:
  22024. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22025. // Invalid dates are coerced to `NaN`.
  22026. return eq(+object, +other);
  22027. case errorTag:
  22028. return object.name == other.name && object.message == other.message;
  22029. case regexpTag:
  22030. case stringTag:
  22031. // Coerce regexes to strings and treat strings, primitives and objects,
  22032. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22033. // for more details.
  22034. return object == (other + '');
  22035. case mapTag:
  22036. var convert = mapToArray;
  22037. case setTag:
  22038. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22039. convert || (convert = setToArray);
  22040. if (object.size != other.size && !isPartial) {
  22041. return false;
  22042. }
  22043. // Assume cyclic values are equal.
  22044. var stacked = stack.get(object);
  22045. if (stacked) {
  22046. return stacked == other;
  22047. }
  22048. bitmask |= COMPARE_UNORDERED_FLAG;
  22049. // Recursively compare objects (susceptible to call stack limits).
  22050. stack.set(object, other);
  22051. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22052. stack['delete'](object);
  22053. return result;
  22054. case symbolTag:
  22055. if (symbolValueOf) {
  22056. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22057. }
  22058. }
  22059. return false;
  22060. }
  22061. /**
  22062. * A specialized version of `baseIsEqualDeep` for objects with support for
  22063. * partial deep comparisons.
  22064. *
  22065. * @private
  22066. * @param {Object} object The object to compare.
  22067. * @param {Object} other The other object to compare.
  22068. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22069. * @param {Function} customizer The function to customize comparisons.
  22070. * @param {Function} equalFunc The function to determine equivalents of values.
  22071. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22072. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22073. */
  22074. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  22075. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22076. objProps = getAllKeys(object),
  22077. objLength = objProps.length,
  22078. othProps = getAllKeys(other),
  22079. othLength = othProps.length;
  22080. if (objLength != othLength && !isPartial) {
  22081. return false;
  22082. }
  22083. var index = objLength;
  22084. while (index--) {
  22085. var key = objProps[index];
  22086. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  22087. return false;
  22088. }
  22089. }
  22090. // Assume cyclic values are equal.
  22091. var stacked = stack.get(object);
  22092. if (stacked && stack.get(other)) {
  22093. return stacked == other;
  22094. }
  22095. var result = true;
  22096. stack.set(object, other);
  22097. stack.set(other, object);
  22098. var skipCtor = isPartial;
  22099. while (++index < objLength) {
  22100. key = objProps[index];
  22101. var objValue = object[key],
  22102. othValue = other[key];
  22103. if (customizer) {
  22104. var compared = isPartial
  22105. ? customizer(othValue, objValue, key, other, object, stack)
  22106. : customizer(objValue, othValue, key, object, other, stack);
  22107. }
  22108. // Recursively compare objects (susceptible to call stack limits).
  22109. if (!(compared === undefined
  22110. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  22111. : compared
  22112. )) {
  22113. result = false;
  22114. break;
  22115. }
  22116. skipCtor || (skipCtor = key == 'constructor');
  22117. }
  22118. if (result && !skipCtor) {
  22119. var objCtor = object.constructor,
  22120. othCtor = other.constructor;
  22121. // Non `Object` object instances with different constructors are not equal.
  22122. if (objCtor != othCtor &&
  22123. ('constructor' in object && 'constructor' in other) &&
  22124. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22125. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22126. result = false;
  22127. }
  22128. }
  22129. stack['delete'](object);
  22130. stack['delete'](other);
  22131. return result;
  22132. }
  22133. /**
  22134. * A specialized version of `baseRest` which flattens the rest array.
  22135. *
  22136. * @private
  22137. * @param {Function} func The function to apply a rest parameter to.
  22138. * @returns {Function} Returns the new function.
  22139. */
  22140. function flatRest(func) {
  22141. return setToString(overRest(func, undefined, flatten), func + '');
  22142. }
  22143. /**
  22144. * Creates an array of own enumerable property names and symbols of `object`.
  22145. *
  22146. * @private
  22147. * @param {Object} object The object to query.
  22148. * @returns {Array} Returns the array of property names and symbols.
  22149. */
  22150. function getAllKeys(object) {
  22151. return baseGetAllKeys(object, keys, getSymbols);
  22152. }
  22153. /**
  22154. * Creates an array of own and inherited enumerable property names and
  22155. * symbols of `object`.
  22156. *
  22157. * @private
  22158. * @param {Object} object The object to query.
  22159. * @returns {Array} Returns the array of property names and symbols.
  22160. */
  22161. function getAllKeysIn(object) {
  22162. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  22163. }
  22164. /**
  22165. * Gets metadata for `func`.
  22166. *
  22167. * @private
  22168. * @param {Function} func The function to query.
  22169. * @returns {*} Returns the metadata for `func`.
  22170. */
  22171. var getData = !metaMap ? noop : function(func) {
  22172. return metaMap.get(func);
  22173. };
  22174. /**
  22175. * Gets the name of `func`.
  22176. *
  22177. * @private
  22178. * @param {Function} func The function to query.
  22179. * @returns {string} Returns the function name.
  22180. */
  22181. function getFuncName(func) {
  22182. var result = (func.name + ''),
  22183. array = realNames[result],
  22184. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  22185. while (length--) {
  22186. var data = array[length],
  22187. otherFunc = data.func;
  22188. if (otherFunc == null || otherFunc == func) {
  22189. return data.name;
  22190. }
  22191. }
  22192. return result;
  22193. }
  22194. /**
  22195. * Gets the argument placeholder value for `func`.
  22196. *
  22197. * @private
  22198. * @param {Function} func The function to inspect.
  22199. * @returns {*} Returns the placeholder value.
  22200. */
  22201. function getHolder(func) {
  22202. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  22203. return object.placeholder;
  22204. }
  22205. /**
  22206. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  22207. * this function returns the custom method, otherwise it returns `baseIteratee`.
  22208. * If arguments are provided, the chosen function is invoked with them and
  22209. * its result is returned.
  22210. *
  22211. * @private
  22212. * @param {*} [value] The value to convert to an iteratee.
  22213. * @param {number} [arity] The arity of the created iteratee.
  22214. * @returns {Function} Returns the chosen function or its result.
  22215. */
  22216. function getIteratee() {
  22217. var result = lodash.iteratee || iteratee;
  22218. result = result === iteratee ? baseIteratee : result;
  22219. return arguments.length ? result(arguments[0], arguments[1]) : result;
  22220. }
  22221. /**
  22222. * Gets the data for `map`.
  22223. *
  22224. * @private
  22225. * @param {Object} map The map to query.
  22226. * @param {string} key The reference key.
  22227. * @returns {*} Returns the map data.
  22228. */
  22229. function getMapData(map, key) {
  22230. var data = map.__data__;
  22231. return isKeyable(key)
  22232. ? data[typeof key == 'string' ? 'string' : 'hash']
  22233. : data.map;
  22234. }
  22235. /**
  22236. * Gets the property names, values, and compare flags of `object`.
  22237. *
  22238. * @private
  22239. * @param {Object} object The object to query.
  22240. * @returns {Array} Returns the match data of `object`.
  22241. */
  22242. function getMatchData(object) {
  22243. var result = keys(object),
  22244. length = result.length;
  22245. while (length--) {
  22246. var key = result[length],
  22247. value = object[key];
  22248. result[length] = [key, value, isStrictComparable(value)];
  22249. }
  22250. return result;
  22251. }
  22252. /**
  22253. * Gets the native function at `key` of `object`.
  22254. *
  22255. * @private
  22256. * @param {Object} object The object to query.
  22257. * @param {string} key The key of the method to get.
  22258. * @returns {*} Returns the function if it's native, else `undefined`.
  22259. */
  22260. function getNative(object, key) {
  22261. var value = getValue(object, key);
  22262. return baseIsNative(value) ? value : undefined;
  22263. }
  22264. /**
  22265. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  22266. *
  22267. * @private
  22268. * @param {*} value The value to query.
  22269. * @returns {string} Returns the raw `toStringTag`.
  22270. */
  22271. function getRawTag(value) {
  22272. var isOwn = hasOwnProperty.call(value, symToStringTag),
  22273. tag = value[symToStringTag];
  22274. try {
  22275. value[symToStringTag] = undefined;
  22276. var unmasked = true;
  22277. } catch (e) {}
  22278. var result = nativeObjectToString.call(value);
  22279. if (unmasked) {
  22280. if (isOwn) {
  22281. value[symToStringTag] = tag;
  22282. } else {
  22283. delete value[symToStringTag];
  22284. }
  22285. }
  22286. return result;
  22287. }
  22288. /**
  22289. * Creates an array of the own enumerable symbols of `object`.
  22290. *
  22291. * @private
  22292. * @param {Object} object The object to query.
  22293. * @returns {Array} Returns the array of symbols.
  22294. */
  22295. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  22296. if (object == null) {
  22297. return [];
  22298. }
  22299. object = Object(object);
  22300. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22301. return propertyIsEnumerable.call(object, symbol);
  22302. });
  22303. };
  22304. /**
  22305. * Creates an array of the own and inherited enumerable symbols of `object`.
  22306. *
  22307. * @private
  22308. * @param {Object} object The object to query.
  22309. * @returns {Array} Returns the array of symbols.
  22310. */
  22311. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  22312. var result = [];
  22313. while (object) {
  22314. arrayPush(result, getSymbols(object));
  22315. object = getPrototype(object);
  22316. }
  22317. return result;
  22318. };
  22319. /**
  22320. * Gets the `toStringTag` of `value`.
  22321. *
  22322. * @private
  22323. * @param {*} value The value to query.
  22324. * @returns {string} Returns the `toStringTag`.
  22325. */
  22326. var getTag = baseGetTag;
  22327. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  22328. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  22329. (Map && getTag(new Map) != mapTag) ||
  22330. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  22331. (Set && getTag(new Set) != setTag) ||
  22332. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  22333. getTag = function(value) {
  22334. var result = baseGetTag(value),
  22335. Ctor = result == objectTag ? value.constructor : undefined,
  22336. ctorString = Ctor ? toSource(Ctor) : '';
  22337. if (ctorString) {
  22338. switch (ctorString) {
  22339. case dataViewCtorString: return dataViewTag;
  22340. case mapCtorString: return mapTag;
  22341. case promiseCtorString: return promiseTag;
  22342. case setCtorString: return setTag;
  22343. case weakMapCtorString: return weakMapTag;
  22344. }
  22345. }
  22346. return result;
  22347. };
  22348. }
  22349. /**
  22350. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  22351. *
  22352. * @private
  22353. * @param {number} start The start of the view.
  22354. * @param {number} end The end of the view.
  22355. * @param {Array} transforms The transformations to apply to the view.
  22356. * @returns {Object} Returns an object containing the `start` and `end`
  22357. * positions of the view.
  22358. */
  22359. function getView(start, end, transforms) {
  22360. var index = -1,
  22361. length = transforms.length;
  22362. while (++index < length) {
  22363. var data = transforms[index],
  22364. size = data.size;
  22365. switch (data.type) {
  22366. case 'drop': start += size; break;
  22367. case 'dropRight': end -= size; break;
  22368. case 'take': end = nativeMin(end, start + size); break;
  22369. case 'takeRight': start = nativeMax(start, end - size); break;
  22370. }
  22371. }
  22372. return { 'start': start, 'end': end };
  22373. }
  22374. /**
  22375. * Extracts wrapper details from the `source` body comment.
  22376. *
  22377. * @private
  22378. * @param {string} source The source to inspect.
  22379. * @returns {Array} Returns the wrapper details.
  22380. */
  22381. function getWrapDetails(source) {
  22382. var match = source.match(reWrapDetails);
  22383. return match ? match[1].split(reSplitDetails) : [];
  22384. }
  22385. /**
  22386. * Checks if `path` exists on `object`.
  22387. *
  22388. * @private
  22389. * @param {Object} object The object to query.
  22390. * @param {Array|string} path The path to check.
  22391. * @param {Function} hasFunc The function to check properties.
  22392. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22393. */
  22394. function hasPath(object, path, hasFunc) {
  22395. path = castPath(path, object);
  22396. var index = -1,
  22397. length = path.length,
  22398. result = false;
  22399. while (++index < length) {
  22400. var key = toKey(path[index]);
  22401. if (!(result = object != null && hasFunc(object, key))) {
  22402. break;
  22403. }
  22404. object = object[key];
  22405. }
  22406. if (result || ++index != length) {
  22407. return result;
  22408. }
  22409. length = object == null ? 0 : object.length;
  22410. return !!length && isLength(length) && isIndex(key, length) &&
  22411. (isArray(object) || isArguments(object));
  22412. }
  22413. /**
  22414. * Initializes an array clone.
  22415. *
  22416. * @private
  22417. * @param {Array} array The array to clone.
  22418. * @returns {Array} Returns the initialized clone.
  22419. */
  22420. function initCloneArray(array) {
  22421. var length = array.length,
  22422. result = new array.constructor(length);
  22423. // Add properties assigned by `RegExp#exec`.
  22424. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  22425. result.index = array.index;
  22426. result.input = array.input;
  22427. }
  22428. return result;
  22429. }
  22430. /**
  22431. * Initializes an object clone.
  22432. *
  22433. * @private
  22434. * @param {Object} object The object to clone.
  22435. * @returns {Object} Returns the initialized clone.
  22436. */
  22437. function initCloneObject(object) {
  22438. return (typeof object.constructor == 'function' && !isPrototype(object))
  22439. ? baseCreate(getPrototype(object))
  22440. : {};
  22441. }
  22442. /**
  22443. * Initializes an object clone based on its `toStringTag`.
  22444. *
  22445. * **Note:** This function only supports cloning values with tags of
  22446. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  22447. *
  22448. * @private
  22449. * @param {Object} object The object to clone.
  22450. * @param {string} tag The `toStringTag` of the object to clone.
  22451. * @param {boolean} [isDeep] Specify a deep clone.
  22452. * @returns {Object} Returns the initialized clone.
  22453. */
  22454. function initCloneByTag(object, tag, isDeep) {
  22455. var Ctor = object.constructor;
  22456. switch (tag) {
  22457. case arrayBufferTag:
  22458. return cloneArrayBuffer(object);
  22459. case boolTag:
  22460. case dateTag:
  22461. return new Ctor(+object);
  22462. case dataViewTag:
  22463. return cloneDataView(object, isDeep);
  22464. case float32Tag: case float64Tag:
  22465. case int8Tag: case int16Tag: case int32Tag:
  22466. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  22467. return cloneTypedArray(object, isDeep);
  22468. case mapTag:
  22469. return new Ctor;
  22470. case numberTag:
  22471. case stringTag:
  22472. return new Ctor(object);
  22473. case regexpTag:
  22474. return cloneRegExp(object);
  22475. case setTag:
  22476. return new Ctor;
  22477. case symbolTag:
  22478. return cloneSymbol(object);
  22479. }
  22480. }
  22481. /**
  22482. * Inserts wrapper `details` in a comment at the top of the `source` body.
  22483. *
  22484. * @private
  22485. * @param {string} source The source to modify.
  22486. * @returns {Array} details The details to insert.
  22487. * @returns {string} Returns the modified source.
  22488. */
  22489. function insertWrapDetails(source, details) {
  22490. var length = details.length;
  22491. if (!length) {
  22492. return source;
  22493. }
  22494. var lastIndex = length - 1;
  22495. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  22496. details = details.join(length > 2 ? ', ' : ' ');
  22497. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  22498. }
  22499. /**
  22500. * Checks if `value` is a flattenable `arguments` object or array.
  22501. *
  22502. * @private
  22503. * @param {*} value The value to check.
  22504. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  22505. */
  22506. function isFlattenable(value) {
  22507. return isArray(value) || isArguments(value) ||
  22508. !!(spreadableSymbol && value && value[spreadableSymbol]);
  22509. }
  22510. /**
  22511. * Checks if `value` is a valid array-like index.
  22512. *
  22513. * @private
  22514. * @param {*} value The value to check.
  22515. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22516. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22517. */
  22518. function isIndex(value, length) {
  22519. var type = typeof value;
  22520. length = length == null ? MAX_SAFE_INTEGER : length;
  22521. return !!length &&
  22522. (type == 'number' ||
  22523. (type != 'symbol' && reIsUint.test(value))) &&
  22524. (value > -1 && value % 1 == 0 && value < length);
  22525. }
  22526. /**
  22527. * Checks if the given arguments are from an iteratee call.
  22528. *
  22529. * @private
  22530. * @param {*} value The potential iteratee value argument.
  22531. * @param {*} index The potential iteratee index or key argument.
  22532. * @param {*} object The potential iteratee object argument.
  22533. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  22534. * else `false`.
  22535. */
  22536. function isIterateeCall(value, index, object) {
  22537. if (!isObject(object)) {
  22538. return false;
  22539. }
  22540. var type = typeof index;
  22541. if (type == 'number'
  22542. ? (isArrayLike(object) && isIndex(index, object.length))
  22543. : (type == 'string' && index in object)
  22544. ) {
  22545. return eq(object[index], value);
  22546. }
  22547. return false;
  22548. }
  22549. /**
  22550. * Checks if `value` is a property name and not a property path.
  22551. *
  22552. * @private
  22553. * @param {*} value The value to check.
  22554. * @param {Object} [object] The object to query keys on.
  22555. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22556. */
  22557. function isKey(value, object) {
  22558. if (isArray(value)) {
  22559. return false;
  22560. }
  22561. var type = typeof value;
  22562. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  22563. value == null || isSymbol(value)) {
  22564. return true;
  22565. }
  22566. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  22567. (object != null && value in Object(object));
  22568. }
  22569. /**
  22570. * Checks if `value` is suitable for use as unique object key.
  22571. *
  22572. * @private
  22573. * @param {*} value The value to check.
  22574. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  22575. */
  22576. function isKeyable(value) {
  22577. var type = typeof value;
  22578. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  22579. ? (value !== '__proto__')
  22580. : (value === null);
  22581. }
  22582. /**
  22583. * Checks if `func` has a lazy counterpart.
  22584. *
  22585. * @private
  22586. * @param {Function} func The function to check.
  22587. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  22588. * else `false`.
  22589. */
  22590. function isLaziable(func) {
  22591. var funcName = getFuncName(func),
  22592. other = lodash[funcName];
  22593. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  22594. return false;
  22595. }
  22596. if (func === other) {
  22597. return true;
  22598. }
  22599. var data = getData(other);
  22600. return !!data && func === data[0];
  22601. }
  22602. /**
  22603. * Checks if `func` has its source masked.
  22604. *
  22605. * @private
  22606. * @param {Function} func The function to check.
  22607. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  22608. */
  22609. function isMasked(func) {
  22610. return !!maskSrcKey && (maskSrcKey in func);
  22611. }
  22612. /**
  22613. * Checks if `func` is capable of being masked.
  22614. *
  22615. * @private
  22616. * @param {*} value The value to check.
  22617. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  22618. */
  22619. var isMaskable = coreJsData ? isFunction : stubFalse;
  22620. /**
  22621. * Checks if `value` is likely a prototype object.
  22622. *
  22623. * @private
  22624. * @param {*} value The value to check.
  22625. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  22626. */
  22627. function isPrototype(value) {
  22628. var Ctor = value && value.constructor,
  22629. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  22630. return value === proto;
  22631. }
  22632. /**
  22633. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22634. *
  22635. * @private
  22636. * @param {*} value The value to check.
  22637. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22638. * equality comparisons, else `false`.
  22639. */
  22640. function isStrictComparable(value) {
  22641. return value === value && !isObject(value);
  22642. }
  22643. /**
  22644. * A specialized version of `matchesProperty` for source values suitable
  22645. * for strict equality comparisons, i.e. `===`.
  22646. *
  22647. * @private
  22648. * @param {string} key The key of the property to get.
  22649. * @param {*} srcValue The value to match.
  22650. * @returns {Function} Returns the new spec function.
  22651. */
  22652. function matchesStrictComparable(key, srcValue) {
  22653. return function(object) {
  22654. if (object == null) {
  22655. return false;
  22656. }
  22657. return object[key] === srcValue &&
  22658. (srcValue !== undefined || (key in Object(object)));
  22659. };
  22660. }
  22661. /**
  22662. * A specialized version of `_.memoize` which clears the memoized function's
  22663. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  22664. *
  22665. * @private
  22666. * @param {Function} func The function to have its output memoized.
  22667. * @returns {Function} Returns the new memoized function.
  22668. */
  22669. function memoizeCapped(func) {
  22670. var result = memoize(func, function(key) {
  22671. if (cache.size === MAX_MEMOIZE_SIZE) {
  22672. cache.clear();
  22673. }
  22674. return key;
  22675. });
  22676. var cache = result.cache;
  22677. return result;
  22678. }
  22679. /**
  22680. * Merges the function metadata of `source` into `data`.
  22681. *
  22682. * Merging metadata reduces the number of wrappers used to invoke a function.
  22683. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  22684. * may be applied regardless of execution order. Methods like `_.ary` and
  22685. * `_.rearg` modify function arguments, making the order in which they are
  22686. * executed important, preventing the merging of metadata. However, we make
  22687. * an exception for a safe combined case where curried functions have `_.ary`
  22688. * and or `_.rearg` applied.
  22689. *
  22690. * @private
  22691. * @param {Array} data The destination metadata.
  22692. * @param {Array} source The source metadata.
  22693. * @returns {Array} Returns `data`.
  22694. */
  22695. function mergeData(data, source) {
  22696. var bitmask = data[1],
  22697. srcBitmask = source[1],
  22698. newBitmask = bitmask | srcBitmask,
  22699. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  22700. var isCombo =
  22701. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  22702. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  22703. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  22704. // Exit early if metadata can't be merged.
  22705. if (!(isCommon || isCombo)) {
  22706. return data;
  22707. }
  22708. // Use source `thisArg` if available.
  22709. if (srcBitmask & WRAP_BIND_FLAG) {
  22710. data[2] = source[2];
  22711. // Set when currying a bound function.
  22712. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  22713. }
  22714. // Compose partial arguments.
  22715. var value = source[3];
  22716. if (value) {
  22717. var partials = data[3];
  22718. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  22719. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  22720. }
  22721. // Compose partial right arguments.
  22722. value = source[5];
  22723. if (value) {
  22724. partials = data[5];
  22725. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  22726. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  22727. }
  22728. // Use source `argPos` if available.
  22729. value = source[7];
  22730. if (value) {
  22731. data[7] = value;
  22732. }
  22733. // Use source `ary` if it's smaller.
  22734. if (srcBitmask & WRAP_ARY_FLAG) {
  22735. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  22736. }
  22737. // Use source `arity` if one is not provided.
  22738. if (data[9] == null) {
  22739. data[9] = source[9];
  22740. }
  22741. // Use source `func` and merge bitmasks.
  22742. data[0] = source[0];
  22743. data[1] = newBitmask;
  22744. return data;
  22745. }
  22746. /**
  22747. * This function is like
  22748. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22749. * except that it includes inherited enumerable properties.
  22750. *
  22751. * @private
  22752. * @param {Object} object The object to query.
  22753. * @returns {Array} Returns the array of property names.
  22754. */
  22755. function nativeKeysIn(object) {
  22756. var result = [];
  22757. if (object != null) {
  22758. for (var key in Object(object)) {
  22759. result.push(key);
  22760. }
  22761. }
  22762. return result;
  22763. }
  22764. /**
  22765. * Converts `value` to a string using `Object.prototype.toString`.
  22766. *
  22767. * @private
  22768. * @param {*} value The value to convert.
  22769. * @returns {string} Returns the converted string.
  22770. */
  22771. function objectToString(value) {
  22772. return nativeObjectToString.call(value);
  22773. }
  22774. /**
  22775. * A specialized version of `baseRest` which transforms the rest array.
  22776. *
  22777. * @private
  22778. * @param {Function} func The function to apply a rest parameter to.
  22779. * @param {number} [start=func.length-1] The start position of the rest parameter.
  22780. * @param {Function} transform The rest array transform.
  22781. * @returns {Function} Returns the new function.
  22782. */
  22783. function overRest(func, start, transform) {
  22784. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  22785. return function() {
  22786. var args = arguments,
  22787. index = -1,
  22788. length = nativeMax(args.length - start, 0),
  22789. array = Array(length);
  22790. while (++index < length) {
  22791. array[index] = args[start + index];
  22792. }
  22793. index = -1;
  22794. var otherArgs = Array(start + 1);
  22795. while (++index < start) {
  22796. otherArgs[index] = args[index];
  22797. }
  22798. otherArgs[start] = transform(array);
  22799. return apply(func, this, otherArgs);
  22800. };
  22801. }
  22802. /**
  22803. * Gets the parent value at `path` of `object`.
  22804. *
  22805. * @private
  22806. * @param {Object} object The object to query.
  22807. * @param {Array} path The path to get the parent value of.
  22808. * @returns {*} Returns the parent value.
  22809. */
  22810. function parent(object, path) {
  22811. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  22812. }
  22813. /**
  22814. * Reorder `array` according to the specified indexes where the element at
  22815. * the first index is assigned as the first element, the element at
  22816. * the second index is assigned as the second element, and so on.
  22817. *
  22818. * @private
  22819. * @param {Array} array The array to reorder.
  22820. * @param {Array} indexes The arranged array indexes.
  22821. * @returns {Array} Returns `array`.
  22822. */
  22823. function reorder(array, indexes) {
  22824. var arrLength = array.length,
  22825. length = nativeMin(indexes.length, arrLength),
  22826. oldArray = copyArray(array);
  22827. while (length--) {
  22828. var index = indexes[length];
  22829. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  22830. }
  22831. return array;
  22832. }
  22833. /**
  22834. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  22835. *
  22836. * @private
  22837. * @param {Object} object The object to query.
  22838. * @param {string} key The key of the property to get.
  22839. * @returns {*} Returns the property value.
  22840. */
  22841. function safeGet(object, key) {
  22842. if (key === 'constructor' && typeof object[key] === 'function') {
  22843. return;
  22844. }
  22845. if (key == '__proto__') {
  22846. return;
  22847. }
  22848. return object[key];
  22849. }
  22850. /**
  22851. * Sets metadata for `func`.
  22852. *
  22853. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  22854. * period of time, it will trip its breaker and transition to an identity
  22855. * function to avoid garbage collection pauses in V8. See
  22856. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  22857. * for more details.
  22858. *
  22859. * @private
  22860. * @param {Function} func The function to associate metadata with.
  22861. * @param {*} data The metadata.
  22862. * @returns {Function} Returns `func`.
  22863. */
  22864. var setData = shortOut(baseSetData);
  22865. /**
  22866. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  22867. *
  22868. * @private
  22869. * @param {Function} func The function to delay.
  22870. * @param {number} wait The number of milliseconds to delay invocation.
  22871. * @returns {number|Object} Returns the timer id or timeout object.
  22872. */
  22873. var setTimeout = ctxSetTimeout || function(func, wait) {
  22874. return root.setTimeout(func, wait);
  22875. };
  22876. /**
  22877. * Sets the `toString` method of `func` to return `string`.
  22878. *
  22879. * @private
  22880. * @param {Function} func The function to modify.
  22881. * @param {Function} string The `toString` result.
  22882. * @returns {Function} Returns `func`.
  22883. */
  22884. var setToString = shortOut(baseSetToString);
  22885. /**
  22886. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  22887. * with wrapper details in a comment at the top of the source body.
  22888. *
  22889. * @private
  22890. * @param {Function} wrapper The function to modify.
  22891. * @param {Function} reference The reference function.
  22892. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22893. * @returns {Function} Returns `wrapper`.
  22894. */
  22895. function setWrapToString(wrapper, reference, bitmask) {
  22896. var source = (reference + '');
  22897. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  22898. }
  22899. /**
  22900. * Creates a function that'll short out and invoke `identity` instead
  22901. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  22902. * milliseconds.
  22903. *
  22904. * @private
  22905. * @param {Function} func The function to restrict.
  22906. * @returns {Function} Returns the new shortable function.
  22907. */
  22908. function shortOut(func) {
  22909. var count = 0,
  22910. lastCalled = 0;
  22911. return function() {
  22912. var stamp = nativeNow(),
  22913. remaining = HOT_SPAN - (stamp - lastCalled);
  22914. lastCalled = stamp;
  22915. if (remaining > 0) {
  22916. if (++count >= HOT_COUNT) {
  22917. return arguments[0];
  22918. }
  22919. } else {
  22920. count = 0;
  22921. }
  22922. return func.apply(undefined, arguments);
  22923. };
  22924. }
  22925. /**
  22926. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  22927. *
  22928. * @private
  22929. * @param {Array} array The array to shuffle.
  22930. * @param {number} [size=array.length] The size of `array`.
  22931. * @returns {Array} Returns `array`.
  22932. */
  22933. function shuffleSelf(array, size) {
  22934. var index = -1,
  22935. length = array.length,
  22936. lastIndex = length - 1;
  22937. size = size === undefined ? length : size;
  22938. while (++index < size) {
  22939. var rand = baseRandom(index, lastIndex),
  22940. value = array[rand];
  22941. array[rand] = array[index];
  22942. array[index] = value;
  22943. }
  22944. array.length = size;
  22945. return array;
  22946. }
  22947. /**
  22948. * Converts `string` to a property path array.
  22949. *
  22950. * @private
  22951. * @param {string} string The string to convert.
  22952. * @returns {Array} Returns the property path array.
  22953. */
  22954. var stringToPath = memoizeCapped(function(string) {
  22955. var result = [];
  22956. if (string.charCodeAt(0) === 46 /* . */) {
  22957. result.push('');
  22958. }
  22959. string.replace(rePropName, function(match, number, quote, subString) {
  22960. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  22961. });
  22962. return result;
  22963. });
  22964. /**
  22965. * Converts `value` to a string key if it's not a string or symbol.
  22966. *
  22967. * @private
  22968. * @param {*} value The value to inspect.
  22969. * @returns {string|symbol} Returns the key.
  22970. */
  22971. function toKey(value) {
  22972. if (typeof value == 'string' || isSymbol(value)) {
  22973. return value;
  22974. }
  22975. var result = (value + '');
  22976. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  22977. }
  22978. /**
  22979. * Converts `func` to its source code.
  22980. *
  22981. * @private
  22982. * @param {Function} func The function to convert.
  22983. * @returns {string} Returns the source code.
  22984. */
  22985. function toSource(func) {
  22986. if (func != null) {
  22987. try {
  22988. return funcToString.call(func);
  22989. } catch (e) {}
  22990. try {
  22991. return (func + '');
  22992. } catch (e) {}
  22993. }
  22994. return '';
  22995. }
  22996. /**
  22997. * Updates wrapper `details` based on `bitmask` flags.
  22998. *
  22999. * @private
  23000. * @returns {Array} details The details to modify.
  23001. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23002. * @returns {Array} Returns `details`.
  23003. */
  23004. function updateWrapDetails(details, bitmask) {
  23005. arrayEach(wrapFlags, function(pair) {
  23006. var value = '_.' + pair[0];
  23007. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23008. details.push(value);
  23009. }
  23010. });
  23011. return details.sort();
  23012. }
  23013. /**
  23014. * Creates a clone of `wrapper`.
  23015. *
  23016. * @private
  23017. * @param {Object} wrapper The wrapper to clone.
  23018. * @returns {Object} Returns the cloned wrapper.
  23019. */
  23020. function wrapperClone(wrapper) {
  23021. if (wrapper instanceof LazyWrapper) {
  23022. return wrapper.clone();
  23023. }
  23024. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23025. result.__actions__ = copyArray(wrapper.__actions__);
  23026. result.__index__ = wrapper.__index__;
  23027. result.__values__ = wrapper.__values__;
  23028. return result;
  23029. }
  23030. /*------------------------------------------------------------------------*/
  23031. /**
  23032. * Creates an array of elements split into groups the length of `size`.
  23033. * If `array` can't be split evenly, the final chunk will be the remaining
  23034. * elements.
  23035. *
  23036. * @static
  23037. * @memberOf _
  23038. * @since 3.0.0
  23039. * @category Array
  23040. * @param {Array} array The array to process.
  23041. * @param {number} [size=1] The length of each chunk
  23042. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23043. * @returns {Array} Returns the new array of chunks.
  23044. * @example
  23045. *
  23046. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23047. * // => [['a', 'b'], ['c', 'd']]
  23048. *
  23049. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23050. * // => [['a', 'b', 'c'], ['d']]
  23051. */
  23052. function chunk(array, size, guard) {
  23053. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23054. size = 1;
  23055. } else {
  23056. size = nativeMax(toInteger(size), 0);
  23057. }
  23058. var length = array == null ? 0 : array.length;
  23059. if (!length || size < 1) {
  23060. return [];
  23061. }
  23062. var index = 0,
  23063. resIndex = 0,
  23064. result = Array(nativeCeil(length / size));
  23065. while (index < length) {
  23066. result[resIndex++] = baseSlice(array, index, (index += size));
  23067. }
  23068. return result;
  23069. }
  23070. /**
  23071. * Creates an array with all falsey values removed. The values `false`, `null`,
  23072. * `0`, `""`, `undefined`, and `NaN` are falsey.
  23073. *
  23074. * @static
  23075. * @memberOf _
  23076. * @since 0.1.0
  23077. * @category Array
  23078. * @param {Array} array The array to compact.
  23079. * @returns {Array} Returns the new array of filtered values.
  23080. * @example
  23081. *
  23082. * _.compact([0, 1, false, 2, '', 3]);
  23083. * // => [1, 2, 3]
  23084. */
  23085. function compact(array) {
  23086. var index = -1,
  23087. length = array == null ? 0 : array.length,
  23088. resIndex = 0,
  23089. result = [];
  23090. while (++index < length) {
  23091. var value = array[index];
  23092. if (value) {
  23093. result[resIndex++] = value;
  23094. }
  23095. }
  23096. return result;
  23097. }
  23098. /**
  23099. * Creates a new array concatenating `array` with any additional arrays
  23100. * and/or values.
  23101. *
  23102. * @static
  23103. * @memberOf _
  23104. * @since 4.0.0
  23105. * @category Array
  23106. * @param {Array} array The array to concatenate.
  23107. * @param {...*} [values] The values to concatenate.
  23108. * @returns {Array} Returns the new concatenated array.
  23109. * @example
  23110. *
  23111. * var array = [1];
  23112. * var other = _.concat(array, 2, [3], [[4]]);
  23113. *
  23114. * console.log(other);
  23115. * // => [1, 2, 3, [4]]
  23116. *
  23117. * console.log(array);
  23118. * // => [1]
  23119. */
  23120. function concat() {
  23121. var length = arguments.length;
  23122. if (!length) {
  23123. return [];
  23124. }
  23125. var args = Array(length - 1),
  23126. array = arguments[0],
  23127. index = length;
  23128. while (index--) {
  23129. args[index - 1] = arguments[index];
  23130. }
  23131. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  23132. }
  23133. /**
  23134. * Creates an array of `array` values not included in the other given arrays
  23135. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23136. * for equality comparisons. The order and references of result values are
  23137. * determined by the first array.
  23138. *
  23139. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  23140. *
  23141. * @static
  23142. * @memberOf _
  23143. * @since 0.1.0
  23144. * @category Array
  23145. * @param {Array} array The array to inspect.
  23146. * @param {...Array} [values] The values to exclude.
  23147. * @returns {Array} Returns the new array of filtered values.
  23148. * @see _.without, _.xor
  23149. * @example
  23150. *
  23151. * _.difference([2, 1], [2, 3]);
  23152. * // => [1]
  23153. */
  23154. var difference = baseRest(function(array, values) {
  23155. return isArrayLikeObject(array)
  23156. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  23157. : [];
  23158. });
  23159. /**
  23160. * This method is like `_.difference` except that it accepts `iteratee` which
  23161. * is invoked for each element of `array` and `values` to generate the criterion
  23162. * by which they're compared. The order and references of result values are
  23163. * determined by the first array. The iteratee is invoked with one argument:
  23164. * (value).
  23165. *
  23166. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  23167. *
  23168. * @static
  23169. * @memberOf _
  23170. * @since 4.0.0
  23171. * @category Array
  23172. * @param {Array} array The array to inspect.
  23173. * @param {...Array} [values] The values to exclude.
  23174. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23175. * @returns {Array} Returns the new array of filtered values.
  23176. * @example
  23177. *
  23178. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23179. * // => [1.2]
  23180. *
  23181. * // The `_.property` iteratee shorthand.
  23182. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  23183. * // => [{ 'x': 2 }]
  23184. */
  23185. var differenceBy = baseRest(function(array, values) {
  23186. var iteratee = last(values);
  23187. if (isArrayLikeObject(iteratee)) {
  23188. iteratee = undefined;
  23189. }
  23190. return isArrayLikeObject(array)
  23191. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  23192. : [];
  23193. });
  23194. /**
  23195. * This method is like `_.difference` except that it accepts `comparator`
  23196. * which is invoked to compare elements of `array` to `values`. The order and
  23197. * references of result values are determined by the first array. The comparator
  23198. * is invoked with two arguments: (arrVal, othVal).
  23199. *
  23200. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  23201. *
  23202. * @static
  23203. * @memberOf _
  23204. * @since 4.0.0
  23205. * @category Array
  23206. * @param {Array} array The array to inspect.
  23207. * @param {...Array} [values] The values to exclude.
  23208. * @param {Function} [comparator] The comparator invoked per element.
  23209. * @returns {Array} Returns the new array of filtered values.
  23210. * @example
  23211. *
  23212. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23213. *
  23214. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  23215. * // => [{ 'x': 2, 'y': 1 }]
  23216. */
  23217. var differenceWith = baseRest(function(array, values) {
  23218. var comparator = last(values);
  23219. if (isArrayLikeObject(comparator)) {
  23220. comparator = undefined;
  23221. }
  23222. return isArrayLikeObject(array)
  23223. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  23224. : [];
  23225. });
  23226. /**
  23227. * Creates a slice of `array` with `n` elements dropped from the beginning.
  23228. *
  23229. * @static
  23230. * @memberOf _
  23231. * @since 0.5.0
  23232. * @category Array
  23233. * @param {Array} array The array to query.
  23234. * @param {number} [n=1] The number of elements to drop.
  23235. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23236. * @returns {Array} Returns the slice of `array`.
  23237. * @example
  23238. *
  23239. * _.drop([1, 2, 3]);
  23240. * // => [2, 3]
  23241. *
  23242. * _.drop([1, 2, 3], 2);
  23243. * // => [3]
  23244. *
  23245. * _.drop([1, 2, 3], 5);
  23246. * // => []
  23247. *
  23248. * _.drop([1, 2, 3], 0);
  23249. * // => [1, 2, 3]
  23250. */
  23251. function drop(array, n, guard) {
  23252. var length = array == null ? 0 : array.length;
  23253. if (!length) {
  23254. return [];
  23255. }
  23256. n = (guard || n === undefined) ? 1 : toInteger(n);
  23257. return baseSlice(array, n < 0 ? 0 : n, length);
  23258. }
  23259. /**
  23260. * Creates a slice of `array` with `n` elements dropped from the end.
  23261. *
  23262. * @static
  23263. * @memberOf _
  23264. * @since 3.0.0
  23265. * @category Array
  23266. * @param {Array} array The array to query.
  23267. * @param {number} [n=1] The number of elements to drop.
  23268. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23269. * @returns {Array} Returns the slice of `array`.
  23270. * @example
  23271. *
  23272. * _.dropRight([1, 2, 3]);
  23273. * // => [1, 2]
  23274. *
  23275. * _.dropRight([1, 2, 3], 2);
  23276. * // => [1]
  23277. *
  23278. * _.dropRight([1, 2, 3], 5);
  23279. * // => []
  23280. *
  23281. * _.dropRight([1, 2, 3], 0);
  23282. * // => [1, 2, 3]
  23283. */
  23284. function dropRight(array, n, guard) {
  23285. var length = array == null ? 0 : array.length;
  23286. if (!length) {
  23287. return [];
  23288. }
  23289. n = (guard || n === undefined) ? 1 : toInteger(n);
  23290. n = length - n;
  23291. return baseSlice(array, 0, n < 0 ? 0 : n);
  23292. }
  23293. /**
  23294. * Creates a slice of `array` excluding elements dropped from the end.
  23295. * Elements are dropped until `predicate` returns falsey. The predicate is
  23296. * invoked with three arguments: (value, index, array).
  23297. *
  23298. * @static
  23299. * @memberOf _
  23300. * @since 3.0.0
  23301. * @category Array
  23302. * @param {Array} array The array to query.
  23303. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23304. * @returns {Array} Returns the slice of `array`.
  23305. * @example
  23306. *
  23307. * var users = [
  23308. * { 'user': 'barney', 'active': true },
  23309. * { 'user': 'fred', 'active': false },
  23310. * { 'user': 'pebbles', 'active': false }
  23311. * ];
  23312. *
  23313. * _.dropRightWhile(users, function(o) { return !o.active; });
  23314. * // => objects for ['barney']
  23315. *
  23316. * // The `_.matches` iteratee shorthand.
  23317. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  23318. * // => objects for ['barney', 'fred']
  23319. *
  23320. * // The `_.matchesProperty` iteratee shorthand.
  23321. * _.dropRightWhile(users, ['active', false]);
  23322. * // => objects for ['barney']
  23323. *
  23324. * // The `_.property` iteratee shorthand.
  23325. * _.dropRightWhile(users, 'active');
  23326. * // => objects for ['barney', 'fred', 'pebbles']
  23327. */
  23328. function dropRightWhile(array, predicate) {
  23329. return (array && array.length)
  23330. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  23331. : [];
  23332. }
  23333. /**
  23334. * Creates a slice of `array` excluding elements dropped from the beginning.
  23335. * Elements are dropped until `predicate` returns falsey. The predicate is
  23336. * invoked with three arguments: (value, index, array).
  23337. *
  23338. * @static
  23339. * @memberOf _
  23340. * @since 3.0.0
  23341. * @category Array
  23342. * @param {Array} array The array to query.
  23343. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23344. * @returns {Array} Returns the slice of `array`.
  23345. * @example
  23346. *
  23347. * var users = [
  23348. * { 'user': 'barney', 'active': false },
  23349. * { 'user': 'fred', 'active': false },
  23350. * { 'user': 'pebbles', 'active': true }
  23351. * ];
  23352. *
  23353. * _.dropWhile(users, function(o) { return !o.active; });
  23354. * // => objects for ['pebbles']
  23355. *
  23356. * // The `_.matches` iteratee shorthand.
  23357. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  23358. * // => objects for ['fred', 'pebbles']
  23359. *
  23360. * // The `_.matchesProperty` iteratee shorthand.
  23361. * _.dropWhile(users, ['active', false]);
  23362. * // => objects for ['pebbles']
  23363. *
  23364. * // The `_.property` iteratee shorthand.
  23365. * _.dropWhile(users, 'active');
  23366. * // => objects for ['barney', 'fred', 'pebbles']
  23367. */
  23368. function dropWhile(array, predicate) {
  23369. return (array && array.length)
  23370. ? baseWhile(array, getIteratee(predicate, 3), true)
  23371. : [];
  23372. }
  23373. /**
  23374. * Fills elements of `array` with `value` from `start` up to, but not
  23375. * including, `end`.
  23376. *
  23377. * **Note:** This method mutates `array`.
  23378. *
  23379. * @static
  23380. * @memberOf _
  23381. * @since 3.2.0
  23382. * @category Array
  23383. * @param {Array} array The array to fill.
  23384. * @param {*} value The value to fill `array` with.
  23385. * @param {number} [start=0] The start position.
  23386. * @param {number} [end=array.length] The end position.
  23387. * @returns {Array} Returns `array`.
  23388. * @example
  23389. *
  23390. * var array = [1, 2, 3];
  23391. *
  23392. * _.fill(array, 'a');
  23393. * console.log(array);
  23394. * // => ['a', 'a', 'a']
  23395. *
  23396. * _.fill(Array(3), 2);
  23397. * // => [2, 2, 2]
  23398. *
  23399. * _.fill([4, 6, 8, 10], '*', 1, 3);
  23400. * // => [4, '*', '*', 10]
  23401. */
  23402. function fill(array, value, start, end) {
  23403. var length = array == null ? 0 : array.length;
  23404. if (!length) {
  23405. return [];
  23406. }
  23407. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  23408. start = 0;
  23409. end = length;
  23410. }
  23411. return baseFill(array, value, start, end);
  23412. }
  23413. /**
  23414. * This method is like `_.find` except that it returns the index of the first
  23415. * element `predicate` returns truthy for instead of the element itself.
  23416. *
  23417. * @static
  23418. * @memberOf _
  23419. * @since 1.1.0
  23420. * @category Array
  23421. * @param {Array} array The array to inspect.
  23422. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23423. * @param {number} [fromIndex=0] The index to search from.
  23424. * @returns {number} Returns the index of the found element, else `-1`.
  23425. * @example
  23426. *
  23427. * var users = [
  23428. * { 'user': 'barney', 'active': false },
  23429. * { 'user': 'fred', 'active': false },
  23430. * { 'user': 'pebbles', 'active': true }
  23431. * ];
  23432. *
  23433. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  23434. * // => 0
  23435. *
  23436. * // The `_.matches` iteratee shorthand.
  23437. * _.findIndex(users, { 'user': 'fred', 'active': false });
  23438. * // => 1
  23439. *
  23440. * // The `_.matchesProperty` iteratee shorthand.
  23441. * _.findIndex(users, ['active', false]);
  23442. * // => 0
  23443. *
  23444. * // The `_.property` iteratee shorthand.
  23445. * _.findIndex(users, 'active');
  23446. * // => 2
  23447. */
  23448. function findIndex(array, predicate, fromIndex) {
  23449. var length = array == null ? 0 : array.length;
  23450. if (!length) {
  23451. return -1;
  23452. }
  23453. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23454. if (index < 0) {
  23455. index = nativeMax(length + index, 0);
  23456. }
  23457. return baseFindIndex(array, getIteratee(predicate, 3), index);
  23458. }
  23459. /**
  23460. * This method is like `_.findIndex` except that it iterates over elements
  23461. * of `collection` from right to left.
  23462. *
  23463. * @static
  23464. * @memberOf _
  23465. * @since 2.0.0
  23466. * @category Array
  23467. * @param {Array} array The array to inspect.
  23468. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23469. * @param {number} [fromIndex=array.length-1] The index to search from.
  23470. * @returns {number} Returns the index of the found element, else `-1`.
  23471. * @example
  23472. *
  23473. * var users = [
  23474. * { 'user': 'barney', 'active': true },
  23475. * { 'user': 'fred', 'active': false },
  23476. * { 'user': 'pebbles', 'active': false }
  23477. * ];
  23478. *
  23479. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  23480. * // => 2
  23481. *
  23482. * // The `_.matches` iteratee shorthand.
  23483. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  23484. * // => 0
  23485. *
  23486. * // The `_.matchesProperty` iteratee shorthand.
  23487. * _.findLastIndex(users, ['active', false]);
  23488. * // => 2
  23489. *
  23490. * // The `_.property` iteratee shorthand.
  23491. * _.findLastIndex(users, 'active');
  23492. * // => 0
  23493. */
  23494. function findLastIndex(array, predicate, fromIndex) {
  23495. var length = array == null ? 0 : array.length;
  23496. if (!length) {
  23497. return -1;
  23498. }
  23499. var index = length - 1;
  23500. if (fromIndex !== undefined) {
  23501. index = toInteger(fromIndex);
  23502. index = fromIndex < 0
  23503. ? nativeMax(length + index, 0)
  23504. : nativeMin(index, length - 1);
  23505. }
  23506. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  23507. }
  23508. /**
  23509. * Flattens `array` a single level deep.
  23510. *
  23511. * @static
  23512. * @memberOf _
  23513. * @since 0.1.0
  23514. * @category Array
  23515. * @param {Array} array The array to flatten.
  23516. * @returns {Array} Returns the new flattened array.
  23517. * @example
  23518. *
  23519. * _.flatten([1, [2, [3, [4]], 5]]);
  23520. * // => [1, 2, [3, [4]], 5]
  23521. */
  23522. function flatten(array) {
  23523. var length = array == null ? 0 : array.length;
  23524. return length ? baseFlatten(array, 1) : [];
  23525. }
  23526. /**
  23527. * Recursively flattens `array`.
  23528. *
  23529. * @static
  23530. * @memberOf _
  23531. * @since 3.0.0
  23532. * @category Array
  23533. * @param {Array} array The array to flatten.
  23534. * @returns {Array} Returns the new flattened array.
  23535. * @example
  23536. *
  23537. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  23538. * // => [1, 2, 3, 4, 5]
  23539. */
  23540. function flattenDeep(array) {
  23541. var length = array == null ? 0 : array.length;
  23542. return length ? baseFlatten(array, INFINITY) : [];
  23543. }
  23544. /**
  23545. * Recursively flatten `array` up to `depth` times.
  23546. *
  23547. * @static
  23548. * @memberOf _
  23549. * @since 4.4.0
  23550. * @category Array
  23551. * @param {Array} array The array to flatten.
  23552. * @param {number} [depth=1] The maximum recursion depth.
  23553. * @returns {Array} Returns the new flattened array.
  23554. * @example
  23555. *
  23556. * var array = [1, [2, [3, [4]], 5]];
  23557. *
  23558. * _.flattenDepth(array, 1);
  23559. * // => [1, 2, [3, [4]], 5]
  23560. *
  23561. * _.flattenDepth(array, 2);
  23562. * // => [1, 2, 3, [4], 5]
  23563. */
  23564. function flattenDepth(array, depth) {
  23565. var length = array == null ? 0 : array.length;
  23566. if (!length) {
  23567. return [];
  23568. }
  23569. depth = depth === undefined ? 1 : toInteger(depth);
  23570. return baseFlatten(array, depth);
  23571. }
  23572. /**
  23573. * The inverse of `_.toPairs`; this method returns an object composed
  23574. * from key-value `pairs`.
  23575. *
  23576. * @static
  23577. * @memberOf _
  23578. * @since 4.0.0
  23579. * @category Array
  23580. * @param {Array} pairs The key-value pairs.
  23581. * @returns {Object} Returns the new object.
  23582. * @example
  23583. *
  23584. * _.fromPairs([['a', 1], ['b', 2]]);
  23585. * // => { 'a': 1, 'b': 2 }
  23586. */
  23587. function fromPairs(pairs) {
  23588. var index = -1,
  23589. length = pairs == null ? 0 : pairs.length,
  23590. result = {};
  23591. while (++index < length) {
  23592. var pair = pairs[index];
  23593. result[pair[0]] = pair[1];
  23594. }
  23595. return result;
  23596. }
  23597. /**
  23598. * Gets the first element of `array`.
  23599. *
  23600. * @static
  23601. * @memberOf _
  23602. * @since 0.1.0
  23603. * @alias first
  23604. * @category Array
  23605. * @param {Array} array The array to query.
  23606. * @returns {*} Returns the first element of `array`.
  23607. * @example
  23608. *
  23609. * _.head([1, 2, 3]);
  23610. * // => 1
  23611. *
  23612. * _.head([]);
  23613. * // => undefined
  23614. */
  23615. function head(array) {
  23616. return (array && array.length) ? array[0] : undefined;
  23617. }
  23618. /**
  23619. * Gets the index at which the first occurrence of `value` is found in `array`
  23620. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23621. * for equality comparisons. If `fromIndex` is negative, it's used as the
  23622. * offset from the end of `array`.
  23623. *
  23624. * @static
  23625. * @memberOf _
  23626. * @since 0.1.0
  23627. * @category Array
  23628. * @param {Array} array The array to inspect.
  23629. * @param {*} value The value to search for.
  23630. * @param {number} [fromIndex=0] The index to search from.
  23631. * @returns {number} Returns the index of the matched value, else `-1`.
  23632. * @example
  23633. *
  23634. * _.indexOf([1, 2, 1, 2], 2);
  23635. * // => 1
  23636. *
  23637. * // Search from the `fromIndex`.
  23638. * _.indexOf([1, 2, 1, 2], 2, 2);
  23639. * // => 3
  23640. */
  23641. function indexOf(array, value, fromIndex) {
  23642. var length = array == null ? 0 : array.length;
  23643. if (!length) {
  23644. return -1;
  23645. }
  23646. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  23647. if (index < 0) {
  23648. index = nativeMax(length + index, 0);
  23649. }
  23650. return baseIndexOf(array, value, index);
  23651. }
  23652. /**
  23653. * Gets all but the last element of `array`.
  23654. *
  23655. * @static
  23656. * @memberOf _
  23657. * @since 0.1.0
  23658. * @category Array
  23659. * @param {Array} array The array to query.
  23660. * @returns {Array} Returns the slice of `array`.
  23661. * @example
  23662. *
  23663. * _.initial([1, 2, 3]);
  23664. * // => [1, 2]
  23665. */
  23666. function initial(array) {
  23667. var length = array == null ? 0 : array.length;
  23668. return length ? baseSlice(array, 0, -1) : [];
  23669. }
  23670. /**
  23671. * Creates an array of unique values that are included in all given arrays
  23672. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23673. * for equality comparisons. The order and references of result values are
  23674. * determined by the first array.
  23675. *
  23676. * @static
  23677. * @memberOf _
  23678. * @since 0.1.0
  23679. * @category Array
  23680. * @param {...Array} [arrays] The arrays to inspect.
  23681. * @returns {Array} Returns the new array of intersecting values.
  23682. * @example
  23683. *
  23684. * _.intersection([2, 1], [2, 3]);
  23685. * // => [2]
  23686. */
  23687. var intersection = baseRest(function(arrays) {
  23688. var mapped = arrayMap(arrays, castArrayLikeObject);
  23689. return (mapped.length && mapped[0] === arrays[0])
  23690. ? baseIntersection(mapped)
  23691. : [];
  23692. });
  23693. /**
  23694. * This method is like `_.intersection` except that it accepts `iteratee`
  23695. * which is invoked for each element of each `arrays` to generate the criterion
  23696. * by which they're compared. The order and references of result values are
  23697. * determined by the first array. The iteratee is invoked with one argument:
  23698. * (value).
  23699. *
  23700. * @static
  23701. * @memberOf _
  23702. * @since 4.0.0
  23703. * @category Array
  23704. * @param {...Array} [arrays] The arrays to inspect.
  23705. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23706. * @returns {Array} Returns the new array of intersecting values.
  23707. * @example
  23708. *
  23709. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  23710. * // => [2.1]
  23711. *
  23712. * // The `_.property` iteratee shorthand.
  23713. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  23714. * // => [{ 'x': 1 }]
  23715. */
  23716. var intersectionBy = baseRest(function(arrays) {
  23717. var iteratee = last(arrays),
  23718. mapped = arrayMap(arrays, castArrayLikeObject);
  23719. if (iteratee === last(mapped)) {
  23720. iteratee = undefined;
  23721. } else {
  23722. mapped.pop();
  23723. }
  23724. return (mapped.length && mapped[0] === arrays[0])
  23725. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  23726. : [];
  23727. });
  23728. /**
  23729. * This method is like `_.intersection` except that it accepts `comparator`
  23730. * which is invoked to compare elements of `arrays`. The order and references
  23731. * of result values are determined by the first array. The comparator is
  23732. * invoked with two arguments: (arrVal, othVal).
  23733. *
  23734. * @static
  23735. * @memberOf _
  23736. * @since 4.0.0
  23737. * @category Array
  23738. * @param {...Array} [arrays] The arrays to inspect.
  23739. * @param {Function} [comparator] The comparator invoked per element.
  23740. * @returns {Array} Returns the new array of intersecting values.
  23741. * @example
  23742. *
  23743. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  23744. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23745. *
  23746. * _.intersectionWith(objects, others, _.isEqual);
  23747. * // => [{ 'x': 1, 'y': 2 }]
  23748. */
  23749. var intersectionWith = baseRest(function(arrays) {
  23750. var comparator = last(arrays),
  23751. mapped = arrayMap(arrays, castArrayLikeObject);
  23752. comparator = typeof comparator == 'function' ? comparator : undefined;
  23753. if (comparator) {
  23754. mapped.pop();
  23755. }
  23756. return (mapped.length && mapped[0] === arrays[0])
  23757. ? baseIntersection(mapped, undefined, comparator)
  23758. : [];
  23759. });
  23760. /**
  23761. * Converts all elements in `array` into a string separated by `separator`.
  23762. *
  23763. * @static
  23764. * @memberOf _
  23765. * @since 4.0.0
  23766. * @category Array
  23767. * @param {Array} array The array to convert.
  23768. * @param {string} [separator=','] The element separator.
  23769. * @returns {string} Returns the joined string.
  23770. * @example
  23771. *
  23772. * _.join(['a', 'b', 'c'], '~');
  23773. * // => 'a~b~c'
  23774. */
  23775. function join(array, separator) {
  23776. return array == null ? '' : nativeJoin.call(array, separator);
  23777. }
  23778. /**
  23779. * Gets the last element of `array`.
  23780. *
  23781. * @static
  23782. * @memberOf _
  23783. * @since 0.1.0
  23784. * @category Array
  23785. * @param {Array} array The array to query.
  23786. * @returns {*} Returns the last element of `array`.
  23787. * @example
  23788. *
  23789. * _.last([1, 2, 3]);
  23790. * // => 3
  23791. */
  23792. function last(array) {
  23793. var length = array == null ? 0 : array.length;
  23794. return length ? array[length - 1] : undefined;
  23795. }
  23796. /**
  23797. * This method is like `_.indexOf` except that it iterates over elements of
  23798. * `array` from right to left.
  23799. *
  23800. * @static
  23801. * @memberOf _
  23802. * @since 0.1.0
  23803. * @category Array
  23804. * @param {Array} array The array to inspect.
  23805. * @param {*} value The value to search for.
  23806. * @param {number} [fromIndex=array.length-1] The index to search from.
  23807. * @returns {number} Returns the index of the matched value, else `-1`.
  23808. * @example
  23809. *
  23810. * _.lastIndexOf([1, 2, 1, 2], 2);
  23811. * // => 3
  23812. *
  23813. * // Search from the `fromIndex`.
  23814. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  23815. * // => 1
  23816. */
  23817. function lastIndexOf(array, value, fromIndex) {
  23818. var length = array == null ? 0 : array.length;
  23819. if (!length) {
  23820. return -1;
  23821. }
  23822. var index = length;
  23823. if (fromIndex !== undefined) {
  23824. index = toInteger(fromIndex);
  23825. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  23826. }
  23827. return value === value
  23828. ? strictLastIndexOf(array, value, index)
  23829. : baseFindIndex(array, baseIsNaN, index, true);
  23830. }
  23831. /**
  23832. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  23833. * element from the end is returned.
  23834. *
  23835. * @static
  23836. * @memberOf _
  23837. * @since 4.11.0
  23838. * @category Array
  23839. * @param {Array} array The array to query.
  23840. * @param {number} [n=0] The index of the element to return.
  23841. * @returns {*} Returns the nth element of `array`.
  23842. * @example
  23843. *
  23844. * var array = ['a', 'b', 'c', 'd'];
  23845. *
  23846. * _.nth(array, 1);
  23847. * // => 'b'
  23848. *
  23849. * _.nth(array, -2);
  23850. * // => 'c';
  23851. */
  23852. function nth(array, n) {
  23853. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  23854. }
  23855. /**
  23856. * Removes all given values from `array` using
  23857. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  23858. * for equality comparisons.
  23859. *
  23860. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  23861. * to remove elements from an array by predicate.
  23862. *
  23863. * @static
  23864. * @memberOf _
  23865. * @since 2.0.0
  23866. * @category Array
  23867. * @param {Array} array The array to modify.
  23868. * @param {...*} [values] The values to remove.
  23869. * @returns {Array} Returns `array`.
  23870. * @example
  23871. *
  23872. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23873. *
  23874. * _.pull(array, 'a', 'c');
  23875. * console.log(array);
  23876. * // => ['b', 'b']
  23877. */
  23878. var pull = baseRest(pullAll);
  23879. /**
  23880. * This method is like `_.pull` except that it accepts an array of values to remove.
  23881. *
  23882. * **Note:** Unlike `_.difference`, this method mutates `array`.
  23883. *
  23884. * @static
  23885. * @memberOf _
  23886. * @since 4.0.0
  23887. * @category Array
  23888. * @param {Array} array The array to modify.
  23889. * @param {Array} values The values to remove.
  23890. * @returns {Array} Returns `array`.
  23891. * @example
  23892. *
  23893. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  23894. *
  23895. * _.pullAll(array, ['a', 'c']);
  23896. * console.log(array);
  23897. * // => ['b', 'b']
  23898. */
  23899. function pullAll(array, values) {
  23900. return (array && array.length && values && values.length)
  23901. ? basePullAll(array, values)
  23902. : array;
  23903. }
  23904. /**
  23905. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  23906. * invoked for each element of `array` and `values` to generate the criterion
  23907. * by which they're compared. The iteratee is invoked with one argument: (value).
  23908. *
  23909. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  23910. *
  23911. * @static
  23912. * @memberOf _
  23913. * @since 4.0.0
  23914. * @category Array
  23915. * @param {Array} array The array to modify.
  23916. * @param {Array} values The values to remove.
  23917. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  23918. * @returns {Array} Returns `array`.
  23919. * @example
  23920. *
  23921. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  23922. *
  23923. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  23924. * console.log(array);
  23925. * // => [{ 'x': 2 }]
  23926. */
  23927. function pullAllBy(array, values, iteratee) {
  23928. return (array && array.length && values && values.length)
  23929. ? basePullAll(array, values, getIteratee(iteratee, 2))
  23930. : array;
  23931. }
  23932. /**
  23933. * This method is like `_.pullAll` except that it accepts `comparator` which
  23934. * is invoked to compare elements of `array` to `values`. The comparator is
  23935. * invoked with two arguments: (arrVal, othVal).
  23936. *
  23937. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  23938. *
  23939. * @static
  23940. * @memberOf _
  23941. * @since 4.6.0
  23942. * @category Array
  23943. * @param {Array} array The array to modify.
  23944. * @param {Array} values The values to remove.
  23945. * @param {Function} [comparator] The comparator invoked per element.
  23946. * @returns {Array} Returns `array`.
  23947. * @example
  23948. *
  23949. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  23950. *
  23951. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  23952. * console.log(array);
  23953. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  23954. */
  23955. function pullAllWith(array, values, comparator) {
  23956. return (array && array.length && values && values.length)
  23957. ? basePullAll(array, values, undefined, comparator)
  23958. : array;
  23959. }
  23960. /**
  23961. * Removes elements from `array` corresponding to `indexes` and returns an
  23962. * array of removed elements.
  23963. *
  23964. * **Note:** Unlike `_.at`, this method mutates `array`.
  23965. *
  23966. * @static
  23967. * @memberOf _
  23968. * @since 3.0.0
  23969. * @category Array
  23970. * @param {Array} array The array to modify.
  23971. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  23972. * @returns {Array} Returns the new array of removed elements.
  23973. * @example
  23974. *
  23975. * var array = ['a', 'b', 'c', 'd'];
  23976. * var pulled = _.pullAt(array, [1, 3]);
  23977. *
  23978. * console.log(array);
  23979. * // => ['a', 'c']
  23980. *
  23981. * console.log(pulled);
  23982. * // => ['b', 'd']
  23983. */
  23984. var pullAt = flatRest(function(array, indexes) {
  23985. var length = array == null ? 0 : array.length,
  23986. result = baseAt(array, indexes);
  23987. basePullAt(array, arrayMap(indexes, function(index) {
  23988. return isIndex(index, length) ? +index : index;
  23989. }).sort(compareAscending));
  23990. return result;
  23991. });
  23992. /**
  23993. * Removes all elements from `array` that `predicate` returns truthy for
  23994. * and returns an array of the removed elements. The predicate is invoked
  23995. * with three arguments: (value, index, array).
  23996. *
  23997. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  23998. * to pull elements from an array by value.
  23999. *
  24000. * @static
  24001. * @memberOf _
  24002. * @since 2.0.0
  24003. * @category Array
  24004. * @param {Array} array The array to modify.
  24005. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24006. * @returns {Array} Returns the new array of removed elements.
  24007. * @example
  24008. *
  24009. * var array = [1, 2, 3, 4];
  24010. * var evens = _.remove(array, function(n) {
  24011. * return n % 2 == 0;
  24012. * });
  24013. *
  24014. * console.log(array);
  24015. * // => [1, 3]
  24016. *
  24017. * console.log(evens);
  24018. * // => [2, 4]
  24019. */
  24020. function remove(array, predicate) {
  24021. var result = [];
  24022. if (!(array && array.length)) {
  24023. return result;
  24024. }
  24025. var index = -1,
  24026. indexes = [],
  24027. length = array.length;
  24028. predicate = getIteratee(predicate, 3);
  24029. while (++index < length) {
  24030. var value = array[index];
  24031. if (predicate(value, index, array)) {
  24032. result.push(value);
  24033. indexes.push(index);
  24034. }
  24035. }
  24036. basePullAt(array, indexes);
  24037. return result;
  24038. }
  24039. /**
  24040. * Reverses `array` so that the first element becomes the last, the second
  24041. * element becomes the second to last, and so on.
  24042. *
  24043. * **Note:** This method mutates `array` and is based on
  24044. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24045. *
  24046. * @static
  24047. * @memberOf _
  24048. * @since 4.0.0
  24049. * @category Array
  24050. * @param {Array} array The array to modify.
  24051. * @returns {Array} Returns `array`.
  24052. * @example
  24053. *
  24054. * var array = [1, 2, 3];
  24055. *
  24056. * _.reverse(array);
  24057. * // => [3, 2, 1]
  24058. *
  24059. * console.log(array);
  24060. * // => [3, 2, 1]
  24061. */
  24062. function reverse(array) {
  24063. return array == null ? array : nativeReverse.call(array);
  24064. }
  24065. /**
  24066. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24067. *
  24068. * **Note:** This method is used instead of
  24069. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  24070. * returned.
  24071. *
  24072. * @static
  24073. * @memberOf _
  24074. * @since 3.0.0
  24075. * @category Array
  24076. * @param {Array} array The array to slice.
  24077. * @param {number} [start=0] The start position.
  24078. * @param {number} [end=array.length] The end position.
  24079. * @returns {Array} Returns the slice of `array`.
  24080. */
  24081. function slice(array, start, end) {
  24082. var length = array == null ? 0 : array.length;
  24083. if (!length) {
  24084. return [];
  24085. }
  24086. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  24087. start = 0;
  24088. end = length;
  24089. }
  24090. else {
  24091. start = start == null ? 0 : toInteger(start);
  24092. end = end === undefined ? length : toInteger(end);
  24093. }
  24094. return baseSlice(array, start, end);
  24095. }
  24096. /**
  24097. * Uses a binary search to determine the lowest index at which `value`
  24098. * should be inserted into `array` in order to maintain its sort order.
  24099. *
  24100. * @static
  24101. * @memberOf _
  24102. * @since 0.1.0
  24103. * @category Array
  24104. * @param {Array} array The sorted array to inspect.
  24105. * @param {*} value The value to evaluate.
  24106. * @returns {number} Returns the index at which `value` should be inserted
  24107. * into `array`.
  24108. * @example
  24109. *
  24110. * _.sortedIndex([30, 50], 40);
  24111. * // => 1
  24112. */
  24113. function sortedIndex(array, value) {
  24114. return baseSortedIndex(array, value);
  24115. }
  24116. /**
  24117. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  24118. * which is invoked for `value` and each element of `array` to compute their
  24119. * sort ranking. The iteratee is invoked with one argument: (value).
  24120. *
  24121. * @static
  24122. * @memberOf _
  24123. * @since 4.0.0
  24124. * @category Array
  24125. * @param {Array} array The sorted array to inspect.
  24126. * @param {*} value The value to evaluate.
  24127. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24128. * @returns {number} Returns the index at which `value` should be inserted
  24129. * into `array`.
  24130. * @example
  24131. *
  24132. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24133. *
  24134. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24135. * // => 0
  24136. *
  24137. * // The `_.property` iteratee shorthand.
  24138. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  24139. * // => 0
  24140. */
  24141. function sortedIndexBy(array, value, iteratee) {
  24142. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  24143. }
  24144. /**
  24145. * This method is like `_.indexOf` except that it performs a binary
  24146. * search on a sorted `array`.
  24147. *
  24148. * @static
  24149. * @memberOf _
  24150. * @since 4.0.0
  24151. * @category Array
  24152. * @param {Array} array The array to inspect.
  24153. * @param {*} value The value to search for.
  24154. * @returns {number} Returns the index of the matched value, else `-1`.
  24155. * @example
  24156. *
  24157. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  24158. * // => 1
  24159. */
  24160. function sortedIndexOf(array, value) {
  24161. var length = array == null ? 0 : array.length;
  24162. if (length) {
  24163. var index = baseSortedIndex(array, value);
  24164. if (index < length && eq(array[index], value)) {
  24165. return index;
  24166. }
  24167. }
  24168. return -1;
  24169. }
  24170. /**
  24171. * This method is like `_.sortedIndex` except that it returns the highest
  24172. * index at which `value` should be inserted into `array` in order to
  24173. * maintain its sort order.
  24174. *
  24175. * @static
  24176. * @memberOf _
  24177. * @since 3.0.0
  24178. * @category Array
  24179. * @param {Array} array The sorted array to inspect.
  24180. * @param {*} value The value to evaluate.
  24181. * @returns {number} Returns the index at which `value` should be inserted
  24182. * into `array`.
  24183. * @example
  24184. *
  24185. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  24186. * // => 4
  24187. */
  24188. function sortedLastIndex(array, value) {
  24189. return baseSortedIndex(array, value, true);
  24190. }
  24191. /**
  24192. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  24193. * which is invoked for `value` and each element of `array` to compute their
  24194. * sort ranking. The iteratee is invoked with one argument: (value).
  24195. *
  24196. * @static
  24197. * @memberOf _
  24198. * @since 4.0.0
  24199. * @category Array
  24200. * @param {Array} array The sorted array to inspect.
  24201. * @param {*} value The value to evaluate.
  24202. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24203. * @returns {number} Returns the index at which `value` should be inserted
  24204. * into `array`.
  24205. * @example
  24206. *
  24207. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  24208. *
  24209. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  24210. * // => 1
  24211. *
  24212. * // The `_.property` iteratee shorthand.
  24213. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  24214. * // => 1
  24215. */
  24216. function sortedLastIndexBy(array, value, iteratee) {
  24217. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  24218. }
  24219. /**
  24220. * This method is like `_.lastIndexOf` except that it performs a binary
  24221. * search on a sorted `array`.
  24222. *
  24223. * @static
  24224. * @memberOf _
  24225. * @since 4.0.0
  24226. * @category Array
  24227. * @param {Array} array The array to inspect.
  24228. * @param {*} value The value to search for.
  24229. * @returns {number} Returns the index of the matched value, else `-1`.
  24230. * @example
  24231. *
  24232. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  24233. * // => 3
  24234. */
  24235. function sortedLastIndexOf(array, value) {
  24236. var length = array == null ? 0 : array.length;
  24237. if (length) {
  24238. var index = baseSortedIndex(array, value, true) - 1;
  24239. if (eq(array[index], value)) {
  24240. return index;
  24241. }
  24242. }
  24243. return -1;
  24244. }
  24245. /**
  24246. * This method is like `_.uniq` except that it's designed and optimized
  24247. * for sorted arrays.
  24248. *
  24249. * @static
  24250. * @memberOf _
  24251. * @since 4.0.0
  24252. * @category Array
  24253. * @param {Array} array The array to inspect.
  24254. * @returns {Array} Returns the new duplicate free array.
  24255. * @example
  24256. *
  24257. * _.sortedUniq([1, 1, 2]);
  24258. * // => [1, 2]
  24259. */
  24260. function sortedUniq(array) {
  24261. return (array && array.length)
  24262. ? baseSortedUniq(array)
  24263. : [];
  24264. }
  24265. /**
  24266. * This method is like `_.uniqBy` except that it's designed and optimized
  24267. * for sorted arrays.
  24268. *
  24269. * @static
  24270. * @memberOf _
  24271. * @since 4.0.0
  24272. * @category Array
  24273. * @param {Array} array The array to inspect.
  24274. * @param {Function} [iteratee] The iteratee invoked per element.
  24275. * @returns {Array} Returns the new duplicate free array.
  24276. * @example
  24277. *
  24278. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  24279. * // => [1.1, 2.3]
  24280. */
  24281. function sortedUniqBy(array, iteratee) {
  24282. return (array && array.length)
  24283. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  24284. : [];
  24285. }
  24286. /**
  24287. * Gets all but the first element of `array`.
  24288. *
  24289. * @static
  24290. * @memberOf _
  24291. * @since 4.0.0
  24292. * @category Array
  24293. * @param {Array} array The array to query.
  24294. * @returns {Array} Returns the slice of `array`.
  24295. * @example
  24296. *
  24297. * _.tail([1, 2, 3]);
  24298. * // => [2, 3]
  24299. */
  24300. function tail(array) {
  24301. var length = array == null ? 0 : array.length;
  24302. return length ? baseSlice(array, 1, length) : [];
  24303. }
  24304. /**
  24305. * Creates a slice of `array` with `n` elements taken from the beginning.
  24306. *
  24307. * @static
  24308. * @memberOf _
  24309. * @since 0.1.0
  24310. * @category Array
  24311. * @param {Array} array The array to query.
  24312. * @param {number} [n=1] The number of elements to take.
  24313. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24314. * @returns {Array} Returns the slice of `array`.
  24315. * @example
  24316. *
  24317. * _.take([1, 2, 3]);
  24318. * // => [1]
  24319. *
  24320. * _.take([1, 2, 3], 2);
  24321. * // => [1, 2]
  24322. *
  24323. * _.take([1, 2, 3], 5);
  24324. * // => [1, 2, 3]
  24325. *
  24326. * _.take([1, 2, 3], 0);
  24327. * // => []
  24328. */
  24329. function take(array, n, guard) {
  24330. if (!(array && array.length)) {
  24331. return [];
  24332. }
  24333. n = (guard || n === undefined) ? 1 : toInteger(n);
  24334. return baseSlice(array, 0, n < 0 ? 0 : n);
  24335. }
  24336. /**
  24337. * Creates a slice of `array` with `n` elements taken from the end.
  24338. *
  24339. * @static
  24340. * @memberOf _
  24341. * @since 3.0.0
  24342. * @category Array
  24343. * @param {Array} array The array to query.
  24344. * @param {number} [n=1] The number of elements to take.
  24345. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24346. * @returns {Array} Returns the slice of `array`.
  24347. * @example
  24348. *
  24349. * _.takeRight([1, 2, 3]);
  24350. * // => [3]
  24351. *
  24352. * _.takeRight([1, 2, 3], 2);
  24353. * // => [2, 3]
  24354. *
  24355. * _.takeRight([1, 2, 3], 5);
  24356. * // => [1, 2, 3]
  24357. *
  24358. * _.takeRight([1, 2, 3], 0);
  24359. * // => []
  24360. */
  24361. function takeRight(array, n, guard) {
  24362. var length = array == null ? 0 : array.length;
  24363. if (!length) {
  24364. return [];
  24365. }
  24366. n = (guard || n === undefined) ? 1 : toInteger(n);
  24367. n = length - n;
  24368. return baseSlice(array, n < 0 ? 0 : n, length);
  24369. }
  24370. /**
  24371. * Creates a slice of `array` with elements taken from the end. Elements are
  24372. * taken until `predicate` returns falsey. The predicate is invoked with
  24373. * three arguments: (value, index, array).
  24374. *
  24375. * @static
  24376. * @memberOf _
  24377. * @since 3.0.0
  24378. * @category Array
  24379. * @param {Array} array The array to query.
  24380. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24381. * @returns {Array} Returns the slice of `array`.
  24382. * @example
  24383. *
  24384. * var users = [
  24385. * { 'user': 'barney', 'active': true },
  24386. * { 'user': 'fred', 'active': false },
  24387. * { 'user': 'pebbles', 'active': false }
  24388. * ];
  24389. *
  24390. * _.takeRightWhile(users, function(o) { return !o.active; });
  24391. * // => objects for ['fred', 'pebbles']
  24392. *
  24393. * // The `_.matches` iteratee shorthand.
  24394. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  24395. * // => objects for ['pebbles']
  24396. *
  24397. * // The `_.matchesProperty` iteratee shorthand.
  24398. * _.takeRightWhile(users, ['active', false]);
  24399. * // => objects for ['fred', 'pebbles']
  24400. *
  24401. * // The `_.property` iteratee shorthand.
  24402. * _.takeRightWhile(users, 'active');
  24403. * // => []
  24404. */
  24405. function takeRightWhile(array, predicate) {
  24406. return (array && array.length)
  24407. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  24408. : [];
  24409. }
  24410. /**
  24411. * Creates a slice of `array` with elements taken from the beginning. Elements
  24412. * are taken until `predicate` returns falsey. The predicate is invoked with
  24413. * three arguments: (value, index, array).
  24414. *
  24415. * @static
  24416. * @memberOf _
  24417. * @since 3.0.0
  24418. * @category Array
  24419. * @param {Array} array The array to query.
  24420. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24421. * @returns {Array} Returns the slice of `array`.
  24422. * @example
  24423. *
  24424. * var users = [
  24425. * { 'user': 'barney', 'active': false },
  24426. * { 'user': 'fred', 'active': false },
  24427. * { 'user': 'pebbles', 'active': true }
  24428. * ];
  24429. *
  24430. * _.takeWhile(users, function(o) { return !o.active; });
  24431. * // => objects for ['barney', 'fred']
  24432. *
  24433. * // The `_.matches` iteratee shorthand.
  24434. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  24435. * // => objects for ['barney']
  24436. *
  24437. * // The `_.matchesProperty` iteratee shorthand.
  24438. * _.takeWhile(users, ['active', false]);
  24439. * // => objects for ['barney', 'fred']
  24440. *
  24441. * // The `_.property` iteratee shorthand.
  24442. * _.takeWhile(users, 'active');
  24443. * // => []
  24444. */
  24445. function takeWhile(array, predicate) {
  24446. return (array && array.length)
  24447. ? baseWhile(array, getIteratee(predicate, 3))
  24448. : [];
  24449. }
  24450. /**
  24451. * Creates an array of unique values, in order, from all given arrays using
  24452. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24453. * for equality comparisons.
  24454. *
  24455. * @static
  24456. * @memberOf _
  24457. * @since 0.1.0
  24458. * @category Array
  24459. * @param {...Array} [arrays] The arrays to inspect.
  24460. * @returns {Array} Returns the new array of combined values.
  24461. * @example
  24462. *
  24463. * _.union([2], [1, 2]);
  24464. * // => [2, 1]
  24465. */
  24466. var union = baseRest(function(arrays) {
  24467. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  24468. });
  24469. /**
  24470. * This method is like `_.union` except that it accepts `iteratee` which is
  24471. * invoked for each element of each `arrays` to generate the criterion by
  24472. * which uniqueness is computed. Result values are chosen from the first
  24473. * array in which the value occurs. The iteratee is invoked with one argument:
  24474. * (value).
  24475. *
  24476. * @static
  24477. * @memberOf _
  24478. * @since 4.0.0
  24479. * @category Array
  24480. * @param {...Array} [arrays] The arrays to inspect.
  24481. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24482. * @returns {Array} Returns the new array of combined values.
  24483. * @example
  24484. *
  24485. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  24486. * // => [2.1, 1.2]
  24487. *
  24488. * // The `_.property` iteratee shorthand.
  24489. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24490. * // => [{ 'x': 1 }, { 'x': 2 }]
  24491. */
  24492. var unionBy = baseRest(function(arrays) {
  24493. var iteratee = last(arrays);
  24494. if (isArrayLikeObject(iteratee)) {
  24495. iteratee = undefined;
  24496. }
  24497. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  24498. });
  24499. /**
  24500. * This method is like `_.union` except that it accepts `comparator` which
  24501. * is invoked to compare elements of `arrays`. Result values are chosen from
  24502. * the first array in which the value occurs. The comparator is invoked
  24503. * with two arguments: (arrVal, othVal).
  24504. *
  24505. * @static
  24506. * @memberOf _
  24507. * @since 4.0.0
  24508. * @category Array
  24509. * @param {...Array} [arrays] The arrays to inspect.
  24510. * @param {Function} [comparator] The comparator invoked per element.
  24511. * @returns {Array} Returns the new array of combined values.
  24512. * @example
  24513. *
  24514. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24515. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24516. *
  24517. * _.unionWith(objects, others, _.isEqual);
  24518. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24519. */
  24520. var unionWith = baseRest(function(arrays) {
  24521. var comparator = last(arrays);
  24522. comparator = typeof comparator == 'function' ? comparator : undefined;
  24523. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  24524. });
  24525. /**
  24526. * Creates a duplicate-free version of an array, using
  24527. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24528. * for equality comparisons, in which only the first occurrence of each element
  24529. * is kept. The order of result values is determined by the order they occur
  24530. * in the array.
  24531. *
  24532. * @static
  24533. * @memberOf _
  24534. * @since 0.1.0
  24535. * @category Array
  24536. * @param {Array} array The array to inspect.
  24537. * @returns {Array} Returns the new duplicate free array.
  24538. * @example
  24539. *
  24540. * _.uniq([2, 1, 2]);
  24541. * // => [2, 1]
  24542. */
  24543. function uniq(array) {
  24544. return (array && array.length) ? baseUniq(array) : [];
  24545. }
  24546. /**
  24547. * This method is like `_.uniq` except that it accepts `iteratee` which is
  24548. * invoked for each element in `array` to generate the criterion by which
  24549. * uniqueness is computed. The order of result values is determined by the
  24550. * order they occur in the array. The iteratee is invoked with one argument:
  24551. * (value).
  24552. *
  24553. * @static
  24554. * @memberOf _
  24555. * @since 4.0.0
  24556. * @category Array
  24557. * @param {Array} array The array to inspect.
  24558. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24559. * @returns {Array} Returns the new duplicate free array.
  24560. * @example
  24561. *
  24562. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  24563. * // => [2.1, 1.2]
  24564. *
  24565. * // The `_.property` iteratee shorthand.
  24566. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  24567. * // => [{ 'x': 1 }, { 'x': 2 }]
  24568. */
  24569. function uniqBy(array, iteratee) {
  24570. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  24571. }
  24572. /**
  24573. * This method is like `_.uniq` except that it accepts `comparator` which
  24574. * is invoked to compare elements of `array`. The order of result values is
  24575. * determined by the order they occur in the array.The comparator is invoked
  24576. * with two arguments: (arrVal, othVal).
  24577. *
  24578. * @static
  24579. * @memberOf _
  24580. * @since 4.0.0
  24581. * @category Array
  24582. * @param {Array} array The array to inspect.
  24583. * @param {Function} [comparator] The comparator invoked per element.
  24584. * @returns {Array} Returns the new duplicate free array.
  24585. * @example
  24586. *
  24587. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24588. *
  24589. * _.uniqWith(objects, _.isEqual);
  24590. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  24591. */
  24592. function uniqWith(array, comparator) {
  24593. comparator = typeof comparator == 'function' ? comparator : undefined;
  24594. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  24595. }
  24596. /**
  24597. * This method is like `_.zip` except that it accepts an array of grouped
  24598. * elements and creates an array regrouping the elements to their pre-zip
  24599. * configuration.
  24600. *
  24601. * @static
  24602. * @memberOf _
  24603. * @since 1.2.0
  24604. * @category Array
  24605. * @param {Array} array The array of grouped elements to process.
  24606. * @returns {Array} Returns the new array of regrouped elements.
  24607. * @example
  24608. *
  24609. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  24610. * // => [['a', 1, true], ['b', 2, false]]
  24611. *
  24612. * _.unzip(zipped);
  24613. * // => [['a', 'b'], [1, 2], [true, false]]
  24614. */
  24615. function unzip(array) {
  24616. if (!(array && array.length)) {
  24617. return [];
  24618. }
  24619. var length = 0;
  24620. array = arrayFilter(array, function(group) {
  24621. if (isArrayLikeObject(group)) {
  24622. length = nativeMax(group.length, length);
  24623. return true;
  24624. }
  24625. });
  24626. return baseTimes(length, function(index) {
  24627. return arrayMap(array, baseProperty(index));
  24628. });
  24629. }
  24630. /**
  24631. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  24632. * how regrouped values should be combined. The iteratee is invoked with the
  24633. * elements of each group: (...group).
  24634. *
  24635. * @static
  24636. * @memberOf _
  24637. * @since 3.8.0
  24638. * @category Array
  24639. * @param {Array} array The array of grouped elements to process.
  24640. * @param {Function} [iteratee=_.identity] The function to combine
  24641. * regrouped values.
  24642. * @returns {Array} Returns the new array of regrouped elements.
  24643. * @example
  24644. *
  24645. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  24646. * // => [[1, 10, 100], [2, 20, 200]]
  24647. *
  24648. * _.unzipWith(zipped, _.add);
  24649. * // => [3, 30, 300]
  24650. */
  24651. function unzipWith(array, iteratee) {
  24652. if (!(array && array.length)) {
  24653. return [];
  24654. }
  24655. var result = unzip(array);
  24656. if (iteratee == null) {
  24657. return result;
  24658. }
  24659. return arrayMap(result, function(group) {
  24660. return apply(iteratee, undefined, group);
  24661. });
  24662. }
  24663. /**
  24664. * Creates an array excluding all given values using
  24665. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24666. * for equality comparisons.
  24667. *
  24668. * **Note:** Unlike `_.pull`, this method returns a new array.
  24669. *
  24670. * @static
  24671. * @memberOf _
  24672. * @since 0.1.0
  24673. * @category Array
  24674. * @param {Array} array The array to inspect.
  24675. * @param {...*} [values] The values to exclude.
  24676. * @returns {Array} Returns the new array of filtered values.
  24677. * @see _.difference, _.xor
  24678. * @example
  24679. *
  24680. * _.without([2, 1, 2, 3], 1, 2);
  24681. * // => [3]
  24682. */
  24683. var without = baseRest(function(array, values) {
  24684. return isArrayLikeObject(array)
  24685. ? baseDifference(array, values)
  24686. : [];
  24687. });
  24688. /**
  24689. * Creates an array of unique values that is the
  24690. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  24691. * of the given arrays. The order of result values is determined by the order
  24692. * they occur in the arrays.
  24693. *
  24694. * @static
  24695. * @memberOf _
  24696. * @since 2.4.0
  24697. * @category Array
  24698. * @param {...Array} [arrays] The arrays to inspect.
  24699. * @returns {Array} Returns the new array of filtered values.
  24700. * @see _.difference, _.without
  24701. * @example
  24702. *
  24703. * _.xor([2, 1], [2, 3]);
  24704. * // => [1, 3]
  24705. */
  24706. var xor = baseRest(function(arrays) {
  24707. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  24708. });
  24709. /**
  24710. * This method is like `_.xor` except that it accepts `iteratee` which is
  24711. * invoked for each element of each `arrays` to generate the criterion by
  24712. * which by which they're compared. The order of result values is determined
  24713. * by the order they occur in the arrays. The iteratee is invoked with one
  24714. * argument: (value).
  24715. *
  24716. * @static
  24717. * @memberOf _
  24718. * @since 4.0.0
  24719. * @category Array
  24720. * @param {...Array} [arrays] The arrays to inspect.
  24721. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24722. * @returns {Array} Returns the new array of filtered values.
  24723. * @example
  24724. *
  24725. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24726. * // => [1.2, 3.4]
  24727. *
  24728. * // The `_.property` iteratee shorthand.
  24729. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24730. * // => [{ 'x': 2 }]
  24731. */
  24732. var xorBy = baseRest(function(arrays) {
  24733. var iteratee = last(arrays);
  24734. if (isArrayLikeObject(iteratee)) {
  24735. iteratee = undefined;
  24736. }
  24737. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  24738. });
  24739. /**
  24740. * This method is like `_.xor` except that it accepts `comparator` which is
  24741. * invoked to compare elements of `arrays`. The order of result values is
  24742. * determined by the order they occur in the arrays. The comparator is invoked
  24743. * with two arguments: (arrVal, othVal).
  24744. *
  24745. * @static
  24746. * @memberOf _
  24747. * @since 4.0.0
  24748. * @category Array
  24749. * @param {...Array} [arrays] The arrays to inspect.
  24750. * @param {Function} [comparator] The comparator invoked per element.
  24751. * @returns {Array} Returns the new array of filtered values.
  24752. * @example
  24753. *
  24754. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24755. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24756. *
  24757. * _.xorWith(objects, others, _.isEqual);
  24758. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  24759. */
  24760. var xorWith = baseRest(function(arrays) {
  24761. var comparator = last(arrays);
  24762. comparator = typeof comparator == 'function' ? comparator : undefined;
  24763. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  24764. });
  24765. /**
  24766. * Creates an array of grouped elements, the first of which contains the
  24767. * first elements of the given arrays, the second of which contains the
  24768. * second elements of the given arrays, and so on.
  24769. *
  24770. * @static
  24771. * @memberOf _
  24772. * @since 0.1.0
  24773. * @category Array
  24774. * @param {...Array} [arrays] The arrays to process.
  24775. * @returns {Array} Returns the new array of grouped elements.
  24776. * @example
  24777. *
  24778. * _.zip(['a', 'b'], [1, 2], [true, false]);
  24779. * // => [['a', 1, true], ['b', 2, false]]
  24780. */
  24781. var zip = baseRest(unzip);
  24782. /**
  24783. * This method is like `_.fromPairs` except that it accepts two arrays,
  24784. * one of property identifiers and one of corresponding values.
  24785. *
  24786. * @static
  24787. * @memberOf _
  24788. * @since 0.4.0
  24789. * @category Array
  24790. * @param {Array} [props=[]] The property identifiers.
  24791. * @param {Array} [values=[]] The property values.
  24792. * @returns {Object} Returns the new object.
  24793. * @example
  24794. *
  24795. * _.zipObject(['a', 'b'], [1, 2]);
  24796. * // => { 'a': 1, 'b': 2 }
  24797. */
  24798. function zipObject(props, values) {
  24799. return baseZipObject(props || [], values || [], assignValue);
  24800. }
  24801. /**
  24802. * This method is like `_.zipObject` except that it supports property paths.
  24803. *
  24804. * @static
  24805. * @memberOf _
  24806. * @since 4.1.0
  24807. * @category Array
  24808. * @param {Array} [props=[]] The property identifiers.
  24809. * @param {Array} [values=[]] The property values.
  24810. * @returns {Object} Returns the new object.
  24811. * @example
  24812. *
  24813. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  24814. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  24815. */
  24816. function zipObjectDeep(props, values) {
  24817. return baseZipObject(props || [], values || [], baseSet);
  24818. }
  24819. /**
  24820. * This method is like `_.zip` except that it accepts `iteratee` to specify
  24821. * how grouped values should be combined. The iteratee is invoked with the
  24822. * elements of each group: (...group).
  24823. *
  24824. * @static
  24825. * @memberOf _
  24826. * @since 3.8.0
  24827. * @category Array
  24828. * @param {...Array} [arrays] The arrays to process.
  24829. * @param {Function} [iteratee=_.identity] The function to combine
  24830. * grouped values.
  24831. * @returns {Array} Returns the new array of grouped elements.
  24832. * @example
  24833. *
  24834. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  24835. * return a + b + c;
  24836. * });
  24837. * // => [111, 222]
  24838. */
  24839. var zipWith = baseRest(function(arrays) {
  24840. var length = arrays.length,
  24841. iteratee = length > 1 ? arrays[length - 1] : undefined;
  24842. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  24843. return unzipWith(arrays, iteratee);
  24844. });
  24845. /*------------------------------------------------------------------------*/
  24846. /**
  24847. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  24848. * chain sequences enabled. The result of such sequences must be unwrapped
  24849. * with `_#value`.
  24850. *
  24851. * @static
  24852. * @memberOf _
  24853. * @since 1.3.0
  24854. * @category Seq
  24855. * @param {*} value The value to wrap.
  24856. * @returns {Object} Returns the new `lodash` wrapper instance.
  24857. * @example
  24858. *
  24859. * var users = [
  24860. * { 'user': 'barney', 'age': 36 },
  24861. * { 'user': 'fred', 'age': 40 },
  24862. * { 'user': 'pebbles', 'age': 1 }
  24863. * ];
  24864. *
  24865. * var youngest = _
  24866. * .chain(users)
  24867. * .sortBy('age')
  24868. * .map(function(o) {
  24869. * return o.user + ' is ' + o.age;
  24870. * })
  24871. * .head()
  24872. * .value();
  24873. * // => 'pebbles is 1'
  24874. */
  24875. function chain(value) {
  24876. var result = lodash(value);
  24877. result.__chain__ = true;
  24878. return result;
  24879. }
  24880. /**
  24881. * This method invokes `interceptor` and returns `value`. The interceptor
  24882. * is invoked with one argument; (value). The purpose of this method is to
  24883. * "tap into" a method chain sequence in order to modify intermediate results.
  24884. *
  24885. * @static
  24886. * @memberOf _
  24887. * @since 0.1.0
  24888. * @category Seq
  24889. * @param {*} value The value to provide to `interceptor`.
  24890. * @param {Function} interceptor The function to invoke.
  24891. * @returns {*} Returns `value`.
  24892. * @example
  24893. *
  24894. * _([1, 2, 3])
  24895. * .tap(function(array) {
  24896. * // Mutate input array.
  24897. * array.pop();
  24898. * })
  24899. * .reverse()
  24900. * .value();
  24901. * // => [2, 1]
  24902. */
  24903. function tap(value, interceptor) {
  24904. interceptor(value);
  24905. return value;
  24906. }
  24907. /**
  24908. * This method is like `_.tap` except that it returns the result of `interceptor`.
  24909. * The purpose of this method is to "pass thru" values replacing intermediate
  24910. * results in a method chain sequence.
  24911. *
  24912. * @static
  24913. * @memberOf _
  24914. * @since 3.0.0
  24915. * @category Seq
  24916. * @param {*} value The value to provide to `interceptor`.
  24917. * @param {Function} interceptor The function to invoke.
  24918. * @returns {*} Returns the result of `interceptor`.
  24919. * @example
  24920. *
  24921. * _(' abc ')
  24922. * .chain()
  24923. * .trim()
  24924. * .thru(function(value) {
  24925. * return [value];
  24926. * })
  24927. * .value();
  24928. * // => ['abc']
  24929. */
  24930. function thru(value, interceptor) {
  24931. return interceptor(value);
  24932. }
  24933. /**
  24934. * This method is the wrapper version of `_.at`.
  24935. *
  24936. * @name at
  24937. * @memberOf _
  24938. * @since 1.0.0
  24939. * @category Seq
  24940. * @param {...(string|string[])} [paths] The property paths to pick.
  24941. * @returns {Object} Returns the new `lodash` wrapper instance.
  24942. * @example
  24943. *
  24944. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  24945. *
  24946. * _(object).at(['a[0].b.c', 'a[1]']).value();
  24947. * // => [3, 4]
  24948. */
  24949. var wrapperAt = flatRest(function(paths) {
  24950. var length = paths.length,
  24951. start = length ? paths[0] : 0,
  24952. value = this.__wrapped__,
  24953. interceptor = function(object) { return baseAt(object, paths); };
  24954. if (length > 1 || this.__actions__.length ||
  24955. !(value instanceof LazyWrapper) || !isIndex(start)) {
  24956. return this.thru(interceptor);
  24957. }
  24958. value = value.slice(start, +start + (length ? 1 : 0));
  24959. value.__actions__.push({
  24960. 'func': thru,
  24961. 'args': [interceptor],
  24962. 'thisArg': undefined
  24963. });
  24964. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  24965. if (length && !array.length) {
  24966. array.push(undefined);
  24967. }
  24968. return array;
  24969. });
  24970. });
  24971. /**
  24972. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  24973. *
  24974. * @name chain
  24975. * @memberOf _
  24976. * @since 0.1.0
  24977. * @category Seq
  24978. * @returns {Object} Returns the new `lodash` wrapper instance.
  24979. * @example
  24980. *
  24981. * var users = [
  24982. * { 'user': 'barney', 'age': 36 },
  24983. * { 'user': 'fred', 'age': 40 }
  24984. * ];
  24985. *
  24986. * // A sequence without explicit chaining.
  24987. * _(users).head();
  24988. * // => { 'user': 'barney', 'age': 36 }
  24989. *
  24990. * // A sequence with explicit chaining.
  24991. * _(users)
  24992. * .chain()
  24993. * .head()
  24994. * .pick('user')
  24995. * .value();
  24996. * // => { 'user': 'barney' }
  24997. */
  24998. function wrapperChain() {
  24999. return chain(this);
  25000. }
  25001. /**
  25002. * Executes the chain sequence and returns the wrapped result.
  25003. *
  25004. * @name commit
  25005. * @memberOf _
  25006. * @since 3.2.0
  25007. * @category Seq
  25008. * @returns {Object} Returns the new `lodash` wrapper instance.
  25009. * @example
  25010. *
  25011. * var array = [1, 2];
  25012. * var wrapped = _(array).push(3);
  25013. *
  25014. * console.log(array);
  25015. * // => [1, 2]
  25016. *
  25017. * wrapped = wrapped.commit();
  25018. * console.log(array);
  25019. * // => [1, 2, 3]
  25020. *
  25021. * wrapped.last();
  25022. * // => 3
  25023. *
  25024. * console.log(array);
  25025. * // => [1, 2, 3]
  25026. */
  25027. function wrapperCommit() {
  25028. return new LodashWrapper(this.value(), this.__chain__);
  25029. }
  25030. /**
  25031. * Gets the next value on a wrapped object following the
  25032. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25033. *
  25034. * @name next
  25035. * @memberOf _
  25036. * @since 4.0.0
  25037. * @category Seq
  25038. * @returns {Object} Returns the next iterator value.
  25039. * @example
  25040. *
  25041. * var wrapped = _([1, 2]);
  25042. *
  25043. * wrapped.next();
  25044. * // => { 'done': false, 'value': 1 }
  25045. *
  25046. * wrapped.next();
  25047. * // => { 'done': false, 'value': 2 }
  25048. *
  25049. * wrapped.next();
  25050. * // => { 'done': true, 'value': undefined }
  25051. */
  25052. function wrapperNext() {
  25053. if (this.__values__ === undefined) {
  25054. this.__values__ = toArray(this.value());
  25055. }
  25056. var done = this.__index__ >= this.__values__.length,
  25057. value = done ? undefined : this.__values__[this.__index__++];
  25058. return { 'done': done, 'value': value };
  25059. }
  25060. /**
  25061. * Enables the wrapper to be iterable.
  25062. *
  25063. * @name Symbol.iterator
  25064. * @memberOf _
  25065. * @since 4.0.0
  25066. * @category Seq
  25067. * @returns {Object} Returns the wrapper object.
  25068. * @example
  25069. *
  25070. * var wrapped = _([1, 2]);
  25071. *
  25072. * wrapped[Symbol.iterator]() === wrapped;
  25073. * // => true
  25074. *
  25075. * Array.from(wrapped);
  25076. * // => [1, 2]
  25077. */
  25078. function wrapperToIterator() {
  25079. return this;
  25080. }
  25081. /**
  25082. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  25083. *
  25084. * @name plant
  25085. * @memberOf _
  25086. * @since 3.2.0
  25087. * @category Seq
  25088. * @param {*} value The value to plant.
  25089. * @returns {Object} Returns the new `lodash` wrapper instance.
  25090. * @example
  25091. *
  25092. * function square(n) {
  25093. * return n * n;
  25094. * }
  25095. *
  25096. * var wrapped = _([1, 2]).map(square);
  25097. * var other = wrapped.plant([3, 4]);
  25098. *
  25099. * other.value();
  25100. * // => [9, 16]
  25101. *
  25102. * wrapped.value();
  25103. * // => [1, 4]
  25104. */
  25105. function wrapperPlant(value) {
  25106. var result,
  25107. parent = this;
  25108. while (parent instanceof baseLodash) {
  25109. var clone = wrapperClone(parent);
  25110. clone.__index__ = 0;
  25111. clone.__values__ = undefined;
  25112. if (result) {
  25113. previous.__wrapped__ = clone;
  25114. } else {
  25115. result = clone;
  25116. }
  25117. var previous = clone;
  25118. parent = parent.__wrapped__;
  25119. }
  25120. previous.__wrapped__ = value;
  25121. return result;
  25122. }
  25123. /**
  25124. * This method is the wrapper version of `_.reverse`.
  25125. *
  25126. * **Note:** This method mutates the wrapped array.
  25127. *
  25128. * @name reverse
  25129. * @memberOf _
  25130. * @since 0.1.0
  25131. * @category Seq
  25132. * @returns {Object} Returns the new `lodash` wrapper instance.
  25133. * @example
  25134. *
  25135. * var array = [1, 2, 3];
  25136. *
  25137. * _(array).reverse().value()
  25138. * // => [3, 2, 1]
  25139. *
  25140. * console.log(array);
  25141. * // => [3, 2, 1]
  25142. */
  25143. function wrapperReverse() {
  25144. var value = this.__wrapped__;
  25145. if (value instanceof LazyWrapper) {
  25146. var wrapped = value;
  25147. if (this.__actions__.length) {
  25148. wrapped = new LazyWrapper(this);
  25149. }
  25150. wrapped = wrapped.reverse();
  25151. wrapped.__actions__.push({
  25152. 'func': thru,
  25153. 'args': [reverse],
  25154. 'thisArg': undefined
  25155. });
  25156. return new LodashWrapper(wrapped, this.__chain__);
  25157. }
  25158. return this.thru(reverse);
  25159. }
  25160. /**
  25161. * Executes the chain sequence to resolve the unwrapped value.
  25162. *
  25163. * @name value
  25164. * @memberOf _
  25165. * @since 0.1.0
  25166. * @alias toJSON, valueOf
  25167. * @category Seq
  25168. * @returns {*} Returns the resolved unwrapped value.
  25169. * @example
  25170. *
  25171. * _([1, 2, 3]).value();
  25172. * // => [1, 2, 3]
  25173. */
  25174. function wrapperValue() {
  25175. return baseWrapperValue(this.__wrapped__, this.__actions__);
  25176. }
  25177. /*------------------------------------------------------------------------*/
  25178. /**
  25179. * Creates an object composed of keys generated from the results of running
  25180. * each element of `collection` thru `iteratee`. The corresponding value of
  25181. * each key is the number of times the key was returned by `iteratee`. The
  25182. * iteratee is invoked with one argument: (value).
  25183. *
  25184. * @static
  25185. * @memberOf _
  25186. * @since 0.5.0
  25187. * @category Collection
  25188. * @param {Array|Object} collection The collection to iterate over.
  25189. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25190. * @returns {Object} Returns the composed aggregate object.
  25191. * @example
  25192. *
  25193. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  25194. * // => { '4': 1, '6': 2 }
  25195. *
  25196. * // The `_.property` iteratee shorthand.
  25197. * _.countBy(['one', 'two', 'three'], 'length');
  25198. * // => { '3': 2, '5': 1 }
  25199. */
  25200. var countBy = createAggregator(function(result, value, key) {
  25201. if (hasOwnProperty.call(result, key)) {
  25202. ++result[key];
  25203. } else {
  25204. baseAssignValue(result, key, 1);
  25205. }
  25206. });
  25207. /**
  25208. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  25209. * Iteration is stopped once `predicate` returns falsey. The predicate is
  25210. * invoked with three arguments: (value, index|key, collection).
  25211. *
  25212. * **Note:** This method returns `true` for
  25213. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  25214. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  25215. * elements of empty collections.
  25216. *
  25217. * @static
  25218. * @memberOf _
  25219. * @since 0.1.0
  25220. * @category Collection
  25221. * @param {Array|Object} collection The collection to iterate over.
  25222. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25223. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25224. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  25225. * else `false`.
  25226. * @example
  25227. *
  25228. * _.every([true, 1, null, 'yes'], Boolean);
  25229. * // => false
  25230. *
  25231. * var users = [
  25232. * { 'user': 'barney', 'age': 36, 'active': false },
  25233. * { 'user': 'fred', 'age': 40, 'active': false }
  25234. * ];
  25235. *
  25236. * // The `_.matches` iteratee shorthand.
  25237. * _.every(users, { 'user': 'barney', 'active': false });
  25238. * // => false
  25239. *
  25240. * // The `_.matchesProperty` iteratee shorthand.
  25241. * _.every(users, ['active', false]);
  25242. * // => true
  25243. *
  25244. * // The `_.property` iteratee shorthand.
  25245. * _.every(users, 'active');
  25246. * // => false
  25247. */
  25248. function every(collection, predicate, guard) {
  25249. var func = isArray(collection) ? arrayEvery : baseEvery;
  25250. if (guard && isIterateeCall(collection, predicate, guard)) {
  25251. predicate = undefined;
  25252. }
  25253. return func(collection, getIteratee(predicate, 3));
  25254. }
  25255. /**
  25256. * Iterates over elements of `collection`, returning an array of all elements
  25257. * `predicate` returns truthy for. The predicate is invoked with three
  25258. * arguments: (value, index|key, collection).
  25259. *
  25260. * **Note:** Unlike `_.remove`, this method returns a new array.
  25261. *
  25262. * @static
  25263. * @memberOf _
  25264. * @since 0.1.0
  25265. * @category Collection
  25266. * @param {Array|Object} collection The collection to iterate over.
  25267. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25268. * @returns {Array} Returns the new filtered array.
  25269. * @see _.reject
  25270. * @example
  25271. *
  25272. * var users = [
  25273. * { 'user': 'barney', 'age': 36, 'active': true },
  25274. * { 'user': 'fred', 'age': 40, 'active': false }
  25275. * ];
  25276. *
  25277. * _.filter(users, function(o) { return !o.active; });
  25278. * // => objects for ['fred']
  25279. *
  25280. * // The `_.matches` iteratee shorthand.
  25281. * _.filter(users, { 'age': 36, 'active': true });
  25282. * // => objects for ['barney']
  25283. *
  25284. * // The `_.matchesProperty` iteratee shorthand.
  25285. * _.filter(users, ['active', false]);
  25286. * // => objects for ['fred']
  25287. *
  25288. * // The `_.property` iteratee shorthand.
  25289. * _.filter(users, 'active');
  25290. * // => objects for ['barney']
  25291. */
  25292. function filter(collection, predicate) {
  25293. var func = isArray(collection) ? arrayFilter : baseFilter;
  25294. return func(collection, getIteratee(predicate, 3));
  25295. }
  25296. /**
  25297. * Iterates over elements of `collection`, returning the first element
  25298. * `predicate` returns truthy for. The predicate is invoked with three
  25299. * arguments: (value, index|key, collection).
  25300. *
  25301. * @static
  25302. * @memberOf _
  25303. * @since 0.1.0
  25304. * @category Collection
  25305. * @param {Array|Object} collection The collection to inspect.
  25306. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25307. * @param {number} [fromIndex=0] The index to search from.
  25308. * @returns {*} Returns the matched element, else `undefined`.
  25309. * @example
  25310. *
  25311. * var users = [
  25312. * { 'user': 'barney', 'age': 36, 'active': true },
  25313. * { 'user': 'fred', 'age': 40, 'active': false },
  25314. * { 'user': 'pebbles', 'age': 1, 'active': true }
  25315. * ];
  25316. *
  25317. * _.find(users, function(o) { return o.age < 40; });
  25318. * // => object for 'barney'
  25319. *
  25320. * // The `_.matches` iteratee shorthand.
  25321. * _.find(users, { 'age': 1, 'active': true });
  25322. * // => object for 'pebbles'
  25323. *
  25324. * // The `_.matchesProperty` iteratee shorthand.
  25325. * _.find(users, ['active', false]);
  25326. * // => object for 'fred'
  25327. *
  25328. * // The `_.property` iteratee shorthand.
  25329. * _.find(users, 'active');
  25330. * // => object for 'barney'
  25331. */
  25332. var find = createFind(findIndex);
  25333. /**
  25334. * This method is like `_.find` except that it iterates over elements of
  25335. * `collection` from right to left.
  25336. *
  25337. * @static
  25338. * @memberOf _
  25339. * @since 2.0.0
  25340. * @category Collection
  25341. * @param {Array|Object} collection The collection to inspect.
  25342. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25343. * @param {number} [fromIndex=collection.length-1] The index to search from.
  25344. * @returns {*} Returns the matched element, else `undefined`.
  25345. * @example
  25346. *
  25347. * _.findLast([1, 2, 3, 4], function(n) {
  25348. * return n % 2 == 1;
  25349. * });
  25350. * // => 3
  25351. */
  25352. var findLast = createFind(findLastIndex);
  25353. /**
  25354. * Creates a flattened array of values by running each element in `collection`
  25355. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  25356. * with three arguments: (value, index|key, collection).
  25357. *
  25358. * @static
  25359. * @memberOf _
  25360. * @since 4.0.0
  25361. * @category Collection
  25362. * @param {Array|Object} collection The collection to iterate over.
  25363. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25364. * @returns {Array} Returns the new flattened array.
  25365. * @example
  25366. *
  25367. * function duplicate(n) {
  25368. * return [n, n];
  25369. * }
  25370. *
  25371. * _.flatMap([1, 2], duplicate);
  25372. * // => [1, 1, 2, 2]
  25373. */
  25374. function flatMap(collection, iteratee) {
  25375. return baseFlatten(map(collection, iteratee), 1);
  25376. }
  25377. /**
  25378. * This method is like `_.flatMap` except that it recursively flattens the
  25379. * mapped results.
  25380. *
  25381. * @static
  25382. * @memberOf _
  25383. * @since 4.7.0
  25384. * @category Collection
  25385. * @param {Array|Object} collection The collection to iterate over.
  25386. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25387. * @returns {Array} Returns the new flattened array.
  25388. * @example
  25389. *
  25390. * function duplicate(n) {
  25391. * return [[[n, n]]];
  25392. * }
  25393. *
  25394. * _.flatMapDeep([1, 2], duplicate);
  25395. * // => [1, 1, 2, 2]
  25396. */
  25397. function flatMapDeep(collection, iteratee) {
  25398. return baseFlatten(map(collection, iteratee), INFINITY);
  25399. }
  25400. /**
  25401. * This method is like `_.flatMap` except that it recursively flattens the
  25402. * mapped results up to `depth` times.
  25403. *
  25404. * @static
  25405. * @memberOf _
  25406. * @since 4.7.0
  25407. * @category Collection
  25408. * @param {Array|Object} collection The collection to iterate over.
  25409. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25410. * @param {number} [depth=1] The maximum recursion depth.
  25411. * @returns {Array} Returns the new flattened array.
  25412. * @example
  25413. *
  25414. * function duplicate(n) {
  25415. * return [[[n, n]]];
  25416. * }
  25417. *
  25418. * _.flatMapDepth([1, 2], duplicate, 2);
  25419. * // => [[1, 1], [2, 2]]
  25420. */
  25421. function flatMapDepth(collection, iteratee, depth) {
  25422. depth = depth === undefined ? 1 : toInteger(depth);
  25423. return baseFlatten(map(collection, iteratee), depth);
  25424. }
  25425. /**
  25426. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  25427. * The iteratee is invoked with three arguments: (value, index|key, collection).
  25428. * Iteratee functions may exit iteration early by explicitly returning `false`.
  25429. *
  25430. * **Note:** As with other "Collections" methods, objects with a "length"
  25431. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  25432. * or `_.forOwn` for object iteration.
  25433. *
  25434. * @static
  25435. * @memberOf _
  25436. * @since 0.1.0
  25437. * @alias each
  25438. * @category Collection
  25439. * @param {Array|Object} collection The collection to iterate over.
  25440. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25441. * @returns {Array|Object} Returns `collection`.
  25442. * @see _.forEachRight
  25443. * @example
  25444. *
  25445. * _.forEach([1, 2], function(value) {
  25446. * console.log(value);
  25447. * });
  25448. * // => Logs `1` then `2`.
  25449. *
  25450. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  25451. * console.log(key);
  25452. * });
  25453. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  25454. */
  25455. function forEach(collection, iteratee) {
  25456. var func = isArray(collection) ? arrayEach : baseEach;
  25457. return func(collection, getIteratee(iteratee, 3));
  25458. }
  25459. /**
  25460. * This method is like `_.forEach` except that it iterates over elements of
  25461. * `collection` from right to left.
  25462. *
  25463. * @static
  25464. * @memberOf _
  25465. * @since 2.0.0
  25466. * @alias eachRight
  25467. * @category Collection
  25468. * @param {Array|Object} collection The collection to iterate over.
  25469. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25470. * @returns {Array|Object} Returns `collection`.
  25471. * @see _.forEach
  25472. * @example
  25473. *
  25474. * _.forEachRight([1, 2], function(value) {
  25475. * console.log(value);
  25476. * });
  25477. * // => Logs `2` then `1`.
  25478. */
  25479. function forEachRight(collection, iteratee) {
  25480. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  25481. return func(collection, getIteratee(iteratee, 3));
  25482. }
  25483. /**
  25484. * Creates an object composed of keys generated from the results of running
  25485. * each element of `collection` thru `iteratee`. The order of grouped values
  25486. * is determined by the order they occur in `collection`. The corresponding
  25487. * value of each key is an array of elements responsible for generating the
  25488. * key. The iteratee is invoked with one argument: (value).
  25489. *
  25490. * @static
  25491. * @memberOf _
  25492. * @since 0.1.0
  25493. * @category Collection
  25494. * @param {Array|Object} collection The collection to iterate over.
  25495. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25496. * @returns {Object} Returns the composed aggregate object.
  25497. * @example
  25498. *
  25499. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  25500. * // => { '4': [4.2], '6': [6.1, 6.3] }
  25501. *
  25502. * // The `_.property` iteratee shorthand.
  25503. * _.groupBy(['one', 'two', 'three'], 'length');
  25504. * // => { '3': ['one', 'two'], '5': ['three'] }
  25505. */
  25506. var groupBy = createAggregator(function(result, value, key) {
  25507. if (hasOwnProperty.call(result, key)) {
  25508. result[key].push(value);
  25509. } else {
  25510. baseAssignValue(result, key, [value]);
  25511. }
  25512. });
  25513. /**
  25514. * Checks if `value` is in `collection`. If `collection` is a string, it's
  25515. * checked for a substring of `value`, otherwise
  25516. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25517. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  25518. * the offset from the end of `collection`.
  25519. *
  25520. * @static
  25521. * @memberOf _
  25522. * @since 0.1.0
  25523. * @category Collection
  25524. * @param {Array|Object|string} collection The collection to inspect.
  25525. * @param {*} value The value to search for.
  25526. * @param {number} [fromIndex=0] The index to search from.
  25527. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25528. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  25529. * @example
  25530. *
  25531. * _.includes([1, 2, 3], 1);
  25532. * // => true
  25533. *
  25534. * _.includes([1, 2, 3], 1, 2);
  25535. * // => false
  25536. *
  25537. * _.includes({ 'a': 1, 'b': 2 }, 1);
  25538. * // => true
  25539. *
  25540. * _.includes('abcd', 'bc');
  25541. * // => true
  25542. */
  25543. function includes(collection, value, fromIndex, guard) {
  25544. collection = isArrayLike(collection) ? collection : values(collection);
  25545. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  25546. var length = collection.length;
  25547. if (fromIndex < 0) {
  25548. fromIndex = nativeMax(length + fromIndex, 0);
  25549. }
  25550. return isString(collection)
  25551. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  25552. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  25553. }
  25554. /**
  25555. * Invokes the method at `path` of each element in `collection`, returning
  25556. * an array of the results of each invoked method. Any additional arguments
  25557. * are provided to each invoked method. If `path` is a function, it's invoked
  25558. * for, and `this` bound to, each element in `collection`.
  25559. *
  25560. * @static
  25561. * @memberOf _
  25562. * @since 4.0.0
  25563. * @category Collection
  25564. * @param {Array|Object} collection The collection to iterate over.
  25565. * @param {Array|Function|string} path The path of the method to invoke or
  25566. * the function invoked per iteration.
  25567. * @param {...*} [args] The arguments to invoke each method with.
  25568. * @returns {Array} Returns the array of results.
  25569. * @example
  25570. *
  25571. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  25572. * // => [[1, 5, 7], [1, 2, 3]]
  25573. *
  25574. * _.invokeMap([123, 456], String.prototype.split, '');
  25575. * // => [['1', '2', '3'], ['4', '5', '6']]
  25576. */
  25577. var invokeMap = baseRest(function(collection, path, args) {
  25578. var index = -1,
  25579. isFunc = typeof path == 'function',
  25580. result = isArrayLike(collection) ? Array(collection.length) : [];
  25581. baseEach(collection, function(value) {
  25582. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  25583. });
  25584. return result;
  25585. });
  25586. /**
  25587. * Creates an object composed of keys generated from the results of running
  25588. * each element of `collection` thru `iteratee`. The corresponding value of
  25589. * each key is the last element responsible for generating the key. The
  25590. * iteratee is invoked with one argument: (value).
  25591. *
  25592. * @static
  25593. * @memberOf _
  25594. * @since 4.0.0
  25595. * @category Collection
  25596. * @param {Array|Object} collection The collection to iterate over.
  25597. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  25598. * @returns {Object} Returns the composed aggregate object.
  25599. * @example
  25600. *
  25601. * var array = [
  25602. * { 'dir': 'left', 'code': 97 },
  25603. * { 'dir': 'right', 'code': 100 }
  25604. * ];
  25605. *
  25606. * _.keyBy(array, function(o) {
  25607. * return String.fromCharCode(o.code);
  25608. * });
  25609. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  25610. *
  25611. * _.keyBy(array, 'dir');
  25612. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  25613. */
  25614. var keyBy = createAggregator(function(result, value, key) {
  25615. baseAssignValue(result, key, value);
  25616. });
  25617. /**
  25618. * Creates an array of values by running each element in `collection` thru
  25619. * `iteratee`. The iteratee is invoked with three arguments:
  25620. * (value, index|key, collection).
  25621. *
  25622. * Many lodash methods are guarded to work as iteratees for methods like
  25623. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  25624. *
  25625. * The guarded methods are:
  25626. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  25627. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  25628. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  25629. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  25630. *
  25631. * @static
  25632. * @memberOf _
  25633. * @since 0.1.0
  25634. * @category Collection
  25635. * @param {Array|Object} collection The collection to iterate over.
  25636. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25637. * @returns {Array} Returns the new mapped array.
  25638. * @example
  25639. *
  25640. * function square(n) {
  25641. * return n * n;
  25642. * }
  25643. *
  25644. * _.map([4, 8], square);
  25645. * // => [16, 64]
  25646. *
  25647. * _.map({ 'a': 4, 'b': 8 }, square);
  25648. * // => [16, 64] (iteration order is not guaranteed)
  25649. *
  25650. * var users = [
  25651. * { 'user': 'barney' },
  25652. * { 'user': 'fred' }
  25653. * ];
  25654. *
  25655. * // The `_.property` iteratee shorthand.
  25656. * _.map(users, 'user');
  25657. * // => ['barney', 'fred']
  25658. */
  25659. function map(collection, iteratee) {
  25660. var func = isArray(collection) ? arrayMap : baseMap;
  25661. return func(collection, getIteratee(iteratee, 3));
  25662. }
  25663. /**
  25664. * This method is like `_.sortBy` except that it allows specifying the sort
  25665. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  25666. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  25667. * descending or "asc" for ascending sort order of corresponding values.
  25668. *
  25669. * @static
  25670. * @memberOf _
  25671. * @since 4.0.0
  25672. * @category Collection
  25673. * @param {Array|Object} collection The collection to iterate over.
  25674. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  25675. * The iteratees to sort by.
  25676. * @param {string[]} [orders] The sort orders of `iteratees`.
  25677. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  25678. * @returns {Array} Returns the new sorted array.
  25679. * @example
  25680. *
  25681. * var users = [
  25682. * { 'user': 'fred', 'age': 48 },
  25683. * { 'user': 'barney', 'age': 34 },
  25684. * { 'user': 'fred', 'age': 40 },
  25685. * { 'user': 'barney', 'age': 36 }
  25686. * ];
  25687. *
  25688. * // Sort by `user` in ascending order and by `age` in descending order.
  25689. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  25690. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  25691. */
  25692. function orderBy(collection, iteratees, orders, guard) {
  25693. if (collection == null) {
  25694. return [];
  25695. }
  25696. if (!isArray(iteratees)) {
  25697. iteratees = iteratees == null ? [] : [iteratees];
  25698. }
  25699. orders = guard ? undefined : orders;
  25700. if (!isArray(orders)) {
  25701. orders = orders == null ? [] : [orders];
  25702. }
  25703. return baseOrderBy(collection, iteratees, orders);
  25704. }
  25705. /**
  25706. * Creates an array of elements split into two groups, the first of which
  25707. * contains elements `predicate` returns truthy for, the second of which
  25708. * contains elements `predicate` returns falsey for. The predicate is
  25709. * invoked with one argument: (value).
  25710. *
  25711. * @static
  25712. * @memberOf _
  25713. * @since 3.0.0
  25714. * @category Collection
  25715. * @param {Array|Object} collection The collection to iterate over.
  25716. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25717. * @returns {Array} Returns the array of grouped elements.
  25718. * @example
  25719. *
  25720. * var users = [
  25721. * { 'user': 'barney', 'age': 36, 'active': false },
  25722. * { 'user': 'fred', 'age': 40, 'active': true },
  25723. * { 'user': 'pebbles', 'age': 1, 'active': false }
  25724. * ];
  25725. *
  25726. * _.partition(users, function(o) { return o.active; });
  25727. * // => objects for [['fred'], ['barney', 'pebbles']]
  25728. *
  25729. * // The `_.matches` iteratee shorthand.
  25730. * _.partition(users, { 'age': 1, 'active': false });
  25731. * // => objects for [['pebbles'], ['barney', 'fred']]
  25732. *
  25733. * // The `_.matchesProperty` iteratee shorthand.
  25734. * _.partition(users, ['active', false]);
  25735. * // => objects for [['barney', 'pebbles'], ['fred']]
  25736. *
  25737. * // The `_.property` iteratee shorthand.
  25738. * _.partition(users, 'active');
  25739. * // => objects for [['fred'], ['barney', 'pebbles']]
  25740. */
  25741. var partition = createAggregator(function(result, value, key) {
  25742. result[key ? 0 : 1].push(value);
  25743. }, function() { return [[], []]; });
  25744. /**
  25745. * Reduces `collection` to a value which is the accumulated result of running
  25746. * each element in `collection` thru `iteratee`, where each successive
  25747. * invocation is supplied the return value of the previous. If `accumulator`
  25748. * is not given, the first element of `collection` is used as the initial
  25749. * value. The iteratee is invoked with four arguments:
  25750. * (accumulator, value, index|key, collection).
  25751. *
  25752. * Many lodash methods are guarded to work as iteratees for methods like
  25753. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  25754. *
  25755. * The guarded methods are:
  25756. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  25757. * and `sortBy`
  25758. *
  25759. * @static
  25760. * @memberOf _
  25761. * @since 0.1.0
  25762. * @category Collection
  25763. * @param {Array|Object} collection The collection to iterate over.
  25764. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25765. * @param {*} [accumulator] The initial value.
  25766. * @returns {*} Returns the accumulated value.
  25767. * @see _.reduceRight
  25768. * @example
  25769. *
  25770. * _.reduce([1, 2], function(sum, n) {
  25771. * return sum + n;
  25772. * }, 0);
  25773. * // => 3
  25774. *
  25775. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  25776. * (result[value] || (result[value] = [])).push(key);
  25777. * return result;
  25778. * }, {});
  25779. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  25780. */
  25781. function reduce(collection, iteratee, accumulator) {
  25782. var func = isArray(collection) ? arrayReduce : baseReduce,
  25783. initAccum = arguments.length < 3;
  25784. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  25785. }
  25786. /**
  25787. * This method is like `_.reduce` except that it iterates over elements of
  25788. * `collection` from right to left.
  25789. *
  25790. * @static
  25791. * @memberOf _
  25792. * @since 0.1.0
  25793. * @category Collection
  25794. * @param {Array|Object} collection The collection to iterate over.
  25795. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25796. * @param {*} [accumulator] The initial value.
  25797. * @returns {*} Returns the accumulated value.
  25798. * @see _.reduce
  25799. * @example
  25800. *
  25801. * var array = [[0, 1], [2, 3], [4, 5]];
  25802. *
  25803. * _.reduceRight(array, function(flattened, other) {
  25804. * return flattened.concat(other);
  25805. * }, []);
  25806. * // => [4, 5, 2, 3, 0, 1]
  25807. */
  25808. function reduceRight(collection, iteratee, accumulator) {
  25809. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  25810. initAccum = arguments.length < 3;
  25811. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  25812. }
  25813. /**
  25814. * The opposite of `_.filter`; this method returns the elements of `collection`
  25815. * that `predicate` does **not** return truthy for.
  25816. *
  25817. * @static
  25818. * @memberOf _
  25819. * @since 0.1.0
  25820. * @category Collection
  25821. * @param {Array|Object} collection The collection to iterate over.
  25822. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25823. * @returns {Array} Returns the new filtered array.
  25824. * @see _.filter
  25825. * @example
  25826. *
  25827. * var users = [
  25828. * { 'user': 'barney', 'age': 36, 'active': false },
  25829. * { 'user': 'fred', 'age': 40, 'active': true }
  25830. * ];
  25831. *
  25832. * _.reject(users, function(o) { return !o.active; });
  25833. * // => objects for ['fred']
  25834. *
  25835. * // The `_.matches` iteratee shorthand.
  25836. * _.reject(users, { 'age': 40, 'active': true });
  25837. * // => objects for ['barney']
  25838. *
  25839. * // The `_.matchesProperty` iteratee shorthand.
  25840. * _.reject(users, ['active', false]);
  25841. * // => objects for ['fred']
  25842. *
  25843. * // The `_.property` iteratee shorthand.
  25844. * _.reject(users, 'active');
  25845. * // => objects for ['barney']
  25846. */
  25847. function reject(collection, predicate) {
  25848. var func = isArray(collection) ? arrayFilter : baseFilter;
  25849. return func(collection, negate(getIteratee(predicate, 3)));
  25850. }
  25851. /**
  25852. * Gets a random element from `collection`.
  25853. *
  25854. * @static
  25855. * @memberOf _
  25856. * @since 2.0.0
  25857. * @category Collection
  25858. * @param {Array|Object} collection The collection to sample.
  25859. * @returns {*} Returns the random element.
  25860. * @example
  25861. *
  25862. * _.sample([1, 2, 3, 4]);
  25863. * // => 2
  25864. */
  25865. function sample(collection) {
  25866. var func = isArray(collection) ? arraySample : baseSample;
  25867. return func(collection);
  25868. }
  25869. /**
  25870. * Gets `n` random elements at unique keys from `collection` up to the
  25871. * size of `collection`.
  25872. *
  25873. * @static
  25874. * @memberOf _
  25875. * @since 4.0.0
  25876. * @category Collection
  25877. * @param {Array|Object} collection The collection to sample.
  25878. * @param {number} [n=1] The number of elements to sample.
  25879. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25880. * @returns {Array} Returns the random elements.
  25881. * @example
  25882. *
  25883. * _.sampleSize([1, 2, 3], 2);
  25884. * // => [3, 1]
  25885. *
  25886. * _.sampleSize([1, 2, 3], 4);
  25887. * // => [2, 3, 1]
  25888. */
  25889. function sampleSize(collection, n, guard) {
  25890. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  25891. n = 1;
  25892. } else {
  25893. n = toInteger(n);
  25894. }
  25895. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  25896. return func(collection, n);
  25897. }
  25898. /**
  25899. * Creates an array of shuffled values, using a version of the
  25900. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  25901. *
  25902. * @static
  25903. * @memberOf _
  25904. * @since 0.1.0
  25905. * @category Collection
  25906. * @param {Array|Object} collection The collection to shuffle.
  25907. * @returns {Array} Returns the new shuffled array.
  25908. * @example
  25909. *
  25910. * _.shuffle([1, 2, 3, 4]);
  25911. * // => [4, 1, 3, 2]
  25912. */
  25913. function shuffle(collection) {
  25914. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  25915. return func(collection);
  25916. }
  25917. /**
  25918. * Gets the size of `collection` by returning its length for array-like
  25919. * values or the number of own enumerable string keyed properties for objects.
  25920. *
  25921. * @static
  25922. * @memberOf _
  25923. * @since 0.1.0
  25924. * @category Collection
  25925. * @param {Array|Object|string} collection The collection to inspect.
  25926. * @returns {number} Returns the collection size.
  25927. * @example
  25928. *
  25929. * _.size([1, 2, 3]);
  25930. * // => 3
  25931. *
  25932. * _.size({ 'a': 1, 'b': 2 });
  25933. * // => 2
  25934. *
  25935. * _.size('pebbles');
  25936. * // => 7
  25937. */
  25938. function size(collection) {
  25939. if (collection == null) {
  25940. return 0;
  25941. }
  25942. if (isArrayLike(collection)) {
  25943. return isString(collection) ? stringSize(collection) : collection.length;
  25944. }
  25945. var tag = getTag(collection);
  25946. if (tag == mapTag || tag == setTag) {
  25947. return collection.size;
  25948. }
  25949. return baseKeys(collection).length;
  25950. }
  25951. /**
  25952. * Checks if `predicate` returns truthy for **any** element of `collection`.
  25953. * Iteration is stopped once `predicate` returns truthy. The predicate is
  25954. * invoked with three arguments: (value, index|key, collection).
  25955. *
  25956. * @static
  25957. * @memberOf _
  25958. * @since 0.1.0
  25959. * @category Collection
  25960. * @param {Array|Object} collection The collection to iterate over.
  25961. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25962. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25963. * @returns {boolean} Returns `true` if any element passes the predicate check,
  25964. * else `false`.
  25965. * @example
  25966. *
  25967. * _.some([null, 0, 'yes', false], Boolean);
  25968. * // => true
  25969. *
  25970. * var users = [
  25971. * { 'user': 'barney', 'active': true },
  25972. * { 'user': 'fred', 'active': false }
  25973. * ];
  25974. *
  25975. * // The `_.matches` iteratee shorthand.
  25976. * _.some(users, { 'user': 'barney', 'active': false });
  25977. * // => false
  25978. *
  25979. * // The `_.matchesProperty` iteratee shorthand.
  25980. * _.some(users, ['active', false]);
  25981. * // => true
  25982. *
  25983. * // The `_.property` iteratee shorthand.
  25984. * _.some(users, 'active');
  25985. * // => true
  25986. */
  25987. function some(collection, predicate, guard) {
  25988. var func = isArray(collection) ? arraySome : baseSome;
  25989. if (guard && isIterateeCall(collection, predicate, guard)) {
  25990. predicate = undefined;
  25991. }
  25992. return func(collection, getIteratee(predicate, 3));
  25993. }
  25994. /**
  25995. * Creates an array of elements, sorted in ascending order by the results of
  25996. * running each element in a collection thru each iteratee. This method
  25997. * performs a stable sort, that is, it preserves the original sort order of
  25998. * equal elements. The iteratees are invoked with one argument: (value).
  25999. *
  26000. * @static
  26001. * @memberOf _
  26002. * @since 0.1.0
  26003. * @category Collection
  26004. * @param {Array|Object} collection The collection to iterate over.
  26005. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26006. * The iteratees to sort by.
  26007. * @returns {Array} Returns the new sorted array.
  26008. * @example
  26009. *
  26010. * var users = [
  26011. * { 'user': 'fred', 'age': 48 },
  26012. * { 'user': 'barney', 'age': 36 },
  26013. * { 'user': 'fred', 'age': 40 },
  26014. * { 'user': 'barney', 'age': 34 }
  26015. * ];
  26016. *
  26017. * _.sortBy(users, [function(o) { return o.user; }]);
  26018. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26019. *
  26020. * _.sortBy(users, ['user', 'age']);
  26021. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26022. */
  26023. var sortBy = baseRest(function(collection, iteratees) {
  26024. if (collection == null) {
  26025. return [];
  26026. }
  26027. var length = iteratees.length;
  26028. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26029. iteratees = [];
  26030. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26031. iteratees = [iteratees[0]];
  26032. }
  26033. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26034. });
  26035. /*------------------------------------------------------------------------*/
  26036. /**
  26037. * Gets the timestamp of the number of milliseconds that have elapsed since
  26038. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26039. *
  26040. * @static
  26041. * @memberOf _
  26042. * @since 2.4.0
  26043. * @category Date
  26044. * @returns {number} Returns the timestamp.
  26045. * @example
  26046. *
  26047. * _.defer(function(stamp) {
  26048. * console.log(_.now() - stamp);
  26049. * }, _.now());
  26050. * // => Logs the number of milliseconds it took for the deferred invocation.
  26051. */
  26052. var now = ctxNow || function() {
  26053. return root.Date.now();
  26054. };
  26055. /*------------------------------------------------------------------------*/
  26056. /**
  26057. * The opposite of `_.before`; this method creates a function that invokes
  26058. * `func` once it's called `n` or more times.
  26059. *
  26060. * @static
  26061. * @memberOf _
  26062. * @since 0.1.0
  26063. * @category Function
  26064. * @param {number} n The number of calls before `func` is invoked.
  26065. * @param {Function} func The function to restrict.
  26066. * @returns {Function} Returns the new restricted function.
  26067. * @example
  26068. *
  26069. * var saves = ['profile', 'settings'];
  26070. *
  26071. * var done = _.after(saves.length, function() {
  26072. * console.log('done saving!');
  26073. * });
  26074. *
  26075. * _.forEach(saves, function(type) {
  26076. * asyncSave({ 'type': type, 'complete': done });
  26077. * });
  26078. * // => Logs 'done saving!' after the two async saves have completed.
  26079. */
  26080. function after(n, func) {
  26081. if (typeof func != 'function') {
  26082. throw new TypeError(FUNC_ERROR_TEXT);
  26083. }
  26084. n = toInteger(n);
  26085. return function() {
  26086. if (--n < 1) {
  26087. return func.apply(this, arguments);
  26088. }
  26089. };
  26090. }
  26091. /**
  26092. * Creates a function that invokes `func`, with up to `n` arguments,
  26093. * ignoring any additional arguments.
  26094. *
  26095. * @static
  26096. * @memberOf _
  26097. * @since 3.0.0
  26098. * @category Function
  26099. * @param {Function} func The function to cap arguments for.
  26100. * @param {number} [n=func.length] The arity cap.
  26101. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26102. * @returns {Function} Returns the new capped function.
  26103. * @example
  26104. *
  26105. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  26106. * // => [6, 8, 10]
  26107. */
  26108. function ary(func, n, guard) {
  26109. n = guard ? undefined : n;
  26110. n = (func && n == null) ? func.length : n;
  26111. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  26112. }
  26113. /**
  26114. * Creates a function that invokes `func`, with the `this` binding and arguments
  26115. * of the created function, while it's called less than `n` times. Subsequent
  26116. * calls to the created function return the result of the last `func` invocation.
  26117. *
  26118. * @static
  26119. * @memberOf _
  26120. * @since 3.0.0
  26121. * @category Function
  26122. * @param {number} n The number of calls at which `func` is no longer invoked.
  26123. * @param {Function} func The function to restrict.
  26124. * @returns {Function} Returns the new restricted function.
  26125. * @example
  26126. *
  26127. * jQuery(element).on('click', _.before(5, addContactToList));
  26128. * // => Allows adding up to 4 contacts to the list.
  26129. */
  26130. function before(n, func) {
  26131. var result;
  26132. if (typeof func != 'function') {
  26133. throw new TypeError(FUNC_ERROR_TEXT);
  26134. }
  26135. n = toInteger(n);
  26136. return function() {
  26137. if (--n > 0) {
  26138. result = func.apply(this, arguments);
  26139. }
  26140. if (n <= 1) {
  26141. func = undefined;
  26142. }
  26143. return result;
  26144. };
  26145. }
  26146. /**
  26147. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  26148. * and `partials` prepended to the arguments it receives.
  26149. *
  26150. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  26151. * may be used as a placeholder for partially applied arguments.
  26152. *
  26153. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  26154. * property of bound functions.
  26155. *
  26156. * @static
  26157. * @memberOf _
  26158. * @since 0.1.0
  26159. * @category Function
  26160. * @param {Function} func The function to bind.
  26161. * @param {*} thisArg The `this` binding of `func`.
  26162. * @param {...*} [partials] The arguments to be partially applied.
  26163. * @returns {Function} Returns the new bound function.
  26164. * @example
  26165. *
  26166. * function greet(greeting, punctuation) {
  26167. * return greeting + ' ' + this.user + punctuation;
  26168. * }
  26169. *
  26170. * var object = { 'user': 'fred' };
  26171. *
  26172. * var bound = _.bind(greet, object, 'hi');
  26173. * bound('!');
  26174. * // => 'hi fred!'
  26175. *
  26176. * // Bound with placeholders.
  26177. * var bound = _.bind(greet, object, _, '!');
  26178. * bound('hi');
  26179. * // => 'hi fred!'
  26180. */
  26181. var bind = baseRest(function(func, thisArg, partials) {
  26182. var bitmask = WRAP_BIND_FLAG;
  26183. if (partials.length) {
  26184. var holders = replaceHolders(partials, getHolder(bind));
  26185. bitmask |= WRAP_PARTIAL_FLAG;
  26186. }
  26187. return createWrap(func, bitmask, thisArg, partials, holders);
  26188. });
  26189. /**
  26190. * Creates a function that invokes the method at `object[key]` with `partials`
  26191. * prepended to the arguments it receives.
  26192. *
  26193. * This method differs from `_.bind` by allowing bound functions to reference
  26194. * methods that may be redefined or don't yet exist. See
  26195. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  26196. * for more details.
  26197. *
  26198. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  26199. * builds, may be used as a placeholder for partially applied arguments.
  26200. *
  26201. * @static
  26202. * @memberOf _
  26203. * @since 0.10.0
  26204. * @category Function
  26205. * @param {Object} object The object to invoke the method on.
  26206. * @param {string} key The key of the method.
  26207. * @param {...*} [partials] The arguments to be partially applied.
  26208. * @returns {Function} Returns the new bound function.
  26209. * @example
  26210. *
  26211. * var object = {
  26212. * 'user': 'fred',
  26213. * 'greet': function(greeting, punctuation) {
  26214. * return greeting + ' ' + this.user + punctuation;
  26215. * }
  26216. * };
  26217. *
  26218. * var bound = _.bindKey(object, 'greet', 'hi');
  26219. * bound('!');
  26220. * // => 'hi fred!'
  26221. *
  26222. * object.greet = function(greeting, punctuation) {
  26223. * return greeting + 'ya ' + this.user + punctuation;
  26224. * };
  26225. *
  26226. * bound('!');
  26227. * // => 'hiya fred!'
  26228. *
  26229. * // Bound with placeholders.
  26230. * var bound = _.bindKey(object, 'greet', _, '!');
  26231. * bound('hi');
  26232. * // => 'hiya fred!'
  26233. */
  26234. var bindKey = baseRest(function(object, key, partials) {
  26235. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  26236. if (partials.length) {
  26237. var holders = replaceHolders(partials, getHolder(bindKey));
  26238. bitmask |= WRAP_PARTIAL_FLAG;
  26239. }
  26240. return createWrap(key, bitmask, object, partials, holders);
  26241. });
  26242. /**
  26243. * Creates a function that accepts arguments of `func` and either invokes
  26244. * `func` returning its result, if at least `arity` number of arguments have
  26245. * been provided, or returns a function that accepts the remaining `func`
  26246. * arguments, and so on. The arity of `func` may be specified if `func.length`
  26247. * is not sufficient.
  26248. *
  26249. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  26250. * may be used as a placeholder for provided arguments.
  26251. *
  26252. * **Note:** This method doesn't set the "length" property of curried functions.
  26253. *
  26254. * @static
  26255. * @memberOf _
  26256. * @since 2.0.0
  26257. * @category Function
  26258. * @param {Function} func The function to curry.
  26259. * @param {number} [arity=func.length] The arity of `func`.
  26260. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26261. * @returns {Function} Returns the new curried function.
  26262. * @example
  26263. *
  26264. * var abc = function(a, b, c) {
  26265. * return [a, b, c];
  26266. * };
  26267. *
  26268. * var curried = _.curry(abc);
  26269. *
  26270. * curried(1)(2)(3);
  26271. * // => [1, 2, 3]
  26272. *
  26273. * curried(1, 2)(3);
  26274. * // => [1, 2, 3]
  26275. *
  26276. * curried(1, 2, 3);
  26277. * // => [1, 2, 3]
  26278. *
  26279. * // Curried with placeholders.
  26280. * curried(1)(_, 3)(2);
  26281. * // => [1, 2, 3]
  26282. */
  26283. function curry(func, arity, guard) {
  26284. arity = guard ? undefined : arity;
  26285. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26286. result.placeholder = curry.placeholder;
  26287. return result;
  26288. }
  26289. /**
  26290. * This method is like `_.curry` except that arguments are applied to `func`
  26291. * in the manner of `_.partialRight` instead of `_.partial`.
  26292. *
  26293. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  26294. * builds, may be used as a placeholder for provided arguments.
  26295. *
  26296. * **Note:** This method doesn't set the "length" property of curried functions.
  26297. *
  26298. * @static
  26299. * @memberOf _
  26300. * @since 3.0.0
  26301. * @category Function
  26302. * @param {Function} func The function to curry.
  26303. * @param {number} [arity=func.length] The arity of `func`.
  26304. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26305. * @returns {Function} Returns the new curried function.
  26306. * @example
  26307. *
  26308. * var abc = function(a, b, c) {
  26309. * return [a, b, c];
  26310. * };
  26311. *
  26312. * var curried = _.curryRight(abc);
  26313. *
  26314. * curried(3)(2)(1);
  26315. * // => [1, 2, 3]
  26316. *
  26317. * curried(2, 3)(1);
  26318. * // => [1, 2, 3]
  26319. *
  26320. * curried(1, 2, 3);
  26321. * // => [1, 2, 3]
  26322. *
  26323. * // Curried with placeholders.
  26324. * curried(3)(1, _)(2);
  26325. * // => [1, 2, 3]
  26326. */
  26327. function curryRight(func, arity, guard) {
  26328. arity = guard ? undefined : arity;
  26329. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  26330. result.placeholder = curryRight.placeholder;
  26331. return result;
  26332. }
  26333. /**
  26334. * Creates a debounced function that delays invoking `func` until after `wait`
  26335. * milliseconds have elapsed since the last time the debounced function was
  26336. * invoked. The debounced function comes with a `cancel` method to cancel
  26337. * delayed `func` invocations and a `flush` method to immediately invoke them.
  26338. * Provide `options` to indicate whether `func` should be invoked on the
  26339. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  26340. * with the last arguments provided to the debounced function. Subsequent
  26341. * calls to the debounced function return the result of the last `func`
  26342. * invocation.
  26343. *
  26344. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26345. * invoked on the trailing edge of the timeout only if the debounced function
  26346. * is invoked more than once during the `wait` timeout.
  26347. *
  26348. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26349. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26350. *
  26351. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26352. * for details over the differences between `_.debounce` and `_.throttle`.
  26353. *
  26354. * @static
  26355. * @memberOf _
  26356. * @since 0.1.0
  26357. * @category Function
  26358. * @param {Function} func The function to debounce.
  26359. * @param {number} [wait=0] The number of milliseconds to delay.
  26360. * @param {Object} [options={}] The options object.
  26361. * @param {boolean} [options.leading=false]
  26362. * Specify invoking on the leading edge of the timeout.
  26363. * @param {number} [options.maxWait]
  26364. * The maximum time `func` is allowed to be delayed before it's invoked.
  26365. * @param {boolean} [options.trailing=true]
  26366. * Specify invoking on the trailing edge of the timeout.
  26367. * @returns {Function} Returns the new debounced function.
  26368. * @example
  26369. *
  26370. * // Avoid costly calculations while the window size is in flux.
  26371. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  26372. *
  26373. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  26374. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  26375. * 'leading': true,
  26376. * 'trailing': false
  26377. * }));
  26378. *
  26379. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  26380. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  26381. * var source = new EventSource('/stream');
  26382. * jQuery(source).on('message', debounced);
  26383. *
  26384. * // Cancel the trailing debounced invocation.
  26385. * jQuery(window).on('popstate', debounced.cancel);
  26386. */
  26387. function debounce(func, wait, options) {
  26388. var lastArgs,
  26389. lastThis,
  26390. maxWait,
  26391. result,
  26392. timerId,
  26393. lastCallTime,
  26394. lastInvokeTime = 0,
  26395. leading = false,
  26396. maxing = false,
  26397. trailing = true;
  26398. if (typeof func != 'function') {
  26399. throw new TypeError(FUNC_ERROR_TEXT);
  26400. }
  26401. wait = toNumber(wait) || 0;
  26402. if (isObject(options)) {
  26403. leading = !!options.leading;
  26404. maxing = 'maxWait' in options;
  26405. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  26406. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26407. }
  26408. function invokeFunc(time) {
  26409. var args = lastArgs,
  26410. thisArg = lastThis;
  26411. lastArgs = lastThis = undefined;
  26412. lastInvokeTime = time;
  26413. result = func.apply(thisArg, args);
  26414. return result;
  26415. }
  26416. function leadingEdge(time) {
  26417. // Reset any `maxWait` timer.
  26418. lastInvokeTime = time;
  26419. // Start the timer for the trailing edge.
  26420. timerId = setTimeout(timerExpired, wait);
  26421. // Invoke the leading edge.
  26422. return leading ? invokeFunc(time) : result;
  26423. }
  26424. function remainingWait(time) {
  26425. var timeSinceLastCall = time - lastCallTime,
  26426. timeSinceLastInvoke = time - lastInvokeTime,
  26427. timeWaiting = wait - timeSinceLastCall;
  26428. return maxing
  26429. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  26430. : timeWaiting;
  26431. }
  26432. function shouldInvoke(time) {
  26433. var timeSinceLastCall = time - lastCallTime,
  26434. timeSinceLastInvoke = time - lastInvokeTime;
  26435. // Either this is the first call, activity has stopped and we're at the
  26436. // trailing edge, the system time has gone backwards and we're treating
  26437. // it as the trailing edge, or we've hit the `maxWait` limit.
  26438. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  26439. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  26440. }
  26441. function timerExpired() {
  26442. var time = now();
  26443. if (shouldInvoke(time)) {
  26444. return trailingEdge(time);
  26445. }
  26446. // Restart the timer.
  26447. timerId = setTimeout(timerExpired, remainingWait(time));
  26448. }
  26449. function trailingEdge(time) {
  26450. timerId = undefined;
  26451. // Only invoke if we have `lastArgs` which means `func` has been
  26452. // debounced at least once.
  26453. if (trailing && lastArgs) {
  26454. return invokeFunc(time);
  26455. }
  26456. lastArgs = lastThis = undefined;
  26457. return result;
  26458. }
  26459. function cancel() {
  26460. if (timerId !== undefined) {
  26461. clearTimeout(timerId);
  26462. }
  26463. lastInvokeTime = 0;
  26464. lastArgs = lastCallTime = lastThis = timerId = undefined;
  26465. }
  26466. function flush() {
  26467. return timerId === undefined ? result : trailingEdge(now());
  26468. }
  26469. function debounced() {
  26470. var time = now(),
  26471. isInvoking = shouldInvoke(time);
  26472. lastArgs = arguments;
  26473. lastThis = this;
  26474. lastCallTime = time;
  26475. if (isInvoking) {
  26476. if (timerId === undefined) {
  26477. return leadingEdge(lastCallTime);
  26478. }
  26479. if (maxing) {
  26480. // Handle invocations in a tight loop.
  26481. clearTimeout(timerId);
  26482. timerId = setTimeout(timerExpired, wait);
  26483. return invokeFunc(lastCallTime);
  26484. }
  26485. }
  26486. if (timerId === undefined) {
  26487. timerId = setTimeout(timerExpired, wait);
  26488. }
  26489. return result;
  26490. }
  26491. debounced.cancel = cancel;
  26492. debounced.flush = flush;
  26493. return debounced;
  26494. }
  26495. /**
  26496. * Defers invoking the `func` until the current call stack has cleared. Any
  26497. * additional arguments are provided to `func` when it's invoked.
  26498. *
  26499. * @static
  26500. * @memberOf _
  26501. * @since 0.1.0
  26502. * @category Function
  26503. * @param {Function} func The function to defer.
  26504. * @param {...*} [args] The arguments to invoke `func` with.
  26505. * @returns {number} Returns the timer id.
  26506. * @example
  26507. *
  26508. * _.defer(function(text) {
  26509. * console.log(text);
  26510. * }, 'deferred');
  26511. * // => Logs 'deferred' after one millisecond.
  26512. */
  26513. var defer = baseRest(function(func, args) {
  26514. return baseDelay(func, 1, args);
  26515. });
  26516. /**
  26517. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  26518. * provided to `func` when it's invoked.
  26519. *
  26520. * @static
  26521. * @memberOf _
  26522. * @since 0.1.0
  26523. * @category Function
  26524. * @param {Function} func The function to delay.
  26525. * @param {number} wait The number of milliseconds to delay invocation.
  26526. * @param {...*} [args] The arguments to invoke `func` with.
  26527. * @returns {number} Returns the timer id.
  26528. * @example
  26529. *
  26530. * _.delay(function(text) {
  26531. * console.log(text);
  26532. * }, 1000, 'later');
  26533. * // => Logs 'later' after one second.
  26534. */
  26535. var delay = baseRest(function(func, wait, args) {
  26536. return baseDelay(func, toNumber(wait) || 0, args);
  26537. });
  26538. /**
  26539. * Creates a function that invokes `func` with arguments reversed.
  26540. *
  26541. * @static
  26542. * @memberOf _
  26543. * @since 4.0.0
  26544. * @category Function
  26545. * @param {Function} func The function to flip arguments for.
  26546. * @returns {Function} Returns the new flipped function.
  26547. * @example
  26548. *
  26549. * var flipped = _.flip(function() {
  26550. * return _.toArray(arguments);
  26551. * });
  26552. *
  26553. * flipped('a', 'b', 'c', 'd');
  26554. * // => ['d', 'c', 'b', 'a']
  26555. */
  26556. function flip(func) {
  26557. return createWrap(func, WRAP_FLIP_FLAG);
  26558. }
  26559. /**
  26560. * Creates a function that memoizes the result of `func`. If `resolver` is
  26561. * provided, it determines the cache key for storing the result based on the
  26562. * arguments provided to the memoized function. By default, the first argument
  26563. * provided to the memoized function is used as the map cache key. The `func`
  26564. * is invoked with the `this` binding of the memoized function.
  26565. *
  26566. * **Note:** The cache is exposed as the `cache` property on the memoized
  26567. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  26568. * constructor with one whose instances implement the
  26569. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  26570. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  26571. *
  26572. * @static
  26573. * @memberOf _
  26574. * @since 0.1.0
  26575. * @category Function
  26576. * @param {Function} func The function to have its output memoized.
  26577. * @param {Function} [resolver] The function to resolve the cache key.
  26578. * @returns {Function} Returns the new memoized function.
  26579. * @example
  26580. *
  26581. * var object = { 'a': 1, 'b': 2 };
  26582. * var other = { 'c': 3, 'd': 4 };
  26583. *
  26584. * var values = _.memoize(_.values);
  26585. * values(object);
  26586. * // => [1, 2]
  26587. *
  26588. * values(other);
  26589. * // => [3, 4]
  26590. *
  26591. * object.a = 2;
  26592. * values(object);
  26593. * // => [1, 2]
  26594. *
  26595. * // Modify the result cache.
  26596. * values.cache.set(object, ['a', 'b']);
  26597. * values(object);
  26598. * // => ['a', 'b']
  26599. *
  26600. * // Replace `_.memoize.Cache`.
  26601. * _.memoize.Cache = WeakMap;
  26602. */
  26603. function memoize(func, resolver) {
  26604. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  26605. throw new TypeError(FUNC_ERROR_TEXT);
  26606. }
  26607. var memoized = function() {
  26608. var args = arguments,
  26609. key = resolver ? resolver.apply(this, args) : args[0],
  26610. cache = memoized.cache;
  26611. if (cache.has(key)) {
  26612. return cache.get(key);
  26613. }
  26614. var result = func.apply(this, args);
  26615. memoized.cache = cache.set(key, result) || cache;
  26616. return result;
  26617. };
  26618. memoized.cache = new (memoize.Cache || MapCache);
  26619. return memoized;
  26620. }
  26621. // Expose `MapCache`.
  26622. memoize.Cache = MapCache;
  26623. /**
  26624. * Creates a function that negates the result of the predicate `func`. The
  26625. * `func` predicate is invoked with the `this` binding and arguments of the
  26626. * created function.
  26627. *
  26628. * @static
  26629. * @memberOf _
  26630. * @since 3.0.0
  26631. * @category Function
  26632. * @param {Function} predicate The predicate to negate.
  26633. * @returns {Function} Returns the new negated function.
  26634. * @example
  26635. *
  26636. * function isEven(n) {
  26637. * return n % 2 == 0;
  26638. * }
  26639. *
  26640. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  26641. * // => [1, 3, 5]
  26642. */
  26643. function negate(predicate) {
  26644. if (typeof predicate != 'function') {
  26645. throw new TypeError(FUNC_ERROR_TEXT);
  26646. }
  26647. return function() {
  26648. var args = arguments;
  26649. switch (args.length) {
  26650. case 0: return !predicate.call(this);
  26651. case 1: return !predicate.call(this, args[0]);
  26652. case 2: return !predicate.call(this, args[0], args[1]);
  26653. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  26654. }
  26655. return !predicate.apply(this, args);
  26656. };
  26657. }
  26658. /**
  26659. * Creates a function that is restricted to invoking `func` once. Repeat calls
  26660. * to the function return the value of the first invocation. The `func` is
  26661. * invoked with the `this` binding and arguments of the created function.
  26662. *
  26663. * @static
  26664. * @memberOf _
  26665. * @since 0.1.0
  26666. * @category Function
  26667. * @param {Function} func The function to restrict.
  26668. * @returns {Function} Returns the new restricted function.
  26669. * @example
  26670. *
  26671. * var initialize = _.once(createApplication);
  26672. * initialize();
  26673. * initialize();
  26674. * // => `createApplication` is invoked once
  26675. */
  26676. function once(func) {
  26677. return before(2, func);
  26678. }
  26679. /**
  26680. * Creates a function that invokes `func` with its arguments transformed.
  26681. *
  26682. * @static
  26683. * @since 4.0.0
  26684. * @memberOf _
  26685. * @category Function
  26686. * @param {Function} func The function to wrap.
  26687. * @param {...(Function|Function[])} [transforms=[_.identity]]
  26688. * The argument transforms.
  26689. * @returns {Function} Returns the new function.
  26690. * @example
  26691. *
  26692. * function doubled(n) {
  26693. * return n * 2;
  26694. * }
  26695. *
  26696. * function square(n) {
  26697. * return n * n;
  26698. * }
  26699. *
  26700. * var func = _.overArgs(function(x, y) {
  26701. * return [x, y];
  26702. * }, [square, doubled]);
  26703. *
  26704. * func(9, 3);
  26705. * // => [81, 6]
  26706. *
  26707. * func(10, 5);
  26708. * // => [100, 10]
  26709. */
  26710. var overArgs = castRest(function(func, transforms) {
  26711. transforms = (transforms.length == 1 && isArray(transforms[0]))
  26712. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  26713. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  26714. var funcsLength = transforms.length;
  26715. return baseRest(function(args) {
  26716. var index = -1,
  26717. length = nativeMin(args.length, funcsLength);
  26718. while (++index < length) {
  26719. args[index] = transforms[index].call(this, args[index]);
  26720. }
  26721. return apply(func, this, args);
  26722. });
  26723. });
  26724. /**
  26725. * Creates a function that invokes `func` with `partials` prepended to the
  26726. * arguments it receives. This method is like `_.bind` except it does **not**
  26727. * alter the `this` binding.
  26728. *
  26729. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  26730. * builds, may be used as a placeholder for partially applied arguments.
  26731. *
  26732. * **Note:** This method doesn't set the "length" property of partially
  26733. * applied functions.
  26734. *
  26735. * @static
  26736. * @memberOf _
  26737. * @since 0.2.0
  26738. * @category Function
  26739. * @param {Function} func The function to partially apply arguments to.
  26740. * @param {...*} [partials] The arguments to be partially applied.
  26741. * @returns {Function} Returns the new partially applied function.
  26742. * @example
  26743. *
  26744. * function greet(greeting, name) {
  26745. * return greeting + ' ' + name;
  26746. * }
  26747. *
  26748. * var sayHelloTo = _.partial(greet, 'hello');
  26749. * sayHelloTo('fred');
  26750. * // => 'hello fred'
  26751. *
  26752. * // Partially applied with placeholders.
  26753. * var greetFred = _.partial(greet, _, 'fred');
  26754. * greetFred('hi');
  26755. * // => 'hi fred'
  26756. */
  26757. var partial = baseRest(function(func, partials) {
  26758. var holders = replaceHolders(partials, getHolder(partial));
  26759. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  26760. });
  26761. /**
  26762. * This method is like `_.partial` except that partially applied arguments
  26763. * are appended to the arguments it receives.
  26764. *
  26765. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  26766. * builds, may be used as a placeholder for partially applied arguments.
  26767. *
  26768. * **Note:** This method doesn't set the "length" property of partially
  26769. * applied functions.
  26770. *
  26771. * @static
  26772. * @memberOf _
  26773. * @since 1.0.0
  26774. * @category Function
  26775. * @param {Function} func The function to partially apply arguments to.
  26776. * @param {...*} [partials] The arguments to be partially applied.
  26777. * @returns {Function} Returns the new partially applied function.
  26778. * @example
  26779. *
  26780. * function greet(greeting, name) {
  26781. * return greeting + ' ' + name;
  26782. * }
  26783. *
  26784. * var greetFred = _.partialRight(greet, 'fred');
  26785. * greetFred('hi');
  26786. * // => 'hi fred'
  26787. *
  26788. * // Partially applied with placeholders.
  26789. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  26790. * sayHelloTo('fred');
  26791. * // => 'hello fred'
  26792. */
  26793. var partialRight = baseRest(function(func, partials) {
  26794. var holders = replaceHolders(partials, getHolder(partialRight));
  26795. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  26796. });
  26797. /**
  26798. * Creates a function that invokes `func` with arguments arranged according
  26799. * to the specified `indexes` where the argument value at the first index is
  26800. * provided as the first argument, the argument value at the second index is
  26801. * provided as the second argument, and so on.
  26802. *
  26803. * @static
  26804. * @memberOf _
  26805. * @since 3.0.0
  26806. * @category Function
  26807. * @param {Function} func The function to rearrange arguments for.
  26808. * @param {...(number|number[])} indexes The arranged argument indexes.
  26809. * @returns {Function} Returns the new function.
  26810. * @example
  26811. *
  26812. * var rearged = _.rearg(function(a, b, c) {
  26813. * return [a, b, c];
  26814. * }, [2, 0, 1]);
  26815. *
  26816. * rearged('b', 'c', 'a')
  26817. * // => ['a', 'b', 'c']
  26818. */
  26819. var rearg = flatRest(function(func, indexes) {
  26820. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  26821. });
  26822. /**
  26823. * Creates a function that invokes `func` with the `this` binding of the
  26824. * created function and arguments from `start` and beyond provided as
  26825. * an array.
  26826. *
  26827. * **Note:** This method is based on the
  26828. * [rest parameter](https://mdn.io/rest_parameters).
  26829. *
  26830. * @static
  26831. * @memberOf _
  26832. * @since 4.0.0
  26833. * @category Function
  26834. * @param {Function} func The function to apply a rest parameter to.
  26835. * @param {number} [start=func.length-1] The start position of the rest parameter.
  26836. * @returns {Function} Returns the new function.
  26837. * @example
  26838. *
  26839. * var say = _.rest(function(what, names) {
  26840. * return what + ' ' + _.initial(names).join(', ') +
  26841. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  26842. * });
  26843. *
  26844. * say('hello', 'fred', 'barney', 'pebbles');
  26845. * // => 'hello fred, barney, & pebbles'
  26846. */
  26847. function rest(func, start) {
  26848. if (typeof func != 'function') {
  26849. throw new TypeError(FUNC_ERROR_TEXT);
  26850. }
  26851. start = start === undefined ? start : toInteger(start);
  26852. return baseRest(func, start);
  26853. }
  26854. /**
  26855. * Creates a function that invokes `func` with the `this` binding of the
  26856. * create function and an array of arguments much like
  26857. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  26858. *
  26859. * **Note:** This method is based on the
  26860. * [spread operator](https://mdn.io/spread_operator).
  26861. *
  26862. * @static
  26863. * @memberOf _
  26864. * @since 3.2.0
  26865. * @category Function
  26866. * @param {Function} func The function to spread arguments over.
  26867. * @param {number} [start=0] The start position of the spread.
  26868. * @returns {Function} Returns the new function.
  26869. * @example
  26870. *
  26871. * var say = _.spread(function(who, what) {
  26872. * return who + ' says ' + what;
  26873. * });
  26874. *
  26875. * say(['fred', 'hello']);
  26876. * // => 'fred says hello'
  26877. *
  26878. * var numbers = Promise.all([
  26879. * Promise.resolve(40),
  26880. * Promise.resolve(36)
  26881. * ]);
  26882. *
  26883. * numbers.then(_.spread(function(x, y) {
  26884. * return x + y;
  26885. * }));
  26886. * // => a Promise of 76
  26887. */
  26888. function spread(func, start) {
  26889. if (typeof func != 'function') {
  26890. throw new TypeError(FUNC_ERROR_TEXT);
  26891. }
  26892. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  26893. return baseRest(function(args) {
  26894. var array = args[start],
  26895. otherArgs = castSlice(args, 0, start);
  26896. if (array) {
  26897. arrayPush(otherArgs, array);
  26898. }
  26899. return apply(func, this, otherArgs);
  26900. });
  26901. }
  26902. /**
  26903. * Creates a throttled function that only invokes `func` at most once per
  26904. * every `wait` milliseconds. The throttled function comes with a `cancel`
  26905. * method to cancel delayed `func` invocations and a `flush` method to
  26906. * immediately invoke them. Provide `options` to indicate whether `func`
  26907. * should be invoked on the leading and/or trailing edge of the `wait`
  26908. * timeout. The `func` is invoked with the last arguments provided to the
  26909. * throttled function. Subsequent calls to the throttled function return the
  26910. * result of the last `func` invocation.
  26911. *
  26912. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  26913. * invoked on the trailing edge of the timeout only if the throttled function
  26914. * is invoked more than once during the `wait` timeout.
  26915. *
  26916. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  26917. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  26918. *
  26919. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  26920. * for details over the differences between `_.throttle` and `_.debounce`.
  26921. *
  26922. * @static
  26923. * @memberOf _
  26924. * @since 0.1.0
  26925. * @category Function
  26926. * @param {Function} func The function to throttle.
  26927. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  26928. * @param {Object} [options={}] The options object.
  26929. * @param {boolean} [options.leading=true]
  26930. * Specify invoking on the leading edge of the timeout.
  26931. * @param {boolean} [options.trailing=true]
  26932. * Specify invoking on the trailing edge of the timeout.
  26933. * @returns {Function} Returns the new throttled function.
  26934. * @example
  26935. *
  26936. * // Avoid excessively updating the position while scrolling.
  26937. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  26938. *
  26939. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  26940. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  26941. * jQuery(element).on('click', throttled);
  26942. *
  26943. * // Cancel the trailing throttled invocation.
  26944. * jQuery(window).on('popstate', throttled.cancel);
  26945. */
  26946. function throttle(func, wait, options) {
  26947. var leading = true,
  26948. trailing = true;
  26949. if (typeof func != 'function') {
  26950. throw new TypeError(FUNC_ERROR_TEXT);
  26951. }
  26952. if (isObject(options)) {
  26953. leading = 'leading' in options ? !!options.leading : leading;
  26954. trailing = 'trailing' in options ? !!options.trailing : trailing;
  26955. }
  26956. return debounce(func, wait, {
  26957. 'leading': leading,
  26958. 'maxWait': wait,
  26959. 'trailing': trailing
  26960. });
  26961. }
  26962. /**
  26963. * Creates a function that accepts up to one argument, ignoring any
  26964. * additional arguments.
  26965. *
  26966. * @static
  26967. * @memberOf _
  26968. * @since 4.0.0
  26969. * @category Function
  26970. * @param {Function} func The function to cap arguments for.
  26971. * @returns {Function} Returns the new capped function.
  26972. * @example
  26973. *
  26974. * _.map(['6', '8', '10'], _.unary(parseInt));
  26975. * // => [6, 8, 10]
  26976. */
  26977. function unary(func) {
  26978. return ary(func, 1);
  26979. }
  26980. /**
  26981. * Creates a function that provides `value` to `wrapper` as its first
  26982. * argument. Any additional arguments provided to the function are appended
  26983. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  26984. * binding of the created function.
  26985. *
  26986. * @static
  26987. * @memberOf _
  26988. * @since 0.1.0
  26989. * @category Function
  26990. * @param {*} value The value to wrap.
  26991. * @param {Function} [wrapper=identity] The wrapper function.
  26992. * @returns {Function} Returns the new function.
  26993. * @example
  26994. *
  26995. * var p = _.wrap(_.escape, function(func, text) {
  26996. * return '<p>' + func(text) + '</p>';
  26997. * });
  26998. *
  26999. * p('fred, barney, & pebbles');
  27000. * // => '<p>fred, barney, &amp; pebbles</p>'
  27001. */
  27002. function wrap(value, wrapper) {
  27003. return partial(castFunction(wrapper), value);
  27004. }
  27005. /*------------------------------------------------------------------------*/
  27006. /**
  27007. * Casts `value` as an array if it's not one.
  27008. *
  27009. * @static
  27010. * @memberOf _
  27011. * @since 4.4.0
  27012. * @category Lang
  27013. * @param {*} value The value to inspect.
  27014. * @returns {Array} Returns the cast array.
  27015. * @example
  27016. *
  27017. * _.castArray(1);
  27018. * // => [1]
  27019. *
  27020. * _.castArray({ 'a': 1 });
  27021. * // => [{ 'a': 1 }]
  27022. *
  27023. * _.castArray('abc');
  27024. * // => ['abc']
  27025. *
  27026. * _.castArray(null);
  27027. * // => [null]
  27028. *
  27029. * _.castArray(undefined);
  27030. * // => [undefined]
  27031. *
  27032. * _.castArray();
  27033. * // => []
  27034. *
  27035. * var array = [1, 2, 3];
  27036. * console.log(_.castArray(array) === array);
  27037. * // => true
  27038. */
  27039. function castArray() {
  27040. if (!arguments.length) {
  27041. return [];
  27042. }
  27043. var value = arguments[0];
  27044. return isArray(value) ? value : [value];
  27045. }
  27046. /**
  27047. * Creates a shallow clone of `value`.
  27048. *
  27049. * **Note:** This method is loosely based on the
  27050. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27051. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27052. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27053. * arrays. The own enumerable properties of `arguments` objects are cloned
  27054. * as plain objects. An empty object is returned for uncloneable values such
  27055. * as error objects, functions, DOM nodes, and WeakMaps.
  27056. *
  27057. * @static
  27058. * @memberOf _
  27059. * @since 0.1.0
  27060. * @category Lang
  27061. * @param {*} value The value to clone.
  27062. * @returns {*} Returns the cloned value.
  27063. * @see _.cloneDeep
  27064. * @example
  27065. *
  27066. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27067. *
  27068. * var shallow = _.clone(objects);
  27069. * console.log(shallow[0] === objects[0]);
  27070. * // => true
  27071. */
  27072. function clone(value) {
  27073. return baseClone(value, CLONE_SYMBOLS_FLAG);
  27074. }
  27075. /**
  27076. * This method is like `_.clone` except that it accepts `customizer` which
  27077. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  27078. * cloning is handled by the method instead. The `customizer` is invoked with
  27079. * up to four arguments; (value [, index|key, object, stack]).
  27080. *
  27081. * @static
  27082. * @memberOf _
  27083. * @since 4.0.0
  27084. * @category Lang
  27085. * @param {*} value The value to clone.
  27086. * @param {Function} [customizer] The function to customize cloning.
  27087. * @returns {*} Returns the cloned value.
  27088. * @see _.cloneDeepWith
  27089. * @example
  27090. *
  27091. * function customizer(value) {
  27092. * if (_.isElement(value)) {
  27093. * return value.cloneNode(false);
  27094. * }
  27095. * }
  27096. *
  27097. * var el = _.cloneWith(document.body, customizer);
  27098. *
  27099. * console.log(el === document.body);
  27100. * // => false
  27101. * console.log(el.nodeName);
  27102. * // => 'BODY'
  27103. * console.log(el.childNodes.length);
  27104. * // => 0
  27105. */
  27106. function cloneWith(value, customizer) {
  27107. customizer = typeof customizer == 'function' ? customizer : undefined;
  27108. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  27109. }
  27110. /**
  27111. * This method is like `_.clone` except that it recursively clones `value`.
  27112. *
  27113. * @static
  27114. * @memberOf _
  27115. * @since 1.0.0
  27116. * @category Lang
  27117. * @param {*} value The value to recursively clone.
  27118. * @returns {*} Returns the deep cloned value.
  27119. * @see _.clone
  27120. * @example
  27121. *
  27122. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27123. *
  27124. * var deep = _.cloneDeep(objects);
  27125. * console.log(deep[0] === objects[0]);
  27126. * // => false
  27127. */
  27128. function cloneDeep(value) {
  27129. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  27130. }
  27131. /**
  27132. * This method is like `_.cloneWith` except that it recursively clones `value`.
  27133. *
  27134. * @static
  27135. * @memberOf _
  27136. * @since 4.0.0
  27137. * @category Lang
  27138. * @param {*} value The value to recursively clone.
  27139. * @param {Function} [customizer] The function to customize cloning.
  27140. * @returns {*} Returns the deep cloned value.
  27141. * @see _.cloneWith
  27142. * @example
  27143. *
  27144. * function customizer(value) {
  27145. * if (_.isElement(value)) {
  27146. * return value.cloneNode(true);
  27147. * }
  27148. * }
  27149. *
  27150. * var el = _.cloneDeepWith(document.body, customizer);
  27151. *
  27152. * console.log(el === document.body);
  27153. * // => false
  27154. * console.log(el.nodeName);
  27155. * // => 'BODY'
  27156. * console.log(el.childNodes.length);
  27157. * // => 20
  27158. */
  27159. function cloneDeepWith(value, customizer) {
  27160. customizer = typeof customizer == 'function' ? customizer : undefined;
  27161. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  27162. }
  27163. /**
  27164. * Checks if `object` conforms to `source` by invoking the predicate
  27165. * properties of `source` with the corresponding property values of `object`.
  27166. *
  27167. * **Note:** This method is equivalent to `_.conforms` when `source` is
  27168. * partially applied.
  27169. *
  27170. * @static
  27171. * @memberOf _
  27172. * @since 4.14.0
  27173. * @category Lang
  27174. * @param {Object} object The object to inspect.
  27175. * @param {Object} source The object of property predicates to conform to.
  27176. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  27177. * @example
  27178. *
  27179. * var object = { 'a': 1, 'b': 2 };
  27180. *
  27181. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  27182. * // => true
  27183. *
  27184. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  27185. * // => false
  27186. */
  27187. function conformsTo(object, source) {
  27188. return source == null || baseConformsTo(object, source, keys(source));
  27189. }
  27190. /**
  27191. * Performs a
  27192. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  27193. * comparison between two values to determine if they are equivalent.
  27194. *
  27195. * @static
  27196. * @memberOf _
  27197. * @since 4.0.0
  27198. * @category Lang
  27199. * @param {*} value The value to compare.
  27200. * @param {*} other The other value to compare.
  27201. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27202. * @example
  27203. *
  27204. * var object = { 'a': 1 };
  27205. * var other = { 'a': 1 };
  27206. *
  27207. * _.eq(object, object);
  27208. * // => true
  27209. *
  27210. * _.eq(object, other);
  27211. * // => false
  27212. *
  27213. * _.eq('a', 'a');
  27214. * // => true
  27215. *
  27216. * _.eq('a', Object('a'));
  27217. * // => false
  27218. *
  27219. * _.eq(NaN, NaN);
  27220. * // => true
  27221. */
  27222. function eq(value, other) {
  27223. return value === other || (value !== value && other !== other);
  27224. }
  27225. /**
  27226. * Checks if `value` is greater than `other`.
  27227. *
  27228. * @static
  27229. * @memberOf _
  27230. * @since 3.9.0
  27231. * @category Lang
  27232. * @param {*} value The value to compare.
  27233. * @param {*} other The other value to compare.
  27234. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  27235. * else `false`.
  27236. * @see _.lt
  27237. * @example
  27238. *
  27239. * _.gt(3, 1);
  27240. * // => true
  27241. *
  27242. * _.gt(3, 3);
  27243. * // => false
  27244. *
  27245. * _.gt(1, 3);
  27246. * // => false
  27247. */
  27248. var gt = createRelationalOperation(baseGt);
  27249. /**
  27250. * Checks if `value` is greater than or equal to `other`.
  27251. *
  27252. * @static
  27253. * @memberOf _
  27254. * @since 3.9.0
  27255. * @category Lang
  27256. * @param {*} value The value to compare.
  27257. * @param {*} other The other value to compare.
  27258. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  27259. * `other`, else `false`.
  27260. * @see _.lte
  27261. * @example
  27262. *
  27263. * _.gte(3, 1);
  27264. * // => true
  27265. *
  27266. * _.gte(3, 3);
  27267. * // => true
  27268. *
  27269. * _.gte(1, 3);
  27270. * // => false
  27271. */
  27272. var gte = createRelationalOperation(function(value, other) {
  27273. return value >= other;
  27274. });
  27275. /**
  27276. * Checks if `value` is likely an `arguments` object.
  27277. *
  27278. * @static
  27279. * @memberOf _
  27280. * @since 0.1.0
  27281. * @category Lang
  27282. * @param {*} value The value to check.
  27283. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  27284. * else `false`.
  27285. * @example
  27286. *
  27287. * _.isArguments(function() { return arguments; }());
  27288. * // => true
  27289. *
  27290. * _.isArguments([1, 2, 3]);
  27291. * // => false
  27292. */
  27293. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  27294. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  27295. !propertyIsEnumerable.call(value, 'callee');
  27296. };
  27297. /**
  27298. * Checks if `value` is classified as an `Array` object.
  27299. *
  27300. * @static
  27301. * @memberOf _
  27302. * @since 0.1.0
  27303. * @category Lang
  27304. * @param {*} value The value to check.
  27305. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  27306. * @example
  27307. *
  27308. * _.isArray([1, 2, 3]);
  27309. * // => true
  27310. *
  27311. * _.isArray(document.body.children);
  27312. * // => false
  27313. *
  27314. * _.isArray('abc');
  27315. * // => false
  27316. *
  27317. * _.isArray(_.noop);
  27318. * // => false
  27319. */
  27320. var isArray = Array.isArray;
  27321. /**
  27322. * Checks if `value` is classified as an `ArrayBuffer` object.
  27323. *
  27324. * @static
  27325. * @memberOf _
  27326. * @since 4.3.0
  27327. * @category Lang
  27328. * @param {*} value The value to check.
  27329. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  27330. * @example
  27331. *
  27332. * _.isArrayBuffer(new ArrayBuffer(2));
  27333. * // => true
  27334. *
  27335. * _.isArrayBuffer(new Array(2));
  27336. * // => false
  27337. */
  27338. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  27339. /**
  27340. * Checks if `value` is array-like. A value is considered array-like if it's
  27341. * not a function and has a `value.length` that's an integer greater than or
  27342. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  27343. *
  27344. * @static
  27345. * @memberOf _
  27346. * @since 4.0.0
  27347. * @category Lang
  27348. * @param {*} value The value to check.
  27349. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  27350. * @example
  27351. *
  27352. * _.isArrayLike([1, 2, 3]);
  27353. * // => true
  27354. *
  27355. * _.isArrayLike(document.body.children);
  27356. * // => true
  27357. *
  27358. * _.isArrayLike('abc');
  27359. * // => true
  27360. *
  27361. * _.isArrayLike(_.noop);
  27362. * // => false
  27363. */
  27364. function isArrayLike(value) {
  27365. return value != null && isLength(value.length) && !isFunction(value);
  27366. }
  27367. /**
  27368. * This method is like `_.isArrayLike` except that it also checks if `value`
  27369. * is an object.
  27370. *
  27371. * @static
  27372. * @memberOf _
  27373. * @since 4.0.0
  27374. * @category Lang
  27375. * @param {*} value The value to check.
  27376. * @returns {boolean} Returns `true` if `value` is an array-like object,
  27377. * else `false`.
  27378. * @example
  27379. *
  27380. * _.isArrayLikeObject([1, 2, 3]);
  27381. * // => true
  27382. *
  27383. * _.isArrayLikeObject(document.body.children);
  27384. * // => true
  27385. *
  27386. * _.isArrayLikeObject('abc');
  27387. * // => false
  27388. *
  27389. * _.isArrayLikeObject(_.noop);
  27390. * // => false
  27391. */
  27392. function isArrayLikeObject(value) {
  27393. return isObjectLike(value) && isArrayLike(value);
  27394. }
  27395. /**
  27396. * Checks if `value` is classified as a boolean primitive or object.
  27397. *
  27398. * @static
  27399. * @memberOf _
  27400. * @since 0.1.0
  27401. * @category Lang
  27402. * @param {*} value The value to check.
  27403. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  27404. * @example
  27405. *
  27406. * _.isBoolean(false);
  27407. * // => true
  27408. *
  27409. * _.isBoolean(null);
  27410. * // => false
  27411. */
  27412. function isBoolean(value) {
  27413. return value === true || value === false ||
  27414. (isObjectLike(value) && baseGetTag(value) == boolTag);
  27415. }
  27416. /**
  27417. * Checks if `value` is a buffer.
  27418. *
  27419. * @static
  27420. * @memberOf _
  27421. * @since 4.3.0
  27422. * @category Lang
  27423. * @param {*} value The value to check.
  27424. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  27425. * @example
  27426. *
  27427. * _.isBuffer(new Buffer(2));
  27428. * // => true
  27429. *
  27430. * _.isBuffer(new Uint8Array(2));
  27431. * // => false
  27432. */
  27433. var isBuffer = nativeIsBuffer || stubFalse;
  27434. /**
  27435. * Checks if `value` is classified as a `Date` object.
  27436. *
  27437. * @static
  27438. * @memberOf _
  27439. * @since 0.1.0
  27440. * @category Lang
  27441. * @param {*} value The value to check.
  27442. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  27443. * @example
  27444. *
  27445. * _.isDate(new Date);
  27446. * // => true
  27447. *
  27448. * _.isDate('Mon April 23 2012');
  27449. * // => false
  27450. */
  27451. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  27452. /**
  27453. * Checks if `value` is likely a DOM element.
  27454. *
  27455. * @static
  27456. * @memberOf _
  27457. * @since 0.1.0
  27458. * @category Lang
  27459. * @param {*} value The value to check.
  27460. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  27461. * @example
  27462. *
  27463. * _.isElement(document.body);
  27464. * // => true
  27465. *
  27466. * _.isElement('<body>');
  27467. * // => false
  27468. */
  27469. function isElement(value) {
  27470. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  27471. }
  27472. /**
  27473. * Checks if `value` is an empty object, collection, map, or set.
  27474. *
  27475. * Objects are considered empty if they have no own enumerable string keyed
  27476. * properties.
  27477. *
  27478. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  27479. * jQuery-like collections are considered empty if they have a `length` of `0`.
  27480. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  27481. *
  27482. * @static
  27483. * @memberOf _
  27484. * @since 0.1.0
  27485. * @category Lang
  27486. * @param {*} value The value to check.
  27487. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  27488. * @example
  27489. *
  27490. * _.isEmpty(null);
  27491. * // => true
  27492. *
  27493. * _.isEmpty(true);
  27494. * // => true
  27495. *
  27496. * _.isEmpty(1);
  27497. * // => true
  27498. *
  27499. * _.isEmpty([1, 2, 3]);
  27500. * // => false
  27501. *
  27502. * _.isEmpty({ 'a': 1 });
  27503. * // => false
  27504. */
  27505. function isEmpty(value) {
  27506. if (value == null) {
  27507. return true;
  27508. }
  27509. if (isArrayLike(value) &&
  27510. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  27511. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  27512. return !value.length;
  27513. }
  27514. var tag = getTag(value);
  27515. if (tag == mapTag || tag == setTag) {
  27516. return !value.size;
  27517. }
  27518. if (isPrototype(value)) {
  27519. return !baseKeys(value).length;
  27520. }
  27521. for (var key in value) {
  27522. if (hasOwnProperty.call(value, key)) {
  27523. return false;
  27524. }
  27525. }
  27526. return true;
  27527. }
  27528. /**
  27529. * Performs a deep comparison between two values to determine if they are
  27530. * equivalent.
  27531. *
  27532. * **Note:** This method supports comparing arrays, array buffers, booleans,
  27533. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  27534. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  27535. * by their own, not inherited, enumerable properties. Functions and DOM
  27536. * nodes are compared by strict equality, i.e. `===`.
  27537. *
  27538. * @static
  27539. * @memberOf _
  27540. * @since 0.1.0
  27541. * @category Lang
  27542. * @param {*} value The value to compare.
  27543. * @param {*} other The other value to compare.
  27544. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27545. * @example
  27546. *
  27547. * var object = { 'a': 1 };
  27548. * var other = { 'a': 1 };
  27549. *
  27550. * _.isEqual(object, other);
  27551. * // => true
  27552. *
  27553. * object === other;
  27554. * // => false
  27555. */
  27556. function isEqual(value, other) {
  27557. return baseIsEqual(value, other);
  27558. }
  27559. /**
  27560. * This method is like `_.isEqual` except that it accepts `customizer` which
  27561. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27562. * are handled by the method instead. The `customizer` is invoked with up to
  27563. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  27564. *
  27565. * @static
  27566. * @memberOf _
  27567. * @since 4.0.0
  27568. * @category Lang
  27569. * @param {*} value The value to compare.
  27570. * @param {*} other The other value to compare.
  27571. * @param {Function} [customizer] The function to customize comparisons.
  27572. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  27573. * @example
  27574. *
  27575. * function isGreeting(value) {
  27576. * return /^h(?:i|ello)$/.test(value);
  27577. * }
  27578. *
  27579. * function customizer(objValue, othValue) {
  27580. * if (isGreeting(objValue) && isGreeting(othValue)) {
  27581. * return true;
  27582. * }
  27583. * }
  27584. *
  27585. * var array = ['hello', 'goodbye'];
  27586. * var other = ['hi', 'goodbye'];
  27587. *
  27588. * _.isEqualWith(array, other, customizer);
  27589. * // => true
  27590. */
  27591. function isEqualWith(value, other, customizer) {
  27592. customizer = typeof customizer == 'function' ? customizer : undefined;
  27593. var result = customizer ? customizer(value, other) : undefined;
  27594. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  27595. }
  27596. /**
  27597. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  27598. * `SyntaxError`, `TypeError`, or `URIError` object.
  27599. *
  27600. * @static
  27601. * @memberOf _
  27602. * @since 3.0.0
  27603. * @category Lang
  27604. * @param {*} value The value to check.
  27605. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  27606. * @example
  27607. *
  27608. * _.isError(new Error);
  27609. * // => true
  27610. *
  27611. * _.isError(Error);
  27612. * // => false
  27613. */
  27614. function isError(value) {
  27615. if (!isObjectLike(value)) {
  27616. return false;
  27617. }
  27618. var tag = baseGetTag(value);
  27619. return tag == errorTag || tag == domExcTag ||
  27620. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  27621. }
  27622. /**
  27623. * Checks if `value` is a finite primitive number.
  27624. *
  27625. * **Note:** This method is based on
  27626. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  27627. *
  27628. * @static
  27629. * @memberOf _
  27630. * @since 0.1.0
  27631. * @category Lang
  27632. * @param {*} value The value to check.
  27633. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  27634. * @example
  27635. *
  27636. * _.isFinite(3);
  27637. * // => true
  27638. *
  27639. * _.isFinite(Number.MIN_VALUE);
  27640. * // => true
  27641. *
  27642. * _.isFinite(Infinity);
  27643. * // => false
  27644. *
  27645. * _.isFinite('3');
  27646. * // => false
  27647. */
  27648. function isFinite(value) {
  27649. return typeof value == 'number' && nativeIsFinite(value);
  27650. }
  27651. /**
  27652. * Checks if `value` is classified as a `Function` object.
  27653. *
  27654. * @static
  27655. * @memberOf _
  27656. * @since 0.1.0
  27657. * @category Lang
  27658. * @param {*} value The value to check.
  27659. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  27660. * @example
  27661. *
  27662. * _.isFunction(_);
  27663. * // => true
  27664. *
  27665. * _.isFunction(/abc/);
  27666. * // => false
  27667. */
  27668. function isFunction(value) {
  27669. if (!isObject(value)) {
  27670. return false;
  27671. }
  27672. // The use of `Object#toString` avoids issues with the `typeof` operator
  27673. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  27674. var tag = baseGetTag(value);
  27675. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  27676. }
  27677. /**
  27678. * Checks if `value` is an integer.
  27679. *
  27680. * **Note:** This method is based on
  27681. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  27682. *
  27683. * @static
  27684. * @memberOf _
  27685. * @since 4.0.0
  27686. * @category Lang
  27687. * @param {*} value The value to check.
  27688. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  27689. * @example
  27690. *
  27691. * _.isInteger(3);
  27692. * // => true
  27693. *
  27694. * _.isInteger(Number.MIN_VALUE);
  27695. * // => false
  27696. *
  27697. * _.isInteger(Infinity);
  27698. * // => false
  27699. *
  27700. * _.isInteger('3');
  27701. * // => false
  27702. */
  27703. function isInteger(value) {
  27704. return typeof value == 'number' && value == toInteger(value);
  27705. }
  27706. /**
  27707. * Checks if `value` is a valid array-like length.
  27708. *
  27709. * **Note:** This method is loosely based on
  27710. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  27711. *
  27712. * @static
  27713. * @memberOf _
  27714. * @since 4.0.0
  27715. * @category Lang
  27716. * @param {*} value The value to check.
  27717. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  27718. * @example
  27719. *
  27720. * _.isLength(3);
  27721. * // => true
  27722. *
  27723. * _.isLength(Number.MIN_VALUE);
  27724. * // => false
  27725. *
  27726. * _.isLength(Infinity);
  27727. * // => false
  27728. *
  27729. * _.isLength('3');
  27730. * // => false
  27731. */
  27732. function isLength(value) {
  27733. return typeof value == 'number' &&
  27734. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  27735. }
  27736. /**
  27737. * Checks if `value` is the
  27738. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  27739. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  27740. *
  27741. * @static
  27742. * @memberOf _
  27743. * @since 0.1.0
  27744. * @category Lang
  27745. * @param {*} value The value to check.
  27746. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  27747. * @example
  27748. *
  27749. * _.isObject({});
  27750. * // => true
  27751. *
  27752. * _.isObject([1, 2, 3]);
  27753. * // => true
  27754. *
  27755. * _.isObject(_.noop);
  27756. * // => true
  27757. *
  27758. * _.isObject(null);
  27759. * // => false
  27760. */
  27761. function isObject(value) {
  27762. var type = typeof value;
  27763. return value != null && (type == 'object' || type == 'function');
  27764. }
  27765. /**
  27766. * Checks if `value` is object-like. A value is object-like if it's not `null`
  27767. * and has a `typeof` result of "object".
  27768. *
  27769. * @static
  27770. * @memberOf _
  27771. * @since 4.0.0
  27772. * @category Lang
  27773. * @param {*} value The value to check.
  27774. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  27775. * @example
  27776. *
  27777. * _.isObjectLike({});
  27778. * // => true
  27779. *
  27780. * _.isObjectLike([1, 2, 3]);
  27781. * // => true
  27782. *
  27783. * _.isObjectLike(_.noop);
  27784. * // => false
  27785. *
  27786. * _.isObjectLike(null);
  27787. * // => false
  27788. */
  27789. function isObjectLike(value) {
  27790. return value != null && typeof value == 'object';
  27791. }
  27792. /**
  27793. * Checks if `value` is classified as a `Map` object.
  27794. *
  27795. * @static
  27796. * @memberOf _
  27797. * @since 4.3.0
  27798. * @category Lang
  27799. * @param {*} value The value to check.
  27800. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  27801. * @example
  27802. *
  27803. * _.isMap(new Map);
  27804. * // => true
  27805. *
  27806. * _.isMap(new WeakMap);
  27807. * // => false
  27808. */
  27809. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  27810. /**
  27811. * Performs a partial deep comparison between `object` and `source` to
  27812. * determine if `object` contains equivalent property values.
  27813. *
  27814. * **Note:** This method is equivalent to `_.matches` when `source` is
  27815. * partially applied.
  27816. *
  27817. * Partial comparisons will match empty array and empty object `source`
  27818. * values against any array or object value, respectively. See `_.isEqual`
  27819. * for a list of supported value comparisons.
  27820. *
  27821. * @static
  27822. * @memberOf _
  27823. * @since 3.0.0
  27824. * @category Lang
  27825. * @param {Object} object The object to inspect.
  27826. * @param {Object} source The object of property values to match.
  27827. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27828. * @example
  27829. *
  27830. * var object = { 'a': 1, 'b': 2 };
  27831. *
  27832. * _.isMatch(object, { 'b': 2 });
  27833. * // => true
  27834. *
  27835. * _.isMatch(object, { 'b': 1 });
  27836. * // => false
  27837. */
  27838. function isMatch(object, source) {
  27839. return object === source || baseIsMatch(object, source, getMatchData(source));
  27840. }
  27841. /**
  27842. * This method is like `_.isMatch` except that it accepts `customizer` which
  27843. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  27844. * are handled by the method instead. The `customizer` is invoked with five
  27845. * arguments: (objValue, srcValue, index|key, object, source).
  27846. *
  27847. * @static
  27848. * @memberOf _
  27849. * @since 4.0.0
  27850. * @category Lang
  27851. * @param {Object} object The object to inspect.
  27852. * @param {Object} source The object of property values to match.
  27853. * @param {Function} [customizer] The function to customize comparisons.
  27854. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  27855. * @example
  27856. *
  27857. * function isGreeting(value) {
  27858. * return /^h(?:i|ello)$/.test(value);
  27859. * }
  27860. *
  27861. * function customizer(objValue, srcValue) {
  27862. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  27863. * return true;
  27864. * }
  27865. * }
  27866. *
  27867. * var object = { 'greeting': 'hello' };
  27868. * var source = { 'greeting': 'hi' };
  27869. *
  27870. * _.isMatchWith(object, source, customizer);
  27871. * // => true
  27872. */
  27873. function isMatchWith(object, source, customizer) {
  27874. customizer = typeof customizer == 'function' ? customizer : undefined;
  27875. return baseIsMatch(object, source, getMatchData(source), customizer);
  27876. }
  27877. /**
  27878. * Checks if `value` is `NaN`.
  27879. *
  27880. * **Note:** This method is based on
  27881. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  27882. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  27883. * `undefined` and other non-number values.
  27884. *
  27885. * @static
  27886. * @memberOf _
  27887. * @since 0.1.0
  27888. * @category Lang
  27889. * @param {*} value The value to check.
  27890. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  27891. * @example
  27892. *
  27893. * _.isNaN(NaN);
  27894. * // => true
  27895. *
  27896. * _.isNaN(new Number(NaN));
  27897. * // => true
  27898. *
  27899. * isNaN(undefined);
  27900. * // => true
  27901. *
  27902. * _.isNaN(undefined);
  27903. * // => false
  27904. */
  27905. function isNaN(value) {
  27906. // An `NaN` primitive is the only value that is not equal to itself.
  27907. // Perform the `toStringTag` check first to avoid errors with some
  27908. // ActiveX objects in IE.
  27909. return isNumber(value) && value != +value;
  27910. }
  27911. /**
  27912. * Checks if `value` is a pristine native function.
  27913. *
  27914. * **Note:** This method can't reliably detect native functions in the presence
  27915. * of the core-js package because core-js circumvents this kind of detection.
  27916. * Despite multiple requests, the core-js maintainer has made it clear: any
  27917. * attempt to fix the detection will be obstructed. As a result, we're left
  27918. * with little choice but to throw an error. Unfortunately, this also affects
  27919. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  27920. * which rely on core-js.
  27921. *
  27922. * @static
  27923. * @memberOf _
  27924. * @since 3.0.0
  27925. * @category Lang
  27926. * @param {*} value The value to check.
  27927. * @returns {boolean} Returns `true` if `value` is a native function,
  27928. * else `false`.
  27929. * @example
  27930. *
  27931. * _.isNative(Array.prototype.push);
  27932. * // => true
  27933. *
  27934. * _.isNative(_);
  27935. * // => false
  27936. */
  27937. function isNative(value) {
  27938. if (isMaskable(value)) {
  27939. throw new Error(CORE_ERROR_TEXT);
  27940. }
  27941. return baseIsNative(value);
  27942. }
  27943. /**
  27944. * Checks if `value` is `null`.
  27945. *
  27946. * @static
  27947. * @memberOf _
  27948. * @since 0.1.0
  27949. * @category Lang
  27950. * @param {*} value The value to check.
  27951. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  27952. * @example
  27953. *
  27954. * _.isNull(null);
  27955. * // => true
  27956. *
  27957. * _.isNull(void 0);
  27958. * // => false
  27959. */
  27960. function isNull(value) {
  27961. return value === null;
  27962. }
  27963. /**
  27964. * Checks if `value` is `null` or `undefined`.
  27965. *
  27966. * @static
  27967. * @memberOf _
  27968. * @since 4.0.0
  27969. * @category Lang
  27970. * @param {*} value The value to check.
  27971. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  27972. * @example
  27973. *
  27974. * _.isNil(null);
  27975. * // => true
  27976. *
  27977. * _.isNil(void 0);
  27978. * // => true
  27979. *
  27980. * _.isNil(NaN);
  27981. * // => false
  27982. */
  27983. function isNil(value) {
  27984. return value == null;
  27985. }
  27986. /**
  27987. * Checks if `value` is classified as a `Number` primitive or object.
  27988. *
  27989. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  27990. * classified as numbers, use the `_.isFinite` method.
  27991. *
  27992. * @static
  27993. * @memberOf _
  27994. * @since 0.1.0
  27995. * @category Lang
  27996. * @param {*} value The value to check.
  27997. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  27998. * @example
  27999. *
  28000. * _.isNumber(3);
  28001. * // => true
  28002. *
  28003. * _.isNumber(Number.MIN_VALUE);
  28004. * // => true
  28005. *
  28006. * _.isNumber(Infinity);
  28007. * // => true
  28008. *
  28009. * _.isNumber('3');
  28010. * // => false
  28011. */
  28012. function isNumber(value) {
  28013. return typeof value == 'number' ||
  28014. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28015. }
  28016. /**
  28017. * Checks if `value` is a plain object, that is, an object created by the
  28018. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28019. *
  28020. * @static
  28021. * @memberOf _
  28022. * @since 0.8.0
  28023. * @category Lang
  28024. * @param {*} value The value to check.
  28025. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28026. * @example
  28027. *
  28028. * function Foo() {
  28029. * this.a = 1;
  28030. * }
  28031. *
  28032. * _.isPlainObject(new Foo);
  28033. * // => false
  28034. *
  28035. * _.isPlainObject([1, 2, 3]);
  28036. * // => false
  28037. *
  28038. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28039. * // => true
  28040. *
  28041. * _.isPlainObject(Object.create(null));
  28042. * // => true
  28043. */
  28044. function isPlainObject(value) {
  28045. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28046. return false;
  28047. }
  28048. var proto = getPrototype(value);
  28049. if (proto === null) {
  28050. return true;
  28051. }
  28052. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28053. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28054. funcToString.call(Ctor) == objectCtorString;
  28055. }
  28056. /**
  28057. * Checks if `value` is classified as a `RegExp` object.
  28058. *
  28059. * @static
  28060. * @memberOf _
  28061. * @since 0.1.0
  28062. * @category Lang
  28063. * @param {*} value The value to check.
  28064. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28065. * @example
  28066. *
  28067. * _.isRegExp(/abc/);
  28068. * // => true
  28069. *
  28070. * _.isRegExp('/abc/');
  28071. * // => false
  28072. */
  28073. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  28074. /**
  28075. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  28076. * double precision number which isn't the result of a rounded unsafe integer.
  28077. *
  28078. * **Note:** This method is based on
  28079. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  28080. *
  28081. * @static
  28082. * @memberOf _
  28083. * @since 4.0.0
  28084. * @category Lang
  28085. * @param {*} value The value to check.
  28086. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  28087. * @example
  28088. *
  28089. * _.isSafeInteger(3);
  28090. * // => true
  28091. *
  28092. * _.isSafeInteger(Number.MIN_VALUE);
  28093. * // => false
  28094. *
  28095. * _.isSafeInteger(Infinity);
  28096. * // => false
  28097. *
  28098. * _.isSafeInteger('3');
  28099. * // => false
  28100. */
  28101. function isSafeInteger(value) {
  28102. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  28103. }
  28104. /**
  28105. * Checks if `value` is classified as a `Set` object.
  28106. *
  28107. * @static
  28108. * @memberOf _
  28109. * @since 4.3.0
  28110. * @category Lang
  28111. * @param {*} value The value to check.
  28112. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  28113. * @example
  28114. *
  28115. * _.isSet(new Set);
  28116. * // => true
  28117. *
  28118. * _.isSet(new WeakSet);
  28119. * // => false
  28120. */
  28121. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  28122. /**
  28123. * Checks if `value` is classified as a `String` primitive or object.
  28124. *
  28125. * @static
  28126. * @since 0.1.0
  28127. * @memberOf _
  28128. * @category Lang
  28129. * @param {*} value The value to check.
  28130. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  28131. * @example
  28132. *
  28133. * _.isString('abc');
  28134. * // => true
  28135. *
  28136. * _.isString(1);
  28137. * // => false
  28138. */
  28139. function isString(value) {
  28140. return typeof value == 'string' ||
  28141. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  28142. }
  28143. /**
  28144. * Checks if `value` is classified as a `Symbol` primitive or object.
  28145. *
  28146. * @static
  28147. * @memberOf _
  28148. * @since 4.0.0
  28149. * @category Lang
  28150. * @param {*} value The value to check.
  28151. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  28152. * @example
  28153. *
  28154. * _.isSymbol(Symbol.iterator);
  28155. * // => true
  28156. *
  28157. * _.isSymbol('abc');
  28158. * // => false
  28159. */
  28160. function isSymbol(value) {
  28161. return typeof value == 'symbol' ||
  28162. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  28163. }
  28164. /**
  28165. * Checks if `value` is classified as a typed array.
  28166. *
  28167. * @static
  28168. * @memberOf _
  28169. * @since 3.0.0
  28170. * @category Lang
  28171. * @param {*} value The value to check.
  28172. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  28173. * @example
  28174. *
  28175. * _.isTypedArray(new Uint8Array);
  28176. * // => true
  28177. *
  28178. * _.isTypedArray([]);
  28179. * // => false
  28180. */
  28181. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  28182. /**
  28183. * Checks if `value` is `undefined`.
  28184. *
  28185. * @static
  28186. * @since 0.1.0
  28187. * @memberOf _
  28188. * @category Lang
  28189. * @param {*} value The value to check.
  28190. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  28191. * @example
  28192. *
  28193. * _.isUndefined(void 0);
  28194. * // => true
  28195. *
  28196. * _.isUndefined(null);
  28197. * // => false
  28198. */
  28199. function isUndefined(value) {
  28200. return value === undefined;
  28201. }
  28202. /**
  28203. * Checks if `value` is classified as a `WeakMap` object.
  28204. *
  28205. * @static
  28206. * @memberOf _
  28207. * @since 4.3.0
  28208. * @category Lang
  28209. * @param {*} value The value to check.
  28210. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  28211. * @example
  28212. *
  28213. * _.isWeakMap(new WeakMap);
  28214. * // => true
  28215. *
  28216. * _.isWeakMap(new Map);
  28217. * // => false
  28218. */
  28219. function isWeakMap(value) {
  28220. return isObjectLike(value) && getTag(value) == weakMapTag;
  28221. }
  28222. /**
  28223. * Checks if `value` is classified as a `WeakSet` object.
  28224. *
  28225. * @static
  28226. * @memberOf _
  28227. * @since 4.3.0
  28228. * @category Lang
  28229. * @param {*} value The value to check.
  28230. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  28231. * @example
  28232. *
  28233. * _.isWeakSet(new WeakSet);
  28234. * // => true
  28235. *
  28236. * _.isWeakSet(new Set);
  28237. * // => false
  28238. */
  28239. function isWeakSet(value) {
  28240. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  28241. }
  28242. /**
  28243. * Checks if `value` is less than `other`.
  28244. *
  28245. * @static
  28246. * @memberOf _
  28247. * @since 3.9.0
  28248. * @category Lang
  28249. * @param {*} value The value to compare.
  28250. * @param {*} other The other value to compare.
  28251. * @returns {boolean} Returns `true` if `value` is less than `other`,
  28252. * else `false`.
  28253. * @see _.gt
  28254. * @example
  28255. *
  28256. * _.lt(1, 3);
  28257. * // => true
  28258. *
  28259. * _.lt(3, 3);
  28260. * // => false
  28261. *
  28262. * _.lt(3, 1);
  28263. * // => false
  28264. */
  28265. var lt = createRelationalOperation(baseLt);
  28266. /**
  28267. * Checks if `value` is less than or equal to `other`.
  28268. *
  28269. * @static
  28270. * @memberOf _
  28271. * @since 3.9.0
  28272. * @category Lang
  28273. * @param {*} value The value to compare.
  28274. * @param {*} other The other value to compare.
  28275. * @returns {boolean} Returns `true` if `value` is less than or equal to
  28276. * `other`, else `false`.
  28277. * @see _.gte
  28278. * @example
  28279. *
  28280. * _.lte(1, 3);
  28281. * // => true
  28282. *
  28283. * _.lte(3, 3);
  28284. * // => true
  28285. *
  28286. * _.lte(3, 1);
  28287. * // => false
  28288. */
  28289. var lte = createRelationalOperation(function(value, other) {
  28290. return value <= other;
  28291. });
  28292. /**
  28293. * Converts `value` to an array.
  28294. *
  28295. * @static
  28296. * @since 0.1.0
  28297. * @memberOf _
  28298. * @category Lang
  28299. * @param {*} value The value to convert.
  28300. * @returns {Array} Returns the converted array.
  28301. * @example
  28302. *
  28303. * _.toArray({ 'a': 1, 'b': 2 });
  28304. * // => [1, 2]
  28305. *
  28306. * _.toArray('abc');
  28307. * // => ['a', 'b', 'c']
  28308. *
  28309. * _.toArray(1);
  28310. * // => []
  28311. *
  28312. * _.toArray(null);
  28313. * // => []
  28314. */
  28315. function toArray(value) {
  28316. if (!value) {
  28317. return [];
  28318. }
  28319. if (isArrayLike(value)) {
  28320. return isString(value) ? stringToArray(value) : copyArray(value);
  28321. }
  28322. if (symIterator && value[symIterator]) {
  28323. return iteratorToArray(value[symIterator]());
  28324. }
  28325. var tag = getTag(value),
  28326. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  28327. return func(value);
  28328. }
  28329. /**
  28330. * Converts `value` to a finite number.
  28331. *
  28332. * @static
  28333. * @memberOf _
  28334. * @since 4.12.0
  28335. * @category Lang
  28336. * @param {*} value The value to convert.
  28337. * @returns {number} Returns the converted number.
  28338. * @example
  28339. *
  28340. * _.toFinite(3.2);
  28341. * // => 3.2
  28342. *
  28343. * _.toFinite(Number.MIN_VALUE);
  28344. * // => 5e-324
  28345. *
  28346. * _.toFinite(Infinity);
  28347. * // => 1.7976931348623157e+308
  28348. *
  28349. * _.toFinite('3.2');
  28350. * // => 3.2
  28351. */
  28352. function toFinite(value) {
  28353. if (!value) {
  28354. return value === 0 ? value : 0;
  28355. }
  28356. value = toNumber(value);
  28357. if (value === INFINITY || value === -INFINITY) {
  28358. var sign = (value < 0 ? -1 : 1);
  28359. return sign * MAX_INTEGER;
  28360. }
  28361. return value === value ? value : 0;
  28362. }
  28363. /**
  28364. * Converts `value` to an integer.
  28365. *
  28366. * **Note:** This method is loosely based on
  28367. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  28368. *
  28369. * @static
  28370. * @memberOf _
  28371. * @since 4.0.0
  28372. * @category Lang
  28373. * @param {*} value The value to convert.
  28374. * @returns {number} Returns the converted integer.
  28375. * @example
  28376. *
  28377. * _.toInteger(3.2);
  28378. * // => 3
  28379. *
  28380. * _.toInteger(Number.MIN_VALUE);
  28381. * // => 0
  28382. *
  28383. * _.toInteger(Infinity);
  28384. * // => 1.7976931348623157e+308
  28385. *
  28386. * _.toInteger('3.2');
  28387. * // => 3
  28388. */
  28389. function toInteger(value) {
  28390. var result = toFinite(value),
  28391. remainder = result % 1;
  28392. return result === result ? (remainder ? result - remainder : result) : 0;
  28393. }
  28394. /**
  28395. * Converts `value` to an integer suitable for use as the length of an
  28396. * array-like object.
  28397. *
  28398. * **Note:** This method is based on
  28399. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28400. *
  28401. * @static
  28402. * @memberOf _
  28403. * @since 4.0.0
  28404. * @category Lang
  28405. * @param {*} value The value to convert.
  28406. * @returns {number} Returns the converted integer.
  28407. * @example
  28408. *
  28409. * _.toLength(3.2);
  28410. * // => 3
  28411. *
  28412. * _.toLength(Number.MIN_VALUE);
  28413. * // => 0
  28414. *
  28415. * _.toLength(Infinity);
  28416. * // => 4294967295
  28417. *
  28418. * _.toLength('3.2');
  28419. * // => 3
  28420. */
  28421. function toLength(value) {
  28422. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  28423. }
  28424. /**
  28425. * Converts `value` to a number.
  28426. *
  28427. * @static
  28428. * @memberOf _
  28429. * @since 4.0.0
  28430. * @category Lang
  28431. * @param {*} value The value to process.
  28432. * @returns {number} Returns the number.
  28433. * @example
  28434. *
  28435. * _.toNumber(3.2);
  28436. * // => 3.2
  28437. *
  28438. * _.toNumber(Number.MIN_VALUE);
  28439. * // => 5e-324
  28440. *
  28441. * _.toNumber(Infinity);
  28442. * // => Infinity
  28443. *
  28444. * _.toNumber('3.2');
  28445. * // => 3.2
  28446. */
  28447. function toNumber(value) {
  28448. if (typeof value == 'number') {
  28449. return value;
  28450. }
  28451. if (isSymbol(value)) {
  28452. return NAN;
  28453. }
  28454. if (isObject(value)) {
  28455. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  28456. value = isObject(other) ? (other + '') : other;
  28457. }
  28458. if (typeof value != 'string') {
  28459. return value === 0 ? value : +value;
  28460. }
  28461. value = value.replace(reTrim, '');
  28462. var isBinary = reIsBinary.test(value);
  28463. return (isBinary || reIsOctal.test(value))
  28464. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  28465. : (reIsBadHex.test(value) ? NAN : +value);
  28466. }
  28467. /**
  28468. * Converts `value` to a plain object flattening inherited enumerable string
  28469. * keyed properties of `value` to own properties of the plain object.
  28470. *
  28471. * @static
  28472. * @memberOf _
  28473. * @since 3.0.0
  28474. * @category Lang
  28475. * @param {*} value The value to convert.
  28476. * @returns {Object} Returns the converted plain object.
  28477. * @example
  28478. *
  28479. * function Foo() {
  28480. * this.b = 2;
  28481. * }
  28482. *
  28483. * Foo.prototype.c = 3;
  28484. *
  28485. * _.assign({ 'a': 1 }, new Foo);
  28486. * // => { 'a': 1, 'b': 2 }
  28487. *
  28488. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  28489. * // => { 'a': 1, 'b': 2, 'c': 3 }
  28490. */
  28491. function toPlainObject(value) {
  28492. return copyObject(value, keysIn(value));
  28493. }
  28494. /**
  28495. * Converts `value` to a safe integer. A safe integer can be compared and
  28496. * represented correctly.
  28497. *
  28498. * @static
  28499. * @memberOf _
  28500. * @since 4.0.0
  28501. * @category Lang
  28502. * @param {*} value The value to convert.
  28503. * @returns {number} Returns the converted integer.
  28504. * @example
  28505. *
  28506. * _.toSafeInteger(3.2);
  28507. * // => 3
  28508. *
  28509. * _.toSafeInteger(Number.MIN_VALUE);
  28510. * // => 0
  28511. *
  28512. * _.toSafeInteger(Infinity);
  28513. * // => 9007199254740991
  28514. *
  28515. * _.toSafeInteger('3.2');
  28516. * // => 3
  28517. */
  28518. function toSafeInteger(value) {
  28519. return value
  28520. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  28521. : (value === 0 ? value : 0);
  28522. }
  28523. /**
  28524. * Converts `value` to a string. An empty string is returned for `null`
  28525. * and `undefined` values. The sign of `-0` is preserved.
  28526. *
  28527. * @static
  28528. * @memberOf _
  28529. * @since 4.0.0
  28530. * @category Lang
  28531. * @param {*} value The value to convert.
  28532. * @returns {string} Returns the converted string.
  28533. * @example
  28534. *
  28535. * _.toString(null);
  28536. * // => ''
  28537. *
  28538. * _.toString(-0);
  28539. * // => '-0'
  28540. *
  28541. * _.toString([1, 2, 3]);
  28542. * // => '1,2,3'
  28543. */
  28544. function toString(value) {
  28545. return value == null ? '' : baseToString(value);
  28546. }
  28547. /*------------------------------------------------------------------------*/
  28548. /**
  28549. * Assigns own enumerable string keyed properties of source objects to the
  28550. * destination object. Source objects are applied from left to right.
  28551. * Subsequent sources overwrite property assignments of previous sources.
  28552. *
  28553. * **Note:** This method mutates `object` and is loosely based on
  28554. * [`Object.assign`](https://mdn.io/Object/assign).
  28555. *
  28556. * @static
  28557. * @memberOf _
  28558. * @since 0.10.0
  28559. * @category Object
  28560. * @param {Object} object The destination object.
  28561. * @param {...Object} [sources] The source objects.
  28562. * @returns {Object} Returns `object`.
  28563. * @see _.assignIn
  28564. * @example
  28565. *
  28566. * function Foo() {
  28567. * this.a = 1;
  28568. * }
  28569. *
  28570. * function Bar() {
  28571. * this.c = 3;
  28572. * }
  28573. *
  28574. * Foo.prototype.b = 2;
  28575. * Bar.prototype.d = 4;
  28576. *
  28577. * _.assign({ 'a': 0 }, new Foo, new Bar);
  28578. * // => { 'a': 1, 'c': 3 }
  28579. */
  28580. var assign = createAssigner(function(object, source) {
  28581. if (isPrototype(source) || isArrayLike(source)) {
  28582. copyObject(source, keys(source), object);
  28583. return;
  28584. }
  28585. for (var key in source) {
  28586. if (hasOwnProperty.call(source, key)) {
  28587. assignValue(object, key, source[key]);
  28588. }
  28589. }
  28590. });
  28591. /**
  28592. * This method is like `_.assign` except that it iterates over own and
  28593. * inherited source properties.
  28594. *
  28595. * **Note:** This method mutates `object`.
  28596. *
  28597. * @static
  28598. * @memberOf _
  28599. * @since 4.0.0
  28600. * @alias extend
  28601. * @category Object
  28602. * @param {Object} object The destination object.
  28603. * @param {...Object} [sources] The source objects.
  28604. * @returns {Object} Returns `object`.
  28605. * @see _.assign
  28606. * @example
  28607. *
  28608. * function Foo() {
  28609. * this.a = 1;
  28610. * }
  28611. *
  28612. * function Bar() {
  28613. * this.c = 3;
  28614. * }
  28615. *
  28616. * Foo.prototype.b = 2;
  28617. * Bar.prototype.d = 4;
  28618. *
  28619. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  28620. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  28621. */
  28622. var assignIn = createAssigner(function(object, source) {
  28623. copyObject(source, keysIn(source), object);
  28624. });
  28625. /**
  28626. * This method is like `_.assignIn` except that it accepts `customizer`
  28627. * which is invoked to produce the assigned values. If `customizer` returns
  28628. * `undefined`, assignment is handled by the method instead. The `customizer`
  28629. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28630. *
  28631. * **Note:** This method mutates `object`.
  28632. *
  28633. * @static
  28634. * @memberOf _
  28635. * @since 4.0.0
  28636. * @alias extendWith
  28637. * @category Object
  28638. * @param {Object} object The destination object.
  28639. * @param {...Object} sources The source objects.
  28640. * @param {Function} [customizer] The function to customize assigned values.
  28641. * @returns {Object} Returns `object`.
  28642. * @see _.assignWith
  28643. * @example
  28644. *
  28645. * function customizer(objValue, srcValue) {
  28646. * return _.isUndefined(objValue) ? srcValue : objValue;
  28647. * }
  28648. *
  28649. * var defaults = _.partialRight(_.assignInWith, customizer);
  28650. *
  28651. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28652. * // => { 'a': 1, 'b': 2 }
  28653. */
  28654. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  28655. copyObject(source, keysIn(source), object, customizer);
  28656. });
  28657. /**
  28658. * This method is like `_.assign` except that it accepts `customizer`
  28659. * which is invoked to produce the assigned values. If `customizer` returns
  28660. * `undefined`, assignment is handled by the method instead. The `customizer`
  28661. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  28662. *
  28663. * **Note:** This method mutates `object`.
  28664. *
  28665. * @static
  28666. * @memberOf _
  28667. * @since 4.0.0
  28668. * @category Object
  28669. * @param {Object} object The destination object.
  28670. * @param {...Object} sources The source objects.
  28671. * @param {Function} [customizer] The function to customize assigned values.
  28672. * @returns {Object} Returns `object`.
  28673. * @see _.assignInWith
  28674. * @example
  28675. *
  28676. * function customizer(objValue, srcValue) {
  28677. * return _.isUndefined(objValue) ? srcValue : objValue;
  28678. * }
  28679. *
  28680. * var defaults = _.partialRight(_.assignWith, customizer);
  28681. *
  28682. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28683. * // => { 'a': 1, 'b': 2 }
  28684. */
  28685. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  28686. copyObject(source, keys(source), object, customizer);
  28687. });
  28688. /**
  28689. * Creates an array of values corresponding to `paths` of `object`.
  28690. *
  28691. * @static
  28692. * @memberOf _
  28693. * @since 1.0.0
  28694. * @category Object
  28695. * @param {Object} object The object to iterate over.
  28696. * @param {...(string|string[])} [paths] The property paths to pick.
  28697. * @returns {Array} Returns the picked values.
  28698. * @example
  28699. *
  28700. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  28701. *
  28702. * _.at(object, ['a[0].b.c', 'a[1]']);
  28703. * // => [3, 4]
  28704. */
  28705. var at = flatRest(baseAt);
  28706. /**
  28707. * Creates an object that inherits from the `prototype` object. If a
  28708. * `properties` object is given, its own enumerable string keyed properties
  28709. * are assigned to the created object.
  28710. *
  28711. * @static
  28712. * @memberOf _
  28713. * @since 2.3.0
  28714. * @category Object
  28715. * @param {Object} prototype The object to inherit from.
  28716. * @param {Object} [properties] The properties to assign to the object.
  28717. * @returns {Object} Returns the new object.
  28718. * @example
  28719. *
  28720. * function Shape() {
  28721. * this.x = 0;
  28722. * this.y = 0;
  28723. * }
  28724. *
  28725. * function Circle() {
  28726. * Shape.call(this);
  28727. * }
  28728. *
  28729. * Circle.prototype = _.create(Shape.prototype, {
  28730. * 'constructor': Circle
  28731. * });
  28732. *
  28733. * var circle = new Circle;
  28734. * circle instanceof Circle;
  28735. * // => true
  28736. *
  28737. * circle instanceof Shape;
  28738. * // => true
  28739. */
  28740. function create(prototype, properties) {
  28741. var result = baseCreate(prototype);
  28742. return properties == null ? result : baseAssign(result, properties);
  28743. }
  28744. /**
  28745. * Assigns own and inherited enumerable string keyed properties of source
  28746. * objects to the destination object for all destination properties that
  28747. * resolve to `undefined`. Source objects are applied from left to right.
  28748. * Once a property is set, additional values of the same property are ignored.
  28749. *
  28750. * **Note:** This method mutates `object`.
  28751. *
  28752. * @static
  28753. * @since 0.1.0
  28754. * @memberOf _
  28755. * @category Object
  28756. * @param {Object} object The destination object.
  28757. * @param {...Object} [sources] The source objects.
  28758. * @returns {Object} Returns `object`.
  28759. * @see _.defaultsDeep
  28760. * @example
  28761. *
  28762. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  28763. * // => { 'a': 1, 'b': 2 }
  28764. */
  28765. var defaults = baseRest(function(object, sources) {
  28766. object = Object(object);
  28767. var index = -1;
  28768. var length = sources.length;
  28769. var guard = length > 2 ? sources[2] : undefined;
  28770. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  28771. length = 1;
  28772. }
  28773. while (++index < length) {
  28774. var source = sources[index];
  28775. var props = keysIn(source);
  28776. var propsIndex = -1;
  28777. var propsLength = props.length;
  28778. while (++propsIndex < propsLength) {
  28779. var key = props[propsIndex];
  28780. var value = object[key];
  28781. if (value === undefined ||
  28782. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  28783. object[key] = source[key];
  28784. }
  28785. }
  28786. }
  28787. return object;
  28788. });
  28789. /**
  28790. * This method is like `_.defaults` except that it recursively assigns
  28791. * default properties.
  28792. *
  28793. * **Note:** This method mutates `object`.
  28794. *
  28795. * @static
  28796. * @memberOf _
  28797. * @since 3.10.0
  28798. * @category Object
  28799. * @param {Object} object The destination object.
  28800. * @param {...Object} [sources] The source objects.
  28801. * @returns {Object} Returns `object`.
  28802. * @see _.defaults
  28803. * @example
  28804. *
  28805. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  28806. * // => { 'a': { 'b': 2, 'c': 3 } }
  28807. */
  28808. var defaultsDeep = baseRest(function(args) {
  28809. args.push(undefined, customDefaultsMerge);
  28810. return apply(mergeWith, undefined, args);
  28811. });
  28812. /**
  28813. * This method is like `_.find` except that it returns the key of the first
  28814. * element `predicate` returns truthy for instead of the element itself.
  28815. *
  28816. * @static
  28817. * @memberOf _
  28818. * @since 1.1.0
  28819. * @category Object
  28820. * @param {Object} object The object to inspect.
  28821. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28822. * @returns {string|undefined} Returns the key of the matched element,
  28823. * else `undefined`.
  28824. * @example
  28825. *
  28826. * var users = {
  28827. * 'barney': { 'age': 36, 'active': true },
  28828. * 'fred': { 'age': 40, 'active': false },
  28829. * 'pebbles': { 'age': 1, 'active': true }
  28830. * };
  28831. *
  28832. * _.findKey(users, function(o) { return o.age < 40; });
  28833. * // => 'barney' (iteration order is not guaranteed)
  28834. *
  28835. * // The `_.matches` iteratee shorthand.
  28836. * _.findKey(users, { 'age': 1, 'active': true });
  28837. * // => 'pebbles'
  28838. *
  28839. * // The `_.matchesProperty` iteratee shorthand.
  28840. * _.findKey(users, ['active', false]);
  28841. * // => 'fred'
  28842. *
  28843. * // The `_.property` iteratee shorthand.
  28844. * _.findKey(users, 'active');
  28845. * // => 'barney'
  28846. */
  28847. function findKey(object, predicate) {
  28848. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  28849. }
  28850. /**
  28851. * This method is like `_.findKey` except that it iterates over elements of
  28852. * a collection in the opposite order.
  28853. *
  28854. * @static
  28855. * @memberOf _
  28856. * @since 2.0.0
  28857. * @category Object
  28858. * @param {Object} object The object to inspect.
  28859. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  28860. * @returns {string|undefined} Returns the key of the matched element,
  28861. * else `undefined`.
  28862. * @example
  28863. *
  28864. * var users = {
  28865. * 'barney': { 'age': 36, 'active': true },
  28866. * 'fred': { 'age': 40, 'active': false },
  28867. * 'pebbles': { 'age': 1, 'active': true }
  28868. * };
  28869. *
  28870. * _.findLastKey(users, function(o) { return o.age < 40; });
  28871. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  28872. *
  28873. * // The `_.matches` iteratee shorthand.
  28874. * _.findLastKey(users, { 'age': 36, 'active': true });
  28875. * // => 'barney'
  28876. *
  28877. * // The `_.matchesProperty` iteratee shorthand.
  28878. * _.findLastKey(users, ['active', false]);
  28879. * // => 'fred'
  28880. *
  28881. * // The `_.property` iteratee shorthand.
  28882. * _.findLastKey(users, 'active');
  28883. * // => 'pebbles'
  28884. */
  28885. function findLastKey(object, predicate) {
  28886. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  28887. }
  28888. /**
  28889. * Iterates over own and inherited enumerable string keyed properties of an
  28890. * object and invokes `iteratee` for each property. The iteratee is invoked
  28891. * with three arguments: (value, key, object). Iteratee functions may exit
  28892. * iteration early by explicitly returning `false`.
  28893. *
  28894. * @static
  28895. * @memberOf _
  28896. * @since 0.3.0
  28897. * @category Object
  28898. * @param {Object} object The object to iterate over.
  28899. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28900. * @returns {Object} Returns `object`.
  28901. * @see _.forInRight
  28902. * @example
  28903. *
  28904. * function Foo() {
  28905. * this.a = 1;
  28906. * this.b = 2;
  28907. * }
  28908. *
  28909. * Foo.prototype.c = 3;
  28910. *
  28911. * _.forIn(new Foo, function(value, key) {
  28912. * console.log(key);
  28913. * });
  28914. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  28915. */
  28916. function forIn(object, iteratee) {
  28917. return object == null
  28918. ? object
  28919. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  28920. }
  28921. /**
  28922. * This method is like `_.forIn` except that it iterates over properties of
  28923. * `object` in the opposite order.
  28924. *
  28925. * @static
  28926. * @memberOf _
  28927. * @since 2.0.0
  28928. * @category Object
  28929. * @param {Object} object The object to iterate over.
  28930. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28931. * @returns {Object} Returns `object`.
  28932. * @see _.forIn
  28933. * @example
  28934. *
  28935. * function Foo() {
  28936. * this.a = 1;
  28937. * this.b = 2;
  28938. * }
  28939. *
  28940. * Foo.prototype.c = 3;
  28941. *
  28942. * _.forInRight(new Foo, function(value, key) {
  28943. * console.log(key);
  28944. * });
  28945. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  28946. */
  28947. function forInRight(object, iteratee) {
  28948. return object == null
  28949. ? object
  28950. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  28951. }
  28952. /**
  28953. * Iterates over own enumerable string keyed properties of an object and
  28954. * invokes `iteratee` for each property. The iteratee is invoked with three
  28955. * arguments: (value, key, object). Iteratee functions may exit iteration
  28956. * early by explicitly returning `false`.
  28957. *
  28958. * @static
  28959. * @memberOf _
  28960. * @since 0.3.0
  28961. * @category Object
  28962. * @param {Object} object The object to iterate over.
  28963. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28964. * @returns {Object} Returns `object`.
  28965. * @see _.forOwnRight
  28966. * @example
  28967. *
  28968. * function Foo() {
  28969. * this.a = 1;
  28970. * this.b = 2;
  28971. * }
  28972. *
  28973. * Foo.prototype.c = 3;
  28974. *
  28975. * _.forOwn(new Foo, function(value, key) {
  28976. * console.log(key);
  28977. * });
  28978. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  28979. */
  28980. function forOwn(object, iteratee) {
  28981. return object && baseForOwn(object, getIteratee(iteratee, 3));
  28982. }
  28983. /**
  28984. * This method is like `_.forOwn` except that it iterates over properties of
  28985. * `object` in the opposite order.
  28986. *
  28987. * @static
  28988. * @memberOf _
  28989. * @since 2.0.0
  28990. * @category Object
  28991. * @param {Object} object The object to iterate over.
  28992. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  28993. * @returns {Object} Returns `object`.
  28994. * @see _.forOwn
  28995. * @example
  28996. *
  28997. * function Foo() {
  28998. * this.a = 1;
  28999. * this.b = 2;
  29000. * }
  29001. *
  29002. * Foo.prototype.c = 3;
  29003. *
  29004. * _.forOwnRight(new Foo, function(value, key) {
  29005. * console.log(key);
  29006. * });
  29007. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29008. */
  29009. function forOwnRight(object, iteratee) {
  29010. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29011. }
  29012. /**
  29013. * Creates an array of function property names from own enumerable properties
  29014. * of `object`.
  29015. *
  29016. * @static
  29017. * @since 0.1.0
  29018. * @memberOf _
  29019. * @category Object
  29020. * @param {Object} object The object to inspect.
  29021. * @returns {Array} Returns the function names.
  29022. * @see _.functionsIn
  29023. * @example
  29024. *
  29025. * function Foo() {
  29026. * this.a = _.constant('a');
  29027. * this.b = _.constant('b');
  29028. * }
  29029. *
  29030. * Foo.prototype.c = _.constant('c');
  29031. *
  29032. * _.functions(new Foo);
  29033. * // => ['a', 'b']
  29034. */
  29035. function functions(object) {
  29036. return object == null ? [] : baseFunctions(object, keys(object));
  29037. }
  29038. /**
  29039. * Creates an array of function property names from own and inherited
  29040. * enumerable properties of `object`.
  29041. *
  29042. * @static
  29043. * @memberOf _
  29044. * @since 4.0.0
  29045. * @category Object
  29046. * @param {Object} object The object to inspect.
  29047. * @returns {Array} Returns the function names.
  29048. * @see _.functions
  29049. * @example
  29050. *
  29051. * function Foo() {
  29052. * this.a = _.constant('a');
  29053. * this.b = _.constant('b');
  29054. * }
  29055. *
  29056. * Foo.prototype.c = _.constant('c');
  29057. *
  29058. * _.functionsIn(new Foo);
  29059. * // => ['a', 'b', 'c']
  29060. */
  29061. function functionsIn(object) {
  29062. return object == null ? [] : baseFunctions(object, keysIn(object));
  29063. }
  29064. /**
  29065. * Gets the value at `path` of `object`. If the resolved value is
  29066. * `undefined`, the `defaultValue` is returned in its place.
  29067. *
  29068. * @static
  29069. * @memberOf _
  29070. * @since 3.7.0
  29071. * @category Object
  29072. * @param {Object} object The object to query.
  29073. * @param {Array|string} path The path of the property to get.
  29074. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29075. * @returns {*} Returns the resolved value.
  29076. * @example
  29077. *
  29078. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29079. *
  29080. * _.get(object, 'a[0].b.c');
  29081. * // => 3
  29082. *
  29083. * _.get(object, ['a', '0', 'b', 'c']);
  29084. * // => 3
  29085. *
  29086. * _.get(object, 'a.b.c', 'default');
  29087. * // => 'default'
  29088. */
  29089. function get(object, path, defaultValue) {
  29090. var result = object == null ? undefined : baseGet(object, path);
  29091. return result === undefined ? defaultValue : result;
  29092. }
  29093. /**
  29094. * Checks if `path` is a direct property of `object`.
  29095. *
  29096. * @static
  29097. * @since 0.1.0
  29098. * @memberOf _
  29099. * @category Object
  29100. * @param {Object} object The object to query.
  29101. * @param {Array|string} path The path to check.
  29102. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29103. * @example
  29104. *
  29105. * var object = { 'a': { 'b': 2 } };
  29106. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  29107. *
  29108. * _.has(object, 'a');
  29109. * // => true
  29110. *
  29111. * _.has(object, 'a.b');
  29112. * // => true
  29113. *
  29114. * _.has(object, ['a', 'b']);
  29115. * // => true
  29116. *
  29117. * _.has(other, 'a');
  29118. * // => false
  29119. */
  29120. function has(object, path) {
  29121. return object != null && hasPath(object, path, baseHas);
  29122. }
  29123. /**
  29124. * Checks if `path` is a direct or inherited property of `object`.
  29125. *
  29126. * @static
  29127. * @memberOf _
  29128. * @since 4.0.0
  29129. * @category Object
  29130. * @param {Object} object The object to query.
  29131. * @param {Array|string} path The path to check.
  29132. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  29133. * @example
  29134. *
  29135. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  29136. *
  29137. * _.hasIn(object, 'a');
  29138. * // => true
  29139. *
  29140. * _.hasIn(object, 'a.b');
  29141. * // => true
  29142. *
  29143. * _.hasIn(object, ['a', 'b']);
  29144. * // => true
  29145. *
  29146. * _.hasIn(object, 'b');
  29147. * // => false
  29148. */
  29149. function hasIn(object, path) {
  29150. return object != null && hasPath(object, path, baseHasIn);
  29151. }
  29152. /**
  29153. * Creates an object composed of the inverted keys and values of `object`.
  29154. * If `object` contains duplicate values, subsequent values overwrite
  29155. * property assignments of previous values.
  29156. *
  29157. * @static
  29158. * @memberOf _
  29159. * @since 0.7.0
  29160. * @category Object
  29161. * @param {Object} object The object to invert.
  29162. * @returns {Object} Returns the new inverted object.
  29163. * @example
  29164. *
  29165. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29166. *
  29167. * _.invert(object);
  29168. * // => { '1': 'c', '2': 'b' }
  29169. */
  29170. var invert = createInverter(function(result, value, key) {
  29171. if (value != null &&
  29172. typeof value.toString != 'function') {
  29173. value = nativeObjectToString.call(value);
  29174. }
  29175. result[value] = key;
  29176. }, constant(identity));
  29177. /**
  29178. * This method is like `_.invert` except that the inverted object is generated
  29179. * from the results of running each element of `object` thru `iteratee`. The
  29180. * corresponding inverted value of each inverted key is an array of keys
  29181. * responsible for generating the inverted value. The iteratee is invoked
  29182. * with one argument: (value).
  29183. *
  29184. * @static
  29185. * @memberOf _
  29186. * @since 4.1.0
  29187. * @category Object
  29188. * @param {Object} object The object to invert.
  29189. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29190. * @returns {Object} Returns the new inverted object.
  29191. * @example
  29192. *
  29193. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  29194. *
  29195. * _.invertBy(object);
  29196. * // => { '1': ['a', 'c'], '2': ['b'] }
  29197. *
  29198. * _.invertBy(object, function(value) {
  29199. * return 'group' + value;
  29200. * });
  29201. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  29202. */
  29203. var invertBy = createInverter(function(result, value, key) {
  29204. if (value != null &&
  29205. typeof value.toString != 'function') {
  29206. value = nativeObjectToString.call(value);
  29207. }
  29208. if (hasOwnProperty.call(result, value)) {
  29209. result[value].push(key);
  29210. } else {
  29211. result[value] = [key];
  29212. }
  29213. }, getIteratee);
  29214. /**
  29215. * Invokes the method at `path` of `object`.
  29216. *
  29217. * @static
  29218. * @memberOf _
  29219. * @since 4.0.0
  29220. * @category Object
  29221. * @param {Object} object The object to query.
  29222. * @param {Array|string} path The path of the method to invoke.
  29223. * @param {...*} [args] The arguments to invoke the method with.
  29224. * @returns {*} Returns the result of the invoked method.
  29225. * @example
  29226. *
  29227. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  29228. *
  29229. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  29230. * // => [2, 3]
  29231. */
  29232. var invoke = baseRest(baseInvoke);
  29233. /**
  29234. * Creates an array of the own enumerable property names of `object`.
  29235. *
  29236. * **Note:** Non-object values are coerced to objects. See the
  29237. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  29238. * for more details.
  29239. *
  29240. * @static
  29241. * @since 0.1.0
  29242. * @memberOf _
  29243. * @category Object
  29244. * @param {Object} object The object to query.
  29245. * @returns {Array} Returns the array of property names.
  29246. * @example
  29247. *
  29248. * function Foo() {
  29249. * this.a = 1;
  29250. * this.b = 2;
  29251. * }
  29252. *
  29253. * Foo.prototype.c = 3;
  29254. *
  29255. * _.keys(new Foo);
  29256. * // => ['a', 'b'] (iteration order is not guaranteed)
  29257. *
  29258. * _.keys('hi');
  29259. * // => ['0', '1']
  29260. */
  29261. function keys(object) {
  29262. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  29263. }
  29264. /**
  29265. * Creates an array of the own and inherited enumerable property names of `object`.
  29266. *
  29267. * **Note:** Non-object values are coerced to objects.
  29268. *
  29269. * @static
  29270. * @memberOf _
  29271. * @since 3.0.0
  29272. * @category Object
  29273. * @param {Object} object The object to query.
  29274. * @returns {Array} Returns the array of property names.
  29275. * @example
  29276. *
  29277. * function Foo() {
  29278. * this.a = 1;
  29279. * this.b = 2;
  29280. * }
  29281. *
  29282. * Foo.prototype.c = 3;
  29283. *
  29284. * _.keysIn(new Foo);
  29285. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  29286. */
  29287. function keysIn(object) {
  29288. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  29289. }
  29290. /**
  29291. * The opposite of `_.mapValues`; this method creates an object with the
  29292. * same values as `object` and keys generated by running each own enumerable
  29293. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  29294. * with three arguments: (value, key, object).
  29295. *
  29296. * @static
  29297. * @memberOf _
  29298. * @since 3.8.0
  29299. * @category Object
  29300. * @param {Object} object The object to iterate over.
  29301. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29302. * @returns {Object} Returns the new mapped object.
  29303. * @see _.mapValues
  29304. * @example
  29305. *
  29306. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  29307. * return key + value;
  29308. * });
  29309. * // => { 'a1': 1, 'b2': 2 }
  29310. */
  29311. function mapKeys(object, iteratee) {
  29312. var result = {};
  29313. iteratee = getIteratee(iteratee, 3);
  29314. baseForOwn(object, function(value, key, object) {
  29315. baseAssignValue(result, iteratee(value, key, object), value);
  29316. });
  29317. return result;
  29318. }
  29319. /**
  29320. * Creates an object with the same keys as `object` and values generated
  29321. * by running each own enumerable string keyed property of `object` thru
  29322. * `iteratee`. The iteratee is invoked with three arguments:
  29323. * (value, key, object).
  29324. *
  29325. * @static
  29326. * @memberOf _
  29327. * @since 2.4.0
  29328. * @category Object
  29329. * @param {Object} object The object to iterate over.
  29330. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29331. * @returns {Object} Returns the new mapped object.
  29332. * @see _.mapKeys
  29333. * @example
  29334. *
  29335. * var users = {
  29336. * 'fred': { 'user': 'fred', 'age': 40 },
  29337. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  29338. * };
  29339. *
  29340. * _.mapValues(users, function(o) { return o.age; });
  29341. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29342. *
  29343. * // The `_.property` iteratee shorthand.
  29344. * _.mapValues(users, 'age');
  29345. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  29346. */
  29347. function mapValues(object, iteratee) {
  29348. var result = {};
  29349. iteratee = getIteratee(iteratee, 3);
  29350. baseForOwn(object, function(value, key, object) {
  29351. baseAssignValue(result, key, iteratee(value, key, object));
  29352. });
  29353. return result;
  29354. }
  29355. /**
  29356. * This method is like `_.assign` except that it recursively merges own and
  29357. * inherited enumerable string keyed properties of source objects into the
  29358. * destination object. Source properties that resolve to `undefined` are
  29359. * skipped if a destination value exists. Array and plain object properties
  29360. * are merged recursively. Other objects and value types are overridden by
  29361. * assignment. Source objects are applied from left to right. Subsequent
  29362. * sources overwrite property assignments of previous sources.
  29363. *
  29364. * **Note:** This method mutates `object`.
  29365. *
  29366. * @static
  29367. * @memberOf _
  29368. * @since 0.5.0
  29369. * @category Object
  29370. * @param {Object} object The destination object.
  29371. * @param {...Object} [sources] The source objects.
  29372. * @returns {Object} Returns `object`.
  29373. * @example
  29374. *
  29375. * var object = {
  29376. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  29377. * };
  29378. *
  29379. * var other = {
  29380. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  29381. * };
  29382. *
  29383. * _.merge(object, other);
  29384. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  29385. */
  29386. var merge = createAssigner(function(object, source, srcIndex) {
  29387. baseMerge(object, source, srcIndex);
  29388. });
  29389. /**
  29390. * This method is like `_.merge` except that it accepts `customizer` which
  29391. * is invoked to produce the merged values of the destination and source
  29392. * properties. If `customizer` returns `undefined`, merging is handled by the
  29393. * method instead. The `customizer` is invoked with six arguments:
  29394. * (objValue, srcValue, key, object, source, stack).
  29395. *
  29396. * **Note:** This method mutates `object`.
  29397. *
  29398. * @static
  29399. * @memberOf _
  29400. * @since 4.0.0
  29401. * @category Object
  29402. * @param {Object} object The destination object.
  29403. * @param {...Object} sources The source objects.
  29404. * @param {Function} customizer The function to customize assigned values.
  29405. * @returns {Object} Returns `object`.
  29406. * @example
  29407. *
  29408. * function customizer(objValue, srcValue) {
  29409. * if (_.isArray(objValue)) {
  29410. * return objValue.concat(srcValue);
  29411. * }
  29412. * }
  29413. *
  29414. * var object = { 'a': [1], 'b': [2] };
  29415. * var other = { 'a': [3], 'b': [4] };
  29416. *
  29417. * _.mergeWith(object, other, customizer);
  29418. * // => { 'a': [1, 3], 'b': [2, 4] }
  29419. */
  29420. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  29421. baseMerge(object, source, srcIndex, customizer);
  29422. });
  29423. /**
  29424. * The opposite of `_.pick`; this method creates an object composed of the
  29425. * own and inherited enumerable property paths of `object` that are not omitted.
  29426. *
  29427. * **Note:** This method is considerably slower than `_.pick`.
  29428. *
  29429. * @static
  29430. * @since 0.1.0
  29431. * @memberOf _
  29432. * @category Object
  29433. * @param {Object} object The source object.
  29434. * @param {...(string|string[])} [paths] The property paths to omit.
  29435. * @returns {Object} Returns the new object.
  29436. * @example
  29437. *
  29438. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29439. *
  29440. * _.omit(object, ['a', 'c']);
  29441. * // => { 'b': '2' }
  29442. */
  29443. var omit = flatRest(function(object, paths) {
  29444. var result = {};
  29445. if (object == null) {
  29446. return result;
  29447. }
  29448. var isDeep = false;
  29449. paths = arrayMap(paths, function(path) {
  29450. path = castPath(path, object);
  29451. isDeep || (isDeep = path.length > 1);
  29452. return path;
  29453. });
  29454. copyObject(object, getAllKeysIn(object), result);
  29455. if (isDeep) {
  29456. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  29457. }
  29458. var length = paths.length;
  29459. while (length--) {
  29460. baseUnset(result, paths[length]);
  29461. }
  29462. return result;
  29463. });
  29464. /**
  29465. * The opposite of `_.pickBy`; this method creates an object composed of
  29466. * the own and inherited enumerable string keyed properties of `object` that
  29467. * `predicate` doesn't return truthy for. The predicate is invoked with two
  29468. * arguments: (value, key).
  29469. *
  29470. * @static
  29471. * @memberOf _
  29472. * @since 4.0.0
  29473. * @category Object
  29474. * @param {Object} object The source object.
  29475. * @param {Function} [predicate=_.identity] The function invoked per property.
  29476. * @returns {Object} Returns the new object.
  29477. * @example
  29478. *
  29479. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29480. *
  29481. * _.omitBy(object, _.isNumber);
  29482. * // => { 'b': '2' }
  29483. */
  29484. function omitBy(object, predicate) {
  29485. return pickBy(object, negate(getIteratee(predicate)));
  29486. }
  29487. /**
  29488. * Creates an object composed of the picked `object` properties.
  29489. *
  29490. * @static
  29491. * @since 0.1.0
  29492. * @memberOf _
  29493. * @category Object
  29494. * @param {Object} object The source object.
  29495. * @param {...(string|string[])} [paths] The property paths to pick.
  29496. * @returns {Object} Returns the new object.
  29497. * @example
  29498. *
  29499. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29500. *
  29501. * _.pick(object, ['a', 'c']);
  29502. * // => { 'a': 1, 'c': 3 }
  29503. */
  29504. var pick = flatRest(function(object, paths) {
  29505. return object == null ? {} : basePick(object, paths);
  29506. });
  29507. /**
  29508. * Creates an object composed of the `object` properties `predicate` returns
  29509. * truthy for. The predicate is invoked with two arguments: (value, key).
  29510. *
  29511. * @static
  29512. * @memberOf _
  29513. * @since 4.0.0
  29514. * @category Object
  29515. * @param {Object} object The source object.
  29516. * @param {Function} [predicate=_.identity] The function invoked per property.
  29517. * @returns {Object} Returns the new object.
  29518. * @example
  29519. *
  29520. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  29521. *
  29522. * _.pickBy(object, _.isNumber);
  29523. * // => { 'a': 1, 'c': 3 }
  29524. */
  29525. function pickBy(object, predicate) {
  29526. if (object == null) {
  29527. return {};
  29528. }
  29529. var props = arrayMap(getAllKeysIn(object), function(prop) {
  29530. return [prop];
  29531. });
  29532. predicate = getIteratee(predicate);
  29533. return basePickBy(object, props, function(value, path) {
  29534. return predicate(value, path[0]);
  29535. });
  29536. }
  29537. /**
  29538. * This method is like `_.get` except that if the resolved value is a
  29539. * function it's invoked with the `this` binding of its parent object and
  29540. * its result is returned.
  29541. *
  29542. * @static
  29543. * @since 0.1.0
  29544. * @memberOf _
  29545. * @category Object
  29546. * @param {Object} object The object to query.
  29547. * @param {Array|string} path The path of the property to resolve.
  29548. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  29549. * @returns {*} Returns the resolved value.
  29550. * @example
  29551. *
  29552. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  29553. *
  29554. * _.result(object, 'a[0].b.c1');
  29555. * // => 3
  29556. *
  29557. * _.result(object, 'a[0].b.c2');
  29558. * // => 4
  29559. *
  29560. * _.result(object, 'a[0].b.c3', 'default');
  29561. * // => 'default'
  29562. *
  29563. * _.result(object, 'a[0].b.c3', _.constant('default'));
  29564. * // => 'default'
  29565. */
  29566. function result(object, path, defaultValue) {
  29567. path = castPath(path, object);
  29568. var index = -1,
  29569. length = path.length;
  29570. // Ensure the loop is entered when path is empty.
  29571. if (!length) {
  29572. length = 1;
  29573. object = undefined;
  29574. }
  29575. while (++index < length) {
  29576. var value = object == null ? undefined : object[toKey(path[index])];
  29577. if (value === undefined) {
  29578. index = length;
  29579. value = defaultValue;
  29580. }
  29581. object = isFunction(value) ? value.call(object) : value;
  29582. }
  29583. return object;
  29584. }
  29585. /**
  29586. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  29587. * it's created. Arrays are created for missing index properties while objects
  29588. * are created for all other missing properties. Use `_.setWith` to customize
  29589. * `path` creation.
  29590. *
  29591. * **Note:** This method mutates `object`.
  29592. *
  29593. * @static
  29594. * @memberOf _
  29595. * @since 3.7.0
  29596. * @category Object
  29597. * @param {Object} object The object to modify.
  29598. * @param {Array|string} path The path of the property to set.
  29599. * @param {*} value The value to set.
  29600. * @returns {Object} Returns `object`.
  29601. * @example
  29602. *
  29603. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29604. *
  29605. * _.set(object, 'a[0].b.c', 4);
  29606. * console.log(object.a[0].b.c);
  29607. * // => 4
  29608. *
  29609. * _.set(object, ['x', '0', 'y', 'z'], 5);
  29610. * console.log(object.x[0].y.z);
  29611. * // => 5
  29612. */
  29613. function set(object, path, value) {
  29614. return object == null ? object : baseSet(object, path, value);
  29615. }
  29616. /**
  29617. * This method is like `_.set` except that it accepts `customizer` which is
  29618. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29619. * path creation is handled by the method instead. The `customizer` is invoked
  29620. * with three arguments: (nsValue, key, nsObject).
  29621. *
  29622. * **Note:** This method mutates `object`.
  29623. *
  29624. * @static
  29625. * @memberOf _
  29626. * @since 4.0.0
  29627. * @category Object
  29628. * @param {Object} object The object to modify.
  29629. * @param {Array|string} path The path of the property to set.
  29630. * @param {*} value The value to set.
  29631. * @param {Function} [customizer] The function to customize assigned values.
  29632. * @returns {Object} Returns `object`.
  29633. * @example
  29634. *
  29635. * var object = {};
  29636. *
  29637. * _.setWith(object, '[0][1]', 'a', Object);
  29638. * // => { '0': { '1': 'a' } }
  29639. */
  29640. function setWith(object, path, value, customizer) {
  29641. customizer = typeof customizer == 'function' ? customizer : undefined;
  29642. return object == null ? object : baseSet(object, path, value, customizer);
  29643. }
  29644. /**
  29645. * Creates an array of own enumerable string keyed-value pairs for `object`
  29646. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  29647. * entries are returned.
  29648. *
  29649. * @static
  29650. * @memberOf _
  29651. * @since 4.0.0
  29652. * @alias entries
  29653. * @category Object
  29654. * @param {Object} object The object to query.
  29655. * @returns {Array} Returns the key-value pairs.
  29656. * @example
  29657. *
  29658. * function Foo() {
  29659. * this.a = 1;
  29660. * this.b = 2;
  29661. * }
  29662. *
  29663. * Foo.prototype.c = 3;
  29664. *
  29665. * _.toPairs(new Foo);
  29666. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  29667. */
  29668. var toPairs = createToPairs(keys);
  29669. /**
  29670. * Creates an array of own and inherited enumerable string keyed-value pairs
  29671. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  29672. * or set, its entries are returned.
  29673. *
  29674. * @static
  29675. * @memberOf _
  29676. * @since 4.0.0
  29677. * @alias entriesIn
  29678. * @category Object
  29679. * @param {Object} object The object to query.
  29680. * @returns {Array} Returns the key-value pairs.
  29681. * @example
  29682. *
  29683. * function Foo() {
  29684. * this.a = 1;
  29685. * this.b = 2;
  29686. * }
  29687. *
  29688. * Foo.prototype.c = 3;
  29689. *
  29690. * _.toPairsIn(new Foo);
  29691. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  29692. */
  29693. var toPairsIn = createToPairs(keysIn);
  29694. /**
  29695. * An alternative to `_.reduce`; this method transforms `object` to a new
  29696. * `accumulator` object which is the result of running each of its own
  29697. * enumerable string keyed properties thru `iteratee`, with each invocation
  29698. * potentially mutating the `accumulator` object. If `accumulator` is not
  29699. * provided, a new object with the same `[[Prototype]]` will be used. The
  29700. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  29701. * Iteratee functions may exit iteration early by explicitly returning `false`.
  29702. *
  29703. * @static
  29704. * @memberOf _
  29705. * @since 1.3.0
  29706. * @category Object
  29707. * @param {Object} object The object to iterate over.
  29708. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29709. * @param {*} [accumulator] The custom accumulator value.
  29710. * @returns {*} Returns the accumulated value.
  29711. * @example
  29712. *
  29713. * _.transform([2, 3, 4], function(result, n) {
  29714. * result.push(n *= n);
  29715. * return n % 2 == 0;
  29716. * }, []);
  29717. * // => [4, 9]
  29718. *
  29719. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  29720. * (result[value] || (result[value] = [])).push(key);
  29721. * }, {});
  29722. * // => { '1': ['a', 'c'], '2': ['b'] }
  29723. */
  29724. function transform(object, iteratee, accumulator) {
  29725. var isArr = isArray(object),
  29726. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  29727. iteratee = getIteratee(iteratee, 4);
  29728. if (accumulator == null) {
  29729. var Ctor = object && object.constructor;
  29730. if (isArrLike) {
  29731. accumulator = isArr ? new Ctor : [];
  29732. }
  29733. else if (isObject(object)) {
  29734. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  29735. }
  29736. else {
  29737. accumulator = {};
  29738. }
  29739. }
  29740. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  29741. return iteratee(accumulator, value, index, object);
  29742. });
  29743. return accumulator;
  29744. }
  29745. /**
  29746. * Removes the property at `path` of `object`.
  29747. *
  29748. * **Note:** This method mutates `object`.
  29749. *
  29750. * @static
  29751. * @memberOf _
  29752. * @since 4.0.0
  29753. * @category Object
  29754. * @param {Object} object The object to modify.
  29755. * @param {Array|string} path The path of the property to unset.
  29756. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  29757. * @example
  29758. *
  29759. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  29760. * _.unset(object, 'a[0].b.c');
  29761. * // => true
  29762. *
  29763. * console.log(object);
  29764. * // => { 'a': [{ 'b': {} }] };
  29765. *
  29766. * _.unset(object, ['a', '0', 'b', 'c']);
  29767. * // => true
  29768. *
  29769. * console.log(object);
  29770. * // => { 'a': [{ 'b': {} }] };
  29771. */
  29772. function unset(object, path) {
  29773. return object == null ? true : baseUnset(object, path);
  29774. }
  29775. /**
  29776. * This method is like `_.set` except that accepts `updater` to produce the
  29777. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  29778. * is invoked with one argument: (value).
  29779. *
  29780. * **Note:** This method mutates `object`.
  29781. *
  29782. * @static
  29783. * @memberOf _
  29784. * @since 4.6.0
  29785. * @category Object
  29786. * @param {Object} object The object to modify.
  29787. * @param {Array|string} path The path of the property to set.
  29788. * @param {Function} updater The function to produce the updated value.
  29789. * @returns {Object} Returns `object`.
  29790. * @example
  29791. *
  29792. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  29793. *
  29794. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  29795. * console.log(object.a[0].b.c);
  29796. * // => 9
  29797. *
  29798. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  29799. * console.log(object.x[0].y.z);
  29800. * // => 0
  29801. */
  29802. function update(object, path, updater) {
  29803. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  29804. }
  29805. /**
  29806. * This method is like `_.update` except that it accepts `customizer` which is
  29807. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  29808. * path creation is handled by the method instead. The `customizer` is invoked
  29809. * with three arguments: (nsValue, key, nsObject).
  29810. *
  29811. * **Note:** This method mutates `object`.
  29812. *
  29813. * @static
  29814. * @memberOf _
  29815. * @since 4.6.0
  29816. * @category Object
  29817. * @param {Object} object The object to modify.
  29818. * @param {Array|string} path The path of the property to set.
  29819. * @param {Function} updater The function to produce the updated value.
  29820. * @param {Function} [customizer] The function to customize assigned values.
  29821. * @returns {Object} Returns `object`.
  29822. * @example
  29823. *
  29824. * var object = {};
  29825. *
  29826. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  29827. * // => { '0': { '1': 'a' } }
  29828. */
  29829. function updateWith(object, path, updater, customizer) {
  29830. customizer = typeof customizer == 'function' ? customizer : undefined;
  29831. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  29832. }
  29833. /**
  29834. * Creates an array of the own enumerable string keyed property values of `object`.
  29835. *
  29836. * **Note:** Non-object values are coerced to objects.
  29837. *
  29838. * @static
  29839. * @since 0.1.0
  29840. * @memberOf _
  29841. * @category Object
  29842. * @param {Object} object The object to query.
  29843. * @returns {Array} Returns the array of property values.
  29844. * @example
  29845. *
  29846. * function Foo() {
  29847. * this.a = 1;
  29848. * this.b = 2;
  29849. * }
  29850. *
  29851. * Foo.prototype.c = 3;
  29852. *
  29853. * _.values(new Foo);
  29854. * // => [1, 2] (iteration order is not guaranteed)
  29855. *
  29856. * _.values('hi');
  29857. * // => ['h', 'i']
  29858. */
  29859. function values(object) {
  29860. return object == null ? [] : baseValues(object, keys(object));
  29861. }
  29862. /**
  29863. * Creates an array of the own and inherited enumerable string keyed property
  29864. * values of `object`.
  29865. *
  29866. * **Note:** Non-object values are coerced to objects.
  29867. *
  29868. * @static
  29869. * @memberOf _
  29870. * @since 3.0.0
  29871. * @category Object
  29872. * @param {Object} object The object to query.
  29873. * @returns {Array} Returns the array of property values.
  29874. * @example
  29875. *
  29876. * function Foo() {
  29877. * this.a = 1;
  29878. * this.b = 2;
  29879. * }
  29880. *
  29881. * Foo.prototype.c = 3;
  29882. *
  29883. * _.valuesIn(new Foo);
  29884. * // => [1, 2, 3] (iteration order is not guaranteed)
  29885. */
  29886. function valuesIn(object) {
  29887. return object == null ? [] : baseValues(object, keysIn(object));
  29888. }
  29889. /*------------------------------------------------------------------------*/
  29890. /**
  29891. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  29892. *
  29893. * @static
  29894. * @memberOf _
  29895. * @since 4.0.0
  29896. * @category Number
  29897. * @param {number} number The number to clamp.
  29898. * @param {number} [lower] The lower bound.
  29899. * @param {number} upper The upper bound.
  29900. * @returns {number} Returns the clamped number.
  29901. * @example
  29902. *
  29903. * _.clamp(-10, -5, 5);
  29904. * // => -5
  29905. *
  29906. * _.clamp(10, -5, 5);
  29907. * // => 5
  29908. */
  29909. function clamp(number, lower, upper) {
  29910. if (upper === undefined) {
  29911. upper = lower;
  29912. lower = undefined;
  29913. }
  29914. if (upper !== undefined) {
  29915. upper = toNumber(upper);
  29916. upper = upper === upper ? upper : 0;
  29917. }
  29918. if (lower !== undefined) {
  29919. lower = toNumber(lower);
  29920. lower = lower === lower ? lower : 0;
  29921. }
  29922. return baseClamp(toNumber(number), lower, upper);
  29923. }
  29924. /**
  29925. * Checks if `n` is between `start` and up to, but not including, `end`. If
  29926. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  29927. * If `start` is greater than `end` the params are swapped to support
  29928. * negative ranges.
  29929. *
  29930. * @static
  29931. * @memberOf _
  29932. * @since 3.3.0
  29933. * @category Number
  29934. * @param {number} number The number to check.
  29935. * @param {number} [start=0] The start of the range.
  29936. * @param {number} end The end of the range.
  29937. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  29938. * @see _.range, _.rangeRight
  29939. * @example
  29940. *
  29941. * _.inRange(3, 2, 4);
  29942. * // => true
  29943. *
  29944. * _.inRange(4, 8);
  29945. * // => true
  29946. *
  29947. * _.inRange(4, 2);
  29948. * // => false
  29949. *
  29950. * _.inRange(2, 2);
  29951. * // => false
  29952. *
  29953. * _.inRange(1.2, 2);
  29954. * // => true
  29955. *
  29956. * _.inRange(5.2, 4);
  29957. * // => false
  29958. *
  29959. * _.inRange(-3, -2, -6);
  29960. * // => true
  29961. */
  29962. function inRange(number, start, end) {
  29963. start = toFinite(start);
  29964. if (end === undefined) {
  29965. end = start;
  29966. start = 0;
  29967. } else {
  29968. end = toFinite(end);
  29969. }
  29970. number = toNumber(number);
  29971. return baseInRange(number, start, end);
  29972. }
  29973. /**
  29974. * Produces a random number between the inclusive `lower` and `upper` bounds.
  29975. * If only one argument is provided a number between `0` and the given number
  29976. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  29977. * floats, a floating-point number is returned instead of an integer.
  29978. *
  29979. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  29980. * floating-point values which can produce unexpected results.
  29981. *
  29982. * @static
  29983. * @memberOf _
  29984. * @since 0.7.0
  29985. * @category Number
  29986. * @param {number} [lower=0] The lower bound.
  29987. * @param {number} [upper=1] The upper bound.
  29988. * @param {boolean} [floating] Specify returning a floating-point number.
  29989. * @returns {number} Returns the random number.
  29990. * @example
  29991. *
  29992. * _.random(0, 5);
  29993. * // => an integer between 0 and 5
  29994. *
  29995. * _.random(5);
  29996. * // => also an integer between 0 and 5
  29997. *
  29998. * _.random(5, true);
  29999. * // => a floating-point number between 0 and 5
  30000. *
  30001. * _.random(1.2, 5.2);
  30002. * // => a floating-point number between 1.2 and 5.2
  30003. */
  30004. function random(lower, upper, floating) {
  30005. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30006. upper = floating = undefined;
  30007. }
  30008. if (floating === undefined) {
  30009. if (typeof upper == 'boolean') {
  30010. floating = upper;
  30011. upper = undefined;
  30012. }
  30013. else if (typeof lower == 'boolean') {
  30014. floating = lower;
  30015. lower = undefined;
  30016. }
  30017. }
  30018. if (lower === undefined && upper === undefined) {
  30019. lower = 0;
  30020. upper = 1;
  30021. }
  30022. else {
  30023. lower = toFinite(lower);
  30024. if (upper === undefined) {
  30025. upper = lower;
  30026. lower = 0;
  30027. } else {
  30028. upper = toFinite(upper);
  30029. }
  30030. }
  30031. if (lower > upper) {
  30032. var temp = lower;
  30033. lower = upper;
  30034. upper = temp;
  30035. }
  30036. if (floating || lower % 1 || upper % 1) {
  30037. var rand = nativeRandom();
  30038. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30039. }
  30040. return baseRandom(lower, upper);
  30041. }
  30042. /*------------------------------------------------------------------------*/
  30043. /**
  30044. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30045. *
  30046. * @static
  30047. * @memberOf _
  30048. * @since 3.0.0
  30049. * @category String
  30050. * @param {string} [string=''] The string to convert.
  30051. * @returns {string} Returns the camel cased string.
  30052. * @example
  30053. *
  30054. * _.camelCase('Foo Bar');
  30055. * // => 'fooBar'
  30056. *
  30057. * _.camelCase('--foo-bar--');
  30058. * // => 'fooBar'
  30059. *
  30060. * _.camelCase('__FOO_BAR__');
  30061. * // => 'fooBar'
  30062. */
  30063. var camelCase = createCompounder(function(result, word, index) {
  30064. word = word.toLowerCase();
  30065. return result + (index ? capitalize(word) : word);
  30066. });
  30067. /**
  30068. * Converts the first character of `string` to upper case and the remaining
  30069. * to lower case.
  30070. *
  30071. * @static
  30072. * @memberOf _
  30073. * @since 3.0.0
  30074. * @category String
  30075. * @param {string} [string=''] The string to capitalize.
  30076. * @returns {string} Returns the capitalized string.
  30077. * @example
  30078. *
  30079. * _.capitalize('FRED');
  30080. * // => 'Fred'
  30081. */
  30082. function capitalize(string) {
  30083. return upperFirst(toString(string).toLowerCase());
  30084. }
  30085. /**
  30086. * Deburrs `string` by converting
  30087. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  30088. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  30089. * letters to basic Latin letters and removing
  30090. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  30091. *
  30092. * @static
  30093. * @memberOf _
  30094. * @since 3.0.0
  30095. * @category String
  30096. * @param {string} [string=''] The string to deburr.
  30097. * @returns {string} Returns the deburred string.
  30098. * @example
  30099. *
  30100. * _.deburr('déjà vu');
  30101. * // => 'deja vu'
  30102. */
  30103. function deburr(string) {
  30104. string = toString(string);
  30105. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  30106. }
  30107. /**
  30108. * Checks if `string` ends with the given target string.
  30109. *
  30110. * @static
  30111. * @memberOf _
  30112. * @since 3.0.0
  30113. * @category String
  30114. * @param {string} [string=''] The string to inspect.
  30115. * @param {string} [target] The string to search for.
  30116. * @param {number} [position=string.length] The position to search up to.
  30117. * @returns {boolean} Returns `true` if `string` ends with `target`,
  30118. * else `false`.
  30119. * @example
  30120. *
  30121. * _.endsWith('abc', 'c');
  30122. * // => true
  30123. *
  30124. * _.endsWith('abc', 'b');
  30125. * // => false
  30126. *
  30127. * _.endsWith('abc', 'b', 2);
  30128. * // => true
  30129. */
  30130. function endsWith(string, target, position) {
  30131. string = toString(string);
  30132. target = baseToString(target);
  30133. var length = string.length;
  30134. position = position === undefined
  30135. ? length
  30136. : baseClamp(toInteger(position), 0, length);
  30137. var end = position;
  30138. position -= target.length;
  30139. return position >= 0 && string.slice(position, end) == target;
  30140. }
  30141. /**
  30142. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  30143. * corresponding HTML entities.
  30144. *
  30145. * **Note:** No other characters are escaped. To escape additional
  30146. * characters use a third-party library like [_he_](https://mths.be/he).
  30147. *
  30148. * Though the ">" character is escaped for symmetry, characters like
  30149. * ">" and "/" don't need escaping in HTML and have no special meaning
  30150. * unless they're part of a tag or unquoted attribute value. See
  30151. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  30152. * (under "semi-related fun fact") for more details.
  30153. *
  30154. * When working with HTML you should always
  30155. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  30156. * XSS vectors.
  30157. *
  30158. * @static
  30159. * @since 0.1.0
  30160. * @memberOf _
  30161. * @category String
  30162. * @param {string} [string=''] The string to escape.
  30163. * @returns {string} Returns the escaped string.
  30164. * @example
  30165. *
  30166. * _.escape('fred, barney, & pebbles');
  30167. * // => 'fred, barney, &amp; pebbles'
  30168. */
  30169. function escape(string) {
  30170. string = toString(string);
  30171. return (string && reHasUnescapedHtml.test(string))
  30172. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  30173. : string;
  30174. }
  30175. /**
  30176. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  30177. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  30178. *
  30179. * @static
  30180. * @memberOf _
  30181. * @since 3.0.0
  30182. * @category String
  30183. * @param {string} [string=''] The string to escape.
  30184. * @returns {string} Returns the escaped string.
  30185. * @example
  30186. *
  30187. * _.escapeRegExp('[lodash](https://lodash.com/)');
  30188. * // => '\[lodash\]\(https://lodash\.com/\)'
  30189. */
  30190. function escapeRegExp(string) {
  30191. string = toString(string);
  30192. return (string && reHasRegExpChar.test(string))
  30193. ? string.replace(reRegExpChar, '\\$&')
  30194. : string;
  30195. }
  30196. /**
  30197. * Converts `string` to
  30198. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  30199. *
  30200. * @static
  30201. * @memberOf _
  30202. * @since 3.0.0
  30203. * @category String
  30204. * @param {string} [string=''] The string to convert.
  30205. * @returns {string} Returns the kebab cased string.
  30206. * @example
  30207. *
  30208. * _.kebabCase('Foo Bar');
  30209. * // => 'foo-bar'
  30210. *
  30211. * _.kebabCase('fooBar');
  30212. * // => 'foo-bar'
  30213. *
  30214. * _.kebabCase('__FOO_BAR__');
  30215. * // => 'foo-bar'
  30216. */
  30217. var kebabCase = createCompounder(function(result, word, index) {
  30218. return result + (index ? '-' : '') + word.toLowerCase();
  30219. });
  30220. /**
  30221. * Converts `string`, as space separated words, to lower case.
  30222. *
  30223. * @static
  30224. * @memberOf _
  30225. * @since 4.0.0
  30226. * @category String
  30227. * @param {string} [string=''] The string to convert.
  30228. * @returns {string} Returns the lower cased string.
  30229. * @example
  30230. *
  30231. * _.lowerCase('--Foo-Bar--');
  30232. * // => 'foo bar'
  30233. *
  30234. * _.lowerCase('fooBar');
  30235. * // => 'foo bar'
  30236. *
  30237. * _.lowerCase('__FOO_BAR__');
  30238. * // => 'foo bar'
  30239. */
  30240. var lowerCase = createCompounder(function(result, word, index) {
  30241. return result + (index ? ' ' : '') + word.toLowerCase();
  30242. });
  30243. /**
  30244. * Converts the first character of `string` to lower case.
  30245. *
  30246. * @static
  30247. * @memberOf _
  30248. * @since 4.0.0
  30249. * @category String
  30250. * @param {string} [string=''] The string to convert.
  30251. * @returns {string} Returns the converted string.
  30252. * @example
  30253. *
  30254. * _.lowerFirst('Fred');
  30255. * // => 'fred'
  30256. *
  30257. * _.lowerFirst('FRED');
  30258. * // => 'fRED'
  30259. */
  30260. var lowerFirst = createCaseFirst('toLowerCase');
  30261. /**
  30262. * Pads `string` on the left and right sides if it's shorter than `length`.
  30263. * Padding characters are truncated if they can't be evenly divided by `length`.
  30264. *
  30265. * @static
  30266. * @memberOf _
  30267. * @since 3.0.0
  30268. * @category String
  30269. * @param {string} [string=''] The string to pad.
  30270. * @param {number} [length=0] The padding length.
  30271. * @param {string} [chars=' '] The string used as padding.
  30272. * @returns {string} Returns the padded string.
  30273. * @example
  30274. *
  30275. * _.pad('abc', 8);
  30276. * // => ' abc '
  30277. *
  30278. * _.pad('abc', 8, '_-');
  30279. * // => '_-abc_-_'
  30280. *
  30281. * _.pad('abc', 3);
  30282. * // => 'abc'
  30283. */
  30284. function pad(string, length, chars) {
  30285. string = toString(string);
  30286. length = toInteger(length);
  30287. var strLength = length ? stringSize(string) : 0;
  30288. if (!length || strLength >= length) {
  30289. return string;
  30290. }
  30291. var mid = (length - strLength) / 2;
  30292. return (
  30293. createPadding(nativeFloor(mid), chars) +
  30294. string +
  30295. createPadding(nativeCeil(mid), chars)
  30296. );
  30297. }
  30298. /**
  30299. * Pads `string` on the right side if it's shorter than `length`. Padding
  30300. * characters are truncated if they exceed `length`.
  30301. *
  30302. * @static
  30303. * @memberOf _
  30304. * @since 4.0.0
  30305. * @category String
  30306. * @param {string} [string=''] The string to pad.
  30307. * @param {number} [length=0] The padding length.
  30308. * @param {string} [chars=' '] The string used as padding.
  30309. * @returns {string} Returns the padded string.
  30310. * @example
  30311. *
  30312. * _.padEnd('abc', 6);
  30313. * // => 'abc '
  30314. *
  30315. * _.padEnd('abc', 6, '_-');
  30316. * // => 'abc_-_'
  30317. *
  30318. * _.padEnd('abc', 3);
  30319. * // => 'abc'
  30320. */
  30321. function padEnd(string, length, chars) {
  30322. string = toString(string);
  30323. length = toInteger(length);
  30324. var strLength = length ? stringSize(string) : 0;
  30325. return (length && strLength < length)
  30326. ? (string + createPadding(length - strLength, chars))
  30327. : string;
  30328. }
  30329. /**
  30330. * Pads `string` on the left side if it's shorter than `length`. Padding
  30331. * characters are truncated if they exceed `length`.
  30332. *
  30333. * @static
  30334. * @memberOf _
  30335. * @since 4.0.0
  30336. * @category String
  30337. * @param {string} [string=''] The string to pad.
  30338. * @param {number} [length=0] The padding length.
  30339. * @param {string} [chars=' '] The string used as padding.
  30340. * @returns {string} Returns the padded string.
  30341. * @example
  30342. *
  30343. * _.padStart('abc', 6);
  30344. * // => ' abc'
  30345. *
  30346. * _.padStart('abc', 6, '_-');
  30347. * // => '_-_abc'
  30348. *
  30349. * _.padStart('abc', 3);
  30350. * // => 'abc'
  30351. */
  30352. function padStart(string, length, chars) {
  30353. string = toString(string);
  30354. length = toInteger(length);
  30355. var strLength = length ? stringSize(string) : 0;
  30356. return (length && strLength < length)
  30357. ? (createPadding(length - strLength, chars) + string)
  30358. : string;
  30359. }
  30360. /**
  30361. * Converts `string` to an integer of the specified radix. If `radix` is
  30362. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  30363. * hexadecimal, in which case a `radix` of `16` is used.
  30364. *
  30365. * **Note:** This method aligns with the
  30366. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  30367. *
  30368. * @static
  30369. * @memberOf _
  30370. * @since 1.1.0
  30371. * @category String
  30372. * @param {string} string The string to convert.
  30373. * @param {number} [radix=10] The radix to interpret `value` by.
  30374. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30375. * @returns {number} Returns the converted integer.
  30376. * @example
  30377. *
  30378. * _.parseInt('08');
  30379. * // => 8
  30380. *
  30381. * _.map(['6', '08', '10'], _.parseInt);
  30382. * // => [6, 8, 10]
  30383. */
  30384. function parseInt(string, radix, guard) {
  30385. if (guard || radix == null) {
  30386. radix = 0;
  30387. } else if (radix) {
  30388. radix = +radix;
  30389. }
  30390. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  30391. }
  30392. /**
  30393. * Repeats the given string `n` times.
  30394. *
  30395. * @static
  30396. * @memberOf _
  30397. * @since 3.0.0
  30398. * @category String
  30399. * @param {string} [string=''] The string to repeat.
  30400. * @param {number} [n=1] The number of times to repeat the string.
  30401. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30402. * @returns {string} Returns the repeated string.
  30403. * @example
  30404. *
  30405. * _.repeat('*', 3);
  30406. * // => '***'
  30407. *
  30408. * _.repeat('abc', 2);
  30409. * // => 'abcabc'
  30410. *
  30411. * _.repeat('abc', 0);
  30412. * // => ''
  30413. */
  30414. function repeat(string, n, guard) {
  30415. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  30416. n = 1;
  30417. } else {
  30418. n = toInteger(n);
  30419. }
  30420. return baseRepeat(toString(string), n);
  30421. }
  30422. /**
  30423. * Replaces matches for `pattern` in `string` with `replacement`.
  30424. *
  30425. * **Note:** This method is based on
  30426. * [`String#replace`](https://mdn.io/String/replace).
  30427. *
  30428. * @static
  30429. * @memberOf _
  30430. * @since 4.0.0
  30431. * @category String
  30432. * @param {string} [string=''] The string to modify.
  30433. * @param {RegExp|string} pattern The pattern to replace.
  30434. * @param {Function|string} replacement The match replacement.
  30435. * @returns {string} Returns the modified string.
  30436. * @example
  30437. *
  30438. * _.replace('Hi Fred', 'Fred', 'Barney');
  30439. * // => 'Hi Barney'
  30440. */
  30441. function replace() {
  30442. var args = arguments,
  30443. string = toString(args[0]);
  30444. return args.length < 3 ? string : string.replace(args[1], args[2]);
  30445. }
  30446. /**
  30447. * Converts `string` to
  30448. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  30449. *
  30450. * @static
  30451. * @memberOf _
  30452. * @since 3.0.0
  30453. * @category String
  30454. * @param {string} [string=''] The string to convert.
  30455. * @returns {string} Returns the snake cased string.
  30456. * @example
  30457. *
  30458. * _.snakeCase('Foo Bar');
  30459. * // => 'foo_bar'
  30460. *
  30461. * _.snakeCase('fooBar');
  30462. * // => 'foo_bar'
  30463. *
  30464. * _.snakeCase('--FOO-BAR--');
  30465. * // => 'foo_bar'
  30466. */
  30467. var snakeCase = createCompounder(function(result, word, index) {
  30468. return result + (index ? '_' : '') + word.toLowerCase();
  30469. });
  30470. /**
  30471. * Splits `string` by `separator`.
  30472. *
  30473. * **Note:** This method is based on
  30474. * [`String#split`](https://mdn.io/String/split).
  30475. *
  30476. * @static
  30477. * @memberOf _
  30478. * @since 4.0.0
  30479. * @category String
  30480. * @param {string} [string=''] The string to split.
  30481. * @param {RegExp|string} separator The separator pattern to split by.
  30482. * @param {number} [limit] The length to truncate results to.
  30483. * @returns {Array} Returns the string segments.
  30484. * @example
  30485. *
  30486. * _.split('a-b-c', '-', 2);
  30487. * // => ['a', 'b']
  30488. */
  30489. function split(string, separator, limit) {
  30490. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  30491. separator = limit = undefined;
  30492. }
  30493. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  30494. if (!limit) {
  30495. return [];
  30496. }
  30497. string = toString(string);
  30498. if (string && (
  30499. typeof separator == 'string' ||
  30500. (separator != null && !isRegExp(separator))
  30501. )) {
  30502. separator = baseToString(separator);
  30503. if (!separator && hasUnicode(string)) {
  30504. return castSlice(stringToArray(string), 0, limit);
  30505. }
  30506. }
  30507. return string.split(separator, limit);
  30508. }
  30509. /**
  30510. * Converts `string` to
  30511. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  30512. *
  30513. * @static
  30514. * @memberOf _
  30515. * @since 3.1.0
  30516. * @category String
  30517. * @param {string} [string=''] The string to convert.
  30518. * @returns {string} Returns the start cased string.
  30519. * @example
  30520. *
  30521. * _.startCase('--foo-bar--');
  30522. * // => 'Foo Bar'
  30523. *
  30524. * _.startCase('fooBar');
  30525. * // => 'Foo Bar'
  30526. *
  30527. * _.startCase('__FOO_BAR__');
  30528. * // => 'FOO BAR'
  30529. */
  30530. var startCase = createCompounder(function(result, word, index) {
  30531. return result + (index ? ' ' : '') + upperFirst(word);
  30532. });
  30533. /**
  30534. * Checks if `string` starts with the given target string.
  30535. *
  30536. * @static
  30537. * @memberOf _
  30538. * @since 3.0.0
  30539. * @category String
  30540. * @param {string} [string=''] The string to inspect.
  30541. * @param {string} [target] The string to search for.
  30542. * @param {number} [position=0] The position to search from.
  30543. * @returns {boolean} Returns `true` if `string` starts with `target`,
  30544. * else `false`.
  30545. * @example
  30546. *
  30547. * _.startsWith('abc', 'a');
  30548. * // => true
  30549. *
  30550. * _.startsWith('abc', 'b');
  30551. * // => false
  30552. *
  30553. * _.startsWith('abc', 'b', 1);
  30554. * // => true
  30555. */
  30556. function startsWith(string, target, position) {
  30557. string = toString(string);
  30558. position = position == null
  30559. ? 0
  30560. : baseClamp(toInteger(position), 0, string.length);
  30561. target = baseToString(target);
  30562. return string.slice(position, position + target.length) == target;
  30563. }
  30564. /**
  30565. * Creates a compiled template function that can interpolate data properties
  30566. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  30567. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  30568. * properties may be accessed as free variables in the template. If a setting
  30569. * object is given, it takes precedence over `_.templateSettings` values.
  30570. *
  30571. * **Note:** In the development build `_.template` utilizes
  30572. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  30573. * for easier debugging.
  30574. *
  30575. * For more information on precompiling templates see
  30576. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  30577. *
  30578. * For more information on Chrome extension sandboxes see
  30579. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  30580. *
  30581. * @static
  30582. * @since 0.1.0
  30583. * @memberOf _
  30584. * @category String
  30585. * @param {string} [string=''] The template string.
  30586. * @param {Object} [options={}] The options object.
  30587. * @param {RegExp} [options.escape=_.templateSettings.escape]
  30588. * The HTML "escape" delimiter.
  30589. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  30590. * The "evaluate" delimiter.
  30591. * @param {Object} [options.imports=_.templateSettings.imports]
  30592. * An object to import into the template as free variables.
  30593. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  30594. * The "interpolate" delimiter.
  30595. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  30596. * The sourceURL of the compiled template.
  30597. * @param {string} [options.variable='obj']
  30598. * The data object variable name.
  30599. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30600. * @returns {Function} Returns the compiled template function.
  30601. * @example
  30602. *
  30603. * // Use the "interpolate" delimiter to create a compiled template.
  30604. * var compiled = _.template('hello <%= user %>!');
  30605. * compiled({ 'user': 'fred' });
  30606. * // => 'hello fred!'
  30607. *
  30608. * // Use the HTML "escape" delimiter to escape data property values.
  30609. * var compiled = _.template('<b><%- value %></b>');
  30610. * compiled({ 'value': '<script>' });
  30611. * // => '<b>&lt;script&gt;</b>'
  30612. *
  30613. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  30614. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  30615. * compiled({ 'users': ['fred', 'barney'] });
  30616. * // => '<li>fred</li><li>barney</li>'
  30617. *
  30618. * // Use the internal `print` function in "evaluate" delimiters.
  30619. * var compiled = _.template('<% print("hello " + user); %>!');
  30620. * compiled({ 'user': 'barney' });
  30621. * // => 'hello barney!'
  30622. *
  30623. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  30624. * // Disable support by replacing the "interpolate" delimiter.
  30625. * var compiled = _.template('hello ${ user }!');
  30626. * compiled({ 'user': 'pebbles' });
  30627. * // => 'hello pebbles!'
  30628. *
  30629. * // Use backslashes to treat delimiters as plain text.
  30630. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  30631. * compiled({ 'value': 'ignored' });
  30632. * // => '<%- value %>'
  30633. *
  30634. * // Use the `imports` option to import `jQuery` as `jq`.
  30635. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  30636. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  30637. * compiled({ 'users': ['fred', 'barney'] });
  30638. * // => '<li>fred</li><li>barney</li>'
  30639. *
  30640. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  30641. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  30642. * compiled(data);
  30643. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  30644. *
  30645. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  30646. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  30647. * compiled.source;
  30648. * // => function(data) {
  30649. * // var __t, __p = '';
  30650. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  30651. * // return __p;
  30652. * // }
  30653. *
  30654. * // Use custom template delimiters.
  30655. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  30656. * var compiled = _.template('hello {{ user }}!');
  30657. * compiled({ 'user': 'mustache' });
  30658. * // => 'hello mustache!'
  30659. *
  30660. * // Use the `source` property to inline compiled templates for meaningful
  30661. * // line numbers in error messages and stack traces.
  30662. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  30663. * var JST = {\
  30664. * "main": ' + _.template(mainText).source + '\
  30665. * };\
  30666. * ');
  30667. */
  30668. function template(string, options, guard) {
  30669. // Based on John Resig's `tmpl` implementation
  30670. // (http://ejohn.org/blog/javascript-micro-templating/)
  30671. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  30672. var settings = lodash.templateSettings;
  30673. if (guard && isIterateeCall(string, options, guard)) {
  30674. options = undefined;
  30675. }
  30676. string = toString(string);
  30677. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  30678. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  30679. importsKeys = keys(imports),
  30680. importsValues = baseValues(imports, importsKeys);
  30681. var isEscaping,
  30682. isEvaluating,
  30683. index = 0,
  30684. interpolate = options.interpolate || reNoMatch,
  30685. source = "__p += '";
  30686. // Compile the regexp to match each delimiter.
  30687. var reDelimiters = RegExp(
  30688. (options.escape || reNoMatch).source + '|' +
  30689. interpolate.source + '|' +
  30690. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  30691. (options.evaluate || reNoMatch).source + '|$'
  30692. , 'g');
  30693. // Use a sourceURL for easier debugging.
  30694. // The sourceURL gets injected into the source that's eval-ed, so be careful
  30695. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  30696. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  30697. var sourceURL = '//# sourceURL=' +
  30698. (hasOwnProperty.call(options, 'sourceURL')
  30699. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  30700. : ('lodash.templateSources[' + (++templateCounter) + ']')
  30701. ) + '\n';
  30702. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  30703. interpolateValue || (interpolateValue = esTemplateValue);
  30704. // Escape characters that can't be included in string literals.
  30705. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  30706. // Replace delimiters with snippets.
  30707. if (escapeValue) {
  30708. isEscaping = true;
  30709. source += "' +\n__e(" + escapeValue + ") +\n'";
  30710. }
  30711. if (evaluateValue) {
  30712. isEvaluating = true;
  30713. source += "';\n" + evaluateValue + ";\n__p += '";
  30714. }
  30715. if (interpolateValue) {
  30716. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  30717. }
  30718. index = offset + match.length;
  30719. // The JS engine embedded in Adobe products needs `match` returned in
  30720. // order to produce the correct `offset` value.
  30721. return match;
  30722. });
  30723. source += "';\n";
  30724. // If `variable` is not specified wrap a with-statement around the generated
  30725. // code to add the data object to the top of the scope chain.
  30726. // Like with sourceURL, we take care to not check the option's prototype,
  30727. // as this configuration is a code injection vector.
  30728. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  30729. if (!variable) {
  30730. source = 'with (obj) {\n' + source + '\n}\n';
  30731. }
  30732. // Cleanup code by stripping empty strings.
  30733. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  30734. .replace(reEmptyStringMiddle, '$1')
  30735. .replace(reEmptyStringTrailing, '$1;');
  30736. // Frame code as the function body.
  30737. source = 'function(' + (variable || 'obj') + ') {\n' +
  30738. (variable
  30739. ? ''
  30740. : 'obj || (obj = {});\n'
  30741. ) +
  30742. "var __t, __p = ''" +
  30743. (isEscaping
  30744. ? ', __e = _.escape'
  30745. : ''
  30746. ) +
  30747. (isEvaluating
  30748. ? ', __j = Array.prototype.join;\n' +
  30749. "function print() { __p += __j.call(arguments, '') }\n"
  30750. : ';\n'
  30751. ) +
  30752. source +
  30753. 'return __p\n}';
  30754. var result = attempt(function() {
  30755. return Function(importsKeys, sourceURL + 'return ' + source)
  30756. .apply(undefined, importsValues);
  30757. });
  30758. // Provide the compiled function's source by its `toString` method or
  30759. // the `source` property as a convenience for inlining compiled templates.
  30760. result.source = source;
  30761. if (isError(result)) {
  30762. throw result;
  30763. }
  30764. return result;
  30765. }
  30766. /**
  30767. * Converts `string`, as a whole, to lower case just like
  30768. * [String#toLowerCase](https://mdn.io/toLowerCase).
  30769. *
  30770. * @static
  30771. * @memberOf _
  30772. * @since 4.0.0
  30773. * @category String
  30774. * @param {string} [string=''] The string to convert.
  30775. * @returns {string} Returns the lower cased string.
  30776. * @example
  30777. *
  30778. * _.toLower('--Foo-Bar--');
  30779. * // => '--foo-bar--'
  30780. *
  30781. * _.toLower('fooBar');
  30782. * // => 'foobar'
  30783. *
  30784. * _.toLower('__FOO_BAR__');
  30785. * // => '__foo_bar__'
  30786. */
  30787. function toLower(value) {
  30788. return toString(value).toLowerCase();
  30789. }
  30790. /**
  30791. * Converts `string`, as a whole, to upper case just like
  30792. * [String#toUpperCase](https://mdn.io/toUpperCase).
  30793. *
  30794. * @static
  30795. * @memberOf _
  30796. * @since 4.0.0
  30797. * @category String
  30798. * @param {string} [string=''] The string to convert.
  30799. * @returns {string} Returns the upper cased string.
  30800. * @example
  30801. *
  30802. * _.toUpper('--foo-bar--');
  30803. * // => '--FOO-BAR--'
  30804. *
  30805. * _.toUpper('fooBar');
  30806. * // => 'FOOBAR'
  30807. *
  30808. * _.toUpper('__foo_bar__');
  30809. * // => '__FOO_BAR__'
  30810. */
  30811. function toUpper(value) {
  30812. return toString(value).toUpperCase();
  30813. }
  30814. /**
  30815. * Removes leading and trailing whitespace or specified characters from `string`.
  30816. *
  30817. * @static
  30818. * @memberOf _
  30819. * @since 3.0.0
  30820. * @category String
  30821. * @param {string} [string=''] The string to trim.
  30822. * @param {string} [chars=whitespace] The characters to trim.
  30823. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30824. * @returns {string} Returns the trimmed string.
  30825. * @example
  30826. *
  30827. * _.trim(' abc ');
  30828. * // => 'abc'
  30829. *
  30830. * _.trim('-_-abc-_-', '_-');
  30831. * // => 'abc'
  30832. *
  30833. * _.map([' foo ', ' bar '], _.trim);
  30834. * // => ['foo', 'bar']
  30835. */
  30836. function trim(string, chars, guard) {
  30837. string = toString(string);
  30838. if (string && (guard || chars === undefined)) {
  30839. return string.replace(reTrim, '');
  30840. }
  30841. if (!string || !(chars = baseToString(chars))) {
  30842. return string;
  30843. }
  30844. var strSymbols = stringToArray(string),
  30845. chrSymbols = stringToArray(chars),
  30846. start = charsStartIndex(strSymbols, chrSymbols),
  30847. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  30848. return castSlice(strSymbols, start, end).join('');
  30849. }
  30850. /**
  30851. * Removes trailing whitespace or specified characters from `string`.
  30852. *
  30853. * @static
  30854. * @memberOf _
  30855. * @since 4.0.0
  30856. * @category String
  30857. * @param {string} [string=''] The string to trim.
  30858. * @param {string} [chars=whitespace] The characters to trim.
  30859. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30860. * @returns {string} Returns the trimmed string.
  30861. * @example
  30862. *
  30863. * _.trimEnd(' abc ');
  30864. * // => ' abc'
  30865. *
  30866. * _.trimEnd('-_-abc-_-', '_-');
  30867. * // => '-_-abc'
  30868. */
  30869. function trimEnd(string, chars, guard) {
  30870. string = toString(string);
  30871. if (string && (guard || chars === undefined)) {
  30872. return string.replace(reTrimEnd, '');
  30873. }
  30874. if (!string || !(chars = baseToString(chars))) {
  30875. return string;
  30876. }
  30877. var strSymbols = stringToArray(string),
  30878. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  30879. return castSlice(strSymbols, 0, end).join('');
  30880. }
  30881. /**
  30882. * Removes leading whitespace or specified characters from `string`.
  30883. *
  30884. * @static
  30885. * @memberOf _
  30886. * @since 4.0.0
  30887. * @category String
  30888. * @param {string} [string=''] The string to trim.
  30889. * @param {string} [chars=whitespace] The characters to trim.
  30890. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  30891. * @returns {string} Returns the trimmed string.
  30892. * @example
  30893. *
  30894. * _.trimStart(' abc ');
  30895. * // => 'abc '
  30896. *
  30897. * _.trimStart('-_-abc-_-', '_-');
  30898. * // => 'abc-_-'
  30899. */
  30900. function trimStart(string, chars, guard) {
  30901. string = toString(string);
  30902. if (string && (guard || chars === undefined)) {
  30903. return string.replace(reTrimStart, '');
  30904. }
  30905. if (!string || !(chars = baseToString(chars))) {
  30906. return string;
  30907. }
  30908. var strSymbols = stringToArray(string),
  30909. start = charsStartIndex(strSymbols, stringToArray(chars));
  30910. return castSlice(strSymbols, start).join('');
  30911. }
  30912. /**
  30913. * Truncates `string` if it's longer than the given maximum string length.
  30914. * The last characters of the truncated string are replaced with the omission
  30915. * string which defaults to "...".
  30916. *
  30917. * @static
  30918. * @memberOf _
  30919. * @since 4.0.0
  30920. * @category String
  30921. * @param {string} [string=''] The string to truncate.
  30922. * @param {Object} [options={}] The options object.
  30923. * @param {number} [options.length=30] The maximum string length.
  30924. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  30925. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  30926. * @returns {string} Returns the truncated string.
  30927. * @example
  30928. *
  30929. * _.truncate('hi-diddly-ho there, neighborino');
  30930. * // => 'hi-diddly-ho there, neighbo...'
  30931. *
  30932. * _.truncate('hi-diddly-ho there, neighborino', {
  30933. * 'length': 24,
  30934. * 'separator': ' '
  30935. * });
  30936. * // => 'hi-diddly-ho there,...'
  30937. *
  30938. * _.truncate('hi-diddly-ho there, neighborino', {
  30939. * 'length': 24,
  30940. * 'separator': /,? +/
  30941. * });
  30942. * // => 'hi-diddly-ho there...'
  30943. *
  30944. * _.truncate('hi-diddly-ho there, neighborino', {
  30945. * 'omission': ' [...]'
  30946. * });
  30947. * // => 'hi-diddly-ho there, neig [...]'
  30948. */
  30949. function truncate(string, options) {
  30950. var length = DEFAULT_TRUNC_LENGTH,
  30951. omission = DEFAULT_TRUNC_OMISSION;
  30952. if (isObject(options)) {
  30953. var separator = 'separator' in options ? options.separator : separator;
  30954. length = 'length' in options ? toInteger(options.length) : length;
  30955. omission = 'omission' in options ? baseToString(options.omission) : omission;
  30956. }
  30957. string = toString(string);
  30958. var strLength = string.length;
  30959. if (hasUnicode(string)) {
  30960. var strSymbols = stringToArray(string);
  30961. strLength = strSymbols.length;
  30962. }
  30963. if (length >= strLength) {
  30964. return string;
  30965. }
  30966. var end = length - stringSize(omission);
  30967. if (end < 1) {
  30968. return omission;
  30969. }
  30970. var result = strSymbols
  30971. ? castSlice(strSymbols, 0, end).join('')
  30972. : string.slice(0, end);
  30973. if (separator === undefined) {
  30974. return result + omission;
  30975. }
  30976. if (strSymbols) {
  30977. end += (result.length - end);
  30978. }
  30979. if (isRegExp(separator)) {
  30980. if (string.slice(end).search(separator)) {
  30981. var match,
  30982. substring = result;
  30983. if (!separator.global) {
  30984. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  30985. }
  30986. separator.lastIndex = 0;
  30987. while ((match = separator.exec(substring))) {
  30988. var newEnd = match.index;
  30989. }
  30990. result = result.slice(0, newEnd === undefined ? end : newEnd);
  30991. }
  30992. } else if (string.indexOf(baseToString(separator), end) != end) {
  30993. var index = result.lastIndexOf(separator);
  30994. if (index > -1) {
  30995. result = result.slice(0, index);
  30996. }
  30997. }
  30998. return result + omission;
  30999. }
  31000. /**
  31001. * The inverse of `_.escape`; this method converts the HTML entities
  31002. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31003. * their corresponding characters.
  31004. *
  31005. * **Note:** No other HTML entities are unescaped. To unescape additional
  31006. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31007. *
  31008. * @static
  31009. * @memberOf _
  31010. * @since 0.6.0
  31011. * @category String
  31012. * @param {string} [string=''] The string to unescape.
  31013. * @returns {string} Returns the unescaped string.
  31014. * @example
  31015. *
  31016. * _.unescape('fred, barney, &amp; pebbles');
  31017. * // => 'fred, barney, & pebbles'
  31018. */
  31019. function unescape(string) {
  31020. string = toString(string);
  31021. return (string && reHasEscapedHtml.test(string))
  31022. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31023. : string;
  31024. }
  31025. /**
  31026. * Converts `string`, as space separated words, to upper case.
  31027. *
  31028. * @static
  31029. * @memberOf _
  31030. * @since 4.0.0
  31031. * @category String
  31032. * @param {string} [string=''] The string to convert.
  31033. * @returns {string} Returns the upper cased string.
  31034. * @example
  31035. *
  31036. * _.upperCase('--foo-bar');
  31037. * // => 'FOO BAR'
  31038. *
  31039. * _.upperCase('fooBar');
  31040. * // => 'FOO BAR'
  31041. *
  31042. * _.upperCase('__foo_bar__');
  31043. * // => 'FOO BAR'
  31044. */
  31045. var upperCase = createCompounder(function(result, word, index) {
  31046. return result + (index ? ' ' : '') + word.toUpperCase();
  31047. });
  31048. /**
  31049. * Converts the first character of `string` to upper case.
  31050. *
  31051. * @static
  31052. * @memberOf _
  31053. * @since 4.0.0
  31054. * @category String
  31055. * @param {string} [string=''] The string to convert.
  31056. * @returns {string} Returns the converted string.
  31057. * @example
  31058. *
  31059. * _.upperFirst('fred');
  31060. * // => 'Fred'
  31061. *
  31062. * _.upperFirst('FRED');
  31063. * // => 'FRED'
  31064. */
  31065. var upperFirst = createCaseFirst('toUpperCase');
  31066. /**
  31067. * Splits `string` into an array of its words.
  31068. *
  31069. * @static
  31070. * @memberOf _
  31071. * @since 3.0.0
  31072. * @category String
  31073. * @param {string} [string=''] The string to inspect.
  31074. * @param {RegExp|string} [pattern] The pattern to match words.
  31075. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31076. * @returns {Array} Returns the words of `string`.
  31077. * @example
  31078. *
  31079. * _.words('fred, barney, & pebbles');
  31080. * // => ['fred', 'barney', 'pebbles']
  31081. *
  31082. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  31083. * // => ['fred', 'barney', '&', 'pebbles']
  31084. */
  31085. function words(string, pattern, guard) {
  31086. string = toString(string);
  31087. pattern = guard ? undefined : pattern;
  31088. if (pattern === undefined) {
  31089. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  31090. }
  31091. return string.match(pattern) || [];
  31092. }
  31093. /*------------------------------------------------------------------------*/
  31094. /**
  31095. * Attempts to invoke `func`, returning either the result or the caught error
  31096. * object. Any additional arguments are provided to `func` when it's invoked.
  31097. *
  31098. * @static
  31099. * @memberOf _
  31100. * @since 3.0.0
  31101. * @category Util
  31102. * @param {Function} func The function to attempt.
  31103. * @param {...*} [args] The arguments to invoke `func` with.
  31104. * @returns {*} Returns the `func` result or error object.
  31105. * @example
  31106. *
  31107. * // Avoid throwing errors for invalid selectors.
  31108. * var elements = _.attempt(function(selector) {
  31109. * return document.querySelectorAll(selector);
  31110. * }, '>_>');
  31111. *
  31112. * if (_.isError(elements)) {
  31113. * elements = [];
  31114. * }
  31115. */
  31116. var attempt = baseRest(function(func, args) {
  31117. try {
  31118. return apply(func, undefined, args);
  31119. } catch (e) {
  31120. return isError(e) ? e : new Error(e);
  31121. }
  31122. });
  31123. /**
  31124. * Binds methods of an object to the object itself, overwriting the existing
  31125. * method.
  31126. *
  31127. * **Note:** This method doesn't set the "length" property of bound functions.
  31128. *
  31129. * @static
  31130. * @since 0.1.0
  31131. * @memberOf _
  31132. * @category Util
  31133. * @param {Object} object The object to bind and assign the bound methods to.
  31134. * @param {...(string|string[])} methodNames The object method names to bind.
  31135. * @returns {Object} Returns `object`.
  31136. * @example
  31137. *
  31138. * var view = {
  31139. * 'label': 'docs',
  31140. * 'click': function() {
  31141. * console.log('clicked ' + this.label);
  31142. * }
  31143. * };
  31144. *
  31145. * _.bindAll(view, ['click']);
  31146. * jQuery(element).on('click', view.click);
  31147. * // => Logs 'clicked docs' when clicked.
  31148. */
  31149. var bindAll = flatRest(function(object, methodNames) {
  31150. arrayEach(methodNames, function(key) {
  31151. key = toKey(key);
  31152. baseAssignValue(object, key, bind(object[key], object));
  31153. });
  31154. return object;
  31155. });
  31156. /**
  31157. * Creates a function that iterates over `pairs` and invokes the corresponding
  31158. * function of the first predicate to return truthy. The predicate-function
  31159. * pairs are invoked with the `this` binding and arguments of the created
  31160. * function.
  31161. *
  31162. * @static
  31163. * @memberOf _
  31164. * @since 4.0.0
  31165. * @category Util
  31166. * @param {Array} pairs The predicate-function pairs.
  31167. * @returns {Function} Returns the new composite function.
  31168. * @example
  31169. *
  31170. * var func = _.cond([
  31171. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  31172. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  31173. * [_.stubTrue, _.constant('no match')]
  31174. * ]);
  31175. *
  31176. * func({ 'a': 1, 'b': 2 });
  31177. * // => 'matches A'
  31178. *
  31179. * func({ 'a': 0, 'b': 1 });
  31180. * // => 'matches B'
  31181. *
  31182. * func({ 'a': '1', 'b': '2' });
  31183. * // => 'no match'
  31184. */
  31185. function cond(pairs) {
  31186. var length = pairs == null ? 0 : pairs.length,
  31187. toIteratee = getIteratee();
  31188. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  31189. if (typeof pair[1] != 'function') {
  31190. throw new TypeError(FUNC_ERROR_TEXT);
  31191. }
  31192. return [toIteratee(pair[0]), pair[1]];
  31193. });
  31194. return baseRest(function(args) {
  31195. var index = -1;
  31196. while (++index < length) {
  31197. var pair = pairs[index];
  31198. if (apply(pair[0], this, args)) {
  31199. return apply(pair[1], this, args);
  31200. }
  31201. }
  31202. });
  31203. }
  31204. /**
  31205. * Creates a function that invokes the predicate properties of `source` with
  31206. * the corresponding property values of a given object, returning `true` if
  31207. * all predicates return truthy, else `false`.
  31208. *
  31209. * **Note:** The created function is equivalent to `_.conformsTo` with
  31210. * `source` partially applied.
  31211. *
  31212. * @static
  31213. * @memberOf _
  31214. * @since 4.0.0
  31215. * @category Util
  31216. * @param {Object} source The object of property predicates to conform to.
  31217. * @returns {Function} Returns the new spec function.
  31218. * @example
  31219. *
  31220. * var objects = [
  31221. * { 'a': 2, 'b': 1 },
  31222. * { 'a': 1, 'b': 2 }
  31223. * ];
  31224. *
  31225. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  31226. * // => [{ 'a': 1, 'b': 2 }]
  31227. */
  31228. function conforms(source) {
  31229. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  31230. }
  31231. /**
  31232. * Creates a function that returns `value`.
  31233. *
  31234. * @static
  31235. * @memberOf _
  31236. * @since 2.4.0
  31237. * @category Util
  31238. * @param {*} value The value to return from the new function.
  31239. * @returns {Function} Returns the new constant function.
  31240. * @example
  31241. *
  31242. * var objects = _.times(2, _.constant({ 'a': 1 }));
  31243. *
  31244. * console.log(objects);
  31245. * // => [{ 'a': 1 }, { 'a': 1 }]
  31246. *
  31247. * console.log(objects[0] === objects[1]);
  31248. * // => true
  31249. */
  31250. function constant(value) {
  31251. return function() {
  31252. return value;
  31253. };
  31254. }
  31255. /**
  31256. * Checks `value` to determine whether a default value should be returned in
  31257. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  31258. * or `undefined`.
  31259. *
  31260. * @static
  31261. * @memberOf _
  31262. * @since 4.14.0
  31263. * @category Util
  31264. * @param {*} value The value to check.
  31265. * @param {*} defaultValue The default value.
  31266. * @returns {*} Returns the resolved value.
  31267. * @example
  31268. *
  31269. * _.defaultTo(1, 10);
  31270. * // => 1
  31271. *
  31272. * _.defaultTo(undefined, 10);
  31273. * // => 10
  31274. */
  31275. function defaultTo(value, defaultValue) {
  31276. return (value == null || value !== value) ? defaultValue : value;
  31277. }
  31278. /**
  31279. * Creates a function that returns the result of invoking the given functions
  31280. * with the `this` binding of the created function, where each successive
  31281. * invocation is supplied the return value of the previous.
  31282. *
  31283. * @static
  31284. * @memberOf _
  31285. * @since 3.0.0
  31286. * @category Util
  31287. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31288. * @returns {Function} Returns the new composite function.
  31289. * @see _.flowRight
  31290. * @example
  31291. *
  31292. * function square(n) {
  31293. * return n * n;
  31294. * }
  31295. *
  31296. * var addSquare = _.flow([_.add, square]);
  31297. * addSquare(1, 2);
  31298. * // => 9
  31299. */
  31300. var flow = createFlow();
  31301. /**
  31302. * This method is like `_.flow` except that it creates a function that
  31303. * invokes the given functions from right to left.
  31304. *
  31305. * @static
  31306. * @since 3.0.0
  31307. * @memberOf _
  31308. * @category Util
  31309. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  31310. * @returns {Function} Returns the new composite function.
  31311. * @see _.flow
  31312. * @example
  31313. *
  31314. * function square(n) {
  31315. * return n * n;
  31316. * }
  31317. *
  31318. * var addSquare = _.flowRight([square, _.add]);
  31319. * addSquare(1, 2);
  31320. * // => 9
  31321. */
  31322. var flowRight = createFlow(true);
  31323. /**
  31324. * This method returns the first argument it receives.
  31325. *
  31326. * @static
  31327. * @since 0.1.0
  31328. * @memberOf _
  31329. * @category Util
  31330. * @param {*} value Any value.
  31331. * @returns {*} Returns `value`.
  31332. * @example
  31333. *
  31334. * var object = { 'a': 1 };
  31335. *
  31336. * console.log(_.identity(object) === object);
  31337. * // => true
  31338. */
  31339. function identity(value) {
  31340. return value;
  31341. }
  31342. /**
  31343. * Creates a function that invokes `func` with the arguments of the created
  31344. * function. If `func` is a property name, the created function returns the
  31345. * property value for a given element. If `func` is an array or object, the
  31346. * created function returns `true` for elements that contain the equivalent
  31347. * source properties, otherwise it returns `false`.
  31348. *
  31349. * @static
  31350. * @since 4.0.0
  31351. * @memberOf _
  31352. * @category Util
  31353. * @param {*} [func=_.identity] The value to convert to a callback.
  31354. * @returns {Function} Returns the callback.
  31355. * @example
  31356. *
  31357. * var users = [
  31358. * { 'user': 'barney', 'age': 36, 'active': true },
  31359. * { 'user': 'fred', 'age': 40, 'active': false }
  31360. * ];
  31361. *
  31362. * // The `_.matches` iteratee shorthand.
  31363. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  31364. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  31365. *
  31366. * // The `_.matchesProperty` iteratee shorthand.
  31367. * _.filter(users, _.iteratee(['user', 'fred']));
  31368. * // => [{ 'user': 'fred', 'age': 40 }]
  31369. *
  31370. * // The `_.property` iteratee shorthand.
  31371. * _.map(users, _.iteratee('user'));
  31372. * // => ['barney', 'fred']
  31373. *
  31374. * // Create custom iteratee shorthands.
  31375. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  31376. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  31377. * return func.test(string);
  31378. * };
  31379. * });
  31380. *
  31381. * _.filter(['abc', 'def'], /ef/);
  31382. * // => ['def']
  31383. */
  31384. function iteratee(func) {
  31385. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  31386. }
  31387. /**
  31388. * Creates a function that performs a partial deep comparison between a given
  31389. * object and `source`, returning `true` if the given object has equivalent
  31390. * property values, else `false`.
  31391. *
  31392. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  31393. * partially applied.
  31394. *
  31395. * Partial comparisons will match empty array and empty object `source`
  31396. * values against any array or object value, respectively. See `_.isEqual`
  31397. * for a list of supported value comparisons.
  31398. *
  31399. * @static
  31400. * @memberOf _
  31401. * @since 3.0.0
  31402. * @category Util
  31403. * @param {Object} source The object of property values to match.
  31404. * @returns {Function} Returns the new spec function.
  31405. * @example
  31406. *
  31407. * var objects = [
  31408. * { 'a': 1, 'b': 2, 'c': 3 },
  31409. * { 'a': 4, 'b': 5, 'c': 6 }
  31410. * ];
  31411. *
  31412. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  31413. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  31414. */
  31415. function matches(source) {
  31416. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  31417. }
  31418. /**
  31419. * Creates a function that performs a partial deep comparison between the
  31420. * value at `path` of a given object to `srcValue`, returning `true` if the
  31421. * object value is equivalent, else `false`.
  31422. *
  31423. * **Note:** Partial comparisons will match empty array and empty object
  31424. * `srcValue` values against any array or object value, respectively. See
  31425. * `_.isEqual` for a list of supported value comparisons.
  31426. *
  31427. * @static
  31428. * @memberOf _
  31429. * @since 3.2.0
  31430. * @category Util
  31431. * @param {Array|string} path The path of the property to get.
  31432. * @param {*} srcValue The value to match.
  31433. * @returns {Function} Returns the new spec function.
  31434. * @example
  31435. *
  31436. * var objects = [
  31437. * { 'a': 1, 'b': 2, 'c': 3 },
  31438. * { 'a': 4, 'b': 5, 'c': 6 }
  31439. * ];
  31440. *
  31441. * _.find(objects, _.matchesProperty('a', 4));
  31442. * // => { 'a': 4, 'b': 5, 'c': 6 }
  31443. */
  31444. function matchesProperty(path, srcValue) {
  31445. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  31446. }
  31447. /**
  31448. * Creates a function that invokes the method at `path` of a given object.
  31449. * Any additional arguments are provided to the invoked method.
  31450. *
  31451. * @static
  31452. * @memberOf _
  31453. * @since 3.7.0
  31454. * @category Util
  31455. * @param {Array|string} path The path of the method to invoke.
  31456. * @param {...*} [args] The arguments to invoke the method with.
  31457. * @returns {Function} Returns the new invoker function.
  31458. * @example
  31459. *
  31460. * var objects = [
  31461. * { 'a': { 'b': _.constant(2) } },
  31462. * { 'a': { 'b': _.constant(1) } }
  31463. * ];
  31464. *
  31465. * _.map(objects, _.method('a.b'));
  31466. * // => [2, 1]
  31467. *
  31468. * _.map(objects, _.method(['a', 'b']));
  31469. * // => [2, 1]
  31470. */
  31471. var method = baseRest(function(path, args) {
  31472. return function(object) {
  31473. return baseInvoke(object, path, args);
  31474. };
  31475. });
  31476. /**
  31477. * The opposite of `_.method`; this method creates a function that invokes
  31478. * the method at a given path of `object`. Any additional arguments are
  31479. * provided to the invoked method.
  31480. *
  31481. * @static
  31482. * @memberOf _
  31483. * @since 3.7.0
  31484. * @category Util
  31485. * @param {Object} object The object to query.
  31486. * @param {...*} [args] The arguments to invoke the method with.
  31487. * @returns {Function} Returns the new invoker function.
  31488. * @example
  31489. *
  31490. * var array = _.times(3, _.constant),
  31491. * object = { 'a': array, 'b': array, 'c': array };
  31492. *
  31493. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  31494. * // => [2, 0]
  31495. *
  31496. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  31497. * // => [2, 0]
  31498. */
  31499. var methodOf = baseRest(function(object, args) {
  31500. return function(path) {
  31501. return baseInvoke(object, path, args);
  31502. };
  31503. });
  31504. /**
  31505. * Adds all own enumerable string keyed function properties of a source
  31506. * object to the destination object. If `object` is a function, then methods
  31507. * are added to its prototype as well.
  31508. *
  31509. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  31510. * avoid conflicts caused by modifying the original.
  31511. *
  31512. * @static
  31513. * @since 0.1.0
  31514. * @memberOf _
  31515. * @category Util
  31516. * @param {Function|Object} [object=lodash] The destination object.
  31517. * @param {Object} source The object of functions to add.
  31518. * @param {Object} [options={}] The options object.
  31519. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  31520. * @returns {Function|Object} Returns `object`.
  31521. * @example
  31522. *
  31523. * function vowels(string) {
  31524. * return _.filter(string, function(v) {
  31525. * return /[aeiou]/i.test(v);
  31526. * });
  31527. * }
  31528. *
  31529. * _.mixin({ 'vowels': vowels });
  31530. * _.vowels('fred');
  31531. * // => ['e']
  31532. *
  31533. * _('fred').vowels().value();
  31534. * // => ['e']
  31535. *
  31536. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  31537. * _('fred').vowels();
  31538. * // => ['e']
  31539. */
  31540. function mixin(object, source, options) {
  31541. var props = keys(source),
  31542. methodNames = baseFunctions(source, props);
  31543. if (options == null &&
  31544. !(isObject(source) && (methodNames.length || !props.length))) {
  31545. options = source;
  31546. source = object;
  31547. object = this;
  31548. methodNames = baseFunctions(source, keys(source));
  31549. }
  31550. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  31551. isFunc = isFunction(object);
  31552. arrayEach(methodNames, function(methodName) {
  31553. var func = source[methodName];
  31554. object[methodName] = func;
  31555. if (isFunc) {
  31556. object.prototype[methodName] = function() {
  31557. var chainAll = this.__chain__;
  31558. if (chain || chainAll) {
  31559. var result = object(this.__wrapped__),
  31560. actions = result.__actions__ = copyArray(this.__actions__);
  31561. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  31562. result.__chain__ = chainAll;
  31563. return result;
  31564. }
  31565. return func.apply(object, arrayPush([this.value()], arguments));
  31566. };
  31567. }
  31568. });
  31569. return object;
  31570. }
  31571. /**
  31572. * Reverts the `_` variable to its previous value and returns a reference to
  31573. * the `lodash` function.
  31574. *
  31575. * @static
  31576. * @since 0.1.0
  31577. * @memberOf _
  31578. * @category Util
  31579. * @returns {Function} Returns the `lodash` function.
  31580. * @example
  31581. *
  31582. * var lodash = _.noConflict();
  31583. */
  31584. function noConflict() {
  31585. if (root._ === this) {
  31586. root._ = oldDash;
  31587. }
  31588. return this;
  31589. }
  31590. /**
  31591. * This method returns `undefined`.
  31592. *
  31593. * @static
  31594. * @memberOf _
  31595. * @since 2.3.0
  31596. * @category Util
  31597. * @example
  31598. *
  31599. * _.times(2, _.noop);
  31600. * // => [undefined, undefined]
  31601. */
  31602. function noop() {
  31603. // No operation performed.
  31604. }
  31605. /**
  31606. * Creates a function that gets the argument at index `n`. If `n` is negative,
  31607. * the nth argument from the end is returned.
  31608. *
  31609. * @static
  31610. * @memberOf _
  31611. * @since 4.0.0
  31612. * @category Util
  31613. * @param {number} [n=0] The index of the argument to return.
  31614. * @returns {Function} Returns the new pass-thru function.
  31615. * @example
  31616. *
  31617. * var func = _.nthArg(1);
  31618. * func('a', 'b', 'c', 'd');
  31619. * // => 'b'
  31620. *
  31621. * var func = _.nthArg(-2);
  31622. * func('a', 'b', 'c', 'd');
  31623. * // => 'c'
  31624. */
  31625. function nthArg(n) {
  31626. n = toInteger(n);
  31627. return baseRest(function(args) {
  31628. return baseNth(args, n);
  31629. });
  31630. }
  31631. /**
  31632. * Creates a function that invokes `iteratees` with the arguments it receives
  31633. * and returns their results.
  31634. *
  31635. * @static
  31636. * @memberOf _
  31637. * @since 4.0.0
  31638. * @category Util
  31639. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  31640. * The iteratees to invoke.
  31641. * @returns {Function} Returns the new function.
  31642. * @example
  31643. *
  31644. * var func = _.over([Math.max, Math.min]);
  31645. *
  31646. * func(1, 2, 3, 4);
  31647. * // => [4, 1]
  31648. */
  31649. var over = createOver(arrayMap);
  31650. /**
  31651. * Creates a function that checks if **all** of the `predicates` return
  31652. * truthy when invoked with the arguments it receives.
  31653. *
  31654. * @static
  31655. * @memberOf _
  31656. * @since 4.0.0
  31657. * @category Util
  31658. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31659. * The predicates to check.
  31660. * @returns {Function} Returns the new function.
  31661. * @example
  31662. *
  31663. * var func = _.overEvery([Boolean, isFinite]);
  31664. *
  31665. * func('1');
  31666. * // => true
  31667. *
  31668. * func(null);
  31669. * // => false
  31670. *
  31671. * func(NaN);
  31672. * // => false
  31673. */
  31674. var overEvery = createOver(arrayEvery);
  31675. /**
  31676. * Creates a function that checks if **any** of the `predicates` return
  31677. * truthy when invoked with the arguments it receives.
  31678. *
  31679. * @static
  31680. * @memberOf _
  31681. * @since 4.0.0
  31682. * @category Util
  31683. * @param {...(Function|Function[])} [predicates=[_.identity]]
  31684. * The predicates to check.
  31685. * @returns {Function} Returns the new function.
  31686. * @example
  31687. *
  31688. * var func = _.overSome([Boolean, isFinite]);
  31689. *
  31690. * func('1');
  31691. * // => true
  31692. *
  31693. * func(null);
  31694. * // => true
  31695. *
  31696. * func(NaN);
  31697. * // => false
  31698. */
  31699. var overSome = createOver(arraySome);
  31700. /**
  31701. * Creates a function that returns the value at `path` of a given object.
  31702. *
  31703. * @static
  31704. * @memberOf _
  31705. * @since 2.4.0
  31706. * @category Util
  31707. * @param {Array|string} path The path of the property to get.
  31708. * @returns {Function} Returns the new accessor function.
  31709. * @example
  31710. *
  31711. * var objects = [
  31712. * { 'a': { 'b': 2 } },
  31713. * { 'a': { 'b': 1 } }
  31714. * ];
  31715. *
  31716. * _.map(objects, _.property('a.b'));
  31717. * // => [2, 1]
  31718. *
  31719. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  31720. * // => [1, 2]
  31721. */
  31722. function property(path) {
  31723. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  31724. }
  31725. /**
  31726. * The opposite of `_.property`; this method creates a function that returns
  31727. * the value at a given path of `object`.
  31728. *
  31729. * @static
  31730. * @memberOf _
  31731. * @since 3.0.0
  31732. * @category Util
  31733. * @param {Object} object The object to query.
  31734. * @returns {Function} Returns the new accessor function.
  31735. * @example
  31736. *
  31737. * var array = [0, 1, 2],
  31738. * object = { 'a': array, 'b': array, 'c': array };
  31739. *
  31740. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  31741. * // => [2, 0]
  31742. *
  31743. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  31744. * // => [2, 0]
  31745. */
  31746. function propertyOf(object) {
  31747. return function(path) {
  31748. return object == null ? undefined : baseGet(object, path);
  31749. };
  31750. }
  31751. /**
  31752. * Creates an array of numbers (positive and/or negative) progressing from
  31753. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  31754. * `start` is specified without an `end` or `step`. If `end` is not specified,
  31755. * it's set to `start` with `start` then set to `0`.
  31756. *
  31757. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  31758. * floating-point values which can produce unexpected results.
  31759. *
  31760. * @static
  31761. * @since 0.1.0
  31762. * @memberOf _
  31763. * @category Util
  31764. * @param {number} [start=0] The start of the range.
  31765. * @param {number} end The end of the range.
  31766. * @param {number} [step=1] The value to increment or decrement by.
  31767. * @returns {Array} Returns the range of numbers.
  31768. * @see _.inRange, _.rangeRight
  31769. * @example
  31770. *
  31771. * _.range(4);
  31772. * // => [0, 1, 2, 3]
  31773. *
  31774. * _.range(-4);
  31775. * // => [0, -1, -2, -3]
  31776. *
  31777. * _.range(1, 5);
  31778. * // => [1, 2, 3, 4]
  31779. *
  31780. * _.range(0, 20, 5);
  31781. * // => [0, 5, 10, 15]
  31782. *
  31783. * _.range(0, -4, -1);
  31784. * // => [0, -1, -2, -3]
  31785. *
  31786. * _.range(1, 4, 0);
  31787. * // => [1, 1, 1]
  31788. *
  31789. * _.range(0);
  31790. * // => []
  31791. */
  31792. var range = createRange();
  31793. /**
  31794. * This method is like `_.range` except that it populates values in
  31795. * descending order.
  31796. *
  31797. * @static
  31798. * @memberOf _
  31799. * @since 4.0.0
  31800. * @category Util
  31801. * @param {number} [start=0] The start of the range.
  31802. * @param {number} end The end of the range.
  31803. * @param {number} [step=1] The value to increment or decrement by.
  31804. * @returns {Array} Returns the range of numbers.
  31805. * @see _.inRange, _.range
  31806. * @example
  31807. *
  31808. * _.rangeRight(4);
  31809. * // => [3, 2, 1, 0]
  31810. *
  31811. * _.rangeRight(-4);
  31812. * // => [-3, -2, -1, 0]
  31813. *
  31814. * _.rangeRight(1, 5);
  31815. * // => [4, 3, 2, 1]
  31816. *
  31817. * _.rangeRight(0, 20, 5);
  31818. * // => [15, 10, 5, 0]
  31819. *
  31820. * _.rangeRight(0, -4, -1);
  31821. * // => [-3, -2, -1, 0]
  31822. *
  31823. * _.rangeRight(1, 4, 0);
  31824. * // => [1, 1, 1]
  31825. *
  31826. * _.rangeRight(0);
  31827. * // => []
  31828. */
  31829. var rangeRight = createRange(true);
  31830. /**
  31831. * This method returns a new empty array.
  31832. *
  31833. * @static
  31834. * @memberOf _
  31835. * @since 4.13.0
  31836. * @category Util
  31837. * @returns {Array} Returns the new empty array.
  31838. * @example
  31839. *
  31840. * var arrays = _.times(2, _.stubArray);
  31841. *
  31842. * console.log(arrays);
  31843. * // => [[], []]
  31844. *
  31845. * console.log(arrays[0] === arrays[1]);
  31846. * // => false
  31847. */
  31848. function stubArray() {
  31849. return [];
  31850. }
  31851. /**
  31852. * This method returns `false`.
  31853. *
  31854. * @static
  31855. * @memberOf _
  31856. * @since 4.13.0
  31857. * @category Util
  31858. * @returns {boolean} Returns `false`.
  31859. * @example
  31860. *
  31861. * _.times(2, _.stubFalse);
  31862. * // => [false, false]
  31863. */
  31864. function stubFalse() {
  31865. return false;
  31866. }
  31867. /**
  31868. * This method returns a new empty object.
  31869. *
  31870. * @static
  31871. * @memberOf _
  31872. * @since 4.13.0
  31873. * @category Util
  31874. * @returns {Object} Returns the new empty object.
  31875. * @example
  31876. *
  31877. * var objects = _.times(2, _.stubObject);
  31878. *
  31879. * console.log(objects);
  31880. * // => [{}, {}]
  31881. *
  31882. * console.log(objects[0] === objects[1]);
  31883. * // => false
  31884. */
  31885. function stubObject() {
  31886. return {};
  31887. }
  31888. /**
  31889. * This method returns an empty string.
  31890. *
  31891. * @static
  31892. * @memberOf _
  31893. * @since 4.13.0
  31894. * @category Util
  31895. * @returns {string} Returns the empty string.
  31896. * @example
  31897. *
  31898. * _.times(2, _.stubString);
  31899. * // => ['', '']
  31900. */
  31901. function stubString() {
  31902. return '';
  31903. }
  31904. /**
  31905. * This method returns `true`.
  31906. *
  31907. * @static
  31908. * @memberOf _
  31909. * @since 4.13.0
  31910. * @category Util
  31911. * @returns {boolean} Returns `true`.
  31912. * @example
  31913. *
  31914. * _.times(2, _.stubTrue);
  31915. * // => [true, true]
  31916. */
  31917. function stubTrue() {
  31918. return true;
  31919. }
  31920. /**
  31921. * Invokes the iteratee `n` times, returning an array of the results of
  31922. * each invocation. The iteratee is invoked with one argument; (index).
  31923. *
  31924. * @static
  31925. * @since 0.1.0
  31926. * @memberOf _
  31927. * @category Util
  31928. * @param {number} n The number of times to invoke `iteratee`.
  31929. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  31930. * @returns {Array} Returns the array of results.
  31931. * @example
  31932. *
  31933. * _.times(3, String);
  31934. * // => ['0', '1', '2']
  31935. *
  31936. * _.times(4, _.constant(0));
  31937. * // => [0, 0, 0, 0]
  31938. */
  31939. function times(n, iteratee) {
  31940. n = toInteger(n);
  31941. if (n < 1 || n > MAX_SAFE_INTEGER) {
  31942. return [];
  31943. }
  31944. var index = MAX_ARRAY_LENGTH,
  31945. length = nativeMin(n, MAX_ARRAY_LENGTH);
  31946. iteratee = getIteratee(iteratee);
  31947. n -= MAX_ARRAY_LENGTH;
  31948. var result = baseTimes(length, iteratee);
  31949. while (++index < n) {
  31950. iteratee(index);
  31951. }
  31952. return result;
  31953. }
  31954. /**
  31955. * Converts `value` to a property path array.
  31956. *
  31957. * @static
  31958. * @memberOf _
  31959. * @since 4.0.0
  31960. * @category Util
  31961. * @param {*} value The value to convert.
  31962. * @returns {Array} Returns the new property path array.
  31963. * @example
  31964. *
  31965. * _.toPath('a.b.c');
  31966. * // => ['a', 'b', 'c']
  31967. *
  31968. * _.toPath('a[0].b.c');
  31969. * // => ['a', '0', 'b', 'c']
  31970. */
  31971. function toPath(value) {
  31972. if (isArray(value)) {
  31973. return arrayMap(value, toKey);
  31974. }
  31975. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  31976. }
  31977. /**
  31978. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  31979. *
  31980. * @static
  31981. * @since 0.1.0
  31982. * @memberOf _
  31983. * @category Util
  31984. * @param {string} [prefix=''] The value to prefix the ID with.
  31985. * @returns {string} Returns the unique ID.
  31986. * @example
  31987. *
  31988. * _.uniqueId('contact_');
  31989. * // => 'contact_104'
  31990. *
  31991. * _.uniqueId();
  31992. * // => '105'
  31993. */
  31994. function uniqueId(prefix) {
  31995. var id = ++idCounter;
  31996. return toString(prefix) + id;
  31997. }
  31998. /*------------------------------------------------------------------------*/
  31999. /**
  32000. * Adds two numbers.
  32001. *
  32002. * @static
  32003. * @memberOf _
  32004. * @since 3.4.0
  32005. * @category Math
  32006. * @param {number} augend The first number in an addition.
  32007. * @param {number} addend The second number in an addition.
  32008. * @returns {number} Returns the total.
  32009. * @example
  32010. *
  32011. * _.add(6, 4);
  32012. * // => 10
  32013. */
  32014. var add = createMathOperation(function(augend, addend) {
  32015. return augend + addend;
  32016. }, 0);
  32017. /**
  32018. * Computes `number` rounded up to `precision`.
  32019. *
  32020. * @static
  32021. * @memberOf _
  32022. * @since 3.10.0
  32023. * @category Math
  32024. * @param {number} number The number to round up.
  32025. * @param {number} [precision=0] The precision to round up to.
  32026. * @returns {number} Returns the rounded up number.
  32027. * @example
  32028. *
  32029. * _.ceil(4.006);
  32030. * // => 5
  32031. *
  32032. * _.ceil(6.004, 2);
  32033. * // => 6.01
  32034. *
  32035. * _.ceil(6040, -2);
  32036. * // => 6100
  32037. */
  32038. var ceil = createRound('ceil');
  32039. /**
  32040. * Divide two numbers.
  32041. *
  32042. * @static
  32043. * @memberOf _
  32044. * @since 4.7.0
  32045. * @category Math
  32046. * @param {number} dividend The first number in a division.
  32047. * @param {number} divisor The second number in a division.
  32048. * @returns {number} Returns the quotient.
  32049. * @example
  32050. *
  32051. * _.divide(6, 4);
  32052. * // => 1.5
  32053. */
  32054. var divide = createMathOperation(function(dividend, divisor) {
  32055. return dividend / divisor;
  32056. }, 1);
  32057. /**
  32058. * Computes `number` rounded down to `precision`.
  32059. *
  32060. * @static
  32061. * @memberOf _
  32062. * @since 3.10.0
  32063. * @category Math
  32064. * @param {number} number The number to round down.
  32065. * @param {number} [precision=0] The precision to round down to.
  32066. * @returns {number} Returns the rounded down number.
  32067. * @example
  32068. *
  32069. * _.floor(4.006);
  32070. * // => 4
  32071. *
  32072. * _.floor(0.046, 2);
  32073. * // => 0.04
  32074. *
  32075. * _.floor(4060, -2);
  32076. * // => 4000
  32077. */
  32078. var floor = createRound('floor');
  32079. /**
  32080. * Computes the maximum value of `array`. If `array` is empty or falsey,
  32081. * `undefined` is returned.
  32082. *
  32083. * @static
  32084. * @since 0.1.0
  32085. * @memberOf _
  32086. * @category Math
  32087. * @param {Array} array The array to iterate over.
  32088. * @returns {*} Returns the maximum value.
  32089. * @example
  32090. *
  32091. * _.max([4, 2, 8, 6]);
  32092. * // => 8
  32093. *
  32094. * _.max([]);
  32095. * // => undefined
  32096. */
  32097. function max(array) {
  32098. return (array && array.length)
  32099. ? baseExtremum(array, identity, baseGt)
  32100. : undefined;
  32101. }
  32102. /**
  32103. * This method is like `_.max` except that it accepts `iteratee` which is
  32104. * invoked for each element in `array` to generate the criterion by which
  32105. * the value is ranked. The iteratee is invoked with one argument: (value).
  32106. *
  32107. * @static
  32108. * @memberOf _
  32109. * @since 4.0.0
  32110. * @category Math
  32111. * @param {Array} array The array to iterate over.
  32112. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32113. * @returns {*} Returns the maximum value.
  32114. * @example
  32115. *
  32116. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32117. *
  32118. * _.maxBy(objects, function(o) { return o.n; });
  32119. * // => { 'n': 2 }
  32120. *
  32121. * // The `_.property` iteratee shorthand.
  32122. * _.maxBy(objects, 'n');
  32123. * // => { 'n': 2 }
  32124. */
  32125. function maxBy(array, iteratee) {
  32126. return (array && array.length)
  32127. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  32128. : undefined;
  32129. }
  32130. /**
  32131. * Computes the mean of the values in `array`.
  32132. *
  32133. * @static
  32134. * @memberOf _
  32135. * @since 4.0.0
  32136. * @category Math
  32137. * @param {Array} array The array to iterate over.
  32138. * @returns {number} Returns the mean.
  32139. * @example
  32140. *
  32141. * _.mean([4, 2, 8, 6]);
  32142. * // => 5
  32143. */
  32144. function mean(array) {
  32145. return baseMean(array, identity);
  32146. }
  32147. /**
  32148. * This method is like `_.mean` except that it accepts `iteratee` which is
  32149. * invoked for each element in `array` to generate the value to be averaged.
  32150. * The iteratee is invoked with one argument: (value).
  32151. *
  32152. * @static
  32153. * @memberOf _
  32154. * @since 4.7.0
  32155. * @category Math
  32156. * @param {Array} array The array to iterate over.
  32157. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32158. * @returns {number} Returns the mean.
  32159. * @example
  32160. *
  32161. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32162. *
  32163. * _.meanBy(objects, function(o) { return o.n; });
  32164. * // => 5
  32165. *
  32166. * // The `_.property` iteratee shorthand.
  32167. * _.meanBy(objects, 'n');
  32168. * // => 5
  32169. */
  32170. function meanBy(array, iteratee) {
  32171. return baseMean(array, getIteratee(iteratee, 2));
  32172. }
  32173. /**
  32174. * Computes the minimum value of `array`. If `array` is empty or falsey,
  32175. * `undefined` is returned.
  32176. *
  32177. * @static
  32178. * @since 0.1.0
  32179. * @memberOf _
  32180. * @category Math
  32181. * @param {Array} array The array to iterate over.
  32182. * @returns {*} Returns the minimum value.
  32183. * @example
  32184. *
  32185. * _.min([4, 2, 8, 6]);
  32186. * // => 2
  32187. *
  32188. * _.min([]);
  32189. * // => undefined
  32190. */
  32191. function min(array) {
  32192. return (array && array.length)
  32193. ? baseExtremum(array, identity, baseLt)
  32194. : undefined;
  32195. }
  32196. /**
  32197. * This method is like `_.min` except that it accepts `iteratee` which is
  32198. * invoked for each element in `array` to generate the criterion by which
  32199. * the value is ranked. The iteratee is invoked with one argument: (value).
  32200. *
  32201. * @static
  32202. * @memberOf _
  32203. * @since 4.0.0
  32204. * @category Math
  32205. * @param {Array} array The array to iterate over.
  32206. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32207. * @returns {*} Returns the minimum value.
  32208. * @example
  32209. *
  32210. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  32211. *
  32212. * _.minBy(objects, function(o) { return o.n; });
  32213. * // => { 'n': 1 }
  32214. *
  32215. * // The `_.property` iteratee shorthand.
  32216. * _.minBy(objects, 'n');
  32217. * // => { 'n': 1 }
  32218. */
  32219. function minBy(array, iteratee) {
  32220. return (array && array.length)
  32221. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  32222. : undefined;
  32223. }
  32224. /**
  32225. * Multiply two numbers.
  32226. *
  32227. * @static
  32228. * @memberOf _
  32229. * @since 4.7.0
  32230. * @category Math
  32231. * @param {number} multiplier The first number in a multiplication.
  32232. * @param {number} multiplicand The second number in a multiplication.
  32233. * @returns {number} Returns the product.
  32234. * @example
  32235. *
  32236. * _.multiply(6, 4);
  32237. * // => 24
  32238. */
  32239. var multiply = createMathOperation(function(multiplier, multiplicand) {
  32240. return multiplier * multiplicand;
  32241. }, 1);
  32242. /**
  32243. * Computes `number` rounded to `precision`.
  32244. *
  32245. * @static
  32246. * @memberOf _
  32247. * @since 3.10.0
  32248. * @category Math
  32249. * @param {number} number The number to round.
  32250. * @param {number} [precision=0] The precision to round to.
  32251. * @returns {number} Returns the rounded number.
  32252. * @example
  32253. *
  32254. * _.round(4.006);
  32255. * // => 4
  32256. *
  32257. * _.round(4.006, 2);
  32258. * // => 4.01
  32259. *
  32260. * _.round(4060, -2);
  32261. * // => 4100
  32262. */
  32263. var round = createRound('round');
  32264. /**
  32265. * Subtract two numbers.
  32266. *
  32267. * @static
  32268. * @memberOf _
  32269. * @since 4.0.0
  32270. * @category Math
  32271. * @param {number} minuend The first number in a subtraction.
  32272. * @param {number} subtrahend The second number in a subtraction.
  32273. * @returns {number} Returns the difference.
  32274. * @example
  32275. *
  32276. * _.subtract(6, 4);
  32277. * // => 2
  32278. */
  32279. var subtract = createMathOperation(function(minuend, subtrahend) {
  32280. return minuend - subtrahend;
  32281. }, 0);
  32282. /**
  32283. * Computes the sum of the values in `array`.
  32284. *
  32285. * @static
  32286. * @memberOf _
  32287. * @since 3.4.0
  32288. * @category Math
  32289. * @param {Array} array The array to iterate over.
  32290. * @returns {number} Returns the sum.
  32291. * @example
  32292. *
  32293. * _.sum([4, 2, 8, 6]);
  32294. * // => 20
  32295. */
  32296. function sum(array) {
  32297. return (array && array.length)
  32298. ? baseSum(array, identity)
  32299. : 0;
  32300. }
  32301. /**
  32302. * This method is like `_.sum` except that it accepts `iteratee` which is
  32303. * invoked for each element in `array` to generate the value to be summed.
  32304. * The iteratee is invoked with one argument: (value).
  32305. *
  32306. * @static
  32307. * @memberOf _
  32308. * @since 4.0.0
  32309. * @category Math
  32310. * @param {Array} array The array to iterate over.
  32311. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  32312. * @returns {number} Returns the sum.
  32313. * @example
  32314. *
  32315. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  32316. *
  32317. * _.sumBy(objects, function(o) { return o.n; });
  32318. * // => 20
  32319. *
  32320. * // The `_.property` iteratee shorthand.
  32321. * _.sumBy(objects, 'n');
  32322. * // => 20
  32323. */
  32324. function sumBy(array, iteratee) {
  32325. return (array && array.length)
  32326. ? baseSum(array, getIteratee(iteratee, 2))
  32327. : 0;
  32328. }
  32329. /*------------------------------------------------------------------------*/
  32330. // Add methods that return wrapped values in chain sequences.
  32331. lodash.after = after;
  32332. lodash.ary = ary;
  32333. lodash.assign = assign;
  32334. lodash.assignIn = assignIn;
  32335. lodash.assignInWith = assignInWith;
  32336. lodash.assignWith = assignWith;
  32337. lodash.at = at;
  32338. lodash.before = before;
  32339. lodash.bind = bind;
  32340. lodash.bindAll = bindAll;
  32341. lodash.bindKey = bindKey;
  32342. lodash.castArray = castArray;
  32343. lodash.chain = chain;
  32344. lodash.chunk = chunk;
  32345. lodash.compact = compact;
  32346. lodash.concat = concat;
  32347. lodash.cond = cond;
  32348. lodash.conforms = conforms;
  32349. lodash.constant = constant;
  32350. lodash.countBy = countBy;
  32351. lodash.create = create;
  32352. lodash.curry = curry;
  32353. lodash.curryRight = curryRight;
  32354. lodash.debounce = debounce;
  32355. lodash.defaults = defaults;
  32356. lodash.defaultsDeep = defaultsDeep;
  32357. lodash.defer = defer;
  32358. lodash.delay = delay;
  32359. lodash.difference = difference;
  32360. lodash.differenceBy = differenceBy;
  32361. lodash.differenceWith = differenceWith;
  32362. lodash.drop = drop;
  32363. lodash.dropRight = dropRight;
  32364. lodash.dropRightWhile = dropRightWhile;
  32365. lodash.dropWhile = dropWhile;
  32366. lodash.fill = fill;
  32367. lodash.filter = filter;
  32368. lodash.flatMap = flatMap;
  32369. lodash.flatMapDeep = flatMapDeep;
  32370. lodash.flatMapDepth = flatMapDepth;
  32371. lodash.flatten = flatten;
  32372. lodash.flattenDeep = flattenDeep;
  32373. lodash.flattenDepth = flattenDepth;
  32374. lodash.flip = flip;
  32375. lodash.flow = flow;
  32376. lodash.flowRight = flowRight;
  32377. lodash.fromPairs = fromPairs;
  32378. lodash.functions = functions;
  32379. lodash.functionsIn = functionsIn;
  32380. lodash.groupBy = groupBy;
  32381. lodash.initial = initial;
  32382. lodash.intersection = intersection;
  32383. lodash.intersectionBy = intersectionBy;
  32384. lodash.intersectionWith = intersectionWith;
  32385. lodash.invert = invert;
  32386. lodash.invertBy = invertBy;
  32387. lodash.invokeMap = invokeMap;
  32388. lodash.iteratee = iteratee;
  32389. lodash.keyBy = keyBy;
  32390. lodash.keys = keys;
  32391. lodash.keysIn = keysIn;
  32392. lodash.map = map;
  32393. lodash.mapKeys = mapKeys;
  32394. lodash.mapValues = mapValues;
  32395. lodash.matches = matches;
  32396. lodash.matchesProperty = matchesProperty;
  32397. lodash.memoize = memoize;
  32398. lodash.merge = merge;
  32399. lodash.mergeWith = mergeWith;
  32400. lodash.method = method;
  32401. lodash.methodOf = methodOf;
  32402. lodash.mixin = mixin;
  32403. lodash.negate = negate;
  32404. lodash.nthArg = nthArg;
  32405. lodash.omit = omit;
  32406. lodash.omitBy = omitBy;
  32407. lodash.once = once;
  32408. lodash.orderBy = orderBy;
  32409. lodash.over = over;
  32410. lodash.overArgs = overArgs;
  32411. lodash.overEvery = overEvery;
  32412. lodash.overSome = overSome;
  32413. lodash.partial = partial;
  32414. lodash.partialRight = partialRight;
  32415. lodash.partition = partition;
  32416. lodash.pick = pick;
  32417. lodash.pickBy = pickBy;
  32418. lodash.property = property;
  32419. lodash.propertyOf = propertyOf;
  32420. lodash.pull = pull;
  32421. lodash.pullAll = pullAll;
  32422. lodash.pullAllBy = pullAllBy;
  32423. lodash.pullAllWith = pullAllWith;
  32424. lodash.pullAt = pullAt;
  32425. lodash.range = range;
  32426. lodash.rangeRight = rangeRight;
  32427. lodash.rearg = rearg;
  32428. lodash.reject = reject;
  32429. lodash.remove = remove;
  32430. lodash.rest = rest;
  32431. lodash.reverse = reverse;
  32432. lodash.sampleSize = sampleSize;
  32433. lodash.set = set;
  32434. lodash.setWith = setWith;
  32435. lodash.shuffle = shuffle;
  32436. lodash.slice = slice;
  32437. lodash.sortBy = sortBy;
  32438. lodash.sortedUniq = sortedUniq;
  32439. lodash.sortedUniqBy = sortedUniqBy;
  32440. lodash.split = split;
  32441. lodash.spread = spread;
  32442. lodash.tail = tail;
  32443. lodash.take = take;
  32444. lodash.takeRight = takeRight;
  32445. lodash.takeRightWhile = takeRightWhile;
  32446. lodash.takeWhile = takeWhile;
  32447. lodash.tap = tap;
  32448. lodash.throttle = throttle;
  32449. lodash.thru = thru;
  32450. lodash.toArray = toArray;
  32451. lodash.toPairs = toPairs;
  32452. lodash.toPairsIn = toPairsIn;
  32453. lodash.toPath = toPath;
  32454. lodash.toPlainObject = toPlainObject;
  32455. lodash.transform = transform;
  32456. lodash.unary = unary;
  32457. lodash.union = union;
  32458. lodash.unionBy = unionBy;
  32459. lodash.unionWith = unionWith;
  32460. lodash.uniq = uniq;
  32461. lodash.uniqBy = uniqBy;
  32462. lodash.uniqWith = uniqWith;
  32463. lodash.unset = unset;
  32464. lodash.unzip = unzip;
  32465. lodash.unzipWith = unzipWith;
  32466. lodash.update = update;
  32467. lodash.updateWith = updateWith;
  32468. lodash.values = values;
  32469. lodash.valuesIn = valuesIn;
  32470. lodash.without = without;
  32471. lodash.words = words;
  32472. lodash.wrap = wrap;
  32473. lodash.xor = xor;
  32474. lodash.xorBy = xorBy;
  32475. lodash.xorWith = xorWith;
  32476. lodash.zip = zip;
  32477. lodash.zipObject = zipObject;
  32478. lodash.zipObjectDeep = zipObjectDeep;
  32479. lodash.zipWith = zipWith;
  32480. // Add aliases.
  32481. lodash.entries = toPairs;
  32482. lodash.entriesIn = toPairsIn;
  32483. lodash.extend = assignIn;
  32484. lodash.extendWith = assignInWith;
  32485. // Add methods to `lodash.prototype`.
  32486. mixin(lodash, lodash);
  32487. /*------------------------------------------------------------------------*/
  32488. // Add methods that return unwrapped values in chain sequences.
  32489. lodash.add = add;
  32490. lodash.attempt = attempt;
  32491. lodash.camelCase = camelCase;
  32492. lodash.capitalize = capitalize;
  32493. lodash.ceil = ceil;
  32494. lodash.clamp = clamp;
  32495. lodash.clone = clone;
  32496. lodash.cloneDeep = cloneDeep;
  32497. lodash.cloneDeepWith = cloneDeepWith;
  32498. lodash.cloneWith = cloneWith;
  32499. lodash.conformsTo = conformsTo;
  32500. lodash.deburr = deburr;
  32501. lodash.defaultTo = defaultTo;
  32502. lodash.divide = divide;
  32503. lodash.endsWith = endsWith;
  32504. lodash.eq = eq;
  32505. lodash.escape = escape;
  32506. lodash.escapeRegExp = escapeRegExp;
  32507. lodash.every = every;
  32508. lodash.find = find;
  32509. lodash.findIndex = findIndex;
  32510. lodash.findKey = findKey;
  32511. lodash.findLast = findLast;
  32512. lodash.findLastIndex = findLastIndex;
  32513. lodash.findLastKey = findLastKey;
  32514. lodash.floor = floor;
  32515. lodash.forEach = forEach;
  32516. lodash.forEachRight = forEachRight;
  32517. lodash.forIn = forIn;
  32518. lodash.forInRight = forInRight;
  32519. lodash.forOwn = forOwn;
  32520. lodash.forOwnRight = forOwnRight;
  32521. lodash.get = get;
  32522. lodash.gt = gt;
  32523. lodash.gte = gte;
  32524. lodash.has = has;
  32525. lodash.hasIn = hasIn;
  32526. lodash.head = head;
  32527. lodash.identity = identity;
  32528. lodash.includes = includes;
  32529. lodash.indexOf = indexOf;
  32530. lodash.inRange = inRange;
  32531. lodash.invoke = invoke;
  32532. lodash.isArguments = isArguments;
  32533. lodash.isArray = isArray;
  32534. lodash.isArrayBuffer = isArrayBuffer;
  32535. lodash.isArrayLike = isArrayLike;
  32536. lodash.isArrayLikeObject = isArrayLikeObject;
  32537. lodash.isBoolean = isBoolean;
  32538. lodash.isBuffer = isBuffer;
  32539. lodash.isDate = isDate;
  32540. lodash.isElement = isElement;
  32541. lodash.isEmpty = isEmpty;
  32542. lodash.isEqual = isEqual;
  32543. lodash.isEqualWith = isEqualWith;
  32544. lodash.isError = isError;
  32545. lodash.isFinite = isFinite;
  32546. lodash.isFunction = isFunction;
  32547. lodash.isInteger = isInteger;
  32548. lodash.isLength = isLength;
  32549. lodash.isMap = isMap;
  32550. lodash.isMatch = isMatch;
  32551. lodash.isMatchWith = isMatchWith;
  32552. lodash.isNaN = isNaN;
  32553. lodash.isNative = isNative;
  32554. lodash.isNil = isNil;
  32555. lodash.isNull = isNull;
  32556. lodash.isNumber = isNumber;
  32557. lodash.isObject = isObject;
  32558. lodash.isObjectLike = isObjectLike;
  32559. lodash.isPlainObject = isPlainObject;
  32560. lodash.isRegExp = isRegExp;
  32561. lodash.isSafeInteger = isSafeInteger;
  32562. lodash.isSet = isSet;
  32563. lodash.isString = isString;
  32564. lodash.isSymbol = isSymbol;
  32565. lodash.isTypedArray = isTypedArray;
  32566. lodash.isUndefined = isUndefined;
  32567. lodash.isWeakMap = isWeakMap;
  32568. lodash.isWeakSet = isWeakSet;
  32569. lodash.join = join;
  32570. lodash.kebabCase = kebabCase;
  32571. lodash.last = last;
  32572. lodash.lastIndexOf = lastIndexOf;
  32573. lodash.lowerCase = lowerCase;
  32574. lodash.lowerFirst = lowerFirst;
  32575. lodash.lt = lt;
  32576. lodash.lte = lte;
  32577. lodash.max = max;
  32578. lodash.maxBy = maxBy;
  32579. lodash.mean = mean;
  32580. lodash.meanBy = meanBy;
  32581. lodash.min = min;
  32582. lodash.minBy = minBy;
  32583. lodash.stubArray = stubArray;
  32584. lodash.stubFalse = stubFalse;
  32585. lodash.stubObject = stubObject;
  32586. lodash.stubString = stubString;
  32587. lodash.stubTrue = stubTrue;
  32588. lodash.multiply = multiply;
  32589. lodash.nth = nth;
  32590. lodash.noConflict = noConflict;
  32591. lodash.noop = noop;
  32592. lodash.now = now;
  32593. lodash.pad = pad;
  32594. lodash.padEnd = padEnd;
  32595. lodash.padStart = padStart;
  32596. lodash.parseInt = parseInt;
  32597. lodash.random = random;
  32598. lodash.reduce = reduce;
  32599. lodash.reduceRight = reduceRight;
  32600. lodash.repeat = repeat;
  32601. lodash.replace = replace;
  32602. lodash.result = result;
  32603. lodash.round = round;
  32604. lodash.runInContext = runInContext;
  32605. lodash.sample = sample;
  32606. lodash.size = size;
  32607. lodash.snakeCase = snakeCase;
  32608. lodash.some = some;
  32609. lodash.sortedIndex = sortedIndex;
  32610. lodash.sortedIndexBy = sortedIndexBy;
  32611. lodash.sortedIndexOf = sortedIndexOf;
  32612. lodash.sortedLastIndex = sortedLastIndex;
  32613. lodash.sortedLastIndexBy = sortedLastIndexBy;
  32614. lodash.sortedLastIndexOf = sortedLastIndexOf;
  32615. lodash.startCase = startCase;
  32616. lodash.startsWith = startsWith;
  32617. lodash.subtract = subtract;
  32618. lodash.sum = sum;
  32619. lodash.sumBy = sumBy;
  32620. lodash.template = template;
  32621. lodash.times = times;
  32622. lodash.toFinite = toFinite;
  32623. lodash.toInteger = toInteger;
  32624. lodash.toLength = toLength;
  32625. lodash.toLower = toLower;
  32626. lodash.toNumber = toNumber;
  32627. lodash.toSafeInteger = toSafeInteger;
  32628. lodash.toString = toString;
  32629. lodash.toUpper = toUpper;
  32630. lodash.trim = trim;
  32631. lodash.trimEnd = trimEnd;
  32632. lodash.trimStart = trimStart;
  32633. lodash.truncate = truncate;
  32634. lodash.unescape = unescape;
  32635. lodash.uniqueId = uniqueId;
  32636. lodash.upperCase = upperCase;
  32637. lodash.upperFirst = upperFirst;
  32638. // Add aliases.
  32639. lodash.each = forEach;
  32640. lodash.eachRight = forEachRight;
  32641. lodash.first = head;
  32642. mixin(lodash, (function() {
  32643. var source = {};
  32644. baseForOwn(lodash, function(func, methodName) {
  32645. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  32646. source[methodName] = func;
  32647. }
  32648. });
  32649. return source;
  32650. }()), { 'chain': false });
  32651. /*------------------------------------------------------------------------*/
  32652. /**
  32653. * The semantic version number.
  32654. *
  32655. * @static
  32656. * @memberOf _
  32657. * @type {string}
  32658. */
  32659. lodash.VERSION = VERSION;
  32660. // Assign default placeholders.
  32661. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  32662. lodash[methodName].placeholder = lodash;
  32663. });
  32664. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  32665. arrayEach(['drop', 'take'], function(methodName, index) {
  32666. LazyWrapper.prototype[methodName] = function(n) {
  32667. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  32668. var result = (this.__filtered__ && !index)
  32669. ? new LazyWrapper(this)
  32670. : this.clone();
  32671. if (result.__filtered__) {
  32672. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  32673. } else {
  32674. result.__views__.push({
  32675. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  32676. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  32677. });
  32678. }
  32679. return result;
  32680. };
  32681. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  32682. return this.reverse()[methodName](n).reverse();
  32683. };
  32684. });
  32685. // Add `LazyWrapper` methods that accept an `iteratee` value.
  32686. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  32687. var type = index + 1,
  32688. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  32689. LazyWrapper.prototype[methodName] = function(iteratee) {
  32690. var result = this.clone();
  32691. result.__iteratees__.push({
  32692. 'iteratee': getIteratee(iteratee, 3),
  32693. 'type': type
  32694. });
  32695. result.__filtered__ = result.__filtered__ || isFilter;
  32696. return result;
  32697. };
  32698. });
  32699. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  32700. arrayEach(['head', 'last'], function(methodName, index) {
  32701. var takeName = 'take' + (index ? 'Right' : '');
  32702. LazyWrapper.prototype[methodName] = function() {
  32703. return this[takeName](1).value()[0];
  32704. };
  32705. });
  32706. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  32707. arrayEach(['initial', 'tail'], function(methodName, index) {
  32708. var dropName = 'drop' + (index ? '' : 'Right');
  32709. LazyWrapper.prototype[methodName] = function() {
  32710. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  32711. };
  32712. });
  32713. LazyWrapper.prototype.compact = function() {
  32714. return this.filter(identity);
  32715. };
  32716. LazyWrapper.prototype.find = function(predicate) {
  32717. return this.filter(predicate).head();
  32718. };
  32719. LazyWrapper.prototype.findLast = function(predicate) {
  32720. return this.reverse().find(predicate);
  32721. };
  32722. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  32723. if (typeof path == 'function') {
  32724. return new LazyWrapper(this);
  32725. }
  32726. return this.map(function(value) {
  32727. return baseInvoke(value, path, args);
  32728. });
  32729. });
  32730. LazyWrapper.prototype.reject = function(predicate) {
  32731. return this.filter(negate(getIteratee(predicate)));
  32732. };
  32733. LazyWrapper.prototype.slice = function(start, end) {
  32734. start = toInteger(start);
  32735. var result = this;
  32736. if (result.__filtered__ && (start > 0 || end < 0)) {
  32737. return new LazyWrapper(result);
  32738. }
  32739. if (start < 0) {
  32740. result = result.takeRight(-start);
  32741. } else if (start) {
  32742. result = result.drop(start);
  32743. }
  32744. if (end !== undefined) {
  32745. end = toInteger(end);
  32746. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  32747. }
  32748. return result;
  32749. };
  32750. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  32751. return this.reverse().takeWhile(predicate).reverse();
  32752. };
  32753. LazyWrapper.prototype.toArray = function() {
  32754. return this.take(MAX_ARRAY_LENGTH);
  32755. };
  32756. // Add `LazyWrapper` methods to `lodash.prototype`.
  32757. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32758. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  32759. isTaker = /^(?:head|last)$/.test(methodName),
  32760. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  32761. retUnwrapped = isTaker || /^find/.test(methodName);
  32762. if (!lodashFunc) {
  32763. return;
  32764. }
  32765. lodash.prototype[methodName] = function() {
  32766. var value = this.__wrapped__,
  32767. args = isTaker ? [1] : arguments,
  32768. isLazy = value instanceof LazyWrapper,
  32769. iteratee = args[0],
  32770. useLazy = isLazy || isArray(value);
  32771. var interceptor = function(value) {
  32772. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  32773. return (isTaker && chainAll) ? result[0] : result;
  32774. };
  32775. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  32776. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  32777. isLazy = useLazy = false;
  32778. }
  32779. var chainAll = this.__chain__,
  32780. isHybrid = !!this.__actions__.length,
  32781. isUnwrapped = retUnwrapped && !chainAll,
  32782. onlyLazy = isLazy && !isHybrid;
  32783. if (!retUnwrapped && useLazy) {
  32784. value = onlyLazy ? value : new LazyWrapper(this);
  32785. var result = func.apply(value, args);
  32786. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  32787. return new LodashWrapper(result, chainAll);
  32788. }
  32789. if (isUnwrapped && onlyLazy) {
  32790. return func.apply(this, args);
  32791. }
  32792. result = this.thru(interceptor);
  32793. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  32794. };
  32795. });
  32796. // Add `Array` methods to `lodash.prototype`.
  32797. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  32798. var func = arrayProto[methodName],
  32799. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  32800. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  32801. lodash.prototype[methodName] = function() {
  32802. var args = arguments;
  32803. if (retUnwrapped && !this.__chain__) {
  32804. var value = this.value();
  32805. return func.apply(isArray(value) ? value : [], args);
  32806. }
  32807. return this[chainName](function(value) {
  32808. return func.apply(isArray(value) ? value : [], args);
  32809. });
  32810. };
  32811. });
  32812. // Map minified method names to their real names.
  32813. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  32814. var lodashFunc = lodash[methodName];
  32815. if (lodashFunc) {
  32816. var key = lodashFunc.name + '';
  32817. if (!hasOwnProperty.call(realNames, key)) {
  32818. realNames[key] = [];
  32819. }
  32820. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  32821. }
  32822. });
  32823. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  32824. 'name': 'wrapper',
  32825. 'func': undefined
  32826. }];
  32827. // Add methods to `LazyWrapper`.
  32828. LazyWrapper.prototype.clone = lazyClone;
  32829. LazyWrapper.prototype.reverse = lazyReverse;
  32830. LazyWrapper.prototype.value = lazyValue;
  32831. // Add chain sequence methods to the `lodash` wrapper.
  32832. lodash.prototype.at = wrapperAt;
  32833. lodash.prototype.chain = wrapperChain;
  32834. lodash.prototype.commit = wrapperCommit;
  32835. lodash.prototype.next = wrapperNext;
  32836. lodash.prototype.plant = wrapperPlant;
  32837. lodash.prototype.reverse = wrapperReverse;
  32838. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  32839. // Add lazy aliases.
  32840. lodash.prototype.first = lodash.prototype.head;
  32841. if (symIterator) {
  32842. lodash.prototype[symIterator] = wrapperToIterator;
  32843. }
  32844. return lodash;
  32845. });
  32846. /*--------------------------------------------------------------------------*/
  32847. // Export lodash.
  32848. var _ = runInContext();
  32849. // Some AMD build optimizers, like r.js, check for condition patterns like:
  32850. if (true) {
  32851. // Expose Lodash on the global object to prevent errors when Lodash is
  32852. // loaded by a script tag in the presence of an AMD loader.
  32853. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  32854. // Use `_.noConflict` to remove Lodash from the global object.
  32855. root._ = _;
  32856. // Define as an anonymous module so, through path mapping, it can be
  32857. // referenced as the "underscore" module.
  32858. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  32859. return _;
  32860. }).call(exports, __webpack_require__, exports, module),
  32861. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  32862. }
  32863. // Check for `exports` after `define` in case a build optimizer adds it.
  32864. else {}
  32865. }.call(this));
  32866. /* 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)))
  32867. /***/ }),
  32868. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  32869. /*!***************************************************!*\
  32870. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  32871. \***************************************************/
  32872. /*! exports provided: default */
  32873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  32874. "use strict";
  32875. __webpack_require__.r(__webpack_exports__);
  32876. /* WEBPACK VAR INJECTION */(function(global) {/**!
  32877. * @fileOverview Kickass library to create and place poppers near their reference elements.
  32878. * @version 1.16.1
  32879. * @license
  32880. * Copyright (c) 2016 Federico Zivolo and contributors
  32881. *
  32882. * Permission is hereby granted, free of charge, to any person obtaining a copy
  32883. * of this software and associated documentation files (the "Software"), to deal
  32884. * in the Software without restriction, including without limitation the rights
  32885. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32886. * copies of the Software, and to permit persons to whom the Software is
  32887. * furnished to do so, subject to the following conditions:
  32888. *
  32889. * The above copyright notice and this permission notice shall be included in all
  32890. * copies or substantial portions of the Software.
  32891. *
  32892. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32893. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32894. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32895. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32896. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32897. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32898. * SOFTWARE.
  32899. */
  32900. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  32901. var timeoutDuration = function () {
  32902. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  32903. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  32904. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  32905. return 1;
  32906. }
  32907. }
  32908. return 0;
  32909. }();
  32910. function microtaskDebounce(fn) {
  32911. var called = false;
  32912. return function () {
  32913. if (called) {
  32914. return;
  32915. }
  32916. called = true;
  32917. window.Promise.resolve().then(function () {
  32918. called = false;
  32919. fn();
  32920. });
  32921. };
  32922. }
  32923. function taskDebounce(fn) {
  32924. var scheduled = false;
  32925. return function () {
  32926. if (!scheduled) {
  32927. scheduled = true;
  32928. setTimeout(function () {
  32929. scheduled = false;
  32930. fn();
  32931. }, timeoutDuration);
  32932. }
  32933. };
  32934. }
  32935. var supportsMicroTasks = isBrowser && window.Promise;
  32936. /**
  32937. * Create a debounced version of a method, that's asynchronously deferred
  32938. * but called in the minimum time possible.
  32939. *
  32940. * @method
  32941. * @memberof Popper.Utils
  32942. * @argument {Function} fn
  32943. * @returns {Function}
  32944. */
  32945. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  32946. /**
  32947. * Check if the given variable is a function
  32948. * @method
  32949. * @memberof Popper.Utils
  32950. * @argument {Any} functionToCheck - variable to check
  32951. * @returns {Boolean} answer to: is a function?
  32952. */
  32953. function isFunction(functionToCheck) {
  32954. var getType = {};
  32955. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  32956. }
  32957. /**
  32958. * Get CSS computed property of the given element
  32959. * @method
  32960. * @memberof Popper.Utils
  32961. * @argument {Eement} element
  32962. * @argument {String} property
  32963. */
  32964. function getStyleComputedProperty(element, property) {
  32965. if (element.nodeType !== 1) {
  32966. return [];
  32967. }
  32968. // NOTE: 1 DOM access here
  32969. var window = element.ownerDocument.defaultView;
  32970. var css = window.getComputedStyle(element, null);
  32971. return property ? css[property] : css;
  32972. }
  32973. /**
  32974. * Returns the parentNode or the host of the element
  32975. * @method
  32976. * @memberof Popper.Utils
  32977. * @argument {Element} element
  32978. * @returns {Element} parent
  32979. */
  32980. function getParentNode(element) {
  32981. if (element.nodeName === 'HTML') {
  32982. return element;
  32983. }
  32984. return element.parentNode || element.host;
  32985. }
  32986. /**
  32987. * Returns the scrolling parent of the given element
  32988. * @method
  32989. * @memberof Popper.Utils
  32990. * @argument {Element} element
  32991. * @returns {Element} scroll parent
  32992. */
  32993. function getScrollParent(element) {
  32994. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  32995. if (!element) {
  32996. return document.body;
  32997. }
  32998. switch (element.nodeName) {
  32999. case 'HTML':
  33000. case 'BODY':
  33001. return element.ownerDocument.body;
  33002. case '#document':
  33003. return element.body;
  33004. }
  33005. // Firefox want us to check `-x` and `-y` variations as well
  33006. var _getStyleComputedProp = getStyleComputedProperty(element),
  33007. overflow = _getStyleComputedProp.overflow,
  33008. overflowX = _getStyleComputedProp.overflowX,
  33009. overflowY = _getStyleComputedProp.overflowY;
  33010. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33011. return element;
  33012. }
  33013. return getScrollParent(getParentNode(element));
  33014. }
  33015. /**
  33016. * Returns the reference node of the reference object, or the reference object itself.
  33017. * @method
  33018. * @memberof Popper.Utils
  33019. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33020. * @returns {Element} parent
  33021. */
  33022. function getReferenceNode(reference) {
  33023. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33024. }
  33025. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33026. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33027. /**
  33028. * Determines if the browser is Internet Explorer
  33029. * @method
  33030. * @memberof Popper.Utils
  33031. * @param {Number} version to check
  33032. * @returns {Boolean} isIE
  33033. */
  33034. function isIE(version) {
  33035. if (version === 11) {
  33036. return isIE11;
  33037. }
  33038. if (version === 10) {
  33039. return isIE10;
  33040. }
  33041. return isIE11 || isIE10;
  33042. }
  33043. /**
  33044. * Returns the offset parent of the given element
  33045. * @method
  33046. * @memberof Popper.Utils
  33047. * @argument {Element} element
  33048. * @returns {Element} offset parent
  33049. */
  33050. function getOffsetParent(element) {
  33051. if (!element) {
  33052. return document.documentElement;
  33053. }
  33054. var noOffsetParent = isIE(10) ? document.body : null;
  33055. // NOTE: 1 DOM access here
  33056. var offsetParent = element.offsetParent || null;
  33057. // Skip hidden elements which don't have an offsetParent
  33058. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33059. offsetParent = (element = element.nextElementSibling).offsetParent;
  33060. }
  33061. var nodeName = offsetParent && offsetParent.nodeName;
  33062. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33063. return element ? element.ownerDocument.documentElement : document.documentElement;
  33064. }
  33065. // .offsetParent will return the closest TH, TD or TABLE in case
  33066. // no offsetParent is present, I hate this job...
  33067. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33068. return getOffsetParent(offsetParent);
  33069. }
  33070. return offsetParent;
  33071. }
  33072. function isOffsetContainer(element) {
  33073. var nodeName = element.nodeName;
  33074. if (nodeName === 'BODY') {
  33075. return false;
  33076. }
  33077. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  33078. }
  33079. /**
  33080. * Finds the root node (document, shadowDOM root) of the given element
  33081. * @method
  33082. * @memberof Popper.Utils
  33083. * @argument {Element} node
  33084. * @returns {Element} root node
  33085. */
  33086. function getRoot(node) {
  33087. if (node.parentNode !== null) {
  33088. return getRoot(node.parentNode);
  33089. }
  33090. return node;
  33091. }
  33092. /**
  33093. * Finds the offset parent common to the two provided nodes
  33094. * @method
  33095. * @memberof Popper.Utils
  33096. * @argument {Element} element1
  33097. * @argument {Element} element2
  33098. * @returns {Element} common offset parent
  33099. */
  33100. function findCommonOffsetParent(element1, element2) {
  33101. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33102. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  33103. return document.documentElement;
  33104. }
  33105. // Here we make sure to give as "start" the element that comes first in the DOM
  33106. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  33107. var start = order ? element1 : element2;
  33108. var end = order ? element2 : element1;
  33109. // Get common ancestor container
  33110. var range = document.createRange();
  33111. range.setStart(start, 0);
  33112. range.setEnd(end, 0);
  33113. var commonAncestorContainer = range.commonAncestorContainer;
  33114. // Both nodes are inside #document
  33115. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  33116. if (isOffsetContainer(commonAncestorContainer)) {
  33117. return commonAncestorContainer;
  33118. }
  33119. return getOffsetParent(commonAncestorContainer);
  33120. }
  33121. // one of the nodes is inside shadowDOM, find which one
  33122. var element1root = getRoot(element1);
  33123. if (element1root.host) {
  33124. return findCommonOffsetParent(element1root.host, element2);
  33125. } else {
  33126. return findCommonOffsetParent(element1, getRoot(element2).host);
  33127. }
  33128. }
  33129. /**
  33130. * Gets the scroll value of the given element in the given side (top and left)
  33131. * @method
  33132. * @memberof Popper.Utils
  33133. * @argument {Element} element
  33134. * @argument {String} side `top` or `left`
  33135. * @returns {number} amount of scrolled pixels
  33136. */
  33137. function getScroll(element) {
  33138. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  33139. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  33140. var nodeName = element.nodeName;
  33141. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33142. var html = element.ownerDocument.documentElement;
  33143. var scrollingElement = element.ownerDocument.scrollingElement || html;
  33144. return scrollingElement[upperSide];
  33145. }
  33146. return element[upperSide];
  33147. }
  33148. /*
  33149. * Sum or subtract the element scroll values (left and top) from a given rect object
  33150. * @method
  33151. * @memberof Popper.Utils
  33152. * @param {Object} rect - Rect object you want to change
  33153. * @param {HTMLElement} element - The element from the function reads the scroll values
  33154. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  33155. * @return {Object} rect - The modifier rect object
  33156. */
  33157. function includeScroll(rect, element) {
  33158. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33159. var scrollTop = getScroll(element, 'top');
  33160. var scrollLeft = getScroll(element, 'left');
  33161. var modifier = subtract ? -1 : 1;
  33162. rect.top += scrollTop * modifier;
  33163. rect.bottom += scrollTop * modifier;
  33164. rect.left += scrollLeft * modifier;
  33165. rect.right += scrollLeft * modifier;
  33166. return rect;
  33167. }
  33168. /*
  33169. * Helper to detect borders of a given element
  33170. * @method
  33171. * @memberof Popper.Utils
  33172. * @param {CSSStyleDeclaration} styles
  33173. * Result of `getStyleComputedProperty` on the given element
  33174. * @param {String} axis - `x` or `y`
  33175. * @return {number} borders - The borders size of the given axis
  33176. */
  33177. function getBordersSize(styles, axis) {
  33178. var sideA = axis === 'x' ? 'Left' : 'Top';
  33179. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  33180. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  33181. }
  33182. function getSize(axis, body, html, computedStyle) {
  33183. 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);
  33184. }
  33185. function getWindowSizes(document) {
  33186. var body = document.body;
  33187. var html = document.documentElement;
  33188. var computedStyle = isIE(10) && getComputedStyle(html);
  33189. return {
  33190. height: getSize('Height', body, html, computedStyle),
  33191. width: getSize('Width', body, html, computedStyle)
  33192. };
  33193. }
  33194. var classCallCheck = function (instance, Constructor) {
  33195. if (!(instance instanceof Constructor)) {
  33196. throw new TypeError("Cannot call a class as a function");
  33197. }
  33198. };
  33199. var createClass = function () {
  33200. function defineProperties(target, props) {
  33201. for (var i = 0; i < props.length; i++) {
  33202. var descriptor = props[i];
  33203. descriptor.enumerable = descriptor.enumerable || false;
  33204. descriptor.configurable = true;
  33205. if ("value" in descriptor) descriptor.writable = true;
  33206. Object.defineProperty(target, descriptor.key, descriptor);
  33207. }
  33208. }
  33209. return function (Constructor, protoProps, staticProps) {
  33210. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  33211. if (staticProps) defineProperties(Constructor, staticProps);
  33212. return Constructor;
  33213. };
  33214. }();
  33215. var defineProperty = function (obj, key, value) {
  33216. if (key in obj) {
  33217. Object.defineProperty(obj, key, {
  33218. value: value,
  33219. enumerable: true,
  33220. configurable: true,
  33221. writable: true
  33222. });
  33223. } else {
  33224. obj[key] = value;
  33225. }
  33226. return obj;
  33227. };
  33228. var _extends = Object.assign || function (target) {
  33229. for (var i = 1; i < arguments.length; i++) {
  33230. var source = arguments[i];
  33231. for (var key in source) {
  33232. if (Object.prototype.hasOwnProperty.call(source, key)) {
  33233. target[key] = source[key];
  33234. }
  33235. }
  33236. }
  33237. return target;
  33238. };
  33239. /**
  33240. * Given element offsets, generate an output similar to getBoundingClientRect
  33241. * @method
  33242. * @memberof Popper.Utils
  33243. * @argument {Object} offsets
  33244. * @returns {Object} ClientRect like output
  33245. */
  33246. function getClientRect(offsets) {
  33247. return _extends({}, offsets, {
  33248. right: offsets.left + offsets.width,
  33249. bottom: offsets.top + offsets.height
  33250. });
  33251. }
  33252. /**
  33253. * Get bounding client rect of given element
  33254. * @method
  33255. * @memberof Popper.Utils
  33256. * @param {HTMLElement} element
  33257. * @return {Object} client rect
  33258. */
  33259. function getBoundingClientRect(element) {
  33260. var rect = {};
  33261. // IE10 10 FIX: Please, don't ask, the element isn't
  33262. // considered in DOM in some circumstances...
  33263. // This isn't reproducible in IE10 compatibility mode of IE11
  33264. try {
  33265. if (isIE(10)) {
  33266. rect = element.getBoundingClientRect();
  33267. var scrollTop = getScroll(element, 'top');
  33268. var scrollLeft = getScroll(element, 'left');
  33269. rect.top += scrollTop;
  33270. rect.left += scrollLeft;
  33271. rect.bottom += scrollTop;
  33272. rect.right += scrollLeft;
  33273. } else {
  33274. rect = element.getBoundingClientRect();
  33275. }
  33276. } catch (e) {}
  33277. var result = {
  33278. left: rect.left,
  33279. top: rect.top,
  33280. width: rect.right - rect.left,
  33281. height: rect.bottom - rect.top
  33282. };
  33283. // subtract scrollbar size from sizes
  33284. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  33285. var width = sizes.width || element.clientWidth || result.width;
  33286. var height = sizes.height || element.clientHeight || result.height;
  33287. var horizScrollbar = element.offsetWidth - width;
  33288. var vertScrollbar = element.offsetHeight - height;
  33289. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  33290. // we make this check conditional for performance reasons
  33291. if (horizScrollbar || vertScrollbar) {
  33292. var styles = getStyleComputedProperty(element);
  33293. horizScrollbar -= getBordersSize(styles, 'x');
  33294. vertScrollbar -= getBordersSize(styles, 'y');
  33295. result.width -= horizScrollbar;
  33296. result.height -= vertScrollbar;
  33297. }
  33298. return getClientRect(result);
  33299. }
  33300. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  33301. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  33302. var isIE10 = isIE(10);
  33303. var isHTML = parent.nodeName === 'HTML';
  33304. var childrenRect = getBoundingClientRect(children);
  33305. var parentRect = getBoundingClientRect(parent);
  33306. var scrollParent = getScrollParent(children);
  33307. var styles = getStyleComputedProperty(parent);
  33308. var borderTopWidth = parseFloat(styles.borderTopWidth);
  33309. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  33310. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  33311. if (fixedPosition && isHTML) {
  33312. parentRect.top = Math.max(parentRect.top, 0);
  33313. parentRect.left = Math.max(parentRect.left, 0);
  33314. }
  33315. var offsets = getClientRect({
  33316. top: childrenRect.top - parentRect.top - borderTopWidth,
  33317. left: childrenRect.left - parentRect.left - borderLeftWidth,
  33318. width: childrenRect.width,
  33319. height: childrenRect.height
  33320. });
  33321. offsets.marginTop = 0;
  33322. offsets.marginLeft = 0;
  33323. // Subtract margins of documentElement in case it's being used as parent
  33324. // we do this only on HTML because it's the only element that behaves
  33325. // differently when margins are applied to it. The margins are included in
  33326. // the box of the documentElement, in the other cases not.
  33327. if (!isIE10 && isHTML) {
  33328. var marginTop = parseFloat(styles.marginTop);
  33329. var marginLeft = parseFloat(styles.marginLeft);
  33330. offsets.top -= borderTopWidth - marginTop;
  33331. offsets.bottom -= borderTopWidth - marginTop;
  33332. offsets.left -= borderLeftWidth - marginLeft;
  33333. offsets.right -= borderLeftWidth - marginLeft;
  33334. // Attach marginTop and marginLeft because in some circumstances we may need them
  33335. offsets.marginTop = marginTop;
  33336. offsets.marginLeft = marginLeft;
  33337. }
  33338. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  33339. offsets = includeScroll(offsets, parent);
  33340. }
  33341. return offsets;
  33342. }
  33343. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  33344. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  33345. var html = element.ownerDocument.documentElement;
  33346. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  33347. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  33348. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  33349. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  33350. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  33351. var offset = {
  33352. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  33353. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  33354. width: width,
  33355. height: height
  33356. };
  33357. return getClientRect(offset);
  33358. }
  33359. /**
  33360. * Check if the given element is fixed or is inside a fixed parent
  33361. * @method
  33362. * @memberof Popper.Utils
  33363. * @argument {Element} element
  33364. * @argument {Element} customContainer
  33365. * @returns {Boolean} answer to "isFixed?"
  33366. */
  33367. function isFixed(element) {
  33368. var nodeName = element.nodeName;
  33369. if (nodeName === 'BODY' || nodeName === 'HTML') {
  33370. return false;
  33371. }
  33372. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  33373. return true;
  33374. }
  33375. var parentNode = getParentNode(element);
  33376. if (!parentNode) {
  33377. return false;
  33378. }
  33379. return isFixed(parentNode);
  33380. }
  33381. /**
  33382. * Finds the first parent of an element that has a transformed property defined
  33383. * @method
  33384. * @memberof Popper.Utils
  33385. * @argument {Element} element
  33386. * @returns {Element} first transformed parent or documentElement
  33387. */
  33388. function getFixedPositionOffsetParent(element) {
  33389. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  33390. if (!element || !element.parentElement || isIE()) {
  33391. return document.documentElement;
  33392. }
  33393. var el = element.parentElement;
  33394. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  33395. el = el.parentElement;
  33396. }
  33397. return el || document.documentElement;
  33398. }
  33399. /**
  33400. * Computed the boundaries limits and return them
  33401. * @method
  33402. * @memberof Popper.Utils
  33403. * @param {HTMLElement} popper
  33404. * @param {HTMLElement} reference
  33405. * @param {number} padding
  33406. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  33407. * @param {Boolean} fixedPosition - Is in fixed position mode
  33408. * @returns {Object} Coordinates of the boundaries
  33409. */
  33410. function getBoundaries(popper, reference, padding, boundariesElement) {
  33411. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  33412. // NOTE: 1 DOM access here
  33413. var boundaries = { top: 0, left: 0 };
  33414. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33415. // Handle viewport case
  33416. if (boundariesElement === 'viewport') {
  33417. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  33418. } else {
  33419. // Handle other cases based on DOM element used as boundaries
  33420. var boundariesNode = void 0;
  33421. if (boundariesElement === 'scrollParent') {
  33422. boundariesNode = getScrollParent(getParentNode(reference));
  33423. if (boundariesNode.nodeName === 'BODY') {
  33424. boundariesNode = popper.ownerDocument.documentElement;
  33425. }
  33426. } else if (boundariesElement === 'window') {
  33427. boundariesNode = popper.ownerDocument.documentElement;
  33428. } else {
  33429. boundariesNode = boundariesElement;
  33430. }
  33431. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  33432. // In case of HTML, we need a different computation
  33433. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  33434. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  33435. height = _getWindowSizes.height,
  33436. width = _getWindowSizes.width;
  33437. boundaries.top += offsets.top - offsets.marginTop;
  33438. boundaries.bottom = height + offsets.top;
  33439. boundaries.left += offsets.left - offsets.marginLeft;
  33440. boundaries.right = width + offsets.left;
  33441. } else {
  33442. // for all the other DOM elements, this one is good
  33443. boundaries = offsets;
  33444. }
  33445. }
  33446. // Add paddings
  33447. padding = padding || 0;
  33448. var isPaddingNumber = typeof padding === 'number';
  33449. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  33450. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  33451. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  33452. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  33453. return boundaries;
  33454. }
  33455. function getArea(_ref) {
  33456. var width = _ref.width,
  33457. height = _ref.height;
  33458. return width * height;
  33459. }
  33460. /**
  33461. * Utility used to transform the `auto` placement to the placement with more
  33462. * available space.
  33463. * @method
  33464. * @memberof Popper.Utils
  33465. * @argument {Object} data - The data object generated by update method
  33466. * @argument {Object} options - Modifiers configuration and options
  33467. * @returns {Object} The data object, properly modified
  33468. */
  33469. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  33470. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  33471. if (placement.indexOf('auto') === -1) {
  33472. return placement;
  33473. }
  33474. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  33475. var rects = {
  33476. top: {
  33477. width: boundaries.width,
  33478. height: refRect.top - boundaries.top
  33479. },
  33480. right: {
  33481. width: boundaries.right - refRect.right,
  33482. height: boundaries.height
  33483. },
  33484. bottom: {
  33485. width: boundaries.width,
  33486. height: boundaries.bottom - refRect.bottom
  33487. },
  33488. left: {
  33489. width: refRect.left - boundaries.left,
  33490. height: boundaries.height
  33491. }
  33492. };
  33493. var sortedAreas = Object.keys(rects).map(function (key) {
  33494. return _extends({
  33495. key: key
  33496. }, rects[key], {
  33497. area: getArea(rects[key])
  33498. });
  33499. }).sort(function (a, b) {
  33500. return b.area - a.area;
  33501. });
  33502. var filteredAreas = sortedAreas.filter(function (_ref2) {
  33503. var width = _ref2.width,
  33504. height = _ref2.height;
  33505. return width >= popper.clientWidth && height >= popper.clientHeight;
  33506. });
  33507. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  33508. var variation = placement.split('-')[1];
  33509. return computedPlacement + (variation ? '-' + variation : '');
  33510. }
  33511. /**
  33512. * Get offsets to the reference element
  33513. * @method
  33514. * @memberof Popper.Utils
  33515. * @param {Object} state
  33516. * @param {Element} popper - the popper element
  33517. * @param {Element} reference - the reference element (the popper will be relative to this)
  33518. * @param {Element} fixedPosition - is in fixed position mode
  33519. * @returns {Object} An object containing the offsets which will be applied to the popper
  33520. */
  33521. function getReferenceOffsets(state, popper, reference) {
  33522. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  33523. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  33524. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  33525. }
  33526. /**
  33527. * Get the outer sizes of the given element (offset size + margins)
  33528. * @method
  33529. * @memberof Popper.Utils
  33530. * @argument {Element} element
  33531. * @returns {Object} object containing width and height properties
  33532. */
  33533. function getOuterSizes(element) {
  33534. var window = element.ownerDocument.defaultView;
  33535. var styles = window.getComputedStyle(element);
  33536. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  33537. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  33538. var result = {
  33539. width: element.offsetWidth + y,
  33540. height: element.offsetHeight + x
  33541. };
  33542. return result;
  33543. }
  33544. /**
  33545. * Get the opposite placement of the given one
  33546. * @method
  33547. * @memberof Popper.Utils
  33548. * @argument {String} placement
  33549. * @returns {String} flipped placement
  33550. */
  33551. function getOppositePlacement(placement) {
  33552. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  33553. return placement.replace(/left|right|bottom|top/g, function (matched) {
  33554. return hash[matched];
  33555. });
  33556. }
  33557. /**
  33558. * Get offsets to the popper
  33559. * @method
  33560. * @memberof Popper.Utils
  33561. * @param {Object} position - CSS position the Popper will get applied
  33562. * @param {HTMLElement} popper - the popper element
  33563. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  33564. * @param {String} placement - one of the valid placement options
  33565. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  33566. */
  33567. function getPopperOffsets(popper, referenceOffsets, placement) {
  33568. placement = placement.split('-')[0];
  33569. // Get popper node sizes
  33570. var popperRect = getOuterSizes(popper);
  33571. // Add position, width and height to our offsets object
  33572. var popperOffsets = {
  33573. width: popperRect.width,
  33574. height: popperRect.height
  33575. };
  33576. // depending by the popper placement we have to compute its offsets slightly differently
  33577. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  33578. var mainSide = isHoriz ? 'top' : 'left';
  33579. var secondarySide = isHoriz ? 'left' : 'top';
  33580. var measurement = isHoriz ? 'height' : 'width';
  33581. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  33582. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  33583. if (placement === secondarySide) {
  33584. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  33585. } else {
  33586. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  33587. }
  33588. return popperOffsets;
  33589. }
  33590. /**
  33591. * Mimics the `find` method of Array
  33592. * @method
  33593. * @memberof Popper.Utils
  33594. * @argument {Array} arr
  33595. * @argument prop
  33596. * @argument value
  33597. * @returns index or -1
  33598. */
  33599. function find(arr, check) {
  33600. // use native find if supported
  33601. if (Array.prototype.find) {
  33602. return arr.find(check);
  33603. }
  33604. // use `filter` to obtain the same behavior of `find`
  33605. return arr.filter(check)[0];
  33606. }
  33607. /**
  33608. * Return the index of the matching object
  33609. * @method
  33610. * @memberof Popper.Utils
  33611. * @argument {Array} arr
  33612. * @argument prop
  33613. * @argument value
  33614. * @returns index or -1
  33615. */
  33616. function findIndex(arr, prop, value) {
  33617. // use native findIndex if supported
  33618. if (Array.prototype.findIndex) {
  33619. return arr.findIndex(function (cur) {
  33620. return cur[prop] === value;
  33621. });
  33622. }
  33623. // use `find` + `indexOf` if `findIndex` isn't supported
  33624. var match = find(arr, function (obj) {
  33625. return obj[prop] === value;
  33626. });
  33627. return arr.indexOf(match);
  33628. }
  33629. /**
  33630. * Loop trough the list of modifiers and run them in order,
  33631. * each of them will then edit the data object.
  33632. * @method
  33633. * @memberof Popper.Utils
  33634. * @param {dataObject} data
  33635. * @param {Array} modifiers
  33636. * @param {String} ends - Optional modifier name used as stopper
  33637. * @returns {dataObject}
  33638. */
  33639. function runModifiers(modifiers, data, ends) {
  33640. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  33641. modifiersToRun.forEach(function (modifier) {
  33642. if (modifier['function']) {
  33643. // eslint-disable-line dot-notation
  33644. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  33645. }
  33646. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  33647. if (modifier.enabled && isFunction(fn)) {
  33648. // Add properties to offsets to make them a complete clientRect object
  33649. // we do this before each modifier to make sure the previous one doesn't
  33650. // mess with these values
  33651. data.offsets.popper = getClientRect(data.offsets.popper);
  33652. data.offsets.reference = getClientRect(data.offsets.reference);
  33653. data = fn(data, modifier);
  33654. }
  33655. });
  33656. return data;
  33657. }
  33658. /**
  33659. * Updates the position of the popper, computing the new offsets and applying
  33660. * the new style.<br />
  33661. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  33662. * @method
  33663. * @memberof Popper
  33664. */
  33665. function update() {
  33666. // if popper is destroyed, don't perform any further update
  33667. if (this.state.isDestroyed) {
  33668. return;
  33669. }
  33670. var data = {
  33671. instance: this,
  33672. styles: {},
  33673. arrowStyles: {},
  33674. attributes: {},
  33675. flipped: false,
  33676. offsets: {}
  33677. };
  33678. // compute reference element offsets
  33679. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  33680. // compute auto placement, store placement inside the data object,
  33681. // modifiers will be able to edit `placement` if needed
  33682. // and refer to originalPlacement to know the original value
  33683. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  33684. // store the computed placement inside `originalPlacement`
  33685. data.originalPlacement = data.placement;
  33686. data.positionFixed = this.options.positionFixed;
  33687. // compute the popper offsets
  33688. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  33689. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  33690. // run the modifiers
  33691. data = runModifiers(this.modifiers, data);
  33692. // the first `update` will call `onCreate` callback
  33693. // the other ones will call `onUpdate` callback
  33694. if (!this.state.isCreated) {
  33695. this.state.isCreated = true;
  33696. this.options.onCreate(data);
  33697. } else {
  33698. this.options.onUpdate(data);
  33699. }
  33700. }
  33701. /**
  33702. * Helper used to know if the given modifier is enabled.
  33703. * @method
  33704. * @memberof Popper.Utils
  33705. * @returns {Boolean}
  33706. */
  33707. function isModifierEnabled(modifiers, modifierName) {
  33708. return modifiers.some(function (_ref) {
  33709. var name = _ref.name,
  33710. enabled = _ref.enabled;
  33711. return enabled && name === modifierName;
  33712. });
  33713. }
  33714. /**
  33715. * Get the prefixed supported property name
  33716. * @method
  33717. * @memberof Popper.Utils
  33718. * @argument {String} property (camelCase)
  33719. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  33720. */
  33721. function getSupportedPropertyName(property) {
  33722. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  33723. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  33724. for (var i = 0; i < prefixes.length; i++) {
  33725. var prefix = prefixes[i];
  33726. var toCheck = prefix ? '' + prefix + upperProp : property;
  33727. if (typeof document.body.style[toCheck] !== 'undefined') {
  33728. return toCheck;
  33729. }
  33730. }
  33731. return null;
  33732. }
  33733. /**
  33734. * Destroys the popper.
  33735. * @method
  33736. * @memberof Popper
  33737. */
  33738. function destroy() {
  33739. this.state.isDestroyed = true;
  33740. // touch DOM only if `applyStyle` modifier is enabled
  33741. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  33742. this.popper.removeAttribute('x-placement');
  33743. this.popper.style.position = '';
  33744. this.popper.style.top = '';
  33745. this.popper.style.left = '';
  33746. this.popper.style.right = '';
  33747. this.popper.style.bottom = '';
  33748. this.popper.style.willChange = '';
  33749. this.popper.style[getSupportedPropertyName('transform')] = '';
  33750. }
  33751. this.disableEventListeners();
  33752. // remove the popper if user explicitly asked for the deletion on destroy
  33753. // do not use `remove` because IE11 doesn't support it
  33754. if (this.options.removeOnDestroy) {
  33755. this.popper.parentNode.removeChild(this.popper);
  33756. }
  33757. return this;
  33758. }
  33759. /**
  33760. * Get the window associated with the element
  33761. * @argument {Element} element
  33762. * @returns {Window}
  33763. */
  33764. function getWindow(element) {
  33765. var ownerDocument = element.ownerDocument;
  33766. return ownerDocument ? ownerDocument.defaultView : window;
  33767. }
  33768. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  33769. var isBody = scrollParent.nodeName === 'BODY';
  33770. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  33771. target.addEventListener(event, callback, { passive: true });
  33772. if (!isBody) {
  33773. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  33774. }
  33775. scrollParents.push(target);
  33776. }
  33777. /**
  33778. * Setup needed event listeners used to update the popper position
  33779. * @method
  33780. * @memberof Popper.Utils
  33781. * @private
  33782. */
  33783. function setupEventListeners(reference, options, state, updateBound) {
  33784. // Resize event listener on window
  33785. state.updateBound = updateBound;
  33786. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  33787. // Scroll event listener on scroll parents
  33788. var scrollElement = getScrollParent(reference);
  33789. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  33790. state.scrollElement = scrollElement;
  33791. state.eventsEnabled = true;
  33792. return state;
  33793. }
  33794. /**
  33795. * It will add resize/scroll events and start recalculating
  33796. * position of the popper element when they are triggered.
  33797. * @method
  33798. * @memberof Popper
  33799. */
  33800. function enableEventListeners() {
  33801. if (!this.state.eventsEnabled) {
  33802. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  33803. }
  33804. }
  33805. /**
  33806. * Remove event listeners used to update the popper position
  33807. * @method
  33808. * @memberof Popper.Utils
  33809. * @private
  33810. */
  33811. function removeEventListeners(reference, state) {
  33812. // Remove resize event listener on window
  33813. getWindow(reference).removeEventListener('resize', state.updateBound);
  33814. // Remove scroll event listener on scroll parents
  33815. state.scrollParents.forEach(function (target) {
  33816. target.removeEventListener('scroll', state.updateBound);
  33817. });
  33818. // Reset state
  33819. state.updateBound = null;
  33820. state.scrollParents = [];
  33821. state.scrollElement = null;
  33822. state.eventsEnabled = false;
  33823. return state;
  33824. }
  33825. /**
  33826. * It will remove resize/scroll events and won't recalculate popper position
  33827. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  33828. * unless you call `update` method manually.
  33829. * @method
  33830. * @memberof Popper
  33831. */
  33832. function disableEventListeners() {
  33833. if (this.state.eventsEnabled) {
  33834. cancelAnimationFrame(this.scheduleUpdate);
  33835. this.state = removeEventListeners(this.reference, this.state);
  33836. }
  33837. }
  33838. /**
  33839. * Tells if a given input is a number
  33840. * @method
  33841. * @memberof Popper.Utils
  33842. * @param {*} input to check
  33843. * @return {Boolean}
  33844. */
  33845. function isNumeric(n) {
  33846. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  33847. }
  33848. /**
  33849. * Set the style to the given popper
  33850. * @method
  33851. * @memberof Popper.Utils
  33852. * @argument {Element} element - Element to apply the style to
  33853. * @argument {Object} styles
  33854. * Object with a list of properties and values which will be applied to the element
  33855. */
  33856. function setStyles(element, styles) {
  33857. Object.keys(styles).forEach(function (prop) {
  33858. var unit = '';
  33859. // add unit if the value is numeric and is one of the following
  33860. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  33861. unit = 'px';
  33862. }
  33863. element.style[prop] = styles[prop] + unit;
  33864. });
  33865. }
  33866. /**
  33867. * Set the attributes to the given popper
  33868. * @method
  33869. * @memberof Popper.Utils
  33870. * @argument {Element} element - Element to apply the attributes to
  33871. * @argument {Object} styles
  33872. * Object with a list of properties and values which will be applied to the element
  33873. */
  33874. function setAttributes(element, attributes) {
  33875. Object.keys(attributes).forEach(function (prop) {
  33876. var value = attributes[prop];
  33877. if (value !== false) {
  33878. element.setAttribute(prop, attributes[prop]);
  33879. } else {
  33880. element.removeAttribute(prop);
  33881. }
  33882. });
  33883. }
  33884. /**
  33885. * @function
  33886. * @memberof Modifiers
  33887. * @argument {Object} data - The data object generated by `update` method
  33888. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  33889. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  33890. * @argument {Object} options - Modifiers configuration and options
  33891. * @returns {Object} The same data object
  33892. */
  33893. function applyStyle(data) {
  33894. // any property present in `data.styles` will be applied to the popper,
  33895. // in this way we can make the 3rd party modifiers add custom styles to it
  33896. // Be aware, modifiers could override the properties defined in the previous
  33897. // lines of this modifier!
  33898. setStyles(data.instance.popper, data.styles);
  33899. // any property present in `data.attributes` will be applied to the popper,
  33900. // they will be set as HTML attributes of the element
  33901. setAttributes(data.instance.popper, data.attributes);
  33902. // if arrowElement is defined and arrowStyles has some properties
  33903. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  33904. setStyles(data.arrowElement, data.arrowStyles);
  33905. }
  33906. return data;
  33907. }
  33908. /**
  33909. * Set the x-placement attribute before everything else because it could be used
  33910. * to add margins to the popper margins needs to be calculated to get the
  33911. * correct popper offsets.
  33912. * @method
  33913. * @memberof Popper.modifiers
  33914. * @param {HTMLElement} reference - The reference element used to position the popper
  33915. * @param {HTMLElement} popper - The HTML element used as popper
  33916. * @param {Object} options - Popper.js options
  33917. */
  33918. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  33919. // compute reference element offsets
  33920. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  33921. // compute auto placement, store placement inside the data object,
  33922. // modifiers will be able to edit `placement` if needed
  33923. // and refer to originalPlacement to know the original value
  33924. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  33925. popper.setAttribute('x-placement', placement);
  33926. // Apply `position` to popper before anything else because
  33927. // without the position applied we can't guarantee correct computations
  33928. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  33929. return options;
  33930. }
  33931. /**
  33932. * @function
  33933. * @memberof Popper.Utils
  33934. * @argument {Object} data - The data object generated by `update` method
  33935. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  33936. * @returns {Object} The popper's position offsets rounded
  33937. *
  33938. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  33939. * good as it can be within reason.
  33940. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  33941. *
  33942. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  33943. * as well on High DPI screens).
  33944. *
  33945. * Firefox prefers no rounding for positioning and does not have blurriness on
  33946. * high DPI screens.
  33947. *
  33948. * Only horizontal placement and left/right values need to be considered.
  33949. */
  33950. function getRoundedOffsets(data, shouldRound) {
  33951. var _data$offsets = data.offsets,
  33952. popper = _data$offsets.popper,
  33953. reference = _data$offsets.reference;
  33954. var round = Math.round,
  33955. floor = Math.floor;
  33956. var noRound = function noRound(v) {
  33957. return v;
  33958. };
  33959. var referenceWidth = round(reference.width);
  33960. var popperWidth = round(popper.width);
  33961. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  33962. var isVariation = data.placement.indexOf('-') !== -1;
  33963. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  33964. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  33965. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  33966. var verticalToInteger = !shouldRound ? noRound : round;
  33967. return {
  33968. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  33969. top: verticalToInteger(popper.top),
  33970. bottom: verticalToInteger(popper.bottom),
  33971. right: horizontalToInteger(popper.right)
  33972. };
  33973. }
  33974. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  33975. /**
  33976. * @function
  33977. * @memberof Modifiers
  33978. * @argument {Object} data - The data object generated by `update` method
  33979. * @argument {Object} options - Modifiers configuration and options
  33980. * @returns {Object} The data object, properly modified
  33981. */
  33982. function computeStyle(data, options) {
  33983. var x = options.x,
  33984. y = options.y;
  33985. var popper = data.offsets.popper;
  33986. // Remove this legacy support in Popper.js v2
  33987. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  33988. return modifier.name === 'applyStyle';
  33989. }).gpuAcceleration;
  33990. if (legacyGpuAccelerationOption !== undefined) {
  33991. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  33992. }
  33993. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  33994. var offsetParent = getOffsetParent(data.instance.popper);
  33995. var offsetParentRect = getBoundingClientRect(offsetParent);
  33996. // Styles
  33997. var styles = {
  33998. position: popper.position
  33999. };
  34000. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34001. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34002. var sideB = y === 'right' ? 'left' : 'right';
  34003. // if gpuAcceleration is set to `true` and transform is supported,
  34004. // we use `translate3d` to apply the position to the popper we
  34005. // automatically use the supported prefixed version if needed
  34006. var prefixedProperty = getSupportedPropertyName('transform');
  34007. // now, let's make a step back and look at this code closely (wtf?)
  34008. // If the content of the popper grows once it's been positioned, it
  34009. // may happen that the popper gets misplaced because of the new content
  34010. // overflowing its reference element
  34011. // To avoid this problem, we provide two options (x and y), which allow
  34012. // the consumer to define the offset origin.
  34013. // If we position a popper on top of a reference element, we can set
  34014. // `x` to `top` to make the popper grow towards its top instead of
  34015. // its bottom.
  34016. var left = void 0,
  34017. top = void 0;
  34018. if (sideA === 'bottom') {
  34019. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34020. // and not the bottom of the html element
  34021. if (offsetParent.nodeName === 'HTML') {
  34022. top = -offsetParent.clientHeight + offsets.bottom;
  34023. } else {
  34024. top = -offsetParentRect.height + offsets.bottom;
  34025. }
  34026. } else {
  34027. top = offsets.top;
  34028. }
  34029. if (sideB === 'right') {
  34030. if (offsetParent.nodeName === 'HTML') {
  34031. left = -offsetParent.clientWidth + offsets.right;
  34032. } else {
  34033. left = -offsetParentRect.width + offsets.right;
  34034. }
  34035. } else {
  34036. left = offsets.left;
  34037. }
  34038. if (gpuAcceleration && prefixedProperty) {
  34039. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34040. styles[sideA] = 0;
  34041. styles[sideB] = 0;
  34042. styles.willChange = 'transform';
  34043. } else {
  34044. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34045. var invertTop = sideA === 'bottom' ? -1 : 1;
  34046. var invertLeft = sideB === 'right' ? -1 : 1;
  34047. styles[sideA] = top * invertTop;
  34048. styles[sideB] = left * invertLeft;
  34049. styles.willChange = sideA + ', ' + sideB;
  34050. }
  34051. // Attributes
  34052. var attributes = {
  34053. 'x-placement': data.placement
  34054. };
  34055. // Update `data` attributes, styles and arrowStyles
  34056. data.attributes = _extends({}, attributes, data.attributes);
  34057. data.styles = _extends({}, styles, data.styles);
  34058. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34059. return data;
  34060. }
  34061. /**
  34062. * Helper used to know if the given modifier depends from another one.<br />
  34063. * It checks if the needed modifier is listed and enabled.
  34064. * @method
  34065. * @memberof Popper.Utils
  34066. * @param {Array} modifiers - list of modifiers
  34067. * @param {String} requestingName - name of requesting modifier
  34068. * @param {String} requestedName - name of requested modifier
  34069. * @returns {Boolean}
  34070. */
  34071. function isModifierRequired(modifiers, requestingName, requestedName) {
  34072. var requesting = find(modifiers, function (_ref) {
  34073. var name = _ref.name;
  34074. return name === requestingName;
  34075. });
  34076. var isRequired = !!requesting && modifiers.some(function (modifier) {
  34077. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  34078. });
  34079. if (!isRequired) {
  34080. var _requesting = '`' + requestingName + '`';
  34081. var requested = '`' + requestedName + '`';
  34082. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  34083. }
  34084. return isRequired;
  34085. }
  34086. /**
  34087. * @function
  34088. * @memberof Modifiers
  34089. * @argument {Object} data - The data object generated by update method
  34090. * @argument {Object} options - Modifiers configuration and options
  34091. * @returns {Object} The data object, properly modified
  34092. */
  34093. function arrow(data, options) {
  34094. var _data$offsets$arrow;
  34095. // arrow depends on keepTogether in order to work
  34096. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  34097. return data;
  34098. }
  34099. var arrowElement = options.element;
  34100. // if arrowElement is a string, suppose it's a CSS selector
  34101. if (typeof arrowElement === 'string') {
  34102. arrowElement = data.instance.popper.querySelector(arrowElement);
  34103. // if arrowElement is not found, don't run the modifier
  34104. if (!arrowElement) {
  34105. return data;
  34106. }
  34107. } else {
  34108. // if the arrowElement isn't a query selector we must check that the
  34109. // provided DOM node is child of its popper node
  34110. if (!data.instance.popper.contains(arrowElement)) {
  34111. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  34112. return data;
  34113. }
  34114. }
  34115. var placement = data.placement.split('-')[0];
  34116. var _data$offsets = data.offsets,
  34117. popper = _data$offsets.popper,
  34118. reference = _data$offsets.reference;
  34119. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  34120. var len = isVertical ? 'height' : 'width';
  34121. var sideCapitalized = isVertical ? 'Top' : 'Left';
  34122. var side = sideCapitalized.toLowerCase();
  34123. var altSide = isVertical ? 'left' : 'top';
  34124. var opSide = isVertical ? 'bottom' : 'right';
  34125. var arrowElementSize = getOuterSizes(arrowElement)[len];
  34126. //
  34127. // extends keepTogether behavior making sure the popper and its
  34128. // reference have enough pixels in conjunction
  34129. //
  34130. // top/left side
  34131. if (reference[opSide] - arrowElementSize < popper[side]) {
  34132. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  34133. }
  34134. // bottom/right side
  34135. if (reference[side] + arrowElementSize > popper[opSide]) {
  34136. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  34137. }
  34138. data.offsets.popper = getClientRect(data.offsets.popper);
  34139. // compute center of the popper
  34140. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  34141. // Compute the sideValue using the updated popper offsets
  34142. // take popper margin in account because we don't have this info available
  34143. var css = getStyleComputedProperty(data.instance.popper);
  34144. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  34145. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  34146. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  34147. // prevent arrowElement from being placed not contiguously to its popper
  34148. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  34149. data.arrowElement = arrowElement;
  34150. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  34151. return data;
  34152. }
  34153. /**
  34154. * Get the opposite placement variation of the given one
  34155. * @method
  34156. * @memberof Popper.Utils
  34157. * @argument {String} placement variation
  34158. * @returns {String} flipped placement variation
  34159. */
  34160. function getOppositeVariation(variation) {
  34161. if (variation === 'end') {
  34162. return 'start';
  34163. } else if (variation === 'start') {
  34164. return 'end';
  34165. }
  34166. return variation;
  34167. }
  34168. /**
  34169. * List of accepted placements to use as values of the `placement` option.<br />
  34170. * Valid placements are:
  34171. * - `auto`
  34172. * - `top`
  34173. * - `right`
  34174. * - `bottom`
  34175. * - `left`
  34176. *
  34177. * Each placement can have a variation from this list:
  34178. * - `-start`
  34179. * - `-end`
  34180. *
  34181. * Variations are interpreted easily if you think of them as the left to right
  34182. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  34183. * is right.<br />
  34184. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  34185. *
  34186. * Some valid examples are:
  34187. * - `top-end` (on top of reference, right aligned)
  34188. * - `right-start` (on right of reference, top aligned)
  34189. * - `bottom` (on bottom, centered)
  34190. * - `auto-end` (on the side with more space available, alignment depends by placement)
  34191. *
  34192. * @static
  34193. * @type {Array}
  34194. * @enum {String}
  34195. * @readonly
  34196. * @method placements
  34197. * @memberof Popper
  34198. */
  34199. 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'];
  34200. // Get rid of `auto` `auto-start` and `auto-end`
  34201. var validPlacements = placements.slice(3);
  34202. /**
  34203. * Given an initial placement, returns all the subsequent placements
  34204. * clockwise (or counter-clockwise).
  34205. *
  34206. * @method
  34207. * @memberof Popper.Utils
  34208. * @argument {String} placement - A valid placement (it accepts variations)
  34209. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  34210. * @returns {Array} placements including their variations
  34211. */
  34212. function clockwise(placement) {
  34213. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34214. var index = validPlacements.indexOf(placement);
  34215. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  34216. return counter ? arr.reverse() : arr;
  34217. }
  34218. var BEHAVIORS = {
  34219. FLIP: 'flip',
  34220. CLOCKWISE: 'clockwise',
  34221. COUNTERCLOCKWISE: 'counterclockwise'
  34222. };
  34223. /**
  34224. * @function
  34225. * @memberof Modifiers
  34226. * @argument {Object} data - The data object generated by update method
  34227. * @argument {Object} options - Modifiers configuration and options
  34228. * @returns {Object} The data object, properly modified
  34229. */
  34230. function flip(data, options) {
  34231. // if `inner` modifier is enabled, we can't use the `flip` modifier
  34232. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  34233. return data;
  34234. }
  34235. if (data.flipped && data.placement === data.originalPlacement) {
  34236. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  34237. return data;
  34238. }
  34239. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  34240. var placement = data.placement.split('-')[0];
  34241. var placementOpposite = getOppositePlacement(placement);
  34242. var variation = data.placement.split('-')[1] || '';
  34243. var flipOrder = [];
  34244. switch (options.behavior) {
  34245. case BEHAVIORS.FLIP:
  34246. flipOrder = [placement, placementOpposite];
  34247. break;
  34248. case BEHAVIORS.CLOCKWISE:
  34249. flipOrder = clockwise(placement);
  34250. break;
  34251. case BEHAVIORS.COUNTERCLOCKWISE:
  34252. flipOrder = clockwise(placement, true);
  34253. break;
  34254. default:
  34255. flipOrder = options.behavior;
  34256. }
  34257. flipOrder.forEach(function (step, index) {
  34258. if (placement !== step || flipOrder.length === index + 1) {
  34259. return data;
  34260. }
  34261. placement = data.placement.split('-')[0];
  34262. placementOpposite = getOppositePlacement(placement);
  34263. var popperOffsets = data.offsets.popper;
  34264. var refOffsets = data.offsets.reference;
  34265. // using floor because the reference offsets may contain decimals we are not going to consider here
  34266. var floor = Math.floor;
  34267. 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);
  34268. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  34269. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  34270. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  34271. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  34272. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  34273. // flip the variation if required
  34274. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34275. // flips variation if reference element overflows boundaries
  34276. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  34277. // flips variation if popper content overflows boundaries
  34278. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  34279. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  34280. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  34281. // this boolean to detect any flip loop
  34282. data.flipped = true;
  34283. if (overlapsRef || overflowsBoundaries) {
  34284. placement = flipOrder[index + 1];
  34285. }
  34286. if (flippedVariation) {
  34287. variation = getOppositeVariation(variation);
  34288. }
  34289. data.placement = placement + (variation ? '-' + variation : '');
  34290. // this object contains `position`, we want to preserve it along with
  34291. // any additional property we may add in the future
  34292. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  34293. data = runModifiers(data.instance.modifiers, data, 'flip');
  34294. }
  34295. });
  34296. return data;
  34297. }
  34298. /**
  34299. * @function
  34300. * @memberof Modifiers
  34301. * @argument {Object} data - The data object generated by update method
  34302. * @argument {Object} options - Modifiers configuration and options
  34303. * @returns {Object} The data object, properly modified
  34304. */
  34305. function keepTogether(data) {
  34306. var _data$offsets = data.offsets,
  34307. popper = _data$offsets.popper,
  34308. reference = _data$offsets.reference;
  34309. var placement = data.placement.split('-')[0];
  34310. var floor = Math.floor;
  34311. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  34312. var side = isVertical ? 'right' : 'bottom';
  34313. var opSide = isVertical ? 'left' : 'top';
  34314. var measurement = isVertical ? 'width' : 'height';
  34315. if (popper[side] < floor(reference[opSide])) {
  34316. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  34317. }
  34318. if (popper[opSide] > floor(reference[side])) {
  34319. data.offsets.popper[opSide] = floor(reference[side]);
  34320. }
  34321. return data;
  34322. }
  34323. /**
  34324. * Converts a string containing value + unit into a px value number
  34325. * @function
  34326. * @memberof {modifiers~offset}
  34327. * @private
  34328. * @argument {String} str - Value + unit string
  34329. * @argument {String} measurement - `height` or `width`
  34330. * @argument {Object} popperOffsets
  34331. * @argument {Object} referenceOffsets
  34332. * @returns {Number|String}
  34333. * Value in pixels, or original string if no values were extracted
  34334. */
  34335. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  34336. // separate value from unit
  34337. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  34338. var value = +split[1];
  34339. var unit = split[2];
  34340. // If it's not a number it's an operator, I guess
  34341. if (!value) {
  34342. return str;
  34343. }
  34344. if (unit.indexOf('%') === 0) {
  34345. var element = void 0;
  34346. switch (unit) {
  34347. case '%p':
  34348. element = popperOffsets;
  34349. break;
  34350. case '%':
  34351. case '%r':
  34352. default:
  34353. element = referenceOffsets;
  34354. }
  34355. var rect = getClientRect(element);
  34356. return rect[measurement] / 100 * value;
  34357. } else if (unit === 'vh' || unit === 'vw') {
  34358. // if is a vh or vw, we calculate the size based on the viewport
  34359. var size = void 0;
  34360. if (unit === 'vh') {
  34361. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  34362. } else {
  34363. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  34364. }
  34365. return size / 100 * value;
  34366. } else {
  34367. // if is an explicit pixel unit, we get rid of the unit and keep the value
  34368. // if is an implicit unit, it's px, and we return just the value
  34369. return value;
  34370. }
  34371. }
  34372. /**
  34373. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  34374. * @function
  34375. * @memberof {modifiers~offset}
  34376. * @private
  34377. * @argument {String} offset
  34378. * @argument {Object} popperOffsets
  34379. * @argument {Object} referenceOffsets
  34380. * @argument {String} basePlacement
  34381. * @returns {Array} a two cells array with x and y offsets in numbers
  34382. */
  34383. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  34384. var offsets = [0, 0];
  34385. // Use height if placement is left or right and index is 0 otherwise use width
  34386. // in this way the first offset will use an axis and the second one
  34387. // will use the other one
  34388. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  34389. // Split the offset string to obtain a list of values and operands
  34390. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  34391. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  34392. return frag.trim();
  34393. });
  34394. // Detect if the offset string contains a pair of values or a single one
  34395. // they could be separated by comma or space
  34396. var divider = fragments.indexOf(find(fragments, function (frag) {
  34397. return frag.search(/,|\s/) !== -1;
  34398. }));
  34399. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  34400. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  34401. }
  34402. // If divider is found, we divide the list of values and operands to divide
  34403. // them by ofset X and Y.
  34404. var splitRegex = /\s*,\s*|\s+/;
  34405. 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];
  34406. // Convert the values with units to absolute pixels to allow our computations
  34407. ops = ops.map(function (op, index) {
  34408. // Most of the units rely on the orientation of the popper
  34409. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  34410. var mergeWithPrevious = false;
  34411. return op
  34412. // This aggregates any `+` or `-` sign that aren't considered operators
  34413. // e.g.: 10 + +5 => [10, +, +5]
  34414. .reduce(function (a, b) {
  34415. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  34416. a[a.length - 1] = b;
  34417. mergeWithPrevious = true;
  34418. return a;
  34419. } else if (mergeWithPrevious) {
  34420. a[a.length - 1] += b;
  34421. mergeWithPrevious = false;
  34422. return a;
  34423. } else {
  34424. return a.concat(b);
  34425. }
  34426. }, [])
  34427. // Here we convert the string values into number values (in px)
  34428. .map(function (str) {
  34429. return toValue(str, measurement, popperOffsets, referenceOffsets);
  34430. });
  34431. });
  34432. // Loop trough the offsets arrays and execute the operations
  34433. ops.forEach(function (op, index) {
  34434. op.forEach(function (frag, index2) {
  34435. if (isNumeric(frag)) {
  34436. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  34437. }
  34438. });
  34439. });
  34440. return offsets;
  34441. }
  34442. /**
  34443. * @function
  34444. * @memberof Modifiers
  34445. * @argument {Object} data - The data object generated by update method
  34446. * @argument {Object} options - Modifiers configuration and options
  34447. * @argument {Number|String} options.offset=0
  34448. * The offset value as described in the modifier description
  34449. * @returns {Object} The data object, properly modified
  34450. */
  34451. function offset(data, _ref) {
  34452. var offset = _ref.offset;
  34453. var placement = data.placement,
  34454. _data$offsets = data.offsets,
  34455. popper = _data$offsets.popper,
  34456. reference = _data$offsets.reference;
  34457. var basePlacement = placement.split('-')[0];
  34458. var offsets = void 0;
  34459. if (isNumeric(+offset)) {
  34460. offsets = [+offset, 0];
  34461. } else {
  34462. offsets = parseOffset(offset, popper, reference, basePlacement);
  34463. }
  34464. if (basePlacement === 'left') {
  34465. popper.top += offsets[0];
  34466. popper.left -= offsets[1];
  34467. } else if (basePlacement === 'right') {
  34468. popper.top += offsets[0];
  34469. popper.left += offsets[1];
  34470. } else if (basePlacement === 'top') {
  34471. popper.left += offsets[0];
  34472. popper.top -= offsets[1];
  34473. } else if (basePlacement === 'bottom') {
  34474. popper.left += offsets[0];
  34475. popper.top += offsets[1];
  34476. }
  34477. data.popper = popper;
  34478. return data;
  34479. }
  34480. /**
  34481. * @function
  34482. * @memberof Modifiers
  34483. * @argument {Object} data - The data object generated by `update` method
  34484. * @argument {Object} options - Modifiers configuration and options
  34485. * @returns {Object} The data object, properly modified
  34486. */
  34487. function preventOverflow(data, options) {
  34488. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  34489. // If offsetParent is the reference element, we really want to
  34490. // go one step up and use the next offsetParent as reference to
  34491. // avoid to make this modifier completely useless and look like broken
  34492. if (data.instance.reference === boundariesElement) {
  34493. boundariesElement = getOffsetParent(boundariesElement);
  34494. }
  34495. // NOTE: DOM access here
  34496. // resets the popper's position so that the document size can be calculated excluding
  34497. // the size of the popper element itself
  34498. var transformProp = getSupportedPropertyName('transform');
  34499. var popperStyles = data.instance.popper.style; // assignment to help minification
  34500. var top = popperStyles.top,
  34501. left = popperStyles.left,
  34502. transform = popperStyles[transformProp];
  34503. popperStyles.top = '';
  34504. popperStyles.left = '';
  34505. popperStyles[transformProp] = '';
  34506. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  34507. // NOTE: DOM access here
  34508. // restores the original style properties after the offsets have been computed
  34509. popperStyles.top = top;
  34510. popperStyles.left = left;
  34511. popperStyles[transformProp] = transform;
  34512. options.boundaries = boundaries;
  34513. var order = options.priority;
  34514. var popper = data.offsets.popper;
  34515. var check = {
  34516. primary: function primary(placement) {
  34517. var value = popper[placement];
  34518. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  34519. value = Math.max(popper[placement], boundaries[placement]);
  34520. }
  34521. return defineProperty({}, placement, value);
  34522. },
  34523. secondary: function secondary(placement) {
  34524. var mainSide = placement === 'right' ? 'left' : 'top';
  34525. var value = popper[mainSide];
  34526. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  34527. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  34528. }
  34529. return defineProperty({}, mainSide, value);
  34530. }
  34531. };
  34532. order.forEach(function (placement) {
  34533. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  34534. popper = _extends({}, popper, check[side](placement));
  34535. });
  34536. data.offsets.popper = popper;
  34537. return data;
  34538. }
  34539. /**
  34540. * @function
  34541. * @memberof Modifiers
  34542. * @argument {Object} data - The data object generated by `update` method
  34543. * @argument {Object} options - Modifiers configuration and options
  34544. * @returns {Object} The data object, properly modified
  34545. */
  34546. function shift(data) {
  34547. var placement = data.placement;
  34548. var basePlacement = placement.split('-')[0];
  34549. var shiftvariation = placement.split('-')[1];
  34550. // if shift shiftvariation is specified, run the modifier
  34551. if (shiftvariation) {
  34552. var _data$offsets = data.offsets,
  34553. reference = _data$offsets.reference,
  34554. popper = _data$offsets.popper;
  34555. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  34556. var side = isVertical ? 'left' : 'top';
  34557. var measurement = isVertical ? 'width' : 'height';
  34558. var shiftOffsets = {
  34559. start: defineProperty({}, side, reference[side]),
  34560. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  34561. };
  34562. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  34563. }
  34564. return data;
  34565. }
  34566. /**
  34567. * @function
  34568. * @memberof Modifiers
  34569. * @argument {Object} data - The data object generated by update method
  34570. * @argument {Object} options - Modifiers configuration and options
  34571. * @returns {Object} The data object, properly modified
  34572. */
  34573. function hide(data) {
  34574. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  34575. return data;
  34576. }
  34577. var refRect = data.offsets.reference;
  34578. var bound = find(data.instance.modifiers, function (modifier) {
  34579. return modifier.name === 'preventOverflow';
  34580. }).boundaries;
  34581. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  34582. // Avoid unnecessary DOM access if visibility hasn't changed
  34583. if (data.hide === true) {
  34584. return data;
  34585. }
  34586. data.hide = true;
  34587. data.attributes['x-out-of-boundaries'] = '';
  34588. } else {
  34589. // Avoid unnecessary DOM access if visibility hasn't changed
  34590. if (data.hide === false) {
  34591. return data;
  34592. }
  34593. data.hide = false;
  34594. data.attributes['x-out-of-boundaries'] = false;
  34595. }
  34596. return data;
  34597. }
  34598. /**
  34599. * @function
  34600. * @memberof Modifiers
  34601. * @argument {Object} data - The data object generated by `update` method
  34602. * @argument {Object} options - Modifiers configuration and options
  34603. * @returns {Object} The data object, properly modified
  34604. */
  34605. function inner(data) {
  34606. var placement = data.placement;
  34607. var basePlacement = placement.split('-')[0];
  34608. var _data$offsets = data.offsets,
  34609. popper = _data$offsets.popper,
  34610. reference = _data$offsets.reference;
  34611. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  34612. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  34613. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  34614. data.placement = getOppositePlacement(placement);
  34615. data.offsets.popper = getClientRect(popper);
  34616. return data;
  34617. }
  34618. /**
  34619. * Modifier function, each modifier can have a function of this type assigned
  34620. * to its `fn` property.<br />
  34621. * These functions will be called on each update, this means that you must
  34622. * make sure they are performant enough to avoid performance bottlenecks.
  34623. *
  34624. * @function ModifierFn
  34625. * @argument {dataObject} data - The data object generated by `update` method
  34626. * @argument {Object} options - Modifiers configuration and options
  34627. * @returns {dataObject} The data object, properly modified
  34628. */
  34629. /**
  34630. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  34631. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  34632. * needed by the library.
  34633. *
  34634. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  34635. * All the other properties are configurations that could be tweaked.
  34636. * @namespace modifiers
  34637. */
  34638. var modifiers = {
  34639. /**
  34640. * Modifier used to shift the popper on the start or end of its reference
  34641. * element.<br />
  34642. * It will read the variation of the `placement` property.<br />
  34643. * It can be one either `-end` or `-start`.
  34644. * @memberof modifiers
  34645. * @inner
  34646. */
  34647. shift: {
  34648. /** @prop {number} order=100 - Index used to define the order of execution */
  34649. order: 100,
  34650. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34651. enabled: true,
  34652. /** @prop {ModifierFn} */
  34653. fn: shift
  34654. },
  34655. /**
  34656. * The `offset` modifier can shift your popper on both its axis.
  34657. *
  34658. * It accepts the following units:
  34659. * - `px` or unit-less, interpreted as pixels
  34660. * - `%` or `%r`, percentage relative to the length of the reference element
  34661. * - `%p`, percentage relative to the length of the popper element
  34662. * - `vw`, CSS viewport width unit
  34663. * - `vh`, CSS viewport height unit
  34664. *
  34665. * For length is intended the main axis relative to the placement of the popper.<br />
  34666. * This means that if the placement is `top` or `bottom`, the length will be the
  34667. * `width`. In case of `left` or `right`, it will be the `height`.
  34668. *
  34669. * You can provide a single value (as `Number` or `String`), or a pair of values
  34670. * as `String` divided by a comma or one (or more) white spaces.<br />
  34671. * The latter is a deprecated method because it leads to confusion and will be
  34672. * removed in v2.<br />
  34673. * Additionally, it accepts additions and subtractions between different units.
  34674. * Note that multiplications and divisions aren't supported.
  34675. *
  34676. * Valid examples are:
  34677. * ```
  34678. * 10
  34679. * '10%'
  34680. * '10, 10'
  34681. * '10%, 10'
  34682. * '10 + 10%'
  34683. * '10 - 5vh + 3%'
  34684. * '-10px + 5vh, 5px - 6%'
  34685. * ```
  34686. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  34687. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  34688. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  34689. *
  34690. * @memberof modifiers
  34691. * @inner
  34692. */
  34693. offset: {
  34694. /** @prop {number} order=200 - Index used to define the order of execution */
  34695. order: 200,
  34696. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34697. enabled: true,
  34698. /** @prop {ModifierFn} */
  34699. fn: offset,
  34700. /** @prop {Number|String} offset=0
  34701. * The offset value as described in the modifier description
  34702. */
  34703. offset: 0
  34704. },
  34705. /**
  34706. * Modifier used to prevent the popper from being positioned outside the boundary.
  34707. *
  34708. * A scenario exists where the reference itself is not within the boundaries.<br />
  34709. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  34710. * In this case we need to decide whether the popper should either:
  34711. *
  34712. * - detach from the reference and remain "trapped" in the boundaries, or
  34713. * - if it should ignore the boundary and "escape with its reference"
  34714. *
  34715. * When `escapeWithReference` is set to`true` and reference is completely
  34716. * outside its boundaries, the popper will overflow (or completely leave)
  34717. * the boundaries in order to remain attached to the edge of the reference.
  34718. *
  34719. * @memberof modifiers
  34720. * @inner
  34721. */
  34722. preventOverflow: {
  34723. /** @prop {number} order=300 - Index used to define the order of execution */
  34724. order: 300,
  34725. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34726. enabled: true,
  34727. /** @prop {ModifierFn} */
  34728. fn: preventOverflow,
  34729. /**
  34730. * @prop {Array} [priority=['left','right','top','bottom']]
  34731. * Popper will try to prevent overflow following these priorities by default,
  34732. * then, it could overflow on the left and on top of the `boundariesElement`
  34733. */
  34734. priority: ['left', 'right', 'top', 'bottom'],
  34735. /**
  34736. * @prop {number} padding=5
  34737. * Amount of pixel used to define a minimum distance between the boundaries
  34738. * and the popper. This makes sure the popper always has a little padding
  34739. * between the edges of its container
  34740. */
  34741. padding: 5,
  34742. /**
  34743. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  34744. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  34745. * `viewport` or any DOM element.
  34746. */
  34747. boundariesElement: 'scrollParent'
  34748. },
  34749. /**
  34750. * Modifier used to make sure the reference and its popper stay near each other
  34751. * without leaving any gap between the two. Especially useful when the arrow is
  34752. * enabled and you want to ensure that it points to its reference element.
  34753. * It cares only about the first axis. You can still have poppers with margin
  34754. * between the popper and its reference element.
  34755. * @memberof modifiers
  34756. * @inner
  34757. */
  34758. keepTogether: {
  34759. /** @prop {number} order=400 - Index used to define the order of execution */
  34760. order: 400,
  34761. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34762. enabled: true,
  34763. /** @prop {ModifierFn} */
  34764. fn: keepTogether
  34765. },
  34766. /**
  34767. * This modifier is used to move the `arrowElement` of the popper to make
  34768. * sure it is positioned between the reference element and its popper element.
  34769. * It will read the outer size of the `arrowElement` node to detect how many
  34770. * pixels of conjunction are needed.
  34771. *
  34772. * It has no effect if no `arrowElement` is provided.
  34773. * @memberof modifiers
  34774. * @inner
  34775. */
  34776. arrow: {
  34777. /** @prop {number} order=500 - Index used to define the order of execution */
  34778. order: 500,
  34779. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34780. enabled: true,
  34781. /** @prop {ModifierFn} */
  34782. fn: arrow,
  34783. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  34784. element: '[x-arrow]'
  34785. },
  34786. /**
  34787. * Modifier used to flip the popper's placement when it starts to overlap its
  34788. * reference element.
  34789. *
  34790. * Requires the `preventOverflow` modifier before it in order to work.
  34791. *
  34792. * **NOTE:** this modifier will interrupt the current update cycle and will
  34793. * restart it if it detects the need to flip the placement.
  34794. * @memberof modifiers
  34795. * @inner
  34796. */
  34797. flip: {
  34798. /** @prop {number} order=600 - Index used to define the order of execution */
  34799. order: 600,
  34800. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34801. enabled: true,
  34802. /** @prop {ModifierFn} */
  34803. fn: flip,
  34804. /**
  34805. * @prop {String|Array} behavior='flip'
  34806. * The behavior used to change the popper's placement. It can be one of
  34807. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  34808. * placements (with optional variations)
  34809. */
  34810. behavior: 'flip',
  34811. /**
  34812. * @prop {number} padding=5
  34813. * The popper will flip if it hits the edges of the `boundariesElement`
  34814. */
  34815. padding: 5,
  34816. /**
  34817. * @prop {String|HTMLElement} boundariesElement='viewport'
  34818. * The element which will define the boundaries of the popper position.
  34819. * The popper will never be placed outside of the defined boundaries
  34820. * (except if `keepTogether` is enabled)
  34821. */
  34822. boundariesElement: 'viewport',
  34823. /**
  34824. * @prop {Boolean} flipVariations=false
  34825. * The popper will switch placement variation between `-start` and `-end` when
  34826. * the reference element overlaps its boundaries.
  34827. *
  34828. * The original placement should have a set variation.
  34829. */
  34830. flipVariations: false,
  34831. /**
  34832. * @prop {Boolean} flipVariationsByContent=false
  34833. * The popper will switch placement variation between `-start` and `-end` when
  34834. * the popper element overlaps its reference boundaries.
  34835. *
  34836. * The original placement should have a set variation.
  34837. */
  34838. flipVariationsByContent: false
  34839. },
  34840. /**
  34841. * Modifier used to make the popper flow toward the inner of the reference element.
  34842. * By default, when this modifier is disabled, the popper will be placed outside
  34843. * the reference element.
  34844. * @memberof modifiers
  34845. * @inner
  34846. */
  34847. inner: {
  34848. /** @prop {number} order=700 - Index used to define the order of execution */
  34849. order: 700,
  34850. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  34851. enabled: false,
  34852. /** @prop {ModifierFn} */
  34853. fn: inner
  34854. },
  34855. /**
  34856. * Modifier used to hide the popper when its reference element is outside of the
  34857. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  34858. * be used to hide with a CSS selector the popper when its reference is
  34859. * out of boundaries.
  34860. *
  34861. * Requires the `preventOverflow` modifier before it in order to work.
  34862. * @memberof modifiers
  34863. * @inner
  34864. */
  34865. hide: {
  34866. /** @prop {number} order=800 - Index used to define the order of execution */
  34867. order: 800,
  34868. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34869. enabled: true,
  34870. /** @prop {ModifierFn} */
  34871. fn: hide
  34872. },
  34873. /**
  34874. * Computes the style that will be applied to the popper element to gets
  34875. * properly positioned.
  34876. *
  34877. * Note that this modifier will not touch the DOM, it just prepares the styles
  34878. * so that `applyStyle` modifier can apply it. This separation is useful
  34879. * in case you need to replace `applyStyle` with a custom implementation.
  34880. *
  34881. * This modifier has `850` as `order` value to maintain backward compatibility
  34882. * with previous versions of Popper.js. Expect the modifiers ordering method
  34883. * to change in future major versions of the library.
  34884. *
  34885. * @memberof modifiers
  34886. * @inner
  34887. */
  34888. computeStyle: {
  34889. /** @prop {number} order=850 - Index used to define the order of execution */
  34890. order: 850,
  34891. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34892. enabled: true,
  34893. /** @prop {ModifierFn} */
  34894. fn: computeStyle,
  34895. /**
  34896. * @prop {Boolean} gpuAcceleration=true
  34897. * If true, it uses the CSS 3D transformation to position the popper.
  34898. * Otherwise, it will use the `top` and `left` properties
  34899. */
  34900. gpuAcceleration: true,
  34901. /**
  34902. * @prop {string} [x='bottom']
  34903. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  34904. * Change this if your popper should grow in a direction different from `bottom`
  34905. */
  34906. x: 'bottom',
  34907. /**
  34908. * @prop {string} [x='left']
  34909. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  34910. * Change this if your popper should grow in a direction different from `right`
  34911. */
  34912. y: 'right'
  34913. },
  34914. /**
  34915. * Applies the computed styles to the popper element.
  34916. *
  34917. * All the DOM manipulations are limited to this modifier. This is useful in case
  34918. * you want to integrate Popper.js inside a framework or view library and you
  34919. * want to delegate all the DOM manipulations to it.
  34920. *
  34921. * Note that if you disable this modifier, you must make sure the popper element
  34922. * has its position set to `absolute` before Popper.js can do its work!
  34923. *
  34924. * Just disable this modifier and define your own to achieve the desired effect.
  34925. *
  34926. * @memberof modifiers
  34927. * @inner
  34928. */
  34929. applyStyle: {
  34930. /** @prop {number} order=900 - Index used to define the order of execution */
  34931. order: 900,
  34932. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  34933. enabled: true,
  34934. /** @prop {ModifierFn} */
  34935. fn: applyStyle,
  34936. /** @prop {Function} */
  34937. onLoad: applyStyleOnLoad,
  34938. /**
  34939. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  34940. * @prop {Boolean} gpuAcceleration=true
  34941. * If true, it uses the CSS 3D transformation to position the popper.
  34942. * Otherwise, it will use the `top` and `left` properties
  34943. */
  34944. gpuAcceleration: undefined
  34945. }
  34946. };
  34947. /**
  34948. * The `dataObject` is an object containing all the information used by Popper.js.
  34949. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  34950. * @name dataObject
  34951. * @property {Object} data.instance The Popper.js instance
  34952. * @property {String} data.placement Placement applied to popper
  34953. * @property {String} data.originalPlacement Placement originally defined on init
  34954. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  34955. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  34956. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  34957. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34958. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  34959. * @property {Object} data.boundaries Offsets of the popper boundaries
  34960. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  34961. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  34962. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  34963. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  34964. */
  34965. /**
  34966. * Default options provided to Popper.js constructor.<br />
  34967. * These can be overridden using the `options` argument of Popper.js.<br />
  34968. * To override an option, simply pass an object with the same
  34969. * structure of the `options` object, as the 3rd argument. For example:
  34970. * ```
  34971. * new Popper(ref, pop, {
  34972. * modifiers: {
  34973. * preventOverflow: { enabled: false }
  34974. * }
  34975. * })
  34976. * ```
  34977. * @type {Object}
  34978. * @static
  34979. * @memberof Popper
  34980. */
  34981. var Defaults = {
  34982. /**
  34983. * Popper's placement.
  34984. * @prop {Popper.placements} placement='bottom'
  34985. */
  34986. placement: 'bottom',
  34987. /**
  34988. * Set this to true if you want popper to position it self in 'fixed' mode
  34989. * @prop {Boolean} positionFixed=false
  34990. */
  34991. positionFixed: false,
  34992. /**
  34993. * Whether events (resize, scroll) are initially enabled.
  34994. * @prop {Boolean} eventsEnabled=true
  34995. */
  34996. eventsEnabled: true,
  34997. /**
  34998. * Set to true if you want to automatically remove the popper when
  34999. * you call the `destroy` method.
  35000. * @prop {Boolean} removeOnDestroy=false
  35001. */
  35002. removeOnDestroy: false,
  35003. /**
  35004. * Callback called when the popper is created.<br />
  35005. * By default, it is set to no-op.<br />
  35006. * Access Popper.js instance with `data.instance`.
  35007. * @prop {onCreate}
  35008. */
  35009. onCreate: function onCreate() {},
  35010. /**
  35011. * Callback called when the popper is updated. This callback is not called
  35012. * on the initialization/creation of the popper, but only on subsequent
  35013. * updates.<br />
  35014. * By default, it is set to no-op.<br />
  35015. * Access Popper.js instance with `data.instance`.
  35016. * @prop {onUpdate}
  35017. */
  35018. onUpdate: function onUpdate() {},
  35019. /**
  35020. * List of modifiers used to modify the offsets before they are applied to the popper.
  35021. * They provide most of the functionalities of Popper.js.
  35022. * @prop {modifiers}
  35023. */
  35024. modifiers: modifiers
  35025. };
  35026. /**
  35027. * @callback onCreate
  35028. * @param {dataObject} data
  35029. */
  35030. /**
  35031. * @callback onUpdate
  35032. * @param {dataObject} data
  35033. */
  35034. // Utils
  35035. // Methods
  35036. var Popper = function () {
  35037. /**
  35038. * Creates a new Popper.js instance.
  35039. * @class Popper
  35040. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35041. * @param {Element} popper - The HTML / XML element used as the popper
  35042. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35043. * @return {Object} instance - The generated Popper.js instance
  35044. */
  35045. function Popper(reference, popper) {
  35046. var _this = this;
  35047. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35048. classCallCheck(this, Popper);
  35049. this.scheduleUpdate = function () {
  35050. return requestAnimationFrame(_this.update);
  35051. };
  35052. // make update() debounced, so that it only runs at most once-per-tick
  35053. this.update = debounce(this.update.bind(this));
  35054. // with {} we create a new object with the options inside it
  35055. this.options = _extends({}, Popper.Defaults, options);
  35056. // init state
  35057. this.state = {
  35058. isDestroyed: false,
  35059. isCreated: false,
  35060. scrollParents: []
  35061. };
  35062. // get reference and popper elements (allow jQuery wrappers)
  35063. this.reference = reference && reference.jquery ? reference[0] : reference;
  35064. this.popper = popper && popper.jquery ? popper[0] : popper;
  35065. // Deep merge modifiers options
  35066. this.options.modifiers = {};
  35067. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35068. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  35069. });
  35070. // Refactoring modifiers' list (Object => Array)
  35071. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  35072. return _extends({
  35073. name: name
  35074. }, _this.options.modifiers[name]);
  35075. })
  35076. // sort the modifiers by order
  35077. .sort(function (a, b) {
  35078. return a.order - b.order;
  35079. });
  35080. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  35081. // such code is executed in the same order of its modifier
  35082. // they could add new properties to their options configuration
  35083. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  35084. this.modifiers.forEach(function (modifierOptions) {
  35085. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  35086. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  35087. }
  35088. });
  35089. // fire the first update to position the popper in the right place
  35090. this.update();
  35091. var eventsEnabled = this.options.eventsEnabled;
  35092. if (eventsEnabled) {
  35093. // setup event listeners, they will take care of update the position in specific situations
  35094. this.enableEventListeners();
  35095. }
  35096. this.state.eventsEnabled = eventsEnabled;
  35097. }
  35098. // We can't use class properties because they don't get listed in the
  35099. // class prototype and break stuff like Sinon stubs
  35100. createClass(Popper, [{
  35101. key: 'update',
  35102. value: function update$$1() {
  35103. return update.call(this);
  35104. }
  35105. }, {
  35106. key: 'destroy',
  35107. value: function destroy$$1() {
  35108. return destroy.call(this);
  35109. }
  35110. }, {
  35111. key: 'enableEventListeners',
  35112. value: function enableEventListeners$$1() {
  35113. return enableEventListeners.call(this);
  35114. }
  35115. }, {
  35116. key: 'disableEventListeners',
  35117. value: function disableEventListeners$$1() {
  35118. return disableEventListeners.call(this);
  35119. }
  35120. /**
  35121. * Schedules an update. It will run on the next UI update available.
  35122. * @method scheduleUpdate
  35123. * @memberof Popper
  35124. */
  35125. /**
  35126. * Collection of utilities useful when writing custom modifiers.
  35127. * Starting from version 1.7, this method is available only if you
  35128. * include `popper-utils.js` before `popper.js`.
  35129. *
  35130. * **DEPRECATION**: This way to access PopperUtils is deprecated
  35131. * and will be removed in v2! Use the PopperUtils module directly instead.
  35132. * Due to the high instability of the methods contained in Utils, we can't
  35133. * guarantee them to follow semver. Use them at your own risk!
  35134. * @static
  35135. * @private
  35136. * @type {Object}
  35137. * @deprecated since version 1.8
  35138. * @member Utils
  35139. * @memberof Popper
  35140. */
  35141. }]);
  35142. return Popper;
  35143. }();
  35144. /**
  35145. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  35146. * and lets you use it as replacement of a real DOM node.<br />
  35147. * You can use this method to position a popper relatively to a set of coordinates
  35148. * in case you don't have a DOM node to use as reference.
  35149. *
  35150. * ```
  35151. * new Popper(referenceObject, popperNode);
  35152. * ```
  35153. *
  35154. * NB: This feature isn't supported in Internet Explorer 10.
  35155. * @name referenceObject
  35156. * @property {Function} data.getBoundingClientRect
  35157. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  35158. * @property {number} data.clientWidth
  35159. * An ES6 getter that will return the width of the virtual reference element.
  35160. * @property {number} data.clientHeight
  35161. * An ES6 getter that will return the height of the virtual reference element.
  35162. */
  35163. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  35164. Popper.placements = placements;
  35165. Popper.Defaults = Defaults;
  35166. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  35167. //# sourceMappingURL=popper.js.map
  35168. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  35169. /***/ }),
  35170. /***/ "./node_modules/process/browser.js":
  35171. /*!*****************************************!*\
  35172. !*** ./node_modules/process/browser.js ***!
  35173. \*****************************************/
  35174. /*! no static exports found */
  35175. /***/ (function(module, exports) {
  35176. // shim for using process in browser
  35177. var process = module.exports = {};
  35178. // cached from whatever global is present so that test runners that stub it
  35179. // don't break things. But we need to wrap it in a try catch in case it is
  35180. // wrapped in strict mode code which doesn't define any globals. It's inside a
  35181. // function because try/catches deoptimize in certain engines.
  35182. var cachedSetTimeout;
  35183. var cachedClearTimeout;
  35184. function defaultSetTimout() {
  35185. throw new Error('setTimeout has not been defined');
  35186. }
  35187. function defaultClearTimeout () {
  35188. throw new Error('clearTimeout has not been defined');
  35189. }
  35190. (function () {
  35191. try {
  35192. if (typeof setTimeout === 'function') {
  35193. cachedSetTimeout = setTimeout;
  35194. } else {
  35195. cachedSetTimeout = defaultSetTimout;
  35196. }
  35197. } catch (e) {
  35198. cachedSetTimeout = defaultSetTimout;
  35199. }
  35200. try {
  35201. if (typeof clearTimeout === 'function') {
  35202. cachedClearTimeout = clearTimeout;
  35203. } else {
  35204. cachedClearTimeout = defaultClearTimeout;
  35205. }
  35206. } catch (e) {
  35207. cachedClearTimeout = defaultClearTimeout;
  35208. }
  35209. } ())
  35210. function runTimeout(fun) {
  35211. if (cachedSetTimeout === setTimeout) {
  35212. //normal enviroments in sane situations
  35213. return setTimeout(fun, 0);
  35214. }
  35215. // if setTimeout wasn't available but was latter defined
  35216. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  35217. cachedSetTimeout = setTimeout;
  35218. return setTimeout(fun, 0);
  35219. }
  35220. try {
  35221. // when when somebody has screwed with setTimeout but no I.E. maddness
  35222. return cachedSetTimeout(fun, 0);
  35223. } catch(e){
  35224. try {
  35225. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35226. return cachedSetTimeout.call(null, fun, 0);
  35227. } catch(e){
  35228. // 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
  35229. return cachedSetTimeout.call(this, fun, 0);
  35230. }
  35231. }
  35232. }
  35233. function runClearTimeout(marker) {
  35234. if (cachedClearTimeout === clearTimeout) {
  35235. //normal enviroments in sane situations
  35236. return clearTimeout(marker);
  35237. }
  35238. // if clearTimeout wasn't available but was latter defined
  35239. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  35240. cachedClearTimeout = clearTimeout;
  35241. return clearTimeout(marker);
  35242. }
  35243. try {
  35244. // when when somebody has screwed with setTimeout but no I.E. maddness
  35245. return cachedClearTimeout(marker);
  35246. } catch (e){
  35247. try {
  35248. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  35249. return cachedClearTimeout.call(null, marker);
  35250. } catch (e){
  35251. // 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.
  35252. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  35253. return cachedClearTimeout.call(this, marker);
  35254. }
  35255. }
  35256. }
  35257. var queue = [];
  35258. var draining = false;
  35259. var currentQueue;
  35260. var queueIndex = -1;
  35261. function cleanUpNextTick() {
  35262. if (!draining || !currentQueue) {
  35263. return;
  35264. }
  35265. draining = false;
  35266. if (currentQueue.length) {
  35267. queue = currentQueue.concat(queue);
  35268. } else {
  35269. queueIndex = -1;
  35270. }
  35271. if (queue.length) {
  35272. drainQueue();
  35273. }
  35274. }
  35275. function drainQueue() {
  35276. if (draining) {
  35277. return;
  35278. }
  35279. var timeout = runTimeout(cleanUpNextTick);
  35280. draining = true;
  35281. var len = queue.length;
  35282. while(len) {
  35283. currentQueue = queue;
  35284. queue = [];
  35285. while (++queueIndex < len) {
  35286. if (currentQueue) {
  35287. currentQueue[queueIndex].run();
  35288. }
  35289. }
  35290. queueIndex = -1;
  35291. len = queue.length;
  35292. }
  35293. currentQueue = null;
  35294. draining = false;
  35295. runClearTimeout(timeout);
  35296. }
  35297. process.nextTick = function (fun) {
  35298. var args = new Array(arguments.length - 1);
  35299. if (arguments.length > 1) {
  35300. for (var i = 1; i < arguments.length; i++) {
  35301. args[i - 1] = arguments[i];
  35302. }
  35303. }
  35304. queue.push(new Item(fun, args));
  35305. if (queue.length === 1 && !draining) {
  35306. runTimeout(drainQueue);
  35307. }
  35308. };
  35309. // v8 likes predictible objects
  35310. function Item(fun, array) {
  35311. this.fun = fun;
  35312. this.array = array;
  35313. }
  35314. Item.prototype.run = function () {
  35315. this.fun.apply(null, this.array);
  35316. };
  35317. process.title = 'browser';
  35318. process.browser = true;
  35319. process.env = {};
  35320. process.argv = [];
  35321. process.version = ''; // empty string to avoid regexp issues
  35322. process.versions = {};
  35323. function noop() {}
  35324. process.on = noop;
  35325. process.addListener = noop;
  35326. process.once = noop;
  35327. process.off = noop;
  35328. process.removeListener = noop;
  35329. process.removeAllListeners = noop;
  35330. process.emit = noop;
  35331. process.prependListener = noop;
  35332. process.prependOnceListener = noop;
  35333. process.listeners = function (name) { return [] }
  35334. process.binding = function (name) {
  35335. throw new Error('process.binding is not supported');
  35336. };
  35337. process.cwd = function () { return '/' };
  35338. process.chdir = function (dir) {
  35339. throw new Error('process.chdir is not supported');
  35340. };
  35341. process.umask = function() { return 0; };
  35342. /***/ }),
  35343. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  35344. /*!***************************************************!*\
  35345. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  35346. \***************************************************/
  35347. /*! no static exports found */
  35348. /***/ (function(module, exports, __webpack_require__) {
  35349. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  35350. * Pusher JavaScript Library v5.0.3
  35351. * https://pusher.com/
  35352. *
  35353. * Copyright 2017, Pusher
  35354. * Released under the MIT licence.
  35355. */
  35356. (function webpackUniversalModuleDefinition(root, factory) {
  35357. if(true)
  35358. module.exports = factory();
  35359. else {}
  35360. })(window, function() {
  35361. return /******/ (function(modules) { // webpackBootstrap
  35362. /******/ // The module cache
  35363. /******/ var installedModules = {};
  35364. /******/
  35365. /******/ // The require function
  35366. /******/ function __webpack_require__(moduleId) {
  35367. /******/
  35368. /******/ // Check if module is in cache
  35369. /******/ if(installedModules[moduleId]) {
  35370. /******/ return installedModules[moduleId].exports;
  35371. /******/ }
  35372. /******/ // Create a new module (and put it into the cache)
  35373. /******/ var module = installedModules[moduleId] = {
  35374. /******/ i: moduleId,
  35375. /******/ l: false,
  35376. /******/ exports: {}
  35377. /******/ };
  35378. /******/
  35379. /******/ // Execute the module function
  35380. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  35381. /******/
  35382. /******/ // Flag the module as loaded
  35383. /******/ module.l = true;
  35384. /******/
  35385. /******/ // Return the exports of the module
  35386. /******/ return module.exports;
  35387. /******/ }
  35388. /******/
  35389. /******/
  35390. /******/ // expose the modules object (__webpack_modules__)
  35391. /******/ __webpack_require__.m = modules;
  35392. /******/
  35393. /******/ // expose the module cache
  35394. /******/ __webpack_require__.c = installedModules;
  35395. /******/
  35396. /******/ // define getter function for harmony exports
  35397. /******/ __webpack_require__.d = function(exports, name, getter) {
  35398. /******/ if(!__webpack_require__.o(exports, name)) {
  35399. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  35400. /******/ }
  35401. /******/ };
  35402. /******/
  35403. /******/ // define __esModule on exports
  35404. /******/ __webpack_require__.r = function(exports) {
  35405. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  35406. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35407. /******/ }
  35408. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  35409. /******/ };
  35410. /******/
  35411. /******/ // create a fake namespace object
  35412. /******/ // mode & 1: value is a module id, require it
  35413. /******/ // mode & 2: merge all properties of value into the ns
  35414. /******/ // mode & 4: return value when already ns object
  35415. /******/ // mode & 8|1: behave like require
  35416. /******/ __webpack_require__.t = function(value, mode) {
  35417. /******/ if(mode & 1) value = __webpack_require__(value);
  35418. /******/ if(mode & 8) return value;
  35419. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  35420. /******/ var ns = Object.create(null);
  35421. /******/ __webpack_require__.r(ns);
  35422. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  35423. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  35424. /******/ return ns;
  35425. /******/ };
  35426. /******/
  35427. /******/ // getDefaultExport function for compatibility with non-harmony modules
  35428. /******/ __webpack_require__.n = function(module) {
  35429. /******/ var getter = module && module.__esModule ?
  35430. /******/ function getDefault() { return module['default']; } :
  35431. /******/ function getModuleExports() { return module; };
  35432. /******/ __webpack_require__.d(getter, 'a', getter);
  35433. /******/ return getter;
  35434. /******/ };
  35435. /******/
  35436. /******/ // Object.prototype.hasOwnProperty.call
  35437. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  35438. /******/
  35439. /******/ // __webpack_public_path__
  35440. /******/ __webpack_require__.p = "";
  35441. /******/
  35442. /******/
  35443. /******/ // Load entry module and return exports
  35444. /******/ return __webpack_require__(__webpack_require__.s = 2);
  35445. /******/ })
  35446. /************************************************************************/
  35447. /******/ ([
  35448. /* 0 */
  35449. /***/ (function(module, exports, __webpack_require__) {
  35450. (function(nacl) {
  35451. 'use strict';
  35452. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  35453. // Public domain.
  35454. //
  35455. // Implementation derived from TweetNaCl version 20140427.
  35456. // See for details: http://tweetnacl.cr.yp.to/
  35457. var gf = function(init) {
  35458. var i, r = new Float64Array(16);
  35459. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  35460. return r;
  35461. };
  35462. // Pluggable, initialized in high-level API below.
  35463. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  35464. var _0 = new Uint8Array(16);
  35465. var _9 = new Uint8Array(32); _9[0] = 9;
  35466. var gf0 = gf(),
  35467. gf1 = gf([1]),
  35468. _121665 = gf([0xdb41, 1]),
  35469. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  35470. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  35471. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  35472. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  35473. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  35474. function ts64(x, i, h, l) {
  35475. x[i] = (h >> 24) & 0xff;
  35476. x[i+1] = (h >> 16) & 0xff;
  35477. x[i+2] = (h >> 8) & 0xff;
  35478. x[i+3] = h & 0xff;
  35479. x[i+4] = (l >> 24) & 0xff;
  35480. x[i+5] = (l >> 16) & 0xff;
  35481. x[i+6] = (l >> 8) & 0xff;
  35482. x[i+7] = l & 0xff;
  35483. }
  35484. function vn(x, xi, y, yi, n) {
  35485. var i,d = 0;
  35486. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  35487. return (1 & ((d - 1) >>> 8)) - 1;
  35488. }
  35489. function crypto_verify_16(x, xi, y, yi) {
  35490. return vn(x,xi,y,yi,16);
  35491. }
  35492. function crypto_verify_32(x, xi, y, yi) {
  35493. return vn(x,xi,y,yi,32);
  35494. }
  35495. function core_salsa20(o, p, k, c) {
  35496. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35497. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35498. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35499. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35500. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35501. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35502. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35503. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35504. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35505. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35506. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35507. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35508. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35509. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35510. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35511. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35512. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35513. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35514. x15 = j15, u;
  35515. for (var i = 0; i < 20; i += 2) {
  35516. u = x0 + x12 | 0;
  35517. x4 ^= u<<7 | u>>>(32-7);
  35518. u = x4 + x0 | 0;
  35519. x8 ^= u<<9 | u>>>(32-9);
  35520. u = x8 + x4 | 0;
  35521. x12 ^= u<<13 | u>>>(32-13);
  35522. u = x12 + x8 | 0;
  35523. x0 ^= u<<18 | u>>>(32-18);
  35524. u = x5 + x1 | 0;
  35525. x9 ^= u<<7 | u>>>(32-7);
  35526. u = x9 + x5 | 0;
  35527. x13 ^= u<<9 | u>>>(32-9);
  35528. u = x13 + x9 | 0;
  35529. x1 ^= u<<13 | u>>>(32-13);
  35530. u = x1 + x13 | 0;
  35531. x5 ^= u<<18 | u>>>(32-18);
  35532. u = x10 + x6 | 0;
  35533. x14 ^= u<<7 | u>>>(32-7);
  35534. u = x14 + x10 | 0;
  35535. x2 ^= u<<9 | u>>>(32-9);
  35536. u = x2 + x14 | 0;
  35537. x6 ^= u<<13 | u>>>(32-13);
  35538. u = x6 + x2 | 0;
  35539. x10 ^= u<<18 | u>>>(32-18);
  35540. u = x15 + x11 | 0;
  35541. x3 ^= u<<7 | u>>>(32-7);
  35542. u = x3 + x15 | 0;
  35543. x7 ^= u<<9 | u>>>(32-9);
  35544. u = x7 + x3 | 0;
  35545. x11 ^= u<<13 | u>>>(32-13);
  35546. u = x11 + x7 | 0;
  35547. x15 ^= u<<18 | u>>>(32-18);
  35548. u = x0 + x3 | 0;
  35549. x1 ^= u<<7 | u>>>(32-7);
  35550. u = x1 + x0 | 0;
  35551. x2 ^= u<<9 | u>>>(32-9);
  35552. u = x2 + x1 | 0;
  35553. x3 ^= u<<13 | u>>>(32-13);
  35554. u = x3 + x2 | 0;
  35555. x0 ^= u<<18 | u>>>(32-18);
  35556. u = x5 + x4 | 0;
  35557. x6 ^= u<<7 | u>>>(32-7);
  35558. u = x6 + x5 | 0;
  35559. x7 ^= u<<9 | u>>>(32-9);
  35560. u = x7 + x6 | 0;
  35561. x4 ^= u<<13 | u>>>(32-13);
  35562. u = x4 + x7 | 0;
  35563. x5 ^= u<<18 | u>>>(32-18);
  35564. u = x10 + x9 | 0;
  35565. x11 ^= u<<7 | u>>>(32-7);
  35566. u = x11 + x10 | 0;
  35567. x8 ^= u<<9 | u>>>(32-9);
  35568. u = x8 + x11 | 0;
  35569. x9 ^= u<<13 | u>>>(32-13);
  35570. u = x9 + x8 | 0;
  35571. x10 ^= u<<18 | u>>>(32-18);
  35572. u = x15 + x14 | 0;
  35573. x12 ^= u<<7 | u>>>(32-7);
  35574. u = x12 + x15 | 0;
  35575. x13 ^= u<<9 | u>>>(32-9);
  35576. u = x13 + x12 | 0;
  35577. x14 ^= u<<13 | u>>>(32-13);
  35578. u = x14 + x13 | 0;
  35579. x15 ^= u<<18 | u>>>(32-18);
  35580. }
  35581. x0 = x0 + j0 | 0;
  35582. x1 = x1 + j1 | 0;
  35583. x2 = x2 + j2 | 0;
  35584. x3 = x3 + j3 | 0;
  35585. x4 = x4 + j4 | 0;
  35586. x5 = x5 + j5 | 0;
  35587. x6 = x6 + j6 | 0;
  35588. x7 = x7 + j7 | 0;
  35589. x8 = x8 + j8 | 0;
  35590. x9 = x9 + j9 | 0;
  35591. x10 = x10 + j10 | 0;
  35592. x11 = x11 + j11 | 0;
  35593. x12 = x12 + j12 | 0;
  35594. x13 = x13 + j13 | 0;
  35595. x14 = x14 + j14 | 0;
  35596. x15 = x15 + j15 | 0;
  35597. o[ 0] = x0 >>> 0 & 0xff;
  35598. o[ 1] = x0 >>> 8 & 0xff;
  35599. o[ 2] = x0 >>> 16 & 0xff;
  35600. o[ 3] = x0 >>> 24 & 0xff;
  35601. o[ 4] = x1 >>> 0 & 0xff;
  35602. o[ 5] = x1 >>> 8 & 0xff;
  35603. o[ 6] = x1 >>> 16 & 0xff;
  35604. o[ 7] = x1 >>> 24 & 0xff;
  35605. o[ 8] = x2 >>> 0 & 0xff;
  35606. o[ 9] = x2 >>> 8 & 0xff;
  35607. o[10] = x2 >>> 16 & 0xff;
  35608. o[11] = x2 >>> 24 & 0xff;
  35609. o[12] = x3 >>> 0 & 0xff;
  35610. o[13] = x3 >>> 8 & 0xff;
  35611. o[14] = x3 >>> 16 & 0xff;
  35612. o[15] = x3 >>> 24 & 0xff;
  35613. o[16] = x4 >>> 0 & 0xff;
  35614. o[17] = x4 >>> 8 & 0xff;
  35615. o[18] = x4 >>> 16 & 0xff;
  35616. o[19] = x4 >>> 24 & 0xff;
  35617. o[20] = x5 >>> 0 & 0xff;
  35618. o[21] = x5 >>> 8 & 0xff;
  35619. o[22] = x5 >>> 16 & 0xff;
  35620. o[23] = x5 >>> 24 & 0xff;
  35621. o[24] = x6 >>> 0 & 0xff;
  35622. o[25] = x6 >>> 8 & 0xff;
  35623. o[26] = x6 >>> 16 & 0xff;
  35624. o[27] = x6 >>> 24 & 0xff;
  35625. o[28] = x7 >>> 0 & 0xff;
  35626. o[29] = x7 >>> 8 & 0xff;
  35627. o[30] = x7 >>> 16 & 0xff;
  35628. o[31] = x7 >>> 24 & 0xff;
  35629. o[32] = x8 >>> 0 & 0xff;
  35630. o[33] = x8 >>> 8 & 0xff;
  35631. o[34] = x8 >>> 16 & 0xff;
  35632. o[35] = x8 >>> 24 & 0xff;
  35633. o[36] = x9 >>> 0 & 0xff;
  35634. o[37] = x9 >>> 8 & 0xff;
  35635. o[38] = x9 >>> 16 & 0xff;
  35636. o[39] = x9 >>> 24 & 0xff;
  35637. o[40] = x10 >>> 0 & 0xff;
  35638. o[41] = x10 >>> 8 & 0xff;
  35639. o[42] = x10 >>> 16 & 0xff;
  35640. o[43] = x10 >>> 24 & 0xff;
  35641. o[44] = x11 >>> 0 & 0xff;
  35642. o[45] = x11 >>> 8 & 0xff;
  35643. o[46] = x11 >>> 16 & 0xff;
  35644. o[47] = x11 >>> 24 & 0xff;
  35645. o[48] = x12 >>> 0 & 0xff;
  35646. o[49] = x12 >>> 8 & 0xff;
  35647. o[50] = x12 >>> 16 & 0xff;
  35648. o[51] = x12 >>> 24 & 0xff;
  35649. o[52] = x13 >>> 0 & 0xff;
  35650. o[53] = x13 >>> 8 & 0xff;
  35651. o[54] = x13 >>> 16 & 0xff;
  35652. o[55] = x13 >>> 24 & 0xff;
  35653. o[56] = x14 >>> 0 & 0xff;
  35654. o[57] = x14 >>> 8 & 0xff;
  35655. o[58] = x14 >>> 16 & 0xff;
  35656. o[59] = x14 >>> 24 & 0xff;
  35657. o[60] = x15 >>> 0 & 0xff;
  35658. o[61] = x15 >>> 8 & 0xff;
  35659. o[62] = x15 >>> 16 & 0xff;
  35660. o[63] = x15 >>> 24 & 0xff;
  35661. }
  35662. function core_hsalsa20(o,p,k,c) {
  35663. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  35664. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  35665. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  35666. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  35667. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  35668. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  35669. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  35670. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  35671. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  35672. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  35673. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  35674. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  35675. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  35676. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  35677. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  35678. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  35679. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  35680. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  35681. x15 = j15, u;
  35682. for (var i = 0; i < 20; i += 2) {
  35683. u = x0 + x12 | 0;
  35684. x4 ^= u<<7 | u>>>(32-7);
  35685. u = x4 + x0 | 0;
  35686. x8 ^= u<<9 | u>>>(32-9);
  35687. u = x8 + x4 | 0;
  35688. x12 ^= u<<13 | u>>>(32-13);
  35689. u = x12 + x8 | 0;
  35690. x0 ^= u<<18 | u>>>(32-18);
  35691. u = x5 + x1 | 0;
  35692. x9 ^= u<<7 | u>>>(32-7);
  35693. u = x9 + x5 | 0;
  35694. x13 ^= u<<9 | u>>>(32-9);
  35695. u = x13 + x9 | 0;
  35696. x1 ^= u<<13 | u>>>(32-13);
  35697. u = x1 + x13 | 0;
  35698. x5 ^= u<<18 | u>>>(32-18);
  35699. u = x10 + x6 | 0;
  35700. x14 ^= u<<7 | u>>>(32-7);
  35701. u = x14 + x10 | 0;
  35702. x2 ^= u<<9 | u>>>(32-9);
  35703. u = x2 + x14 | 0;
  35704. x6 ^= u<<13 | u>>>(32-13);
  35705. u = x6 + x2 | 0;
  35706. x10 ^= u<<18 | u>>>(32-18);
  35707. u = x15 + x11 | 0;
  35708. x3 ^= u<<7 | u>>>(32-7);
  35709. u = x3 + x15 | 0;
  35710. x7 ^= u<<9 | u>>>(32-9);
  35711. u = x7 + x3 | 0;
  35712. x11 ^= u<<13 | u>>>(32-13);
  35713. u = x11 + x7 | 0;
  35714. x15 ^= u<<18 | u>>>(32-18);
  35715. u = x0 + x3 | 0;
  35716. x1 ^= u<<7 | u>>>(32-7);
  35717. u = x1 + x0 | 0;
  35718. x2 ^= u<<9 | u>>>(32-9);
  35719. u = x2 + x1 | 0;
  35720. x3 ^= u<<13 | u>>>(32-13);
  35721. u = x3 + x2 | 0;
  35722. x0 ^= u<<18 | u>>>(32-18);
  35723. u = x5 + x4 | 0;
  35724. x6 ^= u<<7 | u>>>(32-7);
  35725. u = x6 + x5 | 0;
  35726. x7 ^= u<<9 | u>>>(32-9);
  35727. u = x7 + x6 | 0;
  35728. x4 ^= u<<13 | u>>>(32-13);
  35729. u = x4 + x7 | 0;
  35730. x5 ^= u<<18 | u>>>(32-18);
  35731. u = x10 + x9 | 0;
  35732. x11 ^= u<<7 | u>>>(32-7);
  35733. u = x11 + x10 | 0;
  35734. x8 ^= u<<9 | u>>>(32-9);
  35735. u = x8 + x11 | 0;
  35736. x9 ^= u<<13 | u>>>(32-13);
  35737. u = x9 + x8 | 0;
  35738. x10 ^= u<<18 | u>>>(32-18);
  35739. u = x15 + x14 | 0;
  35740. x12 ^= u<<7 | u>>>(32-7);
  35741. u = x12 + x15 | 0;
  35742. x13 ^= u<<9 | u>>>(32-9);
  35743. u = x13 + x12 | 0;
  35744. x14 ^= u<<13 | u>>>(32-13);
  35745. u = x14 + x13 | 0;
  35746. x15 ^= u<<18 | u>>>(32-18);
  35747. }
  35748. o[ 0] = x0 >>> 0 & 0xff;
  35749. o[ 1] = x0 >>> 8 & 0xff;
  35750. o[ 2] = x0 >>> 16 & 0xff;
  35751. o[ 3] = x0 >>> 24 & 0xff;
  35752. o[ 4] = x5 >>> 0 & 0xff;
  35753. o[ 5] = x5 >>> 8 & 0xff;
  35754. o[ 6] = x5 >>> 16 & 0xff;
  35755. o[ 7] = x5 >>> 24 & 0xff;
  35756. o[ 8] = x10 >>> 0 & 0xff;
  35757. o[ 9] = x10 >>> 8 & 0xff;
  35758. o[10] = x10 >>> 16 & 0xff;
  35759. o[11] = x10 >>> 24 & 0xff;
  35760. o[12] = x15 >>> 0 & 0xff;
  35761. o[13] = x15 >>> 8 & 0xff;
  35762. o[14] = x15 >>> 16 & 0xff;
  35763. o[15] = x15 >>> 24 & 0xff;
  35764. o[16] = x6 >>> 0 & 0xff;
  35765. o[17] = x6 >>> 8 & 0xff;
  35766. o[18] = x6 >>> 16 & 0xff;
  35767. o[19] = x6 >>> 24 & 0xff;
  35768. o[20] = x7 >>> 0 & 0xff;
  35769. o[21] = x7 >>> 8 & 0xff;
  35770. o[22] = x7 >>> 16 & 0xff;
  35771. o[23] = x7 >>> 24 & 0xff;
  35772. o[24] = x8 >>> 0 & 0xff;
  35773. o[25] = x8 >>> 8 & 0xff;
  35774. o[26] = x8 >>> 16 & 0xff;
  35775. o[27] = x8 >>> 24 & 0xff;
  35776. o[28] = x9 >>> 0 & 0xff;
  35777. o[29] = x9 >>> 8 & 0xff;
  35778. o[30] = x9 >>> 16 & 0xff;
  35779. o[31] = x9 >>> 24 & 0xff;
  35780. }
  35781. function crypto_core_salsa20(out,inp,k,c) {
  35782. core_salsa20(out,inp,k,c);
  35783. }
  35784. function crypto_core_hsalsa20(out,inp,k,c) {
  35785. core_hsalsa20(out,inp,k,c);
  35786. }
  35787. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  35788. // "expand 32-byte k"
  35789. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  35790. var z = new Uint8Array(16), x = new Uint8Array(64);
  35791. var u, i;
  35792. for (i = 0; i < 16; i++) z[i] = 0;
  35793. for (i = 0; i < 8; i++) z[i] = n[i];
  35794. while (b >= 64) {
  35795. crypto_core_salsa20(x,z,k,sigma);
  35796. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35797. u = 1;
  35798. for (i = 8; i < 16; i++) {
  35799. u = u + (z[i] & 0xff) | 0;
  35800. z[i] = u & 0xff;
  35801. u >>>= 8;
  35802. }
  35803. b -= 64;
  35804. cpos += 64;
  35805. mpos += 64;
  35806. }
  35807. if (b > 0) {
  35808. crypto_core_salsa20(x,z,k,sigma);
  35809. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  35810. }
  35811. return 0;
  35812. }
  35813. function crypto_stream_salsa20(c,cpos,b,n,k) {
  35814. var z = new Uint8Array(16), x = new Uint8Array(64);
  35815. var u, i;
  35816. for (i = 0; i < 16; i++) z[i] = 0;
  35817. for (i = 0; i < 8; i++) z[i] = n[i];
  35818. while (b >= 64) {
  35819. crypto_core_salsa20(x,z,k,sigma);
  35820. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  35821. u = 1;
  35822. for (i = 8; i < 16; i++) {
  35823. u = u + (z[i] & 0xff) | 0;
  35824. z[i] = u & 0xff;
  35825. u >>>= 8;
  35826. }
  35827. b -= 64;
  35828. cpos += 64;
  35829. }
  35830. if (b > 0) {
  35831. crypto_core_salsa20(x,z,k,sigma);
  35832. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  35833. }
  35834. return 0;
  35835. }
  35836. function crypto_stream(c,cpos,d,n,k) {
  35837. var s = new Uint8Array(32);
  35838. crypto_core_hsalsa20(s,n,k,sigma);
  35839. var sn = new Uint8Array(8);
  35840. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35841. return crypto_stream_salsa20(c,cpos,d,sn,s);
  35842. }
  35843. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  35844. var s = new Uint8Array(32);
  35845. crypto_core_hsalsa20(s,n,k,sigma);
  35846. var sn = new Uint8Array(8);
  35847. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  35848. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  35849. }
  35850. /*
  35851. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  35852. * https://github.com/floodyberry/poly1305-donna
  35853. */
  35854. var poly1305 = function(key) {
  35855. this.buffer = new Uint8Array(16);
  35856. this.r = new Uint16Array(10);
  35857. this.h = new Uint16Array(10);
  35858. this.pad = new Uint16Array(8);
  35859. this.leftover = 0;
  35860. this.fin = 0;
  35861. var t0, t1, t2, t3, t4, t5, t6, t7;
  35862. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  35863. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35864. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  35865. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35866. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  35867. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  35868. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35869. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  35870. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35871. this.r[9] = ((t7 >>> 5)) & 0x007f;
  35872. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  35873. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  35874. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  35875. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  35876. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  35877. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  35878. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  35879. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  35880. };
  35881. poly1305.prototype.blocks = function(m, mpos, bytes) {
  35882. var hibit = this.fin ? 0 : (1 << 11);
  35883. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  35884. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  35885. var h0 = this.h[0],
  35886. h1 = this.h[1],
  35887. h2 = this.h[2],
  35888. h3 = this.h[3],
  35889. h4 = this.h[4],
  35890. h5 = this.h[5],
  35891. h6 = this.h[6],
  35892. h7 = this.h[7],
  35893. h8 = this.h[8],
  35894. h9 = this.h[9];
  35895. var r0 = this.r[0],
  35896. r1 = this.r[1],
  35897. r2 = this.r[2],
  35898. r3 = this.r[3],
  35899. r4 = this.r[4],
  35900. r5 = this.r[5],
  35901. r6 = this.r[6],
  35902. r7 = this.r[7],
  35903. r8 = this.r[8],
  35904. r9 = this.r[9];
  35905. while (bytes >= 16) {
  35906. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  35907. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  35908. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  35909. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  35910. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  35911. h5 += ((t4 >>> 1)) & 0x1fff;
  35912. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  35913. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  35914. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  35915. h9 += ((t7 >>> 5)) | hibit;
  35916. c = 0;
  35917. d0 = c;
  35918. d0 += h0 * r0;
  35919. d0 += h1 * (5 * r9);
  35920. d0 += h2 * (5 * r8);
  35921. d0 += h3 * (5 * r7);
  35922. d0 += h4 * (5 * r6);
  35923. c = (d0 >>> 13); d0 &= 0x1fff;
  35924. d0 += h5 * (5 * r5);
  35925. d0 += h6 * (5 * r4);
  35926. d0 += h7 * (5 * r3);
  35927. d0 += h8 * (5 * r2);
  35928. d0 += h9 * (5 * r1);
  35929. c += (d0 >>> 13); d0 &= 0x1fff;
  35930. d1 = c;
  35931. d1 += h0 * r1;
  35932. d1 += h1 * r0;
  35933. d1 += h2 * (5 * r9);
  35934. d1 += h3 * (5 * r8);
  35935. d1 += h4 * (5 * r7);
  35936. c = (d1 >>> 13); d1 &= 0x1fff;
  35937. d1 += h5 * (5 * r6);
  35938. d1 += h6 * (5 * r5);
  35939. d1 += h7 * (5 * r4);
  35940. d1 += h8 * (5 * r3);
  35941. d1 += h9 * (5 * r2);
  35942. c += (d1 >>> 13); d1 &= 0x1fff;
  35943. d2 = c;
  35944. d2 += h0 * r2;
  35945. d2 += h1 * r1;
  35946. d2 += h2 * r0;
  35947. d2 += h3 * (5 * r9);
  35948. d2 += h4 * (5 * r8);
  35949. c = (d2 >>> 13); d2 &= 0x1fff;
  35950. d2 += h5 * (5 * r7);
  35951. d2 += h6 * (5 * r6);
  35952. d2 += h7 * (5 * r5);
  35953. d2 += h8 * (5 * r4);
  35954. d2 += h9 * (5 * r3);
  35955. c += (d2 >>> 13); d2 &= 0x1fff;
  35956. d3 = c;
  35957. d3 += h0 * r3;
  35958. d3 += h1 * r2;
  35959. d3 += h2 * r1;
  35960. d3 += h3 * r0;
  35961. d3 += h4 * (5 * r9);
  35962. c = (d3 >>> 13); d3 &= 0x1fff;
  35963. d3 += h5 * (5 * r8);
  35964. d3 += h6 * (5 * r7);
  35965. d3 += h7 * (5 * r6);
  35966. d3 += h8 * (5 * r5);
  35967. d3 += h9 * (5 * r4);
  35968. c += (d3 >>> 13); d3 &= 0x1fff;
  35969. d4 = c;
  35970. d4 += h0 * r4;
  35971. d4 += h1 * r3;
  35972. d4 += h2 * r2;
  35973. d4 += h3 * r1;
  35974. d4 += h4 * r0;
  35975. c = (d4 >>> 13); d4 &= 0x1fff;
  35976. d4 += h5 * (5 * r9);
  35977. d4 += h6 * (5 * r8);
  35978. d4 += h7 * (5 * r7);
  35979. d4 += h8 * (5 * r6);
  35980. d4 += h9 * (5 * r5);
  35981. c += (d4 >>> 13); d4 &= 0x1fff;
  35982. d5 = c;
  35983. d5 += h0 * r5;
  35984. d5 += h1 * r4;
  35985. d5 += h2 * r3;
  35986. d5 += h3 * r2;
  35987. d5 += h4 * r1;
  35988. c = (d5 >>> 13); d5 &= 0x1fff;
  35989. d5 += h5 * r0;
  35990. d5 += h6 * (5 * r9);
  35991. d5 += h7 * (5 * r8);
  35992. d5 += h8 * (5 * r7);
  35993. d5 += h9 * (5 * r6);
  35994. c += (d5 >>> 13); d5 &= 0x1fff;
  35995. d6 = c;
  35996. d6 += h0 * r6;
  35997. d6 += h1 * r5;
  35998. d6 += h2 * r4;
  35999. d6 += h3 * r3;
  36000. d6 += h4 * r2;
  36001. c = (d6 >>> 13); d6 &= 0x1fff;
  36002. d6 += h5 * r1;
  36003. d6 += h6 * r0;
  36004. d6 += h7 * (5 * r9);
  36005. d6 += h8 * (5 * r8);
  36006. d6 += h9 * (5 * r7);
  36007. c += (d6 >>> 13); d6 &= 0x1fff;
  36008. d7 = c;
  36009. d7 += h0 * r7;
  36010. d7 += h1 * r6;
  36011. d7 += h2 * r5;
  36012. d7 += h3 * r4;
  36013. d7 += h4 * r3;
  36014. c = (d7 >>> 13); d7 &= 0x1fff;
  36015. d7 += h5 * r2;
  36016. d7 += h6 * r1;
  36017. d7 += h7 * r0;
  36018. d7 += h8 * (5 * r9);
  36019. d7 += h9 * (5 * r8);
  36020. c += (d7 >>> 13); d7 &= 0x1fff;
  36021. d8 = c;
  36022. d8 += h0 * r8;
  36023. d8 += h1 * r7;
  36024. d8 += h2 * r6;
  36025. d8 += h3 * r5;
  36026. d8 += h4 * r4;
  36027. c = (d8 >>> 13); d8 &= 0x1fff;
  36028. d8 += h5 * r3;
  36029. d8 += h6 * r2;
  36030. d8 += h7 * r1;
  36031. d8 += h8 * r0;
  36032. d8 += h9 * (5 * r9);
  36033. c += (d8 >>> 13); d8 &= 0x1fff;
  36034. d9 = c;
  36035. d9 += h0 * r9;
  36036. d9 += h1 * r8;
  36037. d9 += h2 * r7;
  36038. d9 += h3 * r6;
  36039. d9 += h4 * r5;
  36040. c = (d9 >>> 13); d9 &= 0x1fff;
  36041. d9 += h5 * r4;
  36042. d9 += h6 * r3;
  36043. d9 += h7 * r2;
  36044. d9 += h8 * r1;
  36045. d9 += h9 * r0;
  36046. c += (d9 >>> 13); d9 &= 0x1fff;
  36047. c = (((c << 2) + c)) | 0;
  36048. c = (c + d0) | 0;
  36049. d0 = c & 0x1fff;
  36050. c = (c >>> 13);
  36051. d1 += c;
  36052. h0 = d0;
  36053. h1 = d1;
  36054. h2 = d2;
  36055. h3 = d3;
  36056. h4 = d4;
  36057. h5 = d5;
  36058. h6 = d6;
  36059. h7 = d7;
  36060. h8 = d8;
  36061. h9 = d9;
  36062. mpos += 16;
  36063. bytes -= 16;
  36064. }
  36065. this.h[0] = h0;
  36066. this.h[1] = h1;
  36067. this.h[2] = h2;
  36068. this.h[3] = h3;
  36069. this.h[4] = h4;
  36070. this.h[5] = h5;
  36071. this.h[6] = h6;
  36072. this.h[7] = h7;
  36073. this.h[8] = h8;
  36074. this.h[9] = h9;
  36075. };
  36076. poly1305.prototype.finish = function(mac, macpos) {
  36077. var g = new Uint16Array(10);
  36078. var c, mask, f, i;
  36079. if (this.leftover) {
  36080. i = this.leftover;
  36081. this.buffer[i++] = 1;
  36082. for (; i < 16; i++) this.buffer[i] = 0;
  36083. this.fin = 1;
  36084. this.blocks(this.buffer, 0, 16);
  36085. }
  36086. c = this.h[1] >>> 13;
  36087. this.h[1] &= 0x1fff;
  36088. for (i = 2; i < 10; i++) {
  36089. this.h[i] += c;
  36090. c = this.h[i] >>> 13;
  36091. this.h[i] &= 0x1fff;
  36092. }
  36093. this.h[0] += (c * 5);
  36094. c = this.h[0] >>> 13;
  36095. this.h[0] &= 0x1fff;
  36096. this.h[1] += c;
  36097. c = this.h[1] >>> 13;
  36098. this.h[1] &= 0x1fff;
  36099. this.h[2] += c;
  36100. g[0] = this.h[0] + 5;
  36101. c = g[0] >>> 13;
  36102. g[0] &= 0x1fff;
  36103. for (i = 1; i < 10; i++) {
  36104. g[i] = this.h[i] + c;
  36105. c = g[i] >>> 13;
  36106. g[i] &= 0x1fff;
  36107. }
  36108. g[9] -= (1 << 13);
  36109. mask = (c ^ 1) - 1;
  36110. for (i = 0; i < 10; i++) g[i] &= mask;
  36111. mask = ~mask;
  36112. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  36113. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  36114. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  36115. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  36116. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  36117. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  36118. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  36119. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  36120. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  36121. f = this.h[0] + this.pad[0];
  36122. this.h[0] = f & 0xffff;
  36123. for (i = 1; i < 8; i++) {
  36124. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  36125. this.h[i] = f & 0xffff;
  36126. }
  36127. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  36128. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  36129. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  36130. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  36131. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  36132. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  36133. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  36134. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  36135. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  36136. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  36137. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  36138. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  36139. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  36140. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  36141. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  36142. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  36143. };
  36144. poly1305.prototype.update = function(m, mpos, bytes) {
  36145. var i, want;
  36146. if (this.leftover) {
  36147. want = (16 - this.leftover);
  36148. if (want > bytes)
  36149. want = bytes;
  36150. for (i = 0; i < want; i++)
  36151. this.buffer[this.leftover + i] = m[mpos+i];
  36152. bytes -= want;
  36153. mpos += want;
  36154. this.leftover += want;
  36155. if (this.leftover < 16)
  36156. return;
  36157. this.blocks(this.buffer, 0, 16);
  36158. this.leftover = 0;
  36159. }
  36160. if (bytes >= 16) {
  36161. want = bytes - (bytes % 16);
  36162. this.blocks(m, mpos, want);
  36163. mpos += want;
  36164. bytes -= want;
  36165. }
  36166. if (bytes) {
  36167. for (i = 0; i < bytes; i++)
  36168. this.buffer[this.leftover + i] = m[mpos+i];
  36169. this.leftover += bytes;
  36170. }
  36171. };
  36172. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  36173. var s = new poly1305(k);
  36174. s.update(m, mpos, n);
  36175. s.finish(out, outpos);
  36176. return 0;
  36177. }
  36178. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  36179. var x = new Uint8Array(16);
  36180. crypto_onetimeauth(x,0,m,mpos,n,k);
  36181. return crypto_verify_16(h,hpos,x,0);
  36182. }
  36183. function crypto_secretbox(c,m,d,n,k) {
  36184. var i;
  36185. if (d < 32) return -1;
  36186. crypto_stream_xor(c,0,m,0,d,n,k);
  36187. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  36188. for (i = 0; i < 16; i++) c[i] = 0;
  36189. return 0;
  36190. }
  36191. function crypto_secretbox_open(m,c,d,n,k) {
  36192. var i;
  36193. var x = new Uint8Array(32);
  36194. if (d < 32) return -1;
  36195. crypto_stream(x,0,32,n,k);
  36196. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  36197. crypto_stream_xor(m,0,c,0,d,n,k);
  36198. for (i = 0; i < 32; i++) m[i] = 0;
  36199. return 0;
  36200. }
  36201. function set25519(r, a) {
  36202. var i;
  36203. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  36204. }
  36205. function car25519(o) {
  36206. var i, v, c = 1;
  36207. for (i = 0; i < 16; i++) {
  36208. v = o[i] + c + 65535;
  36209. c = Math.floor(v / 65536);
  36210. o[i] = v - c * 65536;
  36211. }
  36212. o[0] += c-1 + 37 * (c-1);
  36213. }
  36214. function sel25519(p, q, b) {
  36215. var t, c = ~(b-1);
  36216. for (var i = 0; i < 16; i++) {
  36217. t = c & (p[i] ^ q[i]);
  36218. p[i] ^= t;
  36219. q[i] ^= t;
  36220. }
  36221. }
  36222. function pack25519(o, n) {
  36223. var i, j, b;
  36224. var m = gf(), t = gf();
  36225. for (i = 0; i < 16; i++) t[i] = n[i];
  36226. car25519(t);
  36227. car25519(t);
  36228. car25519(t);
  36229. for (j = 0; j < 2; j++) {
  36230. m[0] = t[0] - 0xffed;
  36231. for (i = 1; i < 15; i++) {
  36232. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  36233. m[i-1] &= 0xffff;
  36234. }
  36235. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  36236. b = (m[15]>>16) & 1;
  36237. m[14] &= 0xffff;
  36238. sel25519(t, m, 1-b);
  36239. }
  36240. for (i = 0; i < 16; i++) {
  36241. o[2*i] = t[i] & 0xff;
  36242. o[2*i+1] = t[i]>>8;
  36243. }
  36244. }
  36245. function neq25519(a, b) {
  36246. var c = new Uint8Array(32), d = new Uint8Array(32);
  36247. pack25519(c, a);
  36248. pack25519(d, b);
  36249. return crypto_verify_32(c, 0, d, 0);
  36250. }
  36251. function par25519(a) {
  36252. var d = new Uint8Array(32);
  36253. pack25519(d, a);
  36254. return d[0] & 1;
  36255. }
  36256. function unpack25519(o, n) {
  36257. var i;
  36258. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  36259. o[15] &= 0x7fff;
  36260. }
  36261. function A(o, a, b) {
  36262. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  36263. }
  36264. function Z(o, a, b) {
  36265. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  36266. }
  36267. function M(o, a, b) {
  36268. var v, c,
  36269. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  36270. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  36271. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  36272. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  36273. b0 = b[0],
  36274. b1 = b[1],
  36275. b2 = b[2],
  36276. b3 = b[3],
  36277. b4 = b[4],
  36278. b5 = b[5],
  36279. b6 = b[6],
  36280. b7 = b[7],
  36281. b8 = b[8],
  36282. b9 = b[9],
  36283. b10 = b[10],
  36284. b11 = b[11],
  36285. b12 = b[12],
  36286. b13 = b[13],
  36287. b14 = b[14],
  36288. b15 = b[15];
  36289. v = a[0];
  36290. t0 += v * b0;
  36291. t1 += v * b1;
  36292. t2 += v * b2;
  36293. t3 += v * b3;
  36294. t4 += v * b4;
  36295. t5 += v * b5;
  36296. t6 += v * b6;
  36297. t7 += v * b7;
  36298. t8 += v * b8;
  36299. t9 += v * b9;
  36300. t10 += v * b10;
  36301. t11 += v * b11;
  36302. t12 += v * b12;
  36303. t13 += v * b13;
  36304. t14 += v * b14;
  36305. t15 += v * b15;
  36306. v = a[1];
  36307. t1 += v * b0;
  36308. t2 += v * b1;
  36309. t3 += v * b2;
  36310. t4 += v * b3;
  36311. t5 += v * b4;
  36312. t6 += v * b5;
  36313. t7 += v * b6;
  36314. t8 += v * b7;
  36315. t9 += v * b8;
  36316. t10 += v * b9;
  36317. t11 += v * b10;
  36318. t12 += v * b11;
  36319. t13 += v * b12;
  36320. t14 += v * b13;
  36321. t15 += v * b14;
  36322. t16 += v * b15;
  36323. v = a[2];
  36324. t2 += v * b0;
  36325. t3 += v * b1;
  36326. t4 += v * b2;
  36327. t5 += v * b3;
  36328. t6 += v * b4;
  36329. t7 += v * b5;
  36330. t8 += v * b6;
  36331. t9 += v * b7;
  36332. t10 += v * b8;
  36333. t11 += v * b9;
  36334. t12 += v * b10;
  36335. t13 += v * b11;
  36336. t14 += v * b12;
  36337. t15 += v * b13;
  36338. t16 += v * b14;
  36339. t17 += v * b15;
  36340. v = a[3];
  36341. t3 += v * b0;
  36342. t4 += v * b1;
  36343. t5 += v * b2;
  36344. t6 += v * b3;
  36345. t7 += v * b4;
  36346. t8 += v * b5;
  36347. t9 += v * b6;
  36348. t10 += v * b7;
  36349. t11 += v * b8;
  36350. t12 += v * b9;
  36351. t13 += v * b10;
  36352. t14 += v * b11;
  36353. t15 += v * b12;
  36354. t16 += v * b13;
  36355. t17 += v * b14;
  36356. t18 += v * b15;
  36357. v = a[4];
  36358. t4 += v * b0;
  36359. t5 += v * b1;
  36360. t6 += v * b2;
  36361. t7 += v * b3;
  36362. t8 += v * b4;
  36363. t9 += v * b5;
  36364. t10 += v * b6;
  36365. t11 += v * b7;
  36366. t12 += v * b8;
  36367. t13 += v * b9;
  36368. t14 += v * b10;
  36369. t15 += v * b11;
  36370. t16 += v * b12;
  36371. t17 += v * b13;
  36372. t18 += v * b14;
  36373. t19 += v * b15;
  36374. v = a[5];
  36375. t5 += v * b0;
  36376. t6 += v * b1;
  36377. t7 += v * b2;
  36378. t8 += v * b3;
  36379. t9 += v * b4;
  36380. t10 += v * b5;
  36381. t11 += v * b6;
  36382. t12 += v * b7;
  36383. t13 += v * b8;
  36384. t14 += v * b9;
  36385. t15 += v * b10;
  36386. t16 += v * b11;
  36387. t17 += v * b12;
  36388. t18 += v * b13;
  36389. t19 += v * b14;
  36390. t20 += v * b15;
  36391. v = a[6];
  36392. t6 += v * b0;
  36393. t7 += v * b1;
  36394. t8 += v * b2;
  36395. t9 += v * b3;
  36396. t10 += v * b4;
  36397. t11 += v * b5;
  36398. t12 += v * b6;
  36399. t13 += v * b7;
  36400. t14 += v * b8;
  36401. t15 += v * b9;
  36402. t16 += v * b10;
  36403. t17 += v * b11;
  36404. t18 += v * b12;
  36405. t19 += v * b13;
  36406. t20 += v * b14;
  36407. t21 += v * b15;
  36408. v = a[7];
  36409. t7 += v * b0;
  36410. t8 += v * b1;
  36411. t9 += v * b2;
  36412. t10 += v * b3;
  36413. t11 += v * b4;
  36414. t12 += v * b5;
  36415. t13 += v * b6;
  36416. t14 += v * b7;
  36417. t15 += v * b8;
  36418. t16 += v * b9;
  36419. t17 += v * b10;
  36420. t18 += v * b11;
  36421. t19 += v * b12;
  36422. t20 += v * b13;
  36423. t21 += v * b14;
  36424. t22 += v * b15;
  36425. v = a[8];
  36426. t8 += v * b0;
  36427. t9 += v * b1;
  36428. t10 += v * b2;
  36429. t11 += v * b3;
  36430. t12 += v * b4;
  36431. t13 += v * b5;
  36432. t14 += v * b6;
  36433. t15 += v * b7;
  36434. t16 += v * b8;
  36435. t17 += v * b9;
  36436. t18 += v * b10;
  36437. t19 += v * b11;
  36438. t20 += v * b12;
  36439. t21 += v * b13;
  36440. t22 += v * b14;
  36441. t23 += v * b15;
  36442. v = a[9];
  36443. t9 += v * b0;
  36444. t10 += v * b1;
  36445. t11 += v * b2;
  36446. t12 += v * b3;
  36447. t13 += v * b4;
  36448. t14 += v * b5;
  36449. t15 += v * b6;
  36450. t16 += v * b7;
  36451. t17 += v * b8;
  36452. t18 += v * b9;
  36453. t19 += v * b10;
  36454. t20 += v * b11;
  36455. t21 += v * b12;
  36456. t22 += v * b13;
  36457. t23 += v * b14;
  36458. t24 += v * b15;
  36459. v = a[10];
  36460. t10 += v * b0;
  36461. t11 += v * b1;
  36462. t12 += v * b2;
  36463. t13 += v * b3;
  36464. t14 += v * b4;
  36465. t15 += v * b5;
  36466. t16 += v * b6;
  36467. t17 += v * b7;
  36468. t18 += v * b8;
  36469. t19 += v * b9;
  36470. t20 += v * b10;
  36471. t21 += v * b11;
  36472. t22 += v * b12;
  36473. t23 += v * b13;
  36474. t24 += v * b14;
  36475. t25 += v * b15;
  36476. v = a[11];
  36477. t11 += v * b0;
  36478. t12 += v * b1;
  36479. t13 += v * b2;
  36480. t14 += v * b3;
  36481. t15 += v * b4;
  36482. t16 += v * b5;
  36483. t17 += v * b6;
  36484. t18 += v * b7;
  36485. t19 += v * b8;
  36486. t20 += v * b9;
  36487. t21 += v * b10;
  36488. t22 += v * b11;
  36489. t23 += v * b12;
  36490. t24 += v * b13;
  36491. t25 += v * b14;
  36492. t26 += v * b15;
  36493. v = a[12];
  36494. t12 += v * b0;
  36495. t13 += v * b1;
  36496. t14 += v * b2;
  36497. t15 += v * b3;
  36498. t16 += v * b4;
  36499. t17 += v * b5;
  36500. t18 += v * b6;
  36501. t19 += v * b7;
  36502. t20 += v * b8;
  36503. t21 += v * b9;
  36504. t22 += v * b10;
  36505. t23 += v * b11;
  36506. t24 += v * b12;
  36507. t25 += v * b13;
  36508. t26 += v * b14;
  36509. t27 += v * b15;
  36510. v = a[13];
  36511. t13 += v * b0;
  36512. t14 += v * b1;
  36513. t15 += v * b2;
  36514. t16 += v * b3;
  36515. t17 += v * b4;
  36516. t18 += v * b5;
  36517. t19 += v * b6;
  36518. t20 += v * b7;
  36519. t21 += v * b8;
  36520. t22 += v * b9;
  36521. t23 += v * b10;
  36522. t24 += v * b11;
  36523. t25 += v * b12;
  36524. t26 += v * b13;
  36525. t27 += v * b14;
  36526. t28 += v * b15;
  36527. v = a[14];
  36528. t14 += v * b0;
  36529. t15 += v * b1;
  36530. t16 += v * b2;
  36531. t17 += v * b3;
  36532. t18 += v * b4;
  36533. t19 += v * b5;
  36534. t20 += v * b6;
  36535. t21 += v * b7;
  36536. t22 += v * b8;
  36537. t23 += v * b9;
  36538. t24 += v * b10;
  36539. t25 += v * b11;
  36540. t26 += v * b12;
  36541. t27 += v * b13;
  36542. t28 += v * b14;
  36543. t29 += v * b15;
  36544. v = a[15];
  36545. t15 += v * b0;
  36546. t16 += v * b1;
  36547. t17 += v * b2;
  36548. t18 += v * b3;
  36549. t19 += v * b4;
  36550. t20 += v * b5;
  36551. t21 += v * b6;
  36552. t22 += v * b7;
  36553. t23 += v * b8;
  36554. t24 += v * b9;
  36555. t25 += v * b10;
  36556. t26 += v * b11;
  36557. t27 += v * b12;
  36558. t28 += v * b13;
  36559. t29 += v * b14;
  36560. t30 += v * b15;
  36561. t0 += 38 * t16;
  36562. t1 += 38 * t17;
  36563. t2 += 38 * t18;
  36564. t3 += 38 * t19;
  36565. t4 += 38 * t20;
  36566. t5 += 38 * t21;
  36567. t6 += 38 * t22;
  36568. t7 += 38 * t23;
  36569. t8 += 38 * t24;
  36570. t9 += 38 * t25;
  36571. t10 += 38 * t26;
  36572. t11 += 38 * t27;
  36573. t12 += 38 * t28;
  36574. t13 += 38 * t29;
  36575. t14 += 38 * t30;
  36576. // t15 left as is
  36577. // first car
  36578. c = 1;
  36579. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36580. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36581. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36582. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36583. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36584. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36585. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36586. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36587. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36588. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36589. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36590. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36591. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36592. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36593. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36594. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36595. t0 += c-1 + 37 * (c-1);
  36596. // second car
  36597. c = 1;
  36598. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  36599. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  36600. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  36601. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  36602. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  36603. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  36604. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  36605. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  36606. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  36607. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  36608. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  36609. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  36610. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  36611. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  36612. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  36613. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  36614. t0 += c-1 + 37 * (c-1);
  36615. o[ 0] = t0;
  36616. o[ 1] = t1;
  36617. o[ 2] = t2;
  36618. o[ 3] = t3;
  36619. o[ 4] = t4;
  36620. o[ 5] = t5;
  36621. o[ 6] = t6;
  36622. o[ 7] = t7;
  36623. o[ 8] = t8;
  36624. o[ 9] = t9;
  36625. o[10] = t10;
  36626. o[11] = t11;
  36627. o[12] = t12;
  36628. o[13] = t13;
  36629. o[14] = t14;
  36630. o[15] = t15;
  36631. }
  36632. function S(o, a) {
  36633. M(o, a, a);
  36634. }
  36635. function inv25519(o, i) {
  36636. var c = gf();
  36637. var a;
  36638. for (a = 0; a < 16; a++) c[a] = i[a];
  36639. for (a = 253; a >= 0; a--) {
  36640. S(c, c);
  36641. if(a !== 2 && a !== 4) M(c, c, i);
  36642. }
  36643. for (a = 0; a < 16; a++) o[a] = c[a];
  36644. }
  36645. function pow2523(o, i) {
  36646. var c = gf();
  36647. var a;
  36648. for (a = 0; a < 16; a++) c[a] = i[a];
  36649. for (a = 250; a >= 0; a--) {
  36650. S(c, c);
  36651. if(a !== 1) M(c, c, i);
  36652. }
  36653. for (a = 0; a < 16; a++) o[a] = c[a];
  36654. }
  36655. function crypto_scalarmult(q, n, p) {
  36656. var z = new Uint8Array(32);
  36657. var x = new Float64Array(80), r, i;
  36658. var a = gf(), b = gf(), c = gf(),
  36659. d = gf(), e = gf(), f = gf();
  36660. for (i = 0; i < 31; i++) z[i] = n[i];
  36661. z[31]=(n[31]&127)|64;
  36662. z[0]&=248;
  36663. unpack25519(x,p);
  36664. for (i = 0; i < 16; i++) {
  36665. b[i]=x[i];
  36666. d[i]=a[i]=c[i]=0;
  36667. }
  36668. a[0]=d[0]=1;
  36669. for (i=254; i>=0; --i) {
  36670. r=(z[i>>>3]>>>(i&7))&1;
  36671. sel25519(a,b,r);
  36672. sel25519(c,d,r);
  36673. A(e,a,c);
  36674. Z(a,a,c);
  36675. A(c,b,d);
  36676. Z(b,b,d);
  36677. S(d,e);
  36678. S(f,a);
  36679. M(a,c,a);
  36680. M(c,b,e);
  36681. A(e,a,c);
  36682. Z(a,a,c);
  36683. S(b,a);
  36684. Z(c,d,f);
  36685. M(a,c,_121665);
  36686. A(a,a,d);
  36687. M(c,c,a);
  36688. M(a,d,f);
  36689. M(d,b,x);
  36690. S(b,e);
  36691. sel25519(a,b,r);
  36692. sel25519(c,d,r);
  36693. }
  36694. for (i = 0; i < 16; i++) {
  36695. x[i+16]=a[i];
  36696. x[i+32]=c[i];
  36697. x[i+48]=b[i];
  36698. x[i+64]=d[i];
  36699. }
  36700. var x32 = x.subarray(32);
  36701. var x16 = x.subarray(16);
  36702. inv25519(x32,x32);
  36703. M(x16,x16,x32);
  36704. pack25519(q,x16);
  36705. return 0;
  36706. }
  36707. function crypto_scalarmult_base(q, n) {
  36708. return crypto_scalarmult(q, n, _9);
  36709. }
  36710. function crypto_box_keypair(y, x) {
  36711. randombytes(x, 32);
  36712. return crypto_scalarmult_base(y, x);
  36713. }
  36714. function crypto_box_beforenm(k, y, x) {
  36715. var s = new Uint8Array(32);
  36716. crypto_scalarmult(s, x, y);
  36717. return crypto_core_hsalsa20(k, _0, s, sigma);
  36718. }
  36719. var crypto_box_afternm = crypto_secretbox;
  36720. var crypto_box_open_afternm = crypto_secretbox_open;
  36721. function crypto_box(c, m, d, n, y, x) {
  36722. var k = new Uint8Array(32);
  36723. crypto_box_beforenm(k, y, x);
  36724. return crypto_box_afternm(c, m, d, n, k);
  36725. }
  36726. function crypto_box_open(m, c, d, n, y, x) {
  36727. var k = new Uint8Array(32);
  36728. crypto_box_beforenm(k, y, x);
  36729. return crypto_box_open_afternm(m, c, d, n, k);
  36730. }
  36731. var K = [
  36732. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  36733. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  36734. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  36735. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  36736. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  36737. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  36738. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  36739. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  36740. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  36741. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  36742. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  36743. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  36744. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  36745. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  36746. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  36747. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  36748. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  36749. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  36750. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  36751. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  36752. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  36753. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  36754. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  36755. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  36756. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  36757. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  36758. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  36759. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  36760. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  36761. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  36762. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  36763. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  36764. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  36765. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  36766. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  36767. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  36768. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  36769. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  36770. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  36771. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  36772. ];
  36773. function crypto_hashblocks_hl(hh, hl, m, n) {
  36774. var wh = new Int32Array(16), wl = new Int32Array(16),
  36775. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  36776. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  36777. th, tl, i, j, h, l, a, b, c, d;
  36778. var ah0 = hh[0],
  36779. ah1 = hh[1],
  36780. ah2 = hh[2],
  36781. ah3 = hh[3],
  36782. ah4 = hh[4],
  36783. ah5 = hh[5],
  36784. ah6 = hh[6],
  36785. ah7 = hh[7],
  36786. al0 = hl[0],
  36787. al1 = hl[1],
  36788. al2 = hl[2],
  36789. al3 = hl[3],
  36790. al4 = hl[4],
  36791. al5 = hl[5],
  36792. al6 = hl[6],
  36793. al7 = hl[7];
  36794. var pos = 0;
  36795. while (n >= 128) {
  36796. for (i = 0; i < 16; i++) {
  36797. j = 8 * i + pos;
  36798. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  36799. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  36800. }
  36801. for (i = 0; i < 80; i++) {
  36802. bh0 = ah0;
  36803. bh1 = ah1;
  36804. bh2 = ah2;
  36805. bh3 = ah3;
  36806. bh4 = ah4;
  36807. bh5 = ah5;
  36808. bh6 = ah6;
  36809. bh7 = ah7;
  36810. bl0 = al0;
  36811. bl1 = al1;
  36812. bl2 = al2;
  36813. bl3 = al3;
  36814. bl4 = al4;
  36815. bl5 = al5;
  36816. bl6 = al6;
  36817. bl7 = al7;
  36818. // add
  36819. h = ah7;
  36820. l = al7;
  36821. a = l & 0xffff; b = l >>> 16;
  36822. c = h & 0xffff; d = h >>> 16;
  36823. // Sigma1
  36824. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  36825. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  36826. a += l & 0xffff; b += l >>> 16;
  36827. c += h & 0xffff; d += h >>> 16;
  36828. // Ch
  36829. h = (ah4 & ah5) ^ (~ah4 & ah6);
  36830. l = (al4 & al5) ^ (~al4 & al6);
  36831. a += l & 0xffff; b += l >>> 16;
  36832. c += h & 0xffff; d += h >>> 16;
  36833. // K
  36834. h = K[i*2];
  36835. l = K[i*2+1];
  36836. a += l & 0xffff; b += l >>> 16;
  36837. c += h & 0xffff; d += h >>> 16;
  36838. // w
  36839. h = wh[i%16];
  36840. l = wl[i%16];
  36841. a += l & 0xffff; b += l >>> 16;
  36842. c += h & 0xffff; d += h >>> 16;
  36843. b += a >>> 16;
  36844. c += b >>> 16;
  36845. d += c >>> 16;
  36846. th = c & 0xffff | d << 16;
  36847. tl = a & 0xffff | b << 16;
  36848. // add
  36849. h = th;
  36850. l = tl;
  36851. a = l & 0xffff; b = l >>> 16;
  36852. c = h & 0xffff; d = h >>> 16;
  36853. // Sigma0
  36854. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  36855. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  36856. a += l & 0xffff; b += l >>> 16;
  36857. c += h & 0xffff; d += h >>> 16;
  36858. // Maj
  36859. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  36860. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  36861. a += l & 0xffff; b += l >>> 16;
  36862. c += h & 0xffff; d += h >>> 16;
  36863. b += a >>> 16;
  36864. c += b >>> 16;
  36865. d += c >>> 16;
  36866. bh7 = (c & 0xffff) | (d << 16);
  36867. bl7 = (a & 0xffff) | (b << 16);
  36868. // add
  36869. h = bh3;
  36870. l = bl3;
  36871. a = l & 0xffff; b = l >>> 16;
  36872. c = h & 0xffff; d = h >>> 16;
  36873. h = th;
  36874. l = tl;
  36875. a += l & 0xffff; b += l >>> 16;
  36876. c += h & 0xffff; d += h >>> 16;
  36877. b += a >>> 16;
  36878. c += b >>> 16;
  36879. d += c >>> 16;
  36880. bh3 = (c & 0xffff) | (d << 16);
  36881. bl3 = (a & 0xffff) | (b << 16);
  36882. ah1 = bh0;
  36883. ah2 = bh1;
  36884. ah3 = bh2;
  36885. ah4 = bh3;
  36886. ah5 = bh4;
  36887. ah6 = bh5;
  36888. ah7 = bh6;
  36889. ah0 = bh7;
  36890. al1 = bl0;
  36891. al2 = bl1;
  36892. al3 = bl2;
  36893. al4 = bl3;
  36894. al5 = bl4;
  36895. al6 = bl5;
  36896. al7 = bl6;
  36897. al0 = bl7;
  36898. if (i%16 === 15) {
  36899. for (j = 0; j < 16; j++) {
  36900. // add
  36901. h = wh[j];
  36902. l = wl[j];
  36903. a = l & 0xffff; b = l >>> 16;
  36904. c = h & 0xffff; d = h >>> 16;
  36905. h = wh[(j+9)%16];
  36906. l = wl[(j+9)%16];
  36907. a += l & 0xffff; b += l >>> 16;
  36908. c += h & 0xffff; d += h >>> 16;
  36909. // sigma0
  36910. th = wh[(j+1)%16];
  36911. tl = wl[(j+1)%16];
  36912. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  36913. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  36914. a += l & 0xffff; b += l >>> 16;
  36915. c += h & 0xffff; d += h >>> 16;
  36916. // sigma1
  36917. th = wh[(j+14)%16];
  36918. tl = wl[(j+14)%16];
  36919. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  36920. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  36921. a += l & 0xffff; b += l >>> 16;
  36922. c += h & 0xffff; d += h >>> 16;
  36923. b += a >>> 16;
  36924. c += b >>> 16;
  36925. d += c >>> 16;
  36926. wh[j] = (c & 0xffff) | (d << 16);
  36927. wl[j] = (a & 0xffff) | (b << 16);
  36928. }
  36929. }
  36930. }
  36931. // add
  36932. h = ah0;
  36933. l = al0;
  36934. a = l & 0xffff; b = l >>> 16;
  36935. c = h & 0xffff; d = h >>> 16;
  36936. h = hh[0];
  36937. l = hl[0];
  36938. a += l & 0xffff; b += l >>> 16;
  36939. c += h & 0xffff; d += h >>> 16;
  36940. b += a >>> 16;
  36941. c += b >>> 16;
  36942. d += c >>> 16;
  36943. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  36944. hl[0] = al0 = (a & 0xffff) | (b << 16);
  36945. h = ah1;
  36946. l = al1;
  36947. a = l & 0xffff; b = l >>> 16;
  36948. c = h & 0xffff; d = h >>> 16;
  36949. h = hh[1];
  36950. l = hl[1];
  36951. a += l & 0xffff; b += l >>> 16;
  36952. c += h & 0xffff; d += h >>> 16;
  36953. b += a >>> 16;
  36954. c += b >>> 16;
  36955. d += c >>> 16;
  36956. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  36957. hl[1] = al1 = (a & 0xffff) | (b << 16);
  36958. h = ah2;
  36959. l = al2;
  36960. a = l & 0xffff; b = l >>> 16;
  36961. c = h & 0xffff; d = h >>> 16;
  36962. h = hh[2];
  36963. l = hl[2];
  36964. a += l & 0xffff; b += l >>> 16;
  36965. c += h & 0xffff; d += h >>> 16;
  36966. b += a >>> 16;
  36967. c += b >>> 16;
  36968. d += c >>> 16;
  36969. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  36970. hl[2] = al2 = (a & 0xffff) | (b << 16);
  36971. h = ah3;
  36972. l = al3;
  36973. a = l & 0xffff; b = l >>> 16;
  36974. c = h & 0xffff; d = h >>> 16;
  36975. h = hh[3];
  36976. l = hl[3];
  36977. a += l & 0xffff; b += l >>> 16;
  36978. c += h & 0xffff; d += h >>> 16;
  36979. b += a >>> 16;
  36980. c += b >>> 16;
  36981. d += c >>> 16;
  36982. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  36983. hl[3] = al3 = (a & 0xffff) | (b << 16);
  36984. h = ah4;
  36985. l = al4;
  36986. a = l & 0xffff; b = l >>> 16;
  36987. c = h & 0xffff; d = h >>> 16;
  36988. h = hh[4];
  36989. l = hl[4];
  36990. a += l & 0xffff; b += l >>> 16;
  36991. c += h & 0xffff; d += h >>> 16;
  36992. b += a >>> 16;
  36993. c += b >>> 16;
  36994. d += c >>> 16;
  36995. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  36996. hl[4] = al4 = (a & 0xffff) | (b << 16);
  36997. h = ah5;
  36998. l = al5;
  36999. a = l & 0xffff; b = l >>> 16;
  37000. c = h & 0xffff; d = h >>> 16;
  37001. h = hh[5];
  37002. l = hl[5];
  37003. a += l & 0xffff; b += l >>> 16;
  37004. c += h & 0xffff; d += h >>> 16;
  37005. b += a >>> 16;
  37006. c += b >>> 16;
  37007. d += c >>> 16;
  37008. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37009. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37010. h = ah6;
  37011. l = al6;
  37012. a = l & 0xffff; b = l >>> 16;
  37013. c = h & 0xffff; d = h >>> 16;
  37014. h = hh[6];
  37015. l = hl[6];
  37016. a += l & 0xffff; b += l >>> 16;
  37017. c += h & 0xffff; d += h >>> 16;
  37018. b += a >>> 16;
  37019. c += b >>> 16;
  37020. d += c >>> 16;
  37021. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37022. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37023. h = ah7;
  37024. l = al7;
  37025. a = l & 0xffff; b = l >>> 16;
  37026. c = h & 0xffff; d = h >>> 16;
  37027. h = hh[7];
  37028. l = hl[7];
  37029. a += l & 0xffff; b += l >>> 16;
  37030. c += h & 0xffff; d += h >>> 16;
  37031. b += a >>> 16;
  37032. c += b >>> 16;
  37033. d += c >>> 16;
  37034. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37035. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37036. pos += 128;
  37037. n -= 128;
  37038. }
  37039. return n;
  37040. }
  37041. function crypto_hash(out, m, n) {
  37042. var hh = new Int32Array(8),
  37043. hl = new Int32Array(8),
  37044. x = new Uint8Array(256),
  37045. i, b = n;
  37046. hh[0] = 0x6a09e667;
  37047. hh[1] = 0xbb67ae85;
  37048. hh[2] = 0x3c6ef372;
  37049. hh[3] = 0xa54ff53a;
  37050. hh[4] = 0x510e527f;
  37051. hh[5] = 0x9b05688c;
  37052. hh[6] = 0x1f83d9ab;
  37053. hh[7] = 0x5be0cd19;
  37054. hl[0] = 0xf3bcc908;
  37055. hl[1] = 0x84caa73b;
  37056. hl[2] = 0xfe94f82b;
  37057. hl[3] = 0x5f1d36f1;
  37058. hl[4] = 0xade682d1;
  37059. hl[5] = 0x2b3e6c1f;
  37060. hl[6] = 0xfb41bd6b;
  37061. hl[7] = 0x137e2179;
  37062. crypto_hashblocks_hl(hh, hl, m, n);
  37063. n %= 128;
  37064. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37065. x[n] = 128;
  37066. n = 256-128*(n<112?1:0);
  37067. x[n-9] = 0;
  37068. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  37069. crypto_hashblocks_hl(hh, hl, x, n);
  37070. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  37071. return 0;
  37072. }
  37073. function add(p, q) {
  37074. var a = gf(), b = gf(), c = gf(),
  37075. d = gf(), e = gf(), f = gf(),
  37076. g = gf(), h = gf(), t = gf();
  37077. Z(a, p[1], p[0]);
  37078. Z(t, q[1], q[0]);
  37079. M(a, a, t);
  37080. A(b, p[0], p[1]);
  37081. A(t, q[0], q[1]);
  37082. M(b, b, t);
  37083. M(c, p[3], q[3]);
  37084. M(c, c, D2);
  37085. M(d, p[2], q[2]);
  37086. A(d, d, d);
  37087. Z(e, b, a);
  37088. Z(f, d, c);
  37089. A(g, d, c);
  37090. A(h, b, a);
  37091. M(p[0], e, f);
  37092. M(p[1], h, g);
  37093. M(p[2], g, f);
  37094. M(p[3], e, h);
  37095. }
  37096. function cswap(p, q, b) {
  37097. var i;
  37098. for (i = 0; i < 4; i++) {
  37099. sel25519(p[i], q[i], b);
  37100. }
  37101. }
  37102. function pack(r, p) {
  37103. var tx = gf(), ty = gf(), zi = gf();
  37104. inv25519(zi, p[2]);
  37105. M(tx, p[0], zi);
  37106. M(ty, p[1], zi);
  37107. pack25519(r, ty);
  37108. r[31] ^= par25519(tx) << 7;
  37109. }
  37110. function scalarmult(p, q, s) {
  37111. var b, i;
  37112. set25519(p[0], gf0);
  37113. set25519(p[1], gf1);
  37114. set25519(p[2], gf1);
  37115. set25519(p[3], gf0);
  37116. for (i = 255; i >= 0; --i) {
  37117. b = (s[(i/8)|0] >> (i&7)) & 1;
  37118. cswap(p, q, b);
  37119. add(q, p);
  37120. add(p, p);
  37121. cswap(p, q, b);
  37122. }
  37123. }
  37124. function scalarbase(p, s) {
  37125. var q = [gf(), gf(), gf(), gf()];
  37126. set25519(q[0], X);
  37127. set25519(q[1], Y);
  37128. set25519(q[2], gf1);
  37129. M(q[3], X, Y);
  37130. scalarmult(p, q, s);
  37131. }
  37132. function crypto_sign_keypair(pk, sk, seeded) {
  37133. var d = new Uint8Array(64);
  37134. var p = [gf(), gf(), gf(), gf()];
  37135. var i;
  37136. if (!seeded) randombytes(sk, 32);
  37137. crypto_hash(d, sk, 32);
  37138. d[0] &= 248;
  37139. d[31] &= 127;
  37140. d[31] |= 64;
  37141. scalarbase(p, d);
  37142. pack(pk, p);
  37143. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  37144. return 0;
  37145. }
  37146. var L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);
  37147. function modL(r, x) {
  37148. var carry, i, j, k;
  37149. for (i = 63; i >= 32; --i) {
  37150. carry = 0;
  37151. for (j = i - 32, k = i - 12; j < k; ++j) {
  37152. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  37153. carry = (x[j] + 128) >> 8;
  37154. x[j] -= carry * 256;
  37155. }
  37156. x[j] += carry;
  37157. x[i] = 0;
  37158. }
  37159. carry = 0;
  37160. for (j = 0; j < 32; j++) {
  37161. x[j] += carry - (x[31] >> 4) * L[j];
  37162. carry = x[j] >> 8;
  37163. x[j] &= 255;
  37164. }
  37165. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  37166. for (i = 0; i < 32; i++) {
  37167. x[i+1] += x[i] >> 8;
  37168. r[i] = x[i] & 255;
  37169. }
  37170. }
  37171. function reduce(r) {
  37172. var x = new Float64Array(64), i;
  37173. for (i = 0; i < 64; i++) x[i] = r[i];
  37174. for (i = 0; i < 64; i++) r[i] = 0;
  37175. modL(r, x);
  37176. }
  37177. // Note: difference from C - smlen returned, not passed as argument.
  37178. function crypto_sign(sm, m, n, sk) {
  37179. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  37180. var i, j, x = new Float64Array(64);
  37181. var p = [gf(), gf(), gf(), gf()];
  37182. crypto_hash(d, sk, 32);
  37183. d[0] &= 248;
  37184. d[31] &= 127;
  37185. d[31] |= 64;
  37186. var smlen = n + 64;
  37187. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  37188. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  37189. crypto_hash(r, sm.subarray(32), n+32);
  37190. reduce(r);
  37191. scalarbase(p, r);
  37192. pack(sm, p);
  37193. for (i = 32; i < 64; i++) sm[i] = sk[i];
  37194. crypto_hash(h, sm, n + 64);
  37195. reduce(h);
  37196. for (i = 0; i < 64; i++) x[i] = 0;
  37197. for (i = 0; i < 32; i++) x[i] = r[i];
  37198. for (i = 0; i < 32; i++) {
  37199. for (j = 0; j < 32; j++) {
  37200. x[i+j] += h[i] * d[j];
  37201. }
  37202. }
  37203. modL(sm.subarray(32), x);
  37204. return smlen;
  37205. }
  37206. function unpackneg(r, p) {
  37207. var t = gf(), chk = gf(), num = gf(),
  37208. den = gf(), den2 = gf(), den4 = gf(),
  37209. den6 = gf();
  37210. set25519(r[2], gf1);
  37211. unpack25519(r[1], p);
  37212. S(num, r[1]);
  37213. M(den, num, D);
  37214. Z(num, num, r[2]);
  37215. A(den, r[2], den);
  37216. S(den2, den);
  37217. S(den4, den2);
  37218. M(den6, den4, den2);
  37219. M(t, den6, num);
  37220. M(t, t, den);
  37221. pow2523(t, t);
  37222. M(t, t, num);
  37223. M(t, t, den);
  37224. M(t, t, den);
  37225. M(r[0], t, den);
  37226. S(chk, r[0]);
  37227. M(chk, chk, den);
  37228. if (neq25519(chk, num)) M(r[0], r[0], I);
  37229. S(chk, r[0]);
  37230. M(chk, chk, den);
  37231. if (neq25519(chk, num)) return -1;
  37232. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  37233. M(r[3], r[0], r[1]);
  37234. return 0;
  37235. }
  37236. function crypto_sign_open(m, sm, n, pk) {
  37237. var i, mlen;
  37238. var t = new Uint8Array(32), h = new Uint8Array(64);
  37239. var p = [gf(), gf(), gf(), gf()],
  37240. q = [gf(), gf(), gf(), gf()];
  37241. mlen = -1;
  37242. if (n < 64) return -1;
  37243. if (unpackneg(q, pk)) return -1;
  37244. for (i = 0; i < n; i++) m[i] = sm[i];
  37245. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  37246. crypto_hash(h, m, n);
  37247. reduce(h);
  37248. scalarmult(p, q, h);
  37249. scalarbase(q, sm.subarray(32));
  37250. add(p, q);
  37251. pack(t, p);
  37252. n -= 64;
  37253. if (crypto_verify_32(sm, 0, t, 0)) {
  37254. for (i = 0; i < n; i++) m[i] = 0;
  37255. return -1;
  37256. }
  37257. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  37258. mlen = n;
  37259. return mlen;
  37260. }
  37261. var crypto_secretbox_KEYBYTES = 32,
  37262. crypto_secretbox_NONCEBYTES = 24,
  37263. crypto_secretbox_ZEROBYTES = 32,
  37264. crypto_secretbox_BOXZEROBYTES = 16,
  37265. crypto_scalarmult_BYTES = 32,
  37266. crypto_scalarmult_SCALARBYTES = 32,
  37267. crypto_box_PUBLICKEYBYTES = 32,
  37268. crypto_box_SECRETKEYBYTES = 32,
  37269. crypto_box_BEFORENMBYTES = 32,
  37270. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  37271. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  37272. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  37273. crypto_sign_BYTES = 64,
  37274. crypto_sign_PUBLICKEYBYTES = 32,
  37275. crypto_sign_SECRETKEYBYTES = 64,
  37276. crypto_sign_SEEDBYTES = 32,
  37277. crypto_hash_BYTES = 64;
  37278. nacl.lowlevel = {
  37279. crypto_core_hsalsa20: crypto_core_hsalsa20,
  37280. crypto_stream_xor: crypto_stream_xor,
  37281. crypto_stream: crypto_stream,
  37282. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  37283. crypto_stream_salsa20: crypto_stream_salsa20,
  37284. crypto_onetimeauth: crypto_onetimeauth,
  37285. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  37286. crypto_verify_16: crypto_verify_16,
  37287. crypto_verify_32: crypto_verify_32,
  37288. crypto_secretbox: crypto_secretbox,
  37289. crypto_secretbox_open: crypto_secretbox_open,
  37290. crypto_scalarmult: crypto_scalarmult,
  37291. crypto_scalarmult_base: crypto_scalarmult_base,
  37292. crypto_box_beforenm: crypto_box_beforenm,
  37293. crypto_box_afternm: crypto_box_afternm,
  37294. crypto_box: crypto_box,
  37295. crypto_box_open: crypto_box_open,
  37296. crypto_box_keypair: crypto_box_keypair,
  37297. crypto_hash: crypto_hash,
  37298. crypto_sign: crypto_sign,
  37299. crypto_sign_keypair: crypto_sign_keypair,
  37300. crypto_sign_open: crypto_sign_open,
  37301. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  37302. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  37303. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  37304. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  37305. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  37306. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  37307. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  37308. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  37309. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  37310. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  37311. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  37312. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  37313. crypto_sign_BYTES: crypto_sign_BYTES,
  37314. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  37315. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  37316. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  37317. crypto_hash_BYTES: crypto_hash_BYTES
  37318. };
  37319. /* High-level API */
  37320. function checkLengths(k, n) {
  37321. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  37322. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  37323. }
  37324. function checkBoxLengths(pk, sk) {
  37325. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  37326. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  37327. }
  37328. function checkArrayTypes() {
  37329. for (var i = 0; i < arguments.length; i++) {
  37330. if (!(arguments[i] instanceof Uint8Array))
  37331. throw new TypeError('unexpected type, use Uint8Array');
  37332. }
  37333. }
  37334. function cleanup(arr) {
  37335. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  37336. }
  37337. nacl.randomBytes = function(n) {
  37338. var b = new Uint8Array(n);
  37339. randombytes(b, n);
  37340. return b;
  37341. };
  37342. nacl.secretbox = function(msg, nonce, key) {
  37343. checkArrayTypes(msg, nonce, key);
  37344. checkLengths(key, nonce);
  37345. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  37346. var c = new Uint8Array(m.length);
  37347. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  37348. crypto_secretbox(c, m, m.length, nonce, key);
  37349. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  37350. };
  37351. nacl.secretbox.open = function(box, nonce, key) {
  37352. checkArrayTypes(box, nonce, key);
  37353. checkLengths(key, nonce);
  37354. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  37355. var m = new Uint8Array(c.length);
  37356. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  37357. if (c.length < 32) return null;
  37358. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  37359. return m.subarray(crypto_secretbox_ZEROBYTES);
  37360. };
  37361. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  37362. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  37363. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  37364. nacl.scalarMult = function(n, p) {
  37365. checkArrayTypes(n, p);
  37366. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37367. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  37368. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37369. crypto_scalarmult(q, n, p);
  37370. return q;
  37371. };
  37372. nacl.scalarMult.base = function(n) {
  37373. checkArrayTypes(n);
  37374. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  37375. var q = new Uint8Array(crypto_scalarmult_BYTES);
  37376. crypto_scalarmult_base(q, n);
  37377. return q;
  37378. };
  37379. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  37380. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  37381. nacl.box = function(msg, nonce, publicKey, secretKey) {
  37382. var k = nacl.box.before(publicKey, secretKey);
  37383. return nacl.secretbox(msg, nonce, k);
  37384. };
  37385. nacl.box.before = function(publicKey, secretKey) {
  37386. checkArrayTypes(publicKey, secretKey);
  37387. checkBoxLengths(publicKey, secretKey);
  37388. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  37389. crypto_box_beforenm(k, publicKey, secretKey);
  37390. return k;
  37391. };
  37392. nacl.box.after = nacl.secretbox;
  37393. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  37394. var k = nacl.box.before(publicKey, secretKey);
  37395. return nacl.secretbox.open(msg, nonce, k);
  37396. };
  37397. nacl.box.open.after = nacl.secretbox.open;
  37398. nacl.box.keyPair = function() {
  37399. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37400. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  37401. crypto_box_keypair(pk, sk);
  37402. return {publicKey: pk, secretKey: sk};
  37403. };
  37404. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  37405. checkArrayTypes(secretKey);
  37406. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  37407. throw new Error('bad secret key size');
  37408. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  37409. crypto_scalarmult_base(pk, secretKey);
  37410. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37411. };
  37412. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  37413. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  37414. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  37415. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  37416. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  37417. nacl.sign = function(msg, secretKey) {
  37418. checkArrayTypes(msg, secretKey);
  37419. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37420. throw new Error('bad secret key size');
  37421. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  37422. crypto_sign(signedMsg, msg, msg.length, secretKey);
  37423. return signedMsg;
  37424. };
  37425. nacl.sign.open = function(signedMsg, publicKey) {
  37426. checkArrayTypes(signedMsg, publicKey);
  37427. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37428. throw new Error('bad public key size');
  37429. var tmp = new Uint8Array(signedMsg.length);
  37430. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  37431. if (mlen < 0) return null;
  37432. var m = new Uint8Array(mlen);
  37433. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  37434. return m;
  37435. };
  37436. nacl.sign.detached = function(msg, secretKey) {
  37437. var signedMsg = nacl.sign(msg, secretKey);
  37438. var sig = new Uint8Array(crypto_sign_BYTES);
  37439. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  37440. return sig;
  37441. };
  37442. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  37443. checkArrayTypes(msg, sig, publicKey);
  37444. if (sig.length !== crypto_sign_BYTES)
  37445. throw new Error('bad signature size');
  37446. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  37447. throw new Error('bad public key size');
  37448. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  37449. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  37450. var i;
  37451. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  37452. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  37453. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  37454. };
  37455. nacl.sign.keyPair = function() {
  37456. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37457. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37458. crypto_sign_keypair(pk, sk);
  37459. return {publicKey: pk, secretKey: sk};
  37460. };
  37461. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  37462. checkArrayTypes(secretKey);
  37463. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  37464. throw new Error('bad secret key size');
  37465. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37466. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  37467. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  37468. };
  37469. nacl.sign.keyPair.fromSeed = function(seed) {
  37470. checkArrayTypes(seed);
  37471. if (seed.length !== crypto_sign_SEEDBYTES)
  37472. throw new Error('bad seed size');
  37473. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  37474. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  37475. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  37476. crypto_sign_keypair(pk, sk, true);
  37477. return {publicKey: pk, secretKey: sk};
  37478. };
  37479. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  37480. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  37481. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  37482. nacl.sign.signatureLength = crypto_sign_BYTES;
  37483. nacl.hash = function(msg) {
  37484. checkArrayTypes(msg);
  37485. var h = new Uint8Array(crypto_hash_BYTES);
  37486. crypto_hash(h, msg, msg.length);
  37487. return h;
  37488. };
  37489. nacl.hash.hashLength = crypto_hash_BYTES;
  37490. nacl.verify = function(x, y) {
  37491. checkArrayTypes(x, y);
  37492. // Zero length arguments are considered not equal.
  37493. if (x.length === 0 || y.length === 0) return false;
  37494. if (x.length !== y.length) return false;
  37495. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  37496. };
  37497. nacl.setPRNG = function(fn) {
  37498. randombytes = fn;
  37499. };
  37500. (function() {
  37501. // Initialize PRNG if environment provides CSPRNG.
  37502. // If not, methods calling randombytes will throw.
  37503. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  37504. if (crypto && crypto.getRandomValues) {
  37505. // Browsers.
  37506. var QUOTA = 65536;
  37507. nacl.setPRNG(function(x, n) {
  37508. var i, v = new Uint8Array(n);
  37509. for (i = 0; i < n; i += QUOTA) {
  37510. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  37511. }
  37512. for (i = 0; i < n; i++) x[i] = v[i];
  37513. cleanup(v);
  37514. });
  37515. } else if (true) {
  37516. // Node.js.
  37517. crypto = __webpack_require__(3);
  37518. if (crypto && crypto.randomBytes) {
  37519. nacl.setPRNG(function(x, n) {
  37520. var i, v = crypto.randomBytes(n);
  37521. for (i = 0; i < n; i++) x[i] = v[i];
  37522. cleanup(v);
  37523. });
  37524. }
  37525. }
  37526. })();
  37527. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  37528. /***/ }),
  37529. /* 1 */
  37530. /***/ (function(module, exports, __webpack_require__) {
  37531. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  37532. // Public domain.
  37533. (function(root, f) {
  37534. 'use strict';
  37535. if ( true && module.exports) module.exports = f();
  37536. else if (root.nacl) root.nacl.util = f();
  37537. else {
  37538. root.nacl = {};
  37539. root.nacl.util = f();
  37540. }
  37541. }(this, function() {
  37542. 'use strict';
  37543. var util = {};
  37544. function validateBase64(s) {
  37545. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  37546. throw new TypeError('invalid encoding');
  37547. }
  37548. }
  37549. util.decodeUTF8 = function(s) {
  37550. if (typeof s !== 'string') throw new TypeError('expected string');
  37551. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  37552. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37553. return b;
  37554. };
  37555. util.encodeUTF8 = function(arr) {
  37556. var i, s = [];
  37557. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  37558. return decodeURIComponent(escape(s.join('')));
  37559. };
  37560. if (typeof atob === 'undefined') {
  37561. // Node.js
  37562. if (typeof Buffer.from !== 'undefined') {
  37563. // Node v6 and later
  37564. util.encodeBase64 = function (arr) { // v6 and later
  37565. return Buffer.from(arr).toString('base64');
  37566. };
  37567. util.decodeBase64 = function (s) {
  37568. validateBase64(s);
  37569. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  37570. };
  37571. } else {
  37572. // Node earlier than v6
  37573. util.encodeBase64 = function (arr) { // v6 and later
  37574. return (new Buffer(arr)).toString('base64');
  37575. };
  37576. util.decodeBase64 = function(s) {
  37577. validateBase64(s);
  37578. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  37579. };
  37580. }
  37581. } else {
  37582. // Browsers
  37583. util.encodeBase64 = function(arr) {
  37584. var i, s = [], len = arr.length;
  37585. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  37586. return btoa(s.join(''));
  37587. };
  37588. util.decodeBase64 = function(s) {
  37589. validateBase64(s);
  37590. var i, d = atob(s), b = new Uint8Array(d.length);
  37591. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  37592. return b;
  37593. };
  37594. }
  37595. return util;
  37596. }));
  37597. /***/ }),
  37598. /* 2 */
  37599. /***/ (function(module, exports, __webpack_require__) {
  37600. // required so we don't have to do require('pusher').default etc.
  37601. module.exports = __webpack_require__(4).default;
  37602. /***/ }),
  37603. /* 3 */
  37604. /***/ (function(module, exports) {
  37605. /* (ignored) */
  37606. /***/ }),
  37607. /* 4 */
  37608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37609. "use strict";
  37610. __webpack_require__.r(__webpack_exports__);
  37611. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  37612. var ScriptReceiverFactory = (function () {
  37613. function ScriptReceiverFactory(prefix, name) {
  37614. this.lastId = 0;
  37615. this.prefix = prefix;
  37616. this.name = name;
  37617. }
  37618. ScriptReceiverFactory.prototype.create = function (callback) {
  37619. this.lastId++;
  37620. var number = this.lastId;
  37621. var id = this.prefix + number;
  37622. var name = this.name + "[" + number + "]";
  37623. var called = false;
  37624. var callbackWrapper = function () {
  37625. if (!called) {
  37626. callback.apply(null, arguments);
  37627. called = true;
  37628. }
  37629. };
  37630. this[number] = callbackWrapper;
  37631. return { number: number, id: id, name: name, callback: callbackWrapper };
  37632. };
  37633. ScriptReceiverFactory.prototype.remove = function (receiver) {
  37634. delete this[receiver.number];
  37635. };
  37636. return ScriptReceiverFactory;
  37637. }());
  37638. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  37639. // CONCATENATED MODULE: ./src/core/defaults.ts
  37640. var Defaults = {
  37641. VERSION: "5.0.3",
  37642. PROTOCOL: 7,
  37643. host: 'ws.pusherapp.com',
  37644. ws_port: 80,
  37645. wss_port: 443,
  37646. ws_path: '',
  37647. sockjs_host: 'sockjs.pusher.com',
  37648. sockjs_http_port: 80,
  37649. sockjs_https_port: 443,
  37650. sockjs_path: '/pusher',
  37651. stats_host: 'stats.pusher.com',
  37652. channel_auth_endpoint: '/pusher/auth',
  37653. channel_auth_transport: 'ajax',
  37654. activity_timeout: 120000,
  37655. pong_timeout: 30000,
  37656. unavailable_timeout: 10000,
  37657. cdn_http: "http://js.pusher.com",
  37658. cdn_https: "https://js.pusher.com",
  37659. dependency_suffix: ""
  37660. };
  37661. /* harmony default export */ var defaults = (Defaults);
  37662. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  37663. var dependency_loader_DependencyLoader = (function () {
  37664. function DependencyLoader(options) {
  37665. this.options = options;
  37666. this.receivers = options.receivers || ScriptReceivers;
  37667. this.loading = {};
  37668. }
  37669. DependencyLoader.prototype.load = function (name, options, callback) {
  37670. var self = this;
  37671. if (self.loading[name] && self.loading[name].length > 0) {
  37672. self.loading[name].push(callback);
  37673. }
  37674. else {
  37675. self.loading[name] = [callback];
  37676. var request = runtime.createScriptRequest(self.getPath(name, options));
  37677. var receiver = self.receivers.create(function (error) {
  37678. self.receivers.remove(receiver);
  37679. if (self.loading[name]) {
  37680. var callbacks = self.loading[name];
  37681. delete self.loading[name];
  37682. var successCallback = function (wasSuccessful) {
  37683. if (!wasSuccessful) {
  37684. request.cleanup();
  37685. }
  37686. };
  37687. for (var i = 0; i < callbacks.length; i++) {
  37688. callbacks[i](error, successCallback);
  37689. }
  37690. }
  37691. });
  37692. request.send(receiver);
  37693. }
  37694. };
  37695. DependencyLoader.prototype.getRoot = function (options) {
  37696. var cdn;
  37697. var protocol = runtime.getDocument().location.protocol;
  37698. if ((options && options.useTLS) || protocol === "https:") {
  37699. cdn = this.options.cdn_https;
  37700. }
  37701. else {
  37702. cdn = this.options.cdn_http;
  37703. }
  37704. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  37705. };
  37706. DependencyLoader.prototype.getPath = function (name, options) {
  37707. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  37708. };
  37709. ;
  37710. return DependencyLoader;
  37711. }());
  37712. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  37713. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  37714. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  37715. var Dependencies = new dependency_loader({
  37716. cdn_http: defaults.cdn_http,
  37717. cdn_https: defaults.cdn_https,
  37718. version: defaults.VERSION,
  37719. suffix: defaults.dependency_suffix,
  37720. receivers: DependenciesReceivers
  37721. });
  37722. // CONCATENATED MODULE: ./src/core/base64.ts
  37723. function encode(s) {
  37724. return btoa(utob(s));
  37725. }
  37726. var fromCharCode = String.fromCharCode;
  37727. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  37728. var b64tab = {};
  37729. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  37730. b64tab[b64chars.charAt(base64_i)] = base64_i;
  37731. }
  37732. var cb_utob = function (c) {
  37733. var cc = c.charCodeAt(0);
  37734. return cc < 0x80
  37735. ? c
  37736. : cc < 0x800
  37737. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  37738. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  37739. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  37740. fromCharCode(0x80 | (cc & 0x3f));
  37741. };
  37742. var utob = function (u) {
  37743. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  37744. };
  37745. var cb_encode = function (ccc) {
  37746. var padlen = [0, 2, 1][ccc.length % 3];
  37747. var ord = (ccc.charCodeAt(0) << 16) |
  37748. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  37749. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  37750. var chars = [
  37751. b64chars.charAt(ord >>> 18),
  37752. b64chars.charAt((ord >>> 12) & 63),
  37753. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  37754. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  37755. ];
  37756. return chars.join('');
  37757. };
  37758. var btoa = window.btoa ||
  37759. function (b) {
  37760. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  37761. };
  37762. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  37763. var Timer = (function () {
  37764. function Timer(set, clear, delay, callback) {
  37765. var _this = this;
  37766. this.clear = clear;
  37767. this.timer = set(function () {
  37768. if (_this.timer) {
  37769. _this.timer = callback(_this.timer);
  37770. }
  37771. }, delay);
  37772. }
  37773. Timer.prototype.isRunning = function () {
  37774. return this.timer !== null;
  37775. };
  37776. Timer.prototype.ensureAborted = function () {
  37777. if (this.timer) {
  37778. this.clear(this.timer);
  37779. this.timer = null;
  37780. }
  37781. };
  37782. return Timer;
  37783. }());
  37784. /* harmony default export */ var abstract_timer = (Timer);
  37785. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  37786. var __extends = (undefined && undefined.__extends) || (function () {
  37787. var extendStatics = function (d, b) {
  37788. extendStatics = Object.setPrototypeOf ||
  37789. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  37790. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  37791. return extendStatics(d, b);
  37792. };
  37793. return function (d, b) {
  37794. extendStatics(d, b);
  37795. function __() { this.constructor = d; }
  37796. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  37797. };
  37798. })();
  37799. function timers_clearTimeout(timer) {
  37800. window.clearTimeout(timer);
  37801. }
  37802. function timers_clearInterval(timer) {
  37803. window.clearInterval(timer);
  37804. }
  37805. var OneOffTimer = (function (_super) {
  37806. __extends(OneOffTimer, _super);
  37807. function OneOffTimer(delay, callback) {
  37808. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  37809. callback();
  37810. return null;
  37811. }) || this;
  37812. }
  37813. return OneOffTimer;
  37814. }(abstract_timer));
  37815. var PeriodicTimer = (function (_super) {
  37816. __extends(PeriodicTimer, _super);
  37817. function PeriodicTimer(delay, callback) {
  37818. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  37819. callback();
  37820. return timer;
  37821. }) || this;
  37822. }
  37823. return PeriodicTimer;
  37824. }(abstract_timer));
  37825. // CONCATENATED MODULE: ./src/core/util.ts
  37826. var Util = {
  37827. now: function () {
  37828. if (Date.now) {
  37829. return Date.now();
  37830. }
  37831. else {
  37832. return new Date().valueOf();
  37833. }
  37834. },
  37835. defer: function (callback) {
  37836. return new OneOffTimer(0, callback);
  37837. },
  37838. method: function (name) {
  37839. var args = [];
  37840. for (var _i = 1; _i < arguments.length; _i++) {
  37841. args[_i - 1] = arguments[_i];
  37842. }
  37843. var boundArguments = Array.prototype.slice.call(arguments, 1);
  37844. return function (object) {
  37845. return object[name].apply(object, boundArguments.concat(arguments));
  37846. };
  37847. }
  37848. };
  37849. /* harmony default export */ var util = (Util);
  37850. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  37851. function extend(target) {
  37852. var sources = [];
  37853. for (var _i = 1; _i < arguments.length; _i++) {
  37854. sources[_i - 1] = arguments[_i];
  37855. }
  37856. for (var i = 0; i < sources.length; i++) {
  37857. var extensions = sources[i];
  37858. for (var property in extensions) {
  37859. if (extensions[property] && extensions[property].constructor &&
  37860. extensions[property].constructor === Object) {
  37861. target[property] = extend(target[property] || {}, extensions[property]);
  37862. }
  37863. else {
  37864. target[property] = extensions[property];
  37865. }
  37866. }
  37867. }
  37868. return target;
  37869. }
  37870. function stringify() {
  37871. var m = ["Pusher"];
  37872. for (var i = 0; i < arguments.length; i++) {
  37873. if (typeof arguments[i] === "string") {
  37874. m.push(arguments[i]);
  37875. }
  37876. else {
  37877. m.push(safeJSONStringify(arguments[i]));
  37878. }
  37879. }
  37880. return m.join(" : ");
  37881. }
  37882. function arrayIndexOf(array, item) {
  37883. var nativeIndexOf = Array.prototype.indexOf;
  37884. if (array === null) {
  37885. return -1;
  37886. }
  37887. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  37888. return array.indexOf(item);
  37889. }
  37890. for (var i = 0, l = array.length; i < l; i++) {
  37891. if (array[i] === item) {
  37892. return i;
  37893. }
  37894. }
  37895. return -1;
  37896. }
  37897. function objectApply(object, f) {
  37898. for (var key in object) {
  37899. if (Object.prototype.hasOwnProperty.call(object, key)) {
  37900. f(object[key], key, object);
  37901. }
  37902. }
  37903. }
  37904. function keys(object) {
  37905. var keys = [];
  37906. objectApply(object, function (_, key) {
  37907. keys.push(key);
  37908. });
  37909. return keys;
  37910. }
  37911. function values(object) {
  37912. var values = [];
  37913. objectApply(object, function (value) {
  37914. values.push(value);
  37915. });
  37916. return values;
  37917. }
  37918. function apply(array, f, context) {
  37919. for (var i = 0; i < array.length; i++) {
  37920. f.call(context || window, array[i], i, array);
  37921. }
  37922. }
  37923. function map(array, f) {
  37924. var result = [];
  37925. for (var i = 0; i < array.length; i++) {
  37926. result.push(f(array[i], i, array, result));
  37927. }
  37928. return result;
  37929. }
  37930. function mapObject(object, f) {
  37931. var result = {};
  37932. objectApply(object, function (value, key) {
  37933. result[key] = f(value);
  37934. });
  37935. return result;
  37936. }
  37937. function filter(array, test) {
  37938. test = test || function (value) { return !!value; };
  37939. var result = [];
  37940. for (var i = 0; i < array.length; i++) {
  37941. if (test(array[i], i, array, result)) {
  37942. result.push(array[i]);
  37943. }
  37944. }
  37945. return result;
  37946. }
  37947. function filterObject(object, test) {
  37948. var result = {};
  37949. objectApply(object, function (value, key) {
  37950. if ((test && test(value, key, object, result)) || Boolean(value)) {
  37951. result[key] = value;
  37952. }
  37953. });
  37954. return result;
  37955. }
  37956. function flatten(object) {
  37957. var result = [];
  37958. objectApply(object, function (value, key) {
  37959. result.push([key, value]);
  37960. });
  37961. return result;
  37962. }
  37963. function any(array, test) {
  37964. for (var i = 0; i < array.length; i++) {
  37965. if (test(array[i], i, array)) {
  37966. return true;
  37967. }
  37968. }
  37969. return false;
  37970. }
  37971. function collections_all(array, test) {
  37972. for (var i = 0; i < array.length; i++) {
  37973. if (!test(array[i], i, array)) {
  37974. return false;
  37975. }
  37976. }
  37977. return true;
  37978. }
  37979. function encodeParamsObject(data) {
  37980. return mapObject(data, function (value) {
  37981. if (typeof value === "object") {
  37982. value = safeJSONStringify(value);
  37983. }
  37984. return encodeURIComponent(encode(value.toString()));
  37985. });
  37986. }
  37987. function buildQueryString(data) {
  37988. var params = filterObject(data, function (value) {
  37989. return value !== undefined;
  37990. });
  37991. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  37992. return query;
  37993. }
  37994. function decycleObject(object) {
  37995. var objects = [], paths = [];
  37996. return (function derez(value, path) {
  37997. var i, name, nu;
  37998. switch (typeof value) {
  37999. case 'object':
  38000. if (!value) {
  38001. return null;
  38002. }
  38003. for (i = 0; i < objects.length; i += 1) {
  38004. if (objects[i] === value) {
  38005. return { $ref: paths[i] };
  38006. }
  38007. }
  38008. objects.push(value);
  38009. paths.push(path);
  38010. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38011. nu = [];
  38012. for (i = 0; i < value.length; i += 1) {
  38013. nu[i] = derez(value[i], path + '[' + i + ']');
  38014. }
  38015. }
  38016. else {
  38017. nu = {};
  38018. for (name in value) {
  38019. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38020. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38021. }
  38022. }
  38023. }
  38024. return nu;
  38025. case 'number':
  38026. case 'string':
  38027. case 'boolean':
  38028. return value;
  38029. }
  38030. }(object, '$'));
  38031. }
  38032. function safeJSONStringify(source) {
  38033. try {
  38034. return JSON.stringify(source);
  38035. }
  38036. catch (e) {
  38037. return JSON.stringify(decycleObject(source));
  38038. }
  38039. }
  38040. // CONCATENATED MODULE: ./src/core/logger.ts
  38041. var logger_Logger = (function () {
  38042. function Logger() {
  38043. this.globalLog = function (message) {
  38044. if (window.console && window.console.log) {
  38045. window.console.log(message);
  38046. }
  38047. };
  38048. }
  38049. Logger.prototype.debug = function () {
  38050. var args = [];
  38051. for (var _i = 0; _i < arguments.length; _i++) {
  38052. args[_i] = arguments[_i];
  38053. }
  38054. this.log(this.globalLog, args);
  38055. };
  38056. Logger.prototype.warn = function () {
  38057. var args = [];
  38058. for (var _i = 0; _i < arguments.length; _i++) {
  38059. args[_i] = arguments[_i];
  38060. }
  38061. this.log(this.globalLogWarn, args);
  38062. };
  38063. Logger.prototype.error = function () {
  38064. var args = [];
  38065. for (var _i = 0; _i < arguments.length; _i++) {
  38066. args[_i] = arguments[_i];
  38067. }
  38068. this.log(this.globalLogError, args);
  38069. };
  38070. Logger.prototype.globalLogWarn = function (message) {
  38071. if (window.console && window.console.warn) {
  38072. window.console.warn(message);
  38073. }
  38074. else {
  38075. this.globalLog(message);
  38076. }
  38077. };
  38078. Logger.prototype.globalLogError = function (message) {
  38079. if (window.console && window.console.error) {
  38080. window.console.error(message);
  38081. }
  38082. else {
  38083. this.globalLogWarn(message);
  38084. }
  38085. };
  38086. Logger.prototype.log = function (defaultLoggingFunction) {
  38087. var args = [];
  38088. for (var _i = 1; _i < arguments.length; _i++) {
  38089. args[_i - 1] = arguments[_i];
  38090. }
  38091. var message = stringify.apply(this, arguments);
  38092. if (core_pusher.log) {
  38093. core_pusher.log(message);
  38094. }
  38095. else if (core_pusher.logToConsole) {
  38096. var log = defaultLoggingFunction.bind(this);
  38097. log(message);
  38098. }
  38099. };
  38100. return Logger;
  38101. }());
  38102. /* harmony default export */ var logger = (new logger_Logger());
  38103. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  38104. var urlStore = {
  38105. baseUrl: "https://pusher.com",
  38106. urls: {
  38107. authenticationEndpoint: {
  38108. path: "/docs/authenticating_users",
  38109. },
  38110. javascriptQuickStart: {
  38111. path: "/docs/javascript_quick_start"
  38112. },
  38113. triggeringClientEvents: {
  38114. path: "/docs/client_api_guide/client_events#trigger-events"
  38115. }
  38116. }
  38117. };
  38118. var buildLogSuffix = function (key) {
  38119. var urlPrefix = "See:";
  38120. var urlObj = urlStore.urls[key];
  38121. if (!urlObj)
  38122. return "";
  38123. var url;
  38124. if (urlObj.fullUrl) {
  38125. url = urlObj.fullUrl;
  38126. }
  38127. else if (urlObj.path) {
  38128. url = urlStore.baseUrl + urlObj.path;
  38129. }
  38130. if (!url)
  38131. return "";
  38132. return urlPrefix + " " + url;
  38133. };
  38134. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  38135. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  38136. var ajax = function (context, socketId, callback) {
  38137. var self = this, xhr;
  38138. xhr = runtime.createXHR();
  38139. xhr.open("POST", self.options.authEndpoint, true);
  38140. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  38141. for (var headerName in this.authOptions.headers) {
  38142. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  38143. }
  38144. xhr.onreadystatechange = function () {
  38145. if (xhr.readyState === 4) {
  38146. if (xhr.status === 200) {
  38147. var data, parsed = false;
  38148. try {
  38149. data = JSON.parse(xhr.responseText);
  38150. parsed = true;
  38151. }
  38152. catch (e) {
  38153. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  38154. }
  38155. if (parsed) {
  38156. callback(false, data);
  38157. }
  38158. }
  38159. else {
  38160. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  38161. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  38162. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  38163. ("Clients must be authenticated to join private or presence channels. " + suffix));
  38164. callback(true, xhr.status);
  38165. }
  38166. }
  38167. };
  38168. xhr.send(this.composeQuery(socketId));
  38169. return xhr;
  38170. };
  38171. /* harmony default export */ var xhr_auth = (ajax);
  38172. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  38173. var jsonp = function (context, socketId, callback) {
  38174. if (this.authOptions.headers !== undefined) {
  38175. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  38176. }
  38177. var callbackName = context.nextAuthCallbackID.toString();
  38178. context.nextAuthCallbackID++;
  38179. var document = context.getDocument();
  38180. var script = document.createElement("script");
  38181. context.auth_callbacks[callbackName] = function (data) {
  38182. callback(false, data);
  38183. };
  38184. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  38185. script.src = this.options.authEndpoint +
  38186. '?callback=' +
  38187. encodeURIComponent(callback_name) +
  38188. '&' +
  38189. this.composeQuery(socketId);
  38190. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  38191. head.insertBefore(script, head.firstChild);
  38192. };
  38193. /* harmony default export */ var jsonp_auth = (jsonp);
  38194. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  38195. var ScriptRequest = (function () {
  38196. function ScriptRequest(src) {
  38197. this.src = src;
  38198. }
  38199. ScriptRequest.prototype.send = function (receiver) {
  38200. var self = this;
  38201. var errorString = "Error loading " + self.src;
  38202. self.script = document.createElement("script");
  38203. self.script.id = receiver.id;
  38204. self.script.src = self.src;
  38205. self.script.type = "text/javascript";
  38206. self.script.charset = "UTF-8";
  38207. if (self.script.addEventListener) {
  38208. self.script.onerror = function () {
  38209. receiver.callback(errorString);
  38210. };
  38211. self.script.onload = function () {
  38212. receiver.callback(null);
  38213. };
  38214. }
  38215. else {
  38216. self.script.onreadystatechange = function () {
  38217. if (self.script.readyState === 'loaded' ||
  38218. self.script.readyState === 'complete') {
  38219. receiver.callback(null);
  38220. }
  38221. };
  38222. }
  38223. if (self.script.async === undefined && document.attachEvent &&
  38224. /opera/i.test(navigator.userAgent)) {
  38225. self.errorScript = document.createElement("script");
  38226. self.errorScript.id = receiver.id + "_error";
  38227. self.errorScript.text = receiver.name + "('" + errorString + "');";
  38228. self.script.async = self.errorScript.async = false;
  38229. }
  38230. else {
  38231. self.script.async = true;
  38232. }
  38233. var head = document.getElementsByTagName('head')[0];
  38234. head.insertBefore(self.script, head.firstChild);
  38235. if (self.errorScript) {
  38236. head.insertBefore(self.errorScript, self.script.nextSibling);
  38237. }
  38238. };
  38239. ScriptRequest.prototype.cleanup = function () {
  38240. if (this.script) {
  38241. this.script.onload = this.script.onerror = null;
  38242. this.script.onreadystatechange = null;
  38243. }
  38244. if (this.script && this.script.parentNode) {
  38245. this.script.parentNode.removeChild(this.script);
  38246. }
  38247. if (this.errorScript && this.errorScript.parentNode) {
  38248. this.errorScript.parentNode.removeChild(this.errorScript);
  38249. }
  38250. this.script = null;
  38251. this.errorScript = null;
  38252. };
  38253. return ScriptRequest;
  38254. }());
  38255. /* harmony default export */ var script_request = (ScriptRequest);
  38256. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  38257. var jsonp_request_JSONPRequest = (function () {
  38258. function JSONPRequest(url, data) {
  38259. this.url = url;
  38260. this.data = data;
  38261. }
  38262. JSONPRequest.prototype.send = function (receiver) {
  38263. if (this.request) {
  38264. return;
  38265. }
  38266. var query = buildQueryString(this.data);
  38267. var url = this.url + "/" + receiver.number + "?" + query;
  38268. this.request = runtime.createScriptRequest(url);
  38269. this.request.send(receiver);
  38270. };
  38271. JSONPRequest.prototype.cleanup = function () {
  38272. if (this.request) {
  38273. this.request.cleanup();
  38274. }
  38275. };
  38276. return JSONPRequest;
  38277. }());
  38278. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  38279. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  38280. var getAgent = function (sender, useTLS) {
  38281. return function (data, callback) {
  38282. var scheme = "http" + (useTLS ? "s" : "") + "://";
  38283. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  38284. var request = runtime.createJSONPRequest(url, data);
  38285. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  38286. ScriptReceivers.remove(receiver);
  38287. request.cleanup();
  38288. if (result && result.host) {
  38289. sender.host = result.host;
  38290. }
  38291. if (callback) {
  38292. callback(error, result);
  38293. }
  38294. });
  38295. request.send(receiver);
  38296. };
  38297. };
  38298. var jsonp_timeline_jsonp = {
  38299. name: 'jsonp',
  38300. getAgent: getAgent
  38301. };
  38302. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  38303. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  38304. function getGenericURL(baseScheme, params, path) {
  38305. var scheme = baseScheme + (params.useTLS ? "s" : "");
  38306. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  38307. return scheme + "://" + host + path;
  38308. }
  38309. function getGenericPath(key, queryString) {
  38310. var path = "/app/" + key;
  38311. var query = "?protocol=" + defaults.PROTOCOL +
  38312. "&client=js" +
  38313. "&version=" + defaults.VERSION +
  38314. (queryString ? ("&" + queryString) : "");
  38315. return path + query;
  38316. }
  38317. var ws = {
  38318. getInitial: function (key, params) {
  38319. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  38320. return getGenericURL("ws", params, path);
  38321. }
  38322. };
  38323. var http = {
  38324. getInitial: function (key, params) {
  38325. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  38326. return getGenericURL("http", params, path);
  38327. }
  38328. };
  38329. var sockjs = {
  38330. getInitial: function (key, params) {
  38331. return getGenericURL("http", params, params.httpPath || "/pusher");
  38332. },
  38333. getPath: function (key, params) {
  38334. return getGenericPath(key);
  38335. }
  38336. };
  38337. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  38338. var callback_registry_CallbackRegistry = (function () {
  38339. function CallbackRegistry() {
  38340. this._callbacks = {};
  38341. }
  38342. CallbackRegistry.prototype.get = function (name) {
  38343. return this._callbacks[prefix(name)];
  38344. };
  38345. CallbackRegistry.prototype.add = function (name, callback, context) {
  38346. var prefixedEventName = prefix(name);
  38347. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  38348. this._callbacks[prefixedEventName].push({
  38349. fn: callback,
  38350. context: context
  38351. });
  38352. };
  38353. CallbackRegistry.prototype.remove = function (name, callback, context) {
  38354. if (!name && !callback && !context) {
  38355. this._callbacks = {};
  38356. return;
  38357. }
  38358. var names = name ? [prefix(name)] : keys(this._callbacks);
  38359. if (callback || context) {
  38360. this.removeCallback(names, callback, context);
  38361. }
  38362. else {
  38363. this.removeAllCallbacks(names);
  38364. }
  38365. };
  38366. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  38367. apply(names, function (name) {
  38368. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  38369. return (callback && callback !== binding.fn) ||
  38370. (context && context !== binding.context);
  38371. });
  38372. if (this._callbacks[name].length === 0) {
  38373. delete this._callbacks[name];
  38374. }
  38375. }, this);
  38376. };
  38377. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  38378. apply(names, function (name) {
  38379. delete this._callbacks[name];
  38380. }, this);
  38381. };
  38382. return CallbackRegistry;
  38383. }());
  38384. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  38385. function prefix(name) {
  38386. return "_" + name;
  38387. }
  38388. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  38389. var dispatcher_Dispatcher = (function () {
  38390. function Dispatcher(failThrough) {
  38391. this.callbacks = new callback_registry();
  38392. this.global_callbacks = [];
  38393. this.failThrough = failThrough;
  38394. }
  38395. Dispatcher.prototype.bind = function (eventName, callback, context) {
  38396. this.callbacks.add(eventName, callback, context);
  38397. return this;
  38398. };
  38399. Dispatcher.prototype.bind_global = function (callback) {
  38400. this.global_callbacks.push(callback);
  38401. return this;
  38402. };
  38403. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  38404. this.callbacks.remove(eventName, callback, context);
  38405. return this;
  38406. };
  38407. Dispatcher.prototype.unbind_global = function (callback) {
  38408. if (!callback) {
  38409. this.global_callbacks = [];
  38410. return this;
  38411. }
  38412. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  38413. return this;
  38414. };
  38415. Dispatcher.prototype.unbind_all = function () {
  38416. this.unbind();
  38417. this.unbind_global();
  38418. return this;
  38419. };
  38420. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  38421. for (var i = 0; i < this.global_callbacks.length; i++) {
  38422. this.global_callbacks[i](eventName, data);
  38423. }
  38424. var callbacks = this.callbacks.get(eventName);
  38425. var args = [];
  38426. if (metadata) {
  38427. args.push(data, metadata);
  38428. }
  38429. else if (data) {
  38430. args.push(data);
  38431. }
  38432. if (callbacks && callbacks.length > 0) {
  38433. for (var i = 0; i < callbacks.length; i++) {
  38434. callbacks[i].fn.apply(callbacks[i].context || window, args);
  38435. }
  38436. }
  38437. else if (this.failThrough) {
  38438. this.failThrough(eventName, data);
  38439. }
  38440. return this;
  38441. };
  38442. return Dispatcher;
  38443. }());
  38444. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  38445. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  38446. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  38447. var extendStatics = function (d, b) {
  38448. extendStatics = Object.setPrototypeOf ||
  38449. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38450. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38451. return extendStatics(d, b);
  38452. };
  38453. return function (d, b) {
  38454. extendStatics(d, b);
  38455. function __() { this.constructor = d; }
  38456. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38457. };
  38458. })();
  38459. var transport_connection_TransportConnection = (function (_super) {
  38460. transport_connection_extends(TransportConnection, _super);
  38461. function TransportConnection(hooks, name, priority, key, options) {
  38462. var _this = _super.call(this) || this;
  38463. _this.initialize = runtime.transportConnectionInitializer;
  38464. _this.hooks = hooks;
  38465. _this.name = name;
  38466. _this.priority = priority;
  38467. _this.key = key;
  38468. _this.options = options;
  38469. _this.state = "new";
  38470. _this.timeline = options.timeline;
  38471. _this.activityTimeout = options.activityTimeout;
  38472. _this.id = _this.timeline.generateUniqueID();
  38473. return _this;
  38474. }
  38475. TransportConnection.prototype.handlesActivityChecks = function () {
  38476. return Boolean(this.hooks.handlesActivityChecks);
  38477. };
  38478. TransportConnection.prototype.supportsPing = function () {
  38479. return Boolean(this.hooks.supportsPing);
  38480. };
  38481. TransportConnection.prototype.connect = function () {
  38482. var _this = this;
  38483. if (this.socket || this.state !== "initialized") {
  38484. return false;
  38485. }
  38486. var url = this.hooks.urls.getInitial(this.key, this.options);
  38487. try {
  38488. this.socket = this.hooks.getSocket(url, this.options);
  38489. }
  38490. catch (e) {
  38491. util.defer(function () {
  38492. _this.onError(e);
  38493. _this.changeState("closed");
  38494. });
  38495. return false;
  38496. }
  38497. this.bindListeners();
  38498. logger.debug("Connecting", { transport: this.name, url: url });
  38499. this.changeState("connecting");
  38500. return true;
  38501. };
  38502. TransportConnection.prototype.close = function () {
  38503. if (this.socket) {
  38504. this.socket.close();
  38505. return true;
  38506. }
  38507. else {
  38508. return false;
  38509. }
  38510. };
  38511. TransportConnection.prototype.send = function (data) {
  38512. var _this = this;
  38513. if (this.state === "open") {
  38514. util.defer(function () {
  38515. if (_this.socket) {
  38516. _this.socket.send(data);
  38517. }
  38518. });
  38519. return true;
  38520. }
  38521. else {
  38522. return false;
  38523. }
  38524. };
  38525. TransportConnection.prototype.ping = function () {
  38526. if (this.state === "open" && this.supportsPing()) {
  38527. this.socket.ping();
  38528. }
  38529. };
  38530. TransportConnection.prototype.onOpen = function () {
  38531. if (this.hooks.beforeOpen) {
  38532. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  38533. }
  38534. this.changeState("open");
  38535. this.socket.onopen = undefined;
  38536. };
  38537. TransportConnection.prototype.onError = function (error) {
  38538. this.emit("error", { type: 'WebSocketError', error: error });
  38539. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  38540. };
  38541. TransportConnection.prototype.onClose = function (closeEvent) {
  38542. if (closeEvent) {
  38543. this.changeState("closed", {
  38544. code: closeEvent.code,
  38545. reason: closeEvent.reason,
  38546. wasClean: closeEvent.wasClean
  38547. });
  38548. }
  38549. else {
  38550. this.changeState("closed");
  38551. }
  38552. this.unbindListeners();
  38553. this.socket = undefined;
  38554. };
  38555. TransportConnection.prototype.onMessage = function (message) {
  38556. this.emit("message", message);
  38557. };
  38558. TransportConnection.prototype.onActivity = function () {
  38559. this.emit("activity");
  38560. };
  38561. TransportConnection.prototype.bindListeners = function () {
  38562. var _this = this;
  38563. this.socket.onopen = function () {
  38564. _this.onOpen();
  38565. };
  38566. this.socket.onerror = function (error) {
  38567. _this.onError(error);
  38568. };
  38569. this.socket.onclose = function (closeEvent) {
  38570. _this.onClose(closeEvent);
  38571. };
  38572. this.socket.onmessage = function (message) {
  38573. _this.onMessage(message);
  38574. };
  38575. if (this.supportsPing()) {
  38576. this.socket.onactivity = function () { _this.onActivity(); };
  38577. }
  38578. };
  38579. TransportConnection.prototype.unbindListeners = function () {
  38580. if (this.socket) {
  38581. this.socket.onopen = undefined;
  38582. this.socket.onerror = undefined;
  38583. this.socket.onclose = undefined;
  38584. this.socket.onmessage = undefined;
  38585. if (this.supportsPing()) {
  38586. this.socket.onactivity = undefined;
  38587. }
  38588. }
  38589. };
  38590. TransportConnection.prototype.changeState = function (state, params) {
  38591. this.state = state;
  38592. this.timeline.info(this.buildTimelineMessage({
  38593. state: state,
  38594. params: params
  38595. }));
  38596. this.emit(state, params);
  38597. };
  38598. TransportConnection.prototype.buildTimelineMessage = function (message) {
  38599. return extend({ cid: this.id }, message);
  38600. };
  38601. return TransportConnection;
  38602. }(dispatcher));
  38603. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  38604. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  38605. var transport_Transport = (function () {
  38606. function Transport(hooks) {
  38607. this.hooks = hooks;
  38608. }
  38609. Transport.prototype.isSupported = function (environment) {
  38610. return this.hooks.isSupported(environment);
  38611. };
  38612. Transport.prototype.createConnection = function (name, priority, key, options) {
  38613. return new transport_connection(this.hooks, name, priority, key, options);
  38614. };
  38615. return Transport;
  38616. }());
  38617. /* harmony default export */ var transports_transport = (transport_Transport);
  38618. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  38619. var WSTransport = new transports_transport({
  38620. urls: ws,
  38621. handlesActivityChecks: false,
  38622. supportsPing: false,
  38623. isInitialized: function () {
  38624. return Boolean(runtime.getWebSocketAPI());
  38625. },
  38626. isSupported: function () {
  38627. return Boolean(runtime.getWebSocketAPI());
  38628. },
  38629. getSocket: function (url) {
  38630. return runtime.createWebSocket(url);
  38631. }
  38632. });
  38633. var httpConfiguration = {
  38634. urls: http,
  38635. handlesActivityChecks: false,
  38636. supportsPing: true,
  38637. isInitialized: function () {
  38638. return true;
  38639. }
  38640. };
  38641. var streamingConfiguration = extend({ getSocket: function (url) {
  38642. return runtime.HTTPFactory.createStreamingSocket(url);
  38643. }
  38644. }, httpConfiguration);
  38645. var pollingConfiguration = extend({ getSocket: function (url) {
  38646. return runtime.HTTPFactory.createPollingSocket(url);
  38647. }
  38648. }, httpConfiguration);
  38649. var xhrConfiguration = {
  38650. isSupported: function () {
  38651. return runtime.isXHRSupported();
  38652. }
  38653. };
  38654. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  38655. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  38656. var Transports = {
  38657. ws: WSTransport,
  38658. xhr_streaming: XHRStreamingTransport,
  38659. xhr_polling: XHRPollingTransport
  38660. };
  38661. /* harmony default export */ var transports = (Transports);
  38662. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  38663. var SockJSTransport = new transports_transport({
  38664. file: "sockjs",
  38665. urls: sockjs,
  38666. handlesActivityChecks: true,
  38667. supportsPing: false,
  38668. isSupported: function () {
  38669. return true;
  38670. },
  38671. isInitialized: function () {
  38672. return window.SockJS !== undefined;
  38673. },
  38674. getSocket: function (url, options) {
  38675. return new window.SockJS(url, null, {
  38676. js_path: Dependencies.getPath("sockjs", {
  38677. useTLS: options.useTLS
  38678. }),
  38679. ignore_null_origin: options.ignoreNullOrigin
  38680. });
  38681. },
  38682. beforeOpen: function (socket, path) {
  38683. socket.send(JSON.stringify({
  38684. path: path
  38685. }));
  38686. }
  38687. });
  38688. var xdrConfiguration = {
  38689. isSupported: function (environment) {
  38690. var yes = runtime.isXDRSupported(environment.useTLS);
  38691. return yes;
  38692. }
  38693. };
  38694. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  38695. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  38696. transports.xdr_streaming = XDRStreamingTransport;
  38697. transports.xdr_polling = XDRPollingTransport;
  38698. transports.sockjs = SockJSTransport;
  38699. /* harmony default export */ var transports_transports = (transports);
  38700. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  38701. var net_info_extends = (undefined && undefined.__extends) || (function () {
  38702. var extendStatics = function (d, b) {
  38703. extendStatics = Object.setPrototypeOf ||
  38704. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38705. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38706. return extendStatics(d, b);
  38707. };
  38708. return function (d, b) {
  38709. extendStatics(d, b);
  38710. function __() { this.constructor = d; }
  38711. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38712. };
  38713. })();
  38714. var NetInfo = (function (_super) {
  38715. net_info_extends(NetInfo, _super);
  38716. function NetInfo() {
  38717. var _this = _super.call(this) || this;
  38718. var self = _this;
  38719. if (window.addEventListener !== undefined) {
  38720. window.addEventListener("online", function () {
  38721. self.emit('online');
  38722. }, false);
  38723. window.addEventListener("offline", function () {
  38724. self.emit('offline');
  38725. }, false);
  38726. }
  38727. return _this;
  38728. }
  38729. NetInfo.prototype.isOnline = function () {
  38730. if (window.navigator.onLine === undefined) {
  38731. return true;
  38732. }
  38733. else {
  38734. return window.navigator.onLine;
  38735. }
  38736. };
  38737. return NetInfo;
  38738. }(dispatcher));
  38739. var net_info_Network = new NetInfo();
  38740. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  38741. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  38742. function AssistantToTheTransportManager(manager, transport, options) {
  38743. this.manager = manager;
  38744. this.transport = transport;
  38745. this.minPingDelay = options.minPingDelay;
  38746. this.maxPingDelay = options.maxPingDelay;
  38747. this.pingDelay = undefined;
  38748. }
  38749. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  38750. var _this = this;
  38751. options = extend({}, options, {
  38752. activityTimeout: this.pingDelay
  38753. });
  38754. var connection = this.transport.createConnection(name, priority, key, options);
  38755. var openTimestamp = null;
  38756. var onOpen = function () {
  38757. connection.unbind("open", onOpen);
  38758. connection.bind("closed", onClosed);
  38759. openTimestamp = util.now();
  38760. };
  38761. var onClosed = function (closeEvent) {
  38762. connection.unbind("closed", onClosed);
  38763. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  38764. _this.manager.reportDeath();
  38765. }
  38766. else if (!closeEvent.wasClean && openTimestamp) {
  38767. var lifespan = util.now() - openTimestamp;
  38768. if (lifespan < 2 * _this.maxPingDelay) {
  38769. _this.manager.reportDeath();
  38770. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  38771. }
  38772. }
  38773. };
  38774. connection.bind("open", onOpen);
  38775. return connection;
  38776. };
  38777. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  38778. return this.manager.isAlive() && this.transport.isSupported(environment);
  38779. };
  38780. return AssistantToTheTransportManager;
  38781. }());
  38782. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  38783. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  38784. var Protocol = {
  38785. decodeMessage: function (messageEvent) {
  38786. try {
  38787. var messageData = JSON.parse(messageEvent.data);
  38788. var pusherEventData = messageData.data;
  38789. if (typeof pusherEventData === 'string') {
  38790. try {
  38791. pusherEventData = JSON.parse(messageData.data);
  38792. }
  38793. catch (e) { }
  38794. }
  38795. var pusherEvent = {
  38796. event: messageData.event,
  38797. channel: messageData.channel,
  38798. data: pusherEventData,
  38799. };
  38800. if (messageData.user_id) {
  38801. pusherEvent.user_id = messageData.user_id;
  38802. }
  38803. return pusherEvent;
  38804. }
  38805. catch (e) {
  38806. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  38807. }
  38808. },
  38809. encodeMessage: function (event) {
  38810. return JSON.stringify(event);
  38811. },
  38812. processHandshake: function (messageEvent) {
  38813. var message = Protocol.decodeMessage(messageEvent);
  38814. if (message.event === "pusher:connection_established") {
  38815. if (!message.data.activity_timeout) {
  38816. throw "No activity timeout specified in handshake";
  38817. }
  38818. return {
  38819. action: "connected",
  38820. id: message.data.socket_id,
  38821. activityTimeout: message.data.activity_timeout * 1000
  38822. };
  38823. }
  38824. else if (message.event === "pusher:error") {
  38825. return {
  38826. action: this.getCloseAction(message.data),
  38827. error: this.getCloseError(message.data)
  38828. };
  38829. }
  38830. else {
  38831. throw "Invalid handshake";
  38832. }
  38833. },
  38834. getCloseAction: function (closeEvent) {
  38835. if (closeEvent.code < 4000) {
  38836. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  38837. return "backoff";
  38838. }
  38839. else {
  38840. return null;
  38841. }
  38842. }
  38843. else if (closeEvent.code === 4000) {
  38844. return "tls_only";
  38845. }
  38846. else if (closeEvent.code < 4100) {
  38847. return "refused";
  38848. }
  38849. else if (closeEvent.code < 4200) {
  38850. return "backoff";
  38851. }
  38852. else if (closeEvent.code < 4300) {
  38853. return "retry";
  38854. }
  38855. else {
  38856. return "refused";
  38857. }
  38858. },
  38859. getCloseError: function (closeEvent) {
  38860. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  38861. return {
  38862. type: 'PusherError',
  38863. data: {
  38864. code: closeEvent.code,
  38865. message: closeEvent.reason || closeEvent.message
  38866. }
  38867. };
  38868. }
  38869. else {
  38870. return null;
  38871. }
  38872. }
  38873. };
  38874. /* harmony default export */ var protocol_protocol = (Protocol);
  38875. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  38876. var connection_extends = (undefined && undefined.__extends) || (function () {
  38877. var extendStatics = function (d, b) {
  38878. extendStatics = Object.setPrototypeOf ||
  38879. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38880. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38881. return extendStatics(d, b);
  38882. };
  38883. return function (d, b) {
  38884. extendStatics(d, b);
  38885. function __() { this.constructor = d; }
  38886. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38887. };
  38888. })();
  38889. var connection_Connection = (function (_super) {
  38890. connection_extends(Connection, _super);
  38891. function Connection(id, transport) {
  38892. var _this = _super.call(this) || this;
  38893. _this.id = id;
  38894. _this.transport = transport;
  38895. _this.activityTimeout = transport.activityTimeout;
  38896. _this.bindListeners();
  38897. return _this;
  38898. }
  38899. Connection.prototype.handlesActivityChecks = function () {
  38900. return this.transport.handlesActivityChecks();
  38901. };
  38902. Connection.prototype.send = function (data) {
  38903. return this.transport.send(data);
  38904. };
  38905. Connection.prototype.send_event = function (name, data, channel) {
  38906. var event = { event: name, data: data };
  38907. if (channel) {
  38908. event.channel = channel;
  38909. }
  38910. logger.debug('Event sent', event);
  38911. return this.send(protocol_protocol.encodeMessage(event));
  38912. };
  38913. Connection.prototype.ping = function () {
  38914. if (this.transport.supportsPing()) {
  38915. this.transport.ping();
  38916. }
  38917. else {
  38918. this.send_event('pusher:ping', {});
  38919. }
  38920. };
  38921. Connection.prototype.close = function () {
  38922. this.transport.close();
  38923. };
  38924. Connection.prototype.bindListeners = function () {
  38925. var _this = this;
  38926. var listeners = {
  38927. message: function (messageEvent) {
  38928. var pusherEvent;
  38929. try {
  38930. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  38931. }
  38932. catch (e) {
  38933. _this.emit('error', {
  38934. type: 'MessageParseError',
  38935. error: e,
  38936. data: messageEvent.data
  38937. });
  38938. }
  38939. if (pusherEvent !== undefined) {
  38940. logger.debug('Event recd', pusherEvent);
  38941. switch (pusherEvent.event) {
  38942. case 'pusher:error':
  38943. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  38944. break;
  38945. case 'pusher:ping':
  38946. _this.emit("ping");
  38947. break;
  38948. case 'pusher:pong':
  38949. _this.emit("pong");
  38950. break;
  38951. }
  38952. _this.emit('message', pusherEvent);
  38953. }
  38954. },
  38955. activity: function () {
  38956. _this.emit("activity");
  38957. },
  38958. error: function (error) {
  38959. _this.emit("error", { type: "WebSocketError", error: error });
  38960. },
  38961. closed: function (closeEvent) {
  38962. unbindListeners();
  38963. if (closeEvent && closeEvent.code) {
  38964. _this.handleCloseEvent(closeEvent);
  38965. }
  38966. _this.transport = null;
  38967. _this.emit("closed");
  38968. }
  38969. };
  38970. var unbindListeners = function () {
  38971. objectApply(listeners, function (listener, event) {
  38972. _this.transport.unbind(event, listener);
  38973. });
  38974. };
  38975. objectApply(listeners, function (listener, event) {
  38976. _this.transport.bind(event, listener);
  38977. });
  38978. };
  38979. Connection.prototype.handleCloseEvent = function (closeEvent) {
  38980. var action = protocol_protocol.getCloseAction(closeEvent);
  38981. var error = protocol_protocol.getCloseError(closeEvent);
  38982. if (error) {
  38983. this.emit('error', error);
  38984. }
  38985. if (action) {
  38986. this.emit(action, { action: action, error: error });
  38987. }
  38988. };
  38989. return Connection;
  38990. }(dispatcher));
  38991. /* harmony default export */ var connection_connection = (connection_Connection);
  38992. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  38993. var handshake_Handshake = (function () {
  38994. function Handshake(transport, callback) {
  38995. this.transport = transport;
  38996. this.callback = callback;
  38997. this.bindListeners();
  38998. }
  38999. Handshake.prototype.close = function () {
  39000. this.unbindListeners();
  39001. this.transport.close();
  39002. };
  39003. Handshake.prototype.bindListeners = function () {
  39004. var _this = this;
  39005. this.onMessage = function (m) {
  39006. _this.unbindListeners();
  39007. var result;
  39008. try {
  39009. result = protocol_protocol.processHandshake(m);
  39010. }
  39011. catch (e) {
  39012. _this.finish("error", { error: e });
  39013. _this.transport.close();
  39014. return;
  39015. }
  39016. if (result.action === "connected") {
  39017. _this.finish("connected", {
  39018. connection: new connection_connection(result.id, _this.transport),
  39019. activityTimeout: result.activityTimeout
  39020. });
  39021. }
  39022. else {
  39023. _this.finish(result.action, { error: result.error });
  39024. _this.transport.close();
  39025. }
  39026. };
  39027. this.onClosed = function (closeEvent) {
  39028. _this.unbindListeners();
  39029. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39030. var error = protocol_protocol.getCloseError(closeEvent);
  39031. _this.finish(action, { error: error });
  39032. };
  39033. this.transport.bind("message", this.onMessage);
  39034. this.transport.bind("closed", this.onClosed);
  39035. };
  39036. Handshake.prototype.unbindListeners = function () {
  39037. this.transport.unbind("message", this.onMessage);
  39038. this.transport.unbind("closed", this.onClosed);
  39039. };
  39040. Handshake.prototype.finish = function (action, params) {
  39041. this.callback(extend({ transport: this.transport, action: action }, params));
  39042. };
  39043. return Handshake;
  39044. }());
  39045. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39046. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39047. var pusher_authorizer_PusherAuthorizer = (function () {
  39048. function PusherAuthorizer(channel, options) {
  39049. this.channel = channel;
  39050. var authTransport = options.authTransport;
  39051. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39052. throw "'" + authTransport + "' is not a recognized auth transport";
  39053. }
  39054. this.type = authTransport;
  39055. this.options = options;
  39056. this.authOptions = (options || {}).auth || {};
  39057. }
  39058. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39059. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39060. '&channel_name=' + encodeURIComponent(this.channel.name);
  39061. for (var i in this.authOptions.params) {
  39062. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39063. }
  39064. return query;
  39065. };
  39066. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39067. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39068. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  39069. };
  39070. return PusherAuthorizer;
  39071. }());
  39072. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  39073. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  39074. var timeline_sender_TimelineSender = (function () {
  39075. function TimelineSender(timeline, options) {
  39076. this.timeline = timeline;
  39077. this.options = options || {};
  39078. }
  39079. TimelineSender.prototype.send = function (useTLS, callback) {
  39080. if (this.timeline.isEmpty()) {
  39081. return;
  39082. }
  39083. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  39084. };
  39085. return TimelineSender;
  39086. }());
  39087. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  39088. // CONCATENATED MODULE: ./src/core/errors.ts
  39089. var errors_extends = (undefined && undefined.__extends) || (function () {
  39090. var extendStatics = function (d, b) {
  39091. extendStatics = Object.setPrototypeOf ||
  39092. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39093. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39094. return extendStatics(d, b);
  39095. };
  39096. return function (d, b) {
  39097. extendStatics(d, b);
  39098. function __() { this.constructor = d; }
  39099. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39100. };
  39101. })();
  39102. var BadEventName = (function (_super) {
  39103. errors_extends(BadEventName, _super);
  39104. function BadEventName(msg) {
  39105. var _newTarget = this.constructor;
  39106. var _this = _super.call(this, msg) || this;
  39107. Object.setPrototypeOf(_this, _newTarget.prototype);
  39108. return _this;
  39109. }
  39110. return BadEventName;
  39111. }(Error));
  39112. var RequestTimedOut = (function (_super) {
  39113. errors_extends(RequestTimedOut, _super);
  39114. function RequestTimedOut(msg) {
  39115. var _newTarget = this.constructor;
  39116. var _this = _super.call(this, msg) || this;
  39117. Object.setPrototypeOf(_this, _newTarget.prototype);
  39118. return _this;
  39119. }
  39120. return RequestTimedOut;
  39121. }(Error));
  39122. var TransportPriorityTooLow = (function (_super) {
  39123. errors_extends(TransportPriorityTooLow, _super);
  39124. function TransportPriorityTooLow(msg) {
  39125. var _newTarget = this.constructor;
  39126. var _this = _super.call(this, msg) || this;
  39127. Object.setPrototypeOf(_this, _newTarget.prototype);
  39128. return _this;
  39129. }
  39130. return TransportPriorityTooLow;
  39131. }(Error));
  39132. var TransportClosed = (function (_super) {
  39133. errors_extends(TransportClosed, _super);
  39134. function TransportClosed(msg) {
  39135. var _newTarget = this.constructor;
  39136. var _this = _super.call(this, msg) || this;
  39137. Object.setPrototypeOf(_this, _newTarget.prototype);
  39138. return _this;
  39139. }
  39140. return TransportClosed;
  39141. }(Error));
  39142. var UnsupportedFeature = (function (_super) {
  39143. errors_extends(UnsupportedFeature, _super);
  39144. function UnsupportedFeature(msg) {
  39145. var _newTarget = this.constructor;
  39146. var _this = _super.call(this, msg) || this;
  39147. Object.setPrototypeOf(_this, _newTarget.prototype);
  39148. return _this;
  39149. }
  39150. return UnsupportedFeature;
  39151. }(Error));
  39152. var UnsupportedTransport = (function (_super) {
  39153. errors_extends(UnsupportedTransport, _super);
  39154. function UnsupportedTransport(msg) {
  39155. var _newTarget = this.constructor;
  39156. var _this = _super.call(this, msg) || this;
  39157. Object.setPrototypeOf(_this, _newTarget.prototype);
  39158. return _this;
  39159. }
  39160. return UnsupportedTransport;
  39161. }(Error));
  39162. var UnsupportedStrategy = (function (_super) {
  39163. errors_extends(UnsupportedStrategy, _super);
  39164. function UnsupportedStrategy(msg) {
  39165. var _newTarget = this.constructor;
  39166. var _this = _super.call(this, msg) || this;
  39167. Object.setPrototypeOf(_this, _newTarget.prototype);
  39168. return _this;
  39169. }
  39170. return UnsupportedStrategy;
  39171. }(Error));
  39172. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  39173. var channel_extends = (undefined && undefined.__extends) || (function () {
  39174. var extendStatics = function (d, b) {
  39175. extendStatics = Object.setPrototypeOf ||
  39176. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39177. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39178. return extendStatics(d, b);
  39179. };
  39180. return function (d, b) {
  39181. extendStatics(d, b);
  39182. function __() { this.constructor = d; }
  39183. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39184. };
  39185. })();
  39186. var channel_Channel = (function (_super) {
  39187. channel_extends(Channel, _super);
  39188. function Channel(name, pusher) {
  39189. var _this = _super.call(this, function (event, data) {
  39190. logger.debug('No callbacks on ' + name + ' for ' + event);
  39191. }) || this;
  39192. _this.name = name;
  39193. _this.pusher = pusher;
  39194. _this.subscribed = false;
  39195. _this.subscriptionPending = false;
  39196. _this.subscriptionCancelled = false;
  39197. return _this;
  39198. }
  39199. Channel.prototype.authorize = function (socketId, callback) {
  39200. return callback(false, {});
  39201. };
  39202. Channel.prototype.trigger = function (event, data) {
  39203. if (event.indexOf("client-") !== 0) {
  39204. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  39205. }
  39206. if (!this.subscribed) {
  39207. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  39208. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  39209. }
  39210. return this.pusher.send_event(event, data, this.name);
  39211. };
  39212. Channel.prototype.disconnect = function () {
  39213. this.subscribed = false;
  39214. this.subscriptionPending = false;
  39215. };
  39216. Channel.prototype.handleEvent = function (event) {
  39217. var eventName = event.event;
  39218. var data = event.data;
  39219. if (eventName === "pusher_internal:subscription_succeeded") {
  39220. this.handleSubscriptionSucceededEvent(event);
  39221. }
  39222. else if (eventName.indexOf("pusher_internal:") !== 0) {
  39223. var metadata = {};
  39224. this.emit(eventName, data, metadata);
  39225. }
  39226. };
  39227. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39228. this.subscriptionPending = false;
  39229. this.subscribed = true;
  39230. if (this.subscriptionCancelled) {
  39231. this.pusher.unsubscribe(this.name);
  39232. }
  39233. else {
  39234. this.emit("pusher:subscription_succeeded", event.data);
  39235. }
  39236. };
  39237. Channel.prototype.subscribe = function () {
  39238. var _this = this;
  39239. if (this.subscribed) {
  39240. return;
  39241. }
  39242. this.subscriptionPending = true;
  39243. this.subscriptionCancelled = false;
  39244. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  39245. if (error) {
  39246. logger.error(data);
  39247. _this.emit('pusher:subscription_error', data);
  39248. }
  39249. else {
  39250. _this.pusher.send_event('pusher:subscribe', {
  39251. auth: data.auth,
  39252. channel_data: data.channel_data,
  39253. channel: _this.name
  39254. });
  39255. }
  39256. });
  39257. };
  39258. Channel.prototype.unsubscribe = function () {
  39259. this.subscribed = false;
  39260. this.pusher.send_event('pusher:unsubscribe', {
  39261. channel: this.name
  39262. });
  39263. };
  39264. Channel.prototype.cancelSubscription = function () {
  39265. this.subscriptionCancelled = true;
  39266. };
  39267. Channel.prototype.reinstateSubscription = function () {
  39268. this.subscriptionCancelled = false;
  39269. };
  39270. return Channel;
  39271. }(dispatcher));
  39272. /* harmony default export */ var channels_channel = (channel_Channel);
  39273. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  39274. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  39275. var extendStatics = function (d, b) {
  39276. extendStatics = Object.setPrototypeOf ||
  39277. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39278. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39279. return extendStatics(d, b);
  39280. };
  39281. return function (d, b) {
  39282. extendStatics(d, b);
  39283. function __() { this.constructor = d; }
  39284. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39285. };
  39286. })();
  39287. var private_channel_PrivateChannel = (function (_super) {
  39288. private_channel_extends(PrivateChannel, _super);
  39289. function PrivateChannel() {
  39290. return _super !== null && _super.apply(this, arguments) || this;
  39291. }
  39292. PrivateChannel.prototype.authorize = function (socketId, callback) {
  39293. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  39294. return authorizer.authorize(socketId, callback);
  39295. };
  39296. return PrivateChannel;
  39297. }(channels_channel));
  39298. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  39299. // CONCATENATED MODULE: ./src/core/channels/members.ts
  39300. var members_Members = (function () {
  39301. function Members() {
  39302. this.reset();
  39303. }
  39304. Members.prototype.get = function (id) {
  39305. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  39306. return {
  39307. id: id,
  39308. info: this.members[id]
  39309. };
  39310. }
  39311. else {
  39312. return null;
  39313. }
  39314. };
  39315. Members.prototype.each = function (callback) {
  39316. var _this = this;
  39317. objectApply(this.members, function (member, id) {
  39318. callback(_this.get(id));
  39319. });
  39320. };
  39321. Members.prototype.setMyID = function (id) {
  39322. this.myID = id;
  39323. };
  39324. Members.prototype.onSubscription = function (subscriptionData) {
  39325. this.members = subscriptionData.presence.hash;
  39326. this.count = subscriptionData.presence.count;
  39327. this.me = this.get(this.myID);
  39328. };
  39329. Members.prototype.addMember = function (memberData) {
  39330. if (this.get(memberData.user_id) === null) {
  39331. this.count++;
  39332. }
  39333. this.members[memberData.user_id] = memberData.user_info;
  39334. return this.get(memberData.user_id);
  39335. };
  39336. Members.prototype.removeMember = function (memberData) {
  39337. var member = this.get(memberData.user_id);
  39338. if (member) {
  39339. delete this.members[memberData.user_id];
  39340. this.count--;
  39341. }
  39342. return member;
  39343. };
  39344. Members.prototype.reset = function () {
  39345. this.members = {};
  39346. this.count = 0;
  39347. this.myID = null;
  39348. this.me = null;
  39349. };
  39350. return Members;
  39351. }());
  39352. /* harmony default export */ var members = (members_Members);
  39353. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  39354. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  39355. var extendStatics = function (d, b) {
  39356. extendStatics = Object.setPrototypeOf ||
  39357. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39358. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39359. return extendStatics(d, b);
  39360. };
  39361. return function (d, b) {
  39362. extendStatics(d, b);
  39363. function __() { this.constructor = d; }
  39364. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39365. };
  39366. })();
  39367. var presence_channel_PresenceChannel = (function (_super) {
  39368. presence_channel_extends(PresenceChannel, _super);
  39369. function PresenceChannel(name, pusher) {
  39370. var _this = _super.call(this, name, pusher) || this;
  39371. _this.members = new members();
  39372. return _this;
  39373. }
  39374. PresenceChannel.prototype.authorize = function (socketId, callback) {
  39375. var _this = this;
  39376. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39377. if (!error) {
  39378. if (authData.channel_data === undefined) {
  39379. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39380. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  39381. ("expected 'channel_data' field. " + suffix));
  39382. callback("Invalid auth response");
  39383. return;
  39384. }
  39385. var channelData = JSON.parse(authData.channel_data);
  39386. _this.members.setMyID(channelData.user_id);
  39387. }
  39388. callback(error, authData);
  39389. });
  39390. };
  39391. PresenceChannel.prototype.handleEvent = function (event) {
  39392. var eventName = event.event;
  39393. if (eventName.indexOf("pusher_internal:") === 0) {
  39394. this.handleInternalEvent(event);
  39395. }
  39396. else {
  39397. var data = event.data;
  39398. var metadata = {};
  39399. if (event.user_id) {
  39400. metadata.user_id = event.user_id;
  39401. }
  39402. this.emit(eventName, data, metadata);
  39403. }
  39404. };
  39405. PresenceChannel.prototype.handleInternalEvent = function (event) {
  39406. var eventName = event.event;
  39407. var data = event.data;
  39408. switch (eventName) {
  39409. case "pusher_internal:subscription_succeeded":
  39410. this.handleSubscriptionSucceededEvent(event);
  39411. break;
  39412. case "pusher_internal:member_added":
  39413. var addedMember = this.members.addMember(data);
  39414. this.emit('pusher:member_added', addedMember);
  39415. break;
  39416. case "pusher_internal:member_removed":
  39417. var removedMember = this.members.removeMember(data);
  39418. if (removedMember) {
  39419. this.emit('pusher:member_removed', removedMember);
  39420. }
  39421. break;
  39422. }
  39423. };
  39424. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  39425. this.subscriptionPending = false;
  39426. this.subscribed = true;
  39427. if (this.subscriptionCancelled) {
  39428. this.pusher.unsubscribe(this.name);
  39429. }
  39430. else {
  39431. this.members.onSubscription(event.data);
  39432. this.emit("pusher:subscription_succeeded", this.members);
  39433. }
  39434. };
  39435. PresenceChannel.prototype.disconnect = function () {
  39436. this.members.reset();
  39437. _super.prototype.disconnect.call(this);
  39438. };
  39439. return PresenceChannel;
  39440. }(private_channel));
  39441. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  39442. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  39443. var nacl_fast = __webpack_require__(0);
  39444. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  39445. var nacl_util = __webpack_require__(1);
  39446. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  39447. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  39448. var extendStatics = function (d, b) {
  39449. extendStatics = Object.setPrototypeOf ||
  39450. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39451. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39452. return extendStatics(d, b);
  39453. };
  39454. return function (d, b) {
  39455. extendStatics(d, b);
  39456. function __() { this.constructor = d; }
  39457. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39458. };
  39459. })();
  39460. var encrypted_channel_EncryptedChannel = (function (_super) {
  39461. encrypted_channel_extends(EncryptedChannel, _super);
  39462. function EncryptedChannel() {
  39463. var _this = _super !== null && _super.apply(this, arguments) || this;
  39464. _this.key = null;
  39465. return _this;
  39466. }
  39467. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  39468. var _this = this;
  39469. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  39470. if (error) {
  39471. callback(true, authData);
  39472. return;
  39473. }
  39474. var sharedSecret = authData["shared_secret"];
  39475. if (!sharedSecret) {
  39476. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  39477. callback(true, errorMsg);
  39478. return;
  39479. }
  39480. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  39481. delete authData["shared_secret"];
  39482. callback(false, authData);
  39483. });
  39484. };
  39485. EncryptedChannel.prototype.trigger = function (event, data) {
  39486. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  39487. };
  39488. EncryptedChannel.prototype.handleEvent = function (event) {
  39489. var eventName = event.event;
  39490. var data = event.data;
  39491. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  39492. _super.prototype.handleEvent.call(this, event);
  39493. return;
  39494. }
  39495. this.handleEncryptedEvent(eventName, data);
  39496. };
  39497. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  39498. var _this = this;
  39499. if (!this.key) {
  39500. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  39501. return;
  39502. }
  39503. if (!data.ciphertext || !data.nonce) {
  39504. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  39505. return;
  39506. }
  39507. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  39508. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  39509. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  39510. return;
  39511. }
  39512. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  39513. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  39514. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  39515. return;
  39516. }
  39517. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  39518. if (bytes === null) {
  39519. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  39520. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  39521. if (error) {
  39522. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  39523. return;
  39524. }
  39525. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  39526. if (bytes === null) {
  39527. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  39528. return;
  39529. }
  39530. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39531. return;
  39532. });
  39533. return;
  39534. }
  39535. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  39536. };
  39537. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  39538. try {
  39539. this.emit(eventName, JSON.parse(data));
  39540. }
  39541. catch (e) {
  39542. this.emit(eventName, data);
  39543. }
  39544. return this;
  39545. };
  39546. return EncryptedChannel;
  39547. }(private_channel));
  39548. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  39549. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  39550. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  39551. var extendStatics = function (d, b) {
  39552. extendStatics = Object.setPrototypeOf ||
  39553. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39554. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39555. return extendStatics(d, b);
  39556. };
  39557. return function (d, b) {
  39558. extendStatics(d, b);
  39559. function __() { this.constructor = d; }
  39560. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39561. };
  39562. })();
  39563. var connection_manager_ConnectionManager = (function (_super) {
  39564. connection_manager_extends(ConnectionManager, _super);
  39565. function ConnectionManager(key, options) {
  39566. var _this = _super.call(this) || this;
  39567. _this.key = key;
  39568. _this.options = options || {};
  39569. _this.state = "initialized";
  39570. _this.connection = null;
  39571. _this.usingTLS = !!options.useTLS;
  39572. _this.timeline = _this.options.timeline;
  39573. _this.errorCallbacks = _this.buildErrorCallbacks();
  39574. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  39575. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  39576. var Network = runtime.getNetwork();
  39577. Network.bind("online", function () {
  39578. _this.timeline.info({ netinfo: "online" });
  39579. if (_this.state === "connecting" || _this.state === "unavailable") {
  39580. _this.retryIn(0);
  39581. }
  39582. });
  39583. Network.bind("offline", function () {
  39584. _this.timeline.info({ netinfo: "offline" });
  39585. if (_this.connection) {
  39586. _this.sendActivityCheck();
  39587. }
  39588. });
  39589. _this.updateStrategy();
  39590. return _this;
  39591. }
  39592. ConnectionManager.prototype.connect = function () {
  39593. if (this.connection || this.runner) {
  39594. return;
  39595. }
  39596. if (!this.strategy.isSupported()) {
  39597. this.updateState("failed");
  39598. return;
  39599. }
  39600. this.updateState("connecting");
  39601. this.startConnecting();
  39602. this.setUnavailableTimer();
  39603. };
  39604. ;
  39605. ConnectionManager.prototype.send = function (data) {
  39606. if (this.connection) {
  39607. return this.connection.send(data);
  39608. }
  39609. else {
  39610. return false;
  39611. }
  39612. };
  39613. ;
  39614. ConnectionManager.prototype.send_event = function (name, data, channel) {
  39615. if (this.connection) {
  39616. return this.connection.send_event(name, data, channel);
  39617. }
  39618. else {
  39619. return false;
  39620. }
  39621. };
  39622. ;
  39623. ConnectionManager.prototype.disconnect = function () {
  39624. this.disconnectInternally();
  39625. this.updateState("disconnected");
  39626. };
  39627. ;
  39628. ConnectionManager.prototype.isUsingTLS = function () {
  39629. return this.usingTLS;
  39630. };
  39631. ;
  39632. ConnectionManager.prototype.startConnecting = function () {
  39633. var _this = this;
  39634. var callback = function (error, handshake) {
  39635. if (error) {
  39636. _this.runner = _this.strategy.connect(0, callback);
  39637. }
  39638. else {
  39639. if (handshake.action === "error") {
  39640. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  39641. _this.timeline.error({ handshakeError: handshake.error });
  39642. }
  39643. else {
  39644. _this.abortConnecting();
  39645. _this.handshakeCallbacks[handshake.action](handshake);
  39646. }
  39647. }
  39648. };
  39649. this.runner = this.strategy.connect(0, callback);
  39650. };
  39651. ;
  39652. ConnectionManager.prototype.abortConnecting = function () {
  39653. if (this.runner) {
  39654. this.runner.abort();
  39655. this.runner = null;
  39656. }
  39657. };
  39658. ;
  39659. ConnectionManager.prototype.disconnectInternally = function () {
  39660. this.abortConnecting();
  39661. this.clearRetryTimer();
  39662. this.clearUnavailableTimer();
  39663. if (this.connection) {
  39664. var connection = this.abandonConnection();
  39665. connection.close();
  39666. }
  39667. };
  39668. ;
  39669. ConnectionManager.prototype.updateStrategy = function () {
  39670. this.strategy = this.options.getStrategy({
  39671. key: this.key,
  39672. timeline: this.timeline,
  39673. useTLS: this.usingTLS
  39674. });
  39675. };
  39676. ;
  39677. ConnectionManager.prototype.retryIn = function (delay) {
  39678. var _this = this;
  39679. this.timeline.info({ action: "retry", delay: delay });
  39680. if (delay > 0) {
  39681. this.emit("connecting_in", Math.round(delay / 1000));
  39682. }
  39683. this.retryTimer = new OneOffTimer(delay || 0, function () {
  39684. _this.disconnectInternally();
  39685. _this.connect();
  39686. });
  39687. };
  39688. ;
  39689. ConnectionManager.prototype.clearRetryTimer = function () {
  39690. if (this.retryTimer) {
  39691. this.retryTimer.ensureAborted();
  39692. this.retryTimer = null;
  39693. }
  39694. };
  39695. ;
  39696. ConnectionManager.prototype.setUnavailableTimer = function () {
  39697. var _this = this;
  39698. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  39699. _this.updateState("unavailable");
  39700. });
  39701. };
  39702. ;
  39703. ConnectionManager.prototype.clearUnavailableTimer = function () {
  39704. if (this.unavailableTimer) {
  39705. this.unavailableTimer.ensureAborted();
  39706. }
  39707. };
  39708. ;
  39709. ConnectionManager.prototype.sendActivityCheck = function () {
  39710. var _this = this;
  39711. this.stopActivityCheck();
  39712. this.connection.ping();
  39713. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  39714. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  39715. _this.retryIn(0);
  39716. });
  39717. };
  39718. ;
  39719. ConnectionManager.prototype.resetActivityCheck = function () {
  39720. var _this = this;
  39721. this.stopActivityCheck();
  39722. if (this.connection && !this.connection.handlesActivityChecks()) {
  39723. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  39724. _this.sendActivityCheck();
  39725. });
  39726. }
  39727. };
  39728. ;
  39729. ConnectionManager.prototype.stopActivityCheck = function () {
  39730. if (this.activityTimer) {
  39731. this.activityTimer.ensureAborted();
  39732. }
  39733. };
  39734. ;
  39735. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  39736. var _this = this;
  39737. return extend({}, errorCallbacks, {
  39738. message: function (message) {
  39739. _this.resetActivityCheck();
  39740. _this.emit('message', message);
  39741. },
  39742. ping: function () {
  39743. _this.send_event('pusher:pong', {});
  39744. },
  39745. activity: function () {
  39746. _this.resetActivityCheck();
  39747. },
  39748. error: function (error) {
  39749. _this.emit("error", { type: "WebSocketError", error: error });
  39750. },
  39751. closed: function () {
  39752. _this.abandonConnection();
  39753. if (_this.shouldRetry()) {
  39754. _this.retryIn(1000);
  39755. }
  39756. }
  39757. });
  39758. };
  39759. ;
  39760. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  39761. var _this = this;
  39762. return extend({}, errorCallbacks, {
  39763. connected: function (handshake) {
  39764. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  39765. _this.clearUnavailableTimer();
  39766. _this.setConnection(handshake.connection);
  39767. _this.socket_id = _this.connection.id;
  39768. _this.updateState("connected", { socket_id: _this.socket_id });
  39769. }
  39770. });
  39771. };
  39772. ;
  39773. ConnectionManager.prototype.buildErrorCallbacks = function () {
  39774. var _this = this;
  39775. var withErrorEmitted = function (callback) {
  39776. return function (result) {
  39777. if (result.error) {
  39778. _this.emit("error", { type: "WebSocketError", error: result.error });
  39779. }
  39780. callback(result);
  39781. };
  39782. };
  39783. return {
  39784. tls_only: withErrorEmitted(function () {
  39785. _this.usingTLS = true;
  39786. _this.updateStrategy();
  39787. _this.retryIn(0);
  39788. }),
  39789. refused: withErrorEmitted(function () {
  39790. _this.disconnect();
  39791. }),
  39792. backoff: withErrorEmitted(function () {
  39793. _this.retryIn(1000);
  39794. }),
  39795. retry: withErrorEmitted(function () {
  39796. _this.retryIn(0);
  39797. })
  39798. };
  39799. };
  39800. ;
  39801. ConnectionManager.prototype.setConnection = function (connection) {
  39802. this.connection = connection;
  39803. for (var event in this.connectionCallbacks) {
  39804. this.connection.bind(event, this.connectionCallbacks[event]);
  39805. }
  39806. this.resetActivityCheck();
  39807. };
  39808. ;
  39809. ConnectionManager.prototype.abandonConnection = function () {
  39810. if (!this.connection) {
  39811. return;
  39812. }
  39813. this.stopActivityCheck();
  39814. for (var event in this.connectionCallbacks) {
  39815. this.connection.unbind(event, this.connectionCallbacks[event]);
  39816. }
  39817. var connection = this.connection;
  39818. this.connection = null;
  39819. return connection;
  39820. };
  39821. ConnectionManager.prototype.updateState = function (newState, data) {
  39822. var previousState = this.state;
  39823. this.state = newState;
  39824. if (previousState !== newState) {
  39825. var newStateDescription = newState;
  39826. if (newStateDescription === "connected") {
  39827. newStateDescription += " with new socket ID " + data.socket_id;
  39828. }
  39829. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  39830. this.timeline.info({ state: newState, params: data });
  39831. this.emit('state_change', { previous: previousState, current: newState });
  39832. this.emit(newState, data);
  39833. }
  39834. };
  39835. ConnectionManager.prototype.shouldRetry = function () {
  39836. return this.state === "connecting" || this.state === "connected";
  39837. };
  39838. return ConnectionManager;
  39839. }(dispatcher));
  39840. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  39841. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  39842. var channels_Channels = (function () {
  39843. function Channels() {
  39844. this.channels = {};
  39845. }
  39846. Channels.prototype.add = function (name, pusher) {
  39847. if (!this.channels[name]) {
  39848. this.channels[name] = createChannel(name, pusher);
  39849. }
  39850. return this.channels[name];
  39851. };
  39852. Channels.prototype.all = function () {
  39853. return values(this.channels);
  39854. };
  39855. Channels.prototype.find = function (name) {
  39856. return this.channels[name];
  39857. };
  39858. Channels.prototype.remove = function (name) {
  39859. var channel = this.channels[name];
  39860. delete this.channels[name];
  39861. return channel;
  39862. };
  39863. Channels.prototype.disconnect = function () {
  39864. objectApply(this.channels, function (channel) {
  39865. channel.disconnect();
  39866. });
  39867. };
  39868. return Channels;
  39869. }());
  39870. /* harmony default export */ var channels = (channels_Channels);
  39871. function createChannel(name, pusher) {
  39872. if (name.indexOf('private-encrypted-') === 0) {
  39873. if (false) { var errorMsg; }
  39874. return factory.createEncryptedChannel(name, pusher);
  39875. }
  39876. else if (name.indexOf('private-') === 0) {
  39877. return factory.createPrivateChannel(name, pusher);
  39878. }
  39879. else if (name.indexOf('presence-') === 0) {
  39880. return factory.createPresenceChannel(name, pusher);
  39881. }
  39882. else {
  39883. return factory.createChannel(name, pusher);
  39884. }
  39885. }
  39886. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  39887. var Factory = {
  39888. createChannels: function () {
  39889. return new channels();
  39890. },
  39891. createConnectionManager: function (key, options) {
  39892. return new connection_manager(key, options);
  39893. },
  39894. createChannel: function (name, pusher) {
  39895. return new channels_channel(name, pusher);
  39896. },
  39897. createPrivateChannel: function (name, pusher) {
  39898. return new private_channel(name, pusher);
  39899. },
  39900. createPresenceChannel: function (name, pusher) {
  39901. return new presence_channel(name, pusher);
  39902. },
  39903. createEncryptedChannel: function (name, pusher) {
  39904. return new encrypted_channel(name, pusher);
  39905. },
  39906. createTimelineSender: function (timeline, options) {
  39907. return new timeline_sender(timeline, options);
  39908. },
  39909. createAuthorizer: function (channel, options) {
  39910. if (options.authorizer) {
  39911. return options.authorizer(channel, options);
  39912. }
  39913. return new pusher_authorizer(channel, options);
  39914. },
  39915. createHandshake: function (transport, callback) {
  39916. return new connection_handshake(transport, callback);
  39917. },
  39918. createAssistantToTheTransportManager: function (manager, transport, options) {
  39919. return new assistant_to_the_transport_manager(manager, transport, options);
  39920. }
  39921. };
  39922. /* harmony default export */ var factory = (Factory);
  39923. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  39924. var transport_manager_TransportManager = (function () {
  39925. function TransportManager(options) {
  39926. this.options = options || {};
  39927. this.livesLeft = this.options.lives || Infinity;
  39928. }
  39929. TransportManager.prototype.getAssistant = function (transport) {
  39930. return factory.createAssistantToTheTransportManager(this, transport, {
  39931. minPingDelay: this.options.minPingDelay,
  39932. maxPingDelay: this.options.maxPingDelay
  39933. });
  39934. };
  39935. TransportManager.prototype.isAlive = function () {
  39936. return this.livesLeft > 0;
  39937. };
  39938. TransportManager.prototype.reportDeath = function () {
  39939. this.livesLeft -= 1;
  39940. };
  39941. return TransportManager;
  39942. }());
  39943. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  39944. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  39945. var sequential_strategy_SequentialStrategy = (function () {
  39946. function SequentialStrategy(strategies, options) {
  39947. this.strategies = strategies;
  39948. this.loop = Boolean(options.loop);
  39949. this.failFast = Boolean(options.failFast);
  39950. this.timeout = options.timeout;
  39951. this.timeoutLimit = options.timeoutLimit;
  39952. }
  39953. SequentialStrategy.prototype.isSupported = function () {
  39954. return any(this.strategies, util.method("isSupported"));
  39955. };
  39956. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  39957. var _this = this;
  39958. var strategies = this.strategies;
  39959. var current = 0;
  39960. var timeout = this.timeout;
  39961. var runner = null;
  39962. var tryNextStrategy = function (error, handshake) {
  39963. if (handshake) {
  39964. callback(null, handshake);
  39965. }
  39966. else {
  39967. current = current + 1;
  39968. if (_this.loop) {
  39969. current = current % strategies.length;
  39970. }
  39971. if (current < strategies.length) {
  39972. if (timeout) {
  39973. timeout = timeout * 2;
  39974. if (_this.timeoutLimit) {
  39975. timeout = Math.min(timeout, _this.timeoutLimit);
  39976. }
  39977. }
  39978. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  39979. }
  39980. else {
  39981. callback(true);
  39982. }
  39983. }
  39984. };
  39985. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  39986. return {
  39987. abort: function () {
  39988. runner.abort();
  39989. },
  39990. forceMinPriority: function (p) {
  39991. minPriority = p;
  39992. if (runner) {
  39993. runner.forceMinPriority(p);
  39994. }
  39995. }
  39996. };
  39997. };
  39998. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  39999. var timer = null;
  40000. var runner = null;
  40001. if (options.timeout > 0) {
  40002. timer = new OneOffTimer(options.timeout, function () {
  40003. runner.abort();
  40004. callback(true);
  40005. });
  40006. }
  40007. runner = strategy.connect(minPriority, function (error, handshake) {
  40008. if (error && timer && timer.isRunning() && !options.failFast) {
  40009. return;
  40010. }
  40011. if (timer) {
  40012. timer.ensureAborted();
  40013. }
  40014. callback(error, handshake);
  40015. });
  40016. return {
  40017. abort: function () {
  40018. if (timer) {
  40019. timer.ensureAborted();
  40020. }
  40021. runner.abort();
  40022. },
  40023. forceMinPriority: function (p) {
  40024. runner.forceMinPriority(p);
  40025. }
  40026. };
  40027. };
  40028. return SequentialStrategy;
  40029. }());
  40030. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40031. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40032. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40033. function BestConnectedEverStrategy(strategies) {
  40034. this.strategies = strategies;
  40035. }
  40036. BestConnectedEverStrategy.prototype.isSupported = function () {
  40037. return any(this.strategies, util.method("isSupported"));
  40038. };
  40039. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40040. return connect(this.strategies, minPriority, function (i, runners) {
  40041. return function (error, handshake) {
  40042. runners[i].error = error;
  40043. if (error) {
  40044. if (allRunnersFailed(runners)) {
  40045. callback(true);
  40046. }
  40047. return;
  40048. }
  40049. apply(runners, function (runner) {
  40050. runner.forceMinPriority(handshake.transport.priority);
  40051. });
  40052. callback(null, handshake);
  40053. };
  40054. });
  40055. };
  40056. return BestConnectedEverStrategy;
  40057. }());
  40058. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40059. function connect(strategies, minPriority, callbackBuilder) {
  40060. var runners = map(strategies, function (strategy, i, _, rs) {
  40061. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40062. });
  40063. return {
  40064. abort: function () {
  40065. apply(runners, abortRunner);
  40066. },
  40067. forceMinPriority: function (p) {
  40068. apply(runners, function (runner) {
  40069. runner.forceMinPriority(p);
  40070. });
  40071. }
  40072. };
  40073. }
  40074. function allRunnersFailed(runners) {
  40075. return collections_all(runners, function (runner) {
  40076. return Boolean(runner.error);
  40077. });
  40078. }
  40079. function abortRunner(runner) {
  40080. if (!runner.error && !runner.aborted) {
  40081. runner.abort();
  40082. runner.aborted = true;
  40083. }
  40084. }
  40085. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  40086. var cached_strategy_CachedStrategy = (function () {
  40087. function CachedStrategy(strategy, transports, options) {
  40088. this.strategy = strategy;
  40089. this.transports = transports;
  40090. this.ttl = options.ttl || 1800 * 1000;
  40091. this.usingTLS = options.useTLS;
  40092. this.timeline = options.timeline;
  40093. }
  40094. CachedStrategy.prototype.isSupported = function () {
  40095. return this.strategy.isSupported();
  40096. };
  40097. CachedStrategy.prototype.connect = function (minPriority, callback) {
  40098. var usingTLS = this.usingTLS;
  40099. var info = fetchTransportCache(usingTLS);
  40100. var strategies = [this.strategy];
  40101. if (info && info.timestamp + this.ttl >= util.now()) {
  40102. var transport = this.transports[info.transport];
  40103. if (transport) {
  40104. this.timeline.info({
  40105. cached: true,
  40106. transport: info.transport,
  40107. latency: info.latency
  40108. });
  40109. strategies.push(new sequential_strategy([transport], {
  40110. timeout: info.latency * 2 + 1000,
  40111. failFast: true
  40112. }));
  40113. }
  40114. }
  40115. var startTimestamp = util.now();
  40116. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  40117. if (error) {
  40118. flushTransportCache(usingTLS);
  40119. if (strategies.length > 0) {
  40120. startTimestamp = util.now();
  40121. runner = strategies.pop().connect(minPriority, cb);
  40122. }
  40123. else {
  40124. callback(error);
  40125. }
  40126. }
  40127. else {
  40128. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  40129. callback(null, handshake);
  40130. }
  40131. });
  40132. return {
  40133. abort: function () {
  40134. runner.abort();
  40135. },
  40136. forceMinPriority: function (p) {
  40137. minPriority = p;
  40138. if (runner) {
  40139. runner.forceMinPriority(p);
  40140. }
  40141. }
  40142. };
  40143. };
  40144. return CachedStrategy;
  40145. }());
  40146. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  40147. function getTransportCacheKey(usingTLS) {
  40148. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  40149. }
  40150. function fetchTransportCache(usingTLS) {
  40151. var storage = runtime.getLocalStorage();
  40152. if (storage) {
  40153. try {
  40154. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  40155. if (serializedCache) {
  40156. return JSON.parse(serializedCache);
  40157. }
  40158. }
  40159. catch (e) {
  40160. flushTransportCache(usingTLS);
  40161. }
  40162. }
  40163. return null;
  40164. }
  40165. function storeTransportCache(usingTLS, transport, latency) {
  40166. var storage = runtime.getLocalStorage();
  40167. if (storage) {
  40168. try {
  40169. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  40170. timestamp: util.now(),
  40171. transport: transport,
  40172. latency: latency
  40173. });
  40174. }
  40175. catch (e) {
  40176. }
  40177. }
  40178. }
  40179. function flushTransportCache(usingTLS) {
  40180. var storage = runtime.getLocalStorage();
  40181. if (storage) {
  40182. try {
  40183. delete storage[getTransportCacheKey(usingTLS)];
  40184. }
  40185. catch (e) {
  40186. }
  40187. }
  40188. }
  40189. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  40190. var delayed_strategy_DelayedStrategy = (function () {
  40191. function DelayedStrategy(strategy, _a) {
  40192. var number = _a.delay;
  40193. this.strategy = strategy;
  40194. this.options = { delay: number };
  40195. }
  40196. DelayedStrategy.prototype.isSupported = function () {
  40197. return this.strategy.isSupported();
  40198. };
  40199. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  40200. var strategy = this.strategy;
  40201. var runner;
  40202. var timer = new OneOffTimer(this.options.delay, function () {
  40203. runner = strategy.connect(minPriority, callback);
  40204. });
  40205. return {
  40206. abort: function () {
  40207. timer.ensureAborted();
  40208. if (runner) {
  40209. runner.abort();
  40210. }
  40211. },
  40212. forceMinPriority: function (p) {
  40213. minPriority = p;
  40214. if (runner) {
  40215. runner.forceMinPriority(p);
  40216. }
  40217. }
  40218. };
  40219. };
  40220. return DelayedStrategy;
  40221. }());
  40222. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  40223. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  40224. var IfStrategy = (function () {
  40225. function IfStrategy(test, trueBranch, falseBranch) {
  40226. this.test = test;
  40227. this.trueBranch = trueBranch;
  40228. this.falseBranch = falseBranch;
  40229. }
  40230. IfStrategy.prototype.isSupported = function () {
  40231. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40232. return branch.isSupported();
  40233. };
  40234. IfStrategy.prototype.connect = function (minPriority, callback) {
  40235. var branch = this.test() ? this.trueBranch : this.falseBranch;
  40236. return branch.connect(minPriority, callback);
  40237. };
  40238. return IfStrategy;
  40239. }());
  40240. /* harmony default export */ var if_strategy = (IfStrategy);
  40241. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  40242. var FirstConnectedStrategy = (function () {
  40243. function FirstConnectedStrategy(strategy) {
  40244. this.strategy = strategy;
  40245. }
  40246. FirstConnectedStrategy.prototype.isSupported = function () {
  40247. return this.strategy.isSupported();
  40248. };
  40249. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  40250. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  40251. if (handshake) {
  40252. runner.abort();
  40253. }
  40254. callback(error, handshake);
  40255. });
  40256. return runner;
  40257. };
  40258. return FirstConnectedStrategy;
  40259. }());
  40260. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  40261. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  40262. function testSupportsStrategy(strategy) {
  40263. return function () {
  40264. return strategy.isSupported();
  40265. };
  40266. }
  40267. var getDefaultStrategy = function (config, defineTransport) {
  40268. var definedTransports = {};
  40269. function defineTransportStrategy(name, type, priority, options, manager) {
  40270. var transport = defineTransport(config, name, type, priority, options, manager);
  40271. definedTransports[name] = transport;
  40272. return transport;
  40273. }
  40274. var ws_options = {
  40275. hostNonTLS: config.wsHost + ":" + config.wsPort,
  40276. hostTLS: config.wsHost + ":" + config.wssPort,
  40277. httpPath: config.wsPath
  40278. };
  40279. var wss_options = extend({}, ws_options, {
  40280. useTLS: true
  40281. });
  40282. var sockjs_options = {
  40283. hostNonTLS: config.httpHost + ":" + config.httpPort,
  40284. hostTLS: config.httpHost + ":" + config.httpsPort,
  40285. httpPath: config.httpPath
  40286. };
  40287. var timeouts = {
  40288. loop: true,
  40289. timeout: 15000,
  40290. timeoutLimit: 60000
  40291. };
  40292. var ws_manager = new transport_manager({
  40293. lives: 2,
  40294. minPingDelay: 10000,
  40295. maxPingDelay: config.activity_timeout
  40296. });
  40297. var streaming_manager = new transport_manager({
  40298. lives: 2,
  40299. minPingDelay: 10000,
  40300. maxPingDelay: config.activity_timeout
  40301. });
  40302. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  40303. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  40304. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  40305. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  40306. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  40307. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  40308. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  40309. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  40310. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  40311. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  40312. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  40313. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  40314. var http_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(streaming_loop), new best_connected_ever_strategy([streaming_loop, new delayed_strategy(polling_loop, { delay: 4000 })]), polling_loop)], timeouts);
  40315. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  40316. var wsStrategy;
  40317. if (config.useTLS) {
  40318. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  40319. }
  40320. else {
  40321. wsStrategy = new best_connected_ever_strategy([
  40322. ws_loop,
  40323. new delayed_strategy(wss_loop, { delay: 2000 }),
  40324. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  40325. ]);
  40326. }
  40327. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  40328. ttl: 1800000,
  40329. timeline: config.timeline,
  40330. useTLS: config.useTLS
  40331. });
  40332. };
  40333. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  40334. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  40335. /* harmony default export */ var transport_connection_initializer = (function () {
  40336. var self = this;
  40337. self.timeline.info(self.buildTimelineMessage({
  40338. transport: self.name + (self.options.useTLS ? "s" : "")
  40339. }));
  40340. if (self.hooks.isInitialized()) {
  40341. self.changeState("initialized");
  40342. }
  40343. else if (self.hooks.file) {
  40344. self.changeState("initializing");
  40345. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  40346. if (self.hooks.isInitialized()) {
  40347. self.changeState("initialized");
  40348. callback(true);
  40349. }
  40350. else {
  40351. if (error) {
  40352. self.onError(error);
  40353. }
  40354. self.onClose();
  40355. callback(false);
  40356. }
  40357. });
  40358. }
  40359. else {
  40360. self.onClose();
  40361. }
  40362. });
  40363. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  40364. var http_xdomain_request_hooks = {
  40365. getRequest: function (socket) {
  40366. var xdr = new window.XDomainRequest();
  40367. xdr.ontimeout = function () {
  40368. socket.emit("error", new RequestTimedOut());
  40369. socket.close();
  40370. };
  40371. xdr.onerror = function (e) {
  40372. socket.emit("error", e);
  40373. socket.close();
  40374. };
  40375. xdr.onprogress = function () {
  40376. if (xdr.responseText && xdr.responseText.length > 0) {
  40377. socket.onChunk(200, xdr.responseText);
  40378. }
  40379. };
  40380. xdr.onload = function () {
  40381. if (xdr.responseText && xdr.responseText.length > 0) {
  40382. socket.onChunk(200, xdr.responseText);
  40383. }
  40384. socket.emit("finished", 200);
  40385. socket.close();
  40386. };
  40387. return xdr;
  40388. },
  40389. abortRequest: function (xdr) {
  40390. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  40391. xdr.abort();
  40392. }
  40393. };
  40394. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  40395. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  40396. var http_request_extends = (undefined && undefined.__extends) || (function () {
  40397. var extendStatics = function (d, b) {
  40398. extendStatics = Object.setPrototypeOf ||
  40399. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40400. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40401. return extendStatics(d, b);
  40402. };
  40403. return function (d, b) {
  40404. extendStatics(d, b);
  40405. function __() { this.constructor = d; }
  40406. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40407. };
  40408. })();
  40409. var MAX_BUFFER_LENGTH = 256 * 1024;
  40410. var http_request_HTTPRequest = (function (_super) {
  40411. http_request_extends(HTTPRequest, _super);
  40412. function HTTPRequest(hooks, method, url) {
  40413. var _this = _super.call(this) || this;
  40414. _this.hooks = hooks;
  40415. _this.method = method;
  40416. _this.url = url;
  40417. return _this;
  40418. }
  40419. HTTPRequest.prototype.start = function (payload) {
  40420. var _this = this;
  40421. this.position = 0;
  40422. this.xhr = this.hooks.getRequest(this);
  40423. this.unloader = function () {
  40424. _this.close();
  40425. };
  40426. runtime.addUnloadListener(this.unloader);
  40427. this.xhr.open(this.method, this.url, true);
  40428. if (this.xhr.setRequestHeader) {
  40429. this.xhr.setRequestHeader("Content-Type", "application/json");
  40430. }
  40431. this.xhr.send(payload);
  40432. };
  40433. HTTPRequest.prototype.close = function () {
  40434. if (this.unloader) {
  40435. runtime.removeUnloadListener(this.unloader);
  40436. this.unloader = null;
  40437. }
  40438. if (this.xhr) {
  40439. this.hooks.abortRequest(this.xhr);
  40440. this.xhr = null;
  40441. }
  40442. };
  40443. HTTPRequest.prototype.onChunk = function (status, data) {
  40444. while (true) {
  40445. var chunk = this.advanceBuffer(data);
  40446. if (chunk) {
  40447. this.emit("chunk", { status: status, data: chunk });
  40448. }
  40449. else {
  40450. break;
  40451. }
  40452. }
  40453. if (this.isBufferTooLong(data)) {
  40454. this.emit("buffer_too_long");
  40455. }
  40456. };
  40457. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  40458. var unreadData = buffer.slice(this.position);
  40459. var endOfLinePosition = unreadData.indexOf("\n");
  40460. if (endOfLinePosition !== -1) {
  40461. this.position += endOfLinePosition + 1;
  40462. return unreadData.slice(0, endOfLinePosition);
  40463. }
  40464. else {
  40465. return null;
  40466. }
  40467. };
  40468. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  40469. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  40470. };
  40471. return HTTPRequest;
  40472. }(dispatcher));
  40473. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  40474. // CONCATENATED MODULE: ./src/core/http/state.ts
  40475. var State;
  40476. (function (State) {
  40477. State[State["CONNECTING"] = 0] = "CONNECTING";
  40478. State[State["OPEN"] = 1] = "OPEN";
  40479. State[State["CLOSED"] = 3] = "CLOSED";
  40480. })(State || (State = {}));
  40481. /* harmony default export */ var state = (State);
  40482. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  40483. var autoIncrement = 1;
  40484. var http_socket_HTTPSocket = (function () {
  40485. function HTTPSocket(hooks, url) {
  40486. this.hooks = hooks;
  40487. this.session = randomNumber(1000) + "/" + randomString(8);
  40488. this.location = getLocation(url);
  40489. this.readyState = state.CONNECTING;
  40490. this.openStream();
  40491. }
  40492. HTTPSocket.prototype.send = function (payload) {
  40493. return this.sendRaw(JSON.stringify([payload]));
  40494. };
  40495. HTTPSocket.prototype.ping = function () {
  40496. this.hooks.sendHeartbeat(this);
  40497. };
  40498. HTTPSocket.prototype.close = function (code, reason) {
  40499. this.onClose(code, reason, true);
  40500. };
  40501. HTTPSocket.prototype.sendRaw = function (payload) {
  40502. if (this.readyState === state.OPEN) {
  40503. try {
  40504. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  40505. return true;
  40506. }
  40507. catch (e) {
  40508. return false;
  40509. }
  40510. }
  40511. else {
  40512. return false;
  40513. }
  40514. };
  40515. HTTPSocket.prototype.reconnect = function () {
  40516. this.closeStream();
  40517. this.openStream();
  40518. };
  40519. ;
  40520. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  40521. this.closeStream();
  40522. this.readyState = state.CLOSED;
  40523. if (this.onclose) {
  40524. this.onclose({
  40525. code: code,
  40526. reason: reason,
  40527. wasClean: wasClean
  40528. });
  40529. }
  40530. };
  40531. HTTPSocket.prototype.onChunk = function (chunk) {
  40532. if (chunk.status !== 200) {
  40533. return;
  40534. }
  40535. if (this.readyState === state.OPEN) {
  40536. this.onActivity();
  40537. }
  40538. var payload;
  40539. var type = chunk.data.slice(0, 1);
  40540. switch (type) {
  40541. case 'o':
  40542. payload = JSON.parse(chunk.data.slice(1) || '{}');
  40543. this.onOpen(payload);
  40544. break;
  40545. case 'a':
  40546. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40547. for (var i = 0; i < payload.length; i++) {
  40548. this.onEvent(payload[i]);
  40549. }
  40550. break;
  40551. case 'm':
  40552. payload = JSON.parse(chunk.data.slice(1) || 'null');
  40553. this.onEvent(payload);
  40554. break;
  40555. case 'h':
  40556. this.hooks.onHeartbeat(this);
  40557. break;
  40558. case 'c':
  40559. payload = JSON.parse(chunk.data.slice(1) || '[]');
  40560. this.onClose(payload[0], payload[1], true);
  40561. break;
  40562. }
  40563. };
  40564. HTTPSocket.prototype.onOpen = function (options) {
  40565. if (this.readyState === state.CONNECTING) {
  40566. if (options && options.hostname) {
  40567. this.location.base = replaceHost(this.location.base, options.hostname);
  40568. }
  40569. this.readyState = state.OPEN;
  40570. if (this.onopen) {
  40571. this.onopen();
  40572. }
  40573. }
  40574. else {
  40575. this.onClose(1006, "Server lost session", true);
  40576. }
  40577. };
  40578. HTTPSocket.prototype.onEvent = function (event) {
  40579. if (this.readyState === state.OPEN && this.onmessage) {
  40580. this.onmessage({ data: event });
  40581. }
  40582. };
  40583. HTTPSocket.prototype.onActivity = function () {
  40584. if (this.onactivity) {
  40585. this.onactivity();
  40586. }
  40587. };
  40588. HTTPSocket.prototype.onError = function (error) {
  40589. if (this.onerror) {
  40590. this.onerror(error);
  40591. }
  40592. };
  40593. HTTPSocket.prototype.openStream = function () {
  40594. var _this = this;
  40595. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  40596. this.stream.bind("chunk", function (chunk) {
  40597. _this.onChunk(chunk);
  40598. });
  40599. this.stream.bind("finished", function (status) {
  40600. _this.hooks.onFinished(_this, status);
  40601. });
  40602. this.stream.bind("buffer_too_long", function () {
  40603. _this.reconnect();
  40604. });
  40605. try {
  40606. this.stream.start();
  40607. }
  40608. catch (error) {
  40609. util.defer(function () {
  40610. _this.onError(error);
  40611. _this.onClose(1006, "Could not start streaming", false);
  40612. });
  40613. }
  40614. };
  40615. HTTPSocket.prototype.closeStream = function () {
  40616. if (this.stream) {
  40617. this.stream.unbind_all();
  40618. this.stream.close();
  40619. this.stream = null;
  40620. }
  40621. };
  40622. return HTTPSocket;
  40623. }());
  40624. function getLocation(url) {
  40625. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  40626. return {
  40627. base: parts[1],
  40628. queryString: parts[2]
  40629. };
  40630. }
  40631. function getSendURL(url, session) {
  40632. return url.base + "/" + session + "/xhr_send";
  40633. }
  40634. function getUniqueURL(url) {
  40635. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  40636. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  40637. }
  40638. function replaceHost(url, hostname) {
  40639. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  40640. return urlParts[1] + hostname + urlParts[3];
  40641. }
  40642. function randomNumber(max) {
  40643. return Math.floor(Math.random() * max);
  40644. }
  40645. function randomString(length) {
  40646. var result = [];
  40647. for (var i = 0; i < length; i++) {
  40648. result.push(randomNumber(32).toString(32));
  40649. }
  40650. return result.join('');
  40651. }
  40652. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  40653. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  40654. var http_streaming_socket_hooks = {
  40655. getReceiveURL: function (url, session) {
  40656. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  40657. },
  40658. onHeartbeat: function (socket) {
  40659. socket.sendRaw("[]");
  40660. },
  40661. sendHeartbeat: function (socket) {
  40662. socket.sendRaw("[]");
  40663. },
  40664. onFinished: function (socket, status) {
  40665. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40666. }
  40667. };
  40668. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  40669. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  40670. var http_polling_socket_hooks = {
  40671. getReceiveURL: function (url, session) {
  40672. return url.base + "/" + session + "/xhr" + url.queryString;
  40673. },
  40674. onHeartbeat: function () {
  40675. },
  40676. sendHeartbeat: function (socket) {
  40677. socket.sendRaw("[]");
  40678. },
  40679. onFinished: function (socket, status) {
  40680. if (status === 200) {
  40681. socket.reconnect();
  40682. }
  40683. else {
  40684. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  40685. }
  40686. }
  40687. };
  40688. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  40689. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  40690. var http_xhr_request_hooks = {
  40691. getRequest: function (socket) {
  40692. var Constructor = runtime.getXHRAPI();
  40693. var xhr = new Constructor();
  40694. xhr.onreadystatechange = xhr.onprogress = function () {
  40695. switch (xhr.readyState) {
  40696. case 3:
  40697. if (xhr.responseText && xhr.responseText.length > 0) {
  40698. socket.onChunk(xhr.status, xhr.responseText);
  40699. }
  40700. break;
  40701. case 4:
  40702. if (xhr.responseText && xhr.responseText.length > 0) {
  40703. socket.onChunk(xhr.status, xhr.responseText);
  40704. }
  40705. socket.emit("finished", xhr.status);
  40706. socket.close();
  40707. break;
  40708. }
  40709. };
  40710. return xhr;
  40711. },
  40712. abortRequest: function (xhr) {
  40713. xhr.onreadystatechange = null;
  40714. xhr.abort();
  40715. }
  40716. };
  40717. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  40718. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  40719. var HTTP = {
  40720. createStreamingSocket: function (url) {
  40721. return this.createSocket(http_streaming_socket, url);
  40722. },
  40723. createPollingSocket: function (url) {
  40724. return this.createSocket(http_polling_socket, url);
  40725. },
  40726. createSocket: function (hooks, url) {
  40727. return new http_socket(hooks, url);
  40728. },
  40729. createXHR: function (method, url) {
  40730. return this.createRequest(http_xhr_request, method, url);
  40731. },
  40732. createRequest: function (hooks, method, url) {
  40733. return new http_request(hooks, method, url);
  40734. }
  40735. };
  40736. /* harmony default export */ var http_http = (HTTP);
  40737. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  40738. http_http.createXDR = function (method, url) {
  40739. return this.createRequest(http_xdomain_request, method, url);
  40740. };
  40741. /* harmony default export */ var web_http_http = (http_http);
  40742. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  40743. var Runtime = {
  40744. nextAuthCallbackID: 1,
  40745. auth_callbacks: {},
  40746. ScriptReceivers: ScriptReceivers,
  40747. DependenciesReceivers: DependenciesReceivers,
  40748. getDefaultStrategy: default_strategy,
  40749. Transports: transports_transports,
  40750. transportConnectionInitializer: transport_connection_initializer,
  40751. HTTPFactory: web_http_http,
  40752. TimelineTransport: jsonp_timeline,
  40753. getXHRAPI: function () {
  40754. return window.XMLHttpRequest;
  40755. },
  40756. getWebSocketAPI: function () {
  40757. return window.WebSocket || window.MozWebSocket;
  40758. },
  40759. setup: function (PusherClass) {
  40760. var _this = this;
  40761. window.Pusher = PusherClass;
  40762. var initializeOnDocumentBody = function () {
  40763. _this.onDocumentBody(PusherClass.ready);
  40764. };
  40765. if (!window.JSON) {
  40766. Dependencies.load("json2", {}, initializeOnDocumentBody);
  40767. }
  40768. else {
  40769. initializeOnDocumentBody();
  40770. }
  40771. },
  40772. getDocument: function () {
  40773. return document;
  40774. },
  40775. getProtocol: function () {
  40776. return this.getDocument().location.protocol;
  40777. },
  40778. getAuthorizers: function () {
  40779. return { ajax: xhr_auth, jsonp: jsonp_auth };
  40780. },
  40781. onDocumentBody: function (callback) {
  40782. var _this = this;
  40783. if (document.body) {
  40784. callback();
  40785. }
  40786. else {
  40787. setTimeout(function () {
  40788. _this.onDocumentBody(callback);
  40789. }, 0);
  40790. }
  40791. },
  40792. createJSONPRequest: function (url, data) {
  40793. return new jsonp_request(url, data);
  40794. },
  40795. createScriptRequest: function (src) {
  40796. return new script_request(src);
  40797. },
  40798. getLocalStorage: function () {
  40799. try {
  40800. return window.localStorage;
  40801. }
  40802. catch (e) {
  40803. return undefined;
  40804. }
  40805. },
  40806. createXHR: function () {
  40807. if (this.getXHRAPI()) {
  40808. return this.createXMLHttpRequest();
  40809. }
  40810. else {
  40811. return this.createMicrosoftXHR();
  40812. }
  40813. },
  40814. createXMLHttpRequest: function () {
  40815. var Constructor = this.getXHRAPI();
  40816. return new Constructor();
  40817. },
  40818. createMicrosoftXHR: function () {
  40819. return new ActiveXObject("Microsoft.XMLHTTP");
  40820. },
  40821. getNetwork: function () {
  40822. return net_info_Network;
  40823. },
  40824. createWebSocket: function (url) {
  40825. var Constructor = this.getWebSocketAPI();
  40826. return new Constructor(url);
  40827. },
  40828. createSocketRequest: function (method, url) {
  40829. if (this.isXHRSupported()) {
  40830. return this.HTTPFactory.createXHR(method, url);
  40831. }
  40832. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  40833. return this.HTTPFactory.createXDR(method, url);
  40834. }
  40835. else {
  40836. throw "Cross-origin HTTP requests are not supported";
  40837. }
  40838. },
  40839. isXHRSupported: function () {
  40840. var Constructor = this.getXHRAPI();
  40841. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  40842. },
  40843. isXDRSupported: function (useTLS) {
  40844. var protocol = useTLS ? "https:" : "http:";
  40845. var documentProtocol = this.getProtocol();
  40846. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  40847. },
  40848. addUnloadListener: function (listener) {
  40849. if (window.addEventListener !== undefined) {
  40850. window.addEventListener("unload", listener, false);
  40851. }
  40852. else if (window.attachEvent !== undefined) {
  40853. window.attachEvent("onunload", listener);
  40854. }
  40855. },
  40856. removeUnloadListener: function (listener) {
  40857. if (window.addEventListener !== undefined) {
  40858. window.removeEventListener("unload", listener, false);
  40859. }
  40860. else if (window.detachEvent !== undefined) {
  40861. window.detachEvent("onunload", listener);
  40862. }
  40863. }
  40864. };
  40865. /* harmony default export */ var runtime = (Runtime);
  40866. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  40867. var TimelineLevel;
  40868. (function (TimelineLevel) {
  40869. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  40870. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  40871. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  40872. })(TimelineLevel || (TimelineLevel = {}));
  40873. /* harmony default export */ var timeline_level = (TimelineLevel);
  40874. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  40875. var timeline_Timeline = (function () {
  40876. function Timeline(key, session, options) {
  40877. this.key = key;
  40878. this.session = session;
  40879. this.events = [];
  40880. this.options = options || {};
  40881. this.sent = 0;
  40882. this.uniqueID = 0;
  40883. }
  40884. Timeline.prototype.log = function (level, event) {
  40885. if (level <= this.options.level) {
  40886. this.events.push(extend({}, event, { timestamp: util.now() }));
  40887. if (this.options.limit && this.events.length > this.options.limit) {
  40888. this.events.shift();
  40889. }
  40890. }
  40891. };
  40892. Timeline.prototype.error = function (event) {
  40893. this.log(timeline_level.ERROR, event);
  40894. };
  40895. Timeline.prototype.info = function (event) {
  40896. this.log(timeline_level.INFO, event);
  40897. };
  40898. Timeline.prototype.debug = function (event) {
  40899. this.log(timeline_level.DEBUG, event);
  40900. };
  40901. Timeline.prototype.isEmpty = function () {
  40902. return this.events.length === 0;
  40903. };
  40904. Timeline.prototype.send = function (sendfn, callback) {
  40905. var _this = this;
  40906. var data = extend({
  40907. session: this.session,
  40908. bundle: this.sent + 1,
  40909. key: this.key,
  40910. lib: "js",
  40911. version: this.options.version,
  40912. cluster: this.options.cluster,
  40913. features: this.options.features,
  40914. timeline: this.events
  40915. }, this.options.params);
  40916. this.events = [];
  40917. sendfn(data, function (error, result) {
  40918. if (!error) {
  40919. _this.sent++;
  40920. }
  40921. if (callback) {
  40922. callback(error, result);
  40923. }
  40924. });
  40925. return true;
  40926. };
  40927. Timeline.prototype.generateUniqueID = function () {
  40928. this.uniqueID++;
  40929. return this.uniqueID;
  40930. };
  40931. return Timeline;
  40932. }());
  40933. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  40934. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  40935. var transport_strategy_TransportStrategy = (function () {
  40936. function TransportStrategy(name, priority, transport, options) {
  40937. this.name = name;
  40938. this.priority = priority;
  40939. this.transport = transport;
  40940. this.options = options || {};
  40941. }
  40942. TransportStrategy.prototype.isSupported = function () {
  40943. return this.transport.isSupported({
  40944. useTLS: this.options.useTLS
  40945. });
  40946. };
  40947. TransportStrategy.prototype.connect = function (minPriority, callback) {
  40948. var _this = this;
  40949. if (!this.isSupported()) {
  40950. return failAttempt(new UnsupportedStrategy(), callback);
  40951. }
  40952. else if (this.priority < minPriority) {
  40953. return failAttempt(new TransportPriorityTooLow(), callback);
  40954. }
  40955. var connected = false;
  40956. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  40957. var handshake = null;
  40958. var onInitialized = function () {
  40959. transport.unbind("initialized", onInitialized);
  40960. transport.connect();
  40961. };
  40962. var onOpen = function () {
  40963. handshake = factory.createHandshake(transport, function (result) {
  40964. connected = true;
  40965. unbindListeners();
  40966. callback(null, result);
  40967. });
  40968. };
  40969. var onError = function (error) {
  40970. unbindListeners();
  40971. callback(error);
  40972. };
  40973. var onClosed = function () {
  40974. unbindListeners();
  40975. var serializedTransport;
  40976. serializedTransport = safeJSONStringify(transport);
  40977. callback(new TransportClosed(serializedTransport));
  40978. };
  40979. var unbindListeners = function () {
  40980. transport.unbind("initialized", onInitialized);
  40981. transport.unbind("open", onOpen);
  40982. transport.unbind("error", onError);
  40983. transport.unbind("closed", onClosed);
  40984. };
  40985. transport.bind("initialized", onInitialized);
  40986. transport.bind("open", onOpen);
  40987. transport.bind("error", onError);
  40988. transport.bind("closed", onClosed);
  40989. transport.initialize();
  40990. return {
  40991. abort: function () {
  40992. if (connected) {
  40993. return;
  40994. }
  40995. unbindListeners();
  40996. if (handshake) {
  40997. handshake.close();
  40998. }
  40999. else {
  41000. transport.close();
  41001. }
  41002. },
  41003. forceMinPriority: function (p) {
  41004. if (connected) {
  41005. return;
  41006. }
  41007. if (_this.priority < p) {
  41008. if (handshake) {
  41009. handshake.close();
  41010. }
  41011. else {
  41012. transport.close();
  41013. }
  41014. }
  41015. }
  41016. };
  41017. };
  41018. return TransportStrategy;
  41019. }());
  41020. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41021. function failAttempt(error, callback) {
  41022. util.defer(function () {
  41023. callback(error);
  41024. });
  41025. return {
  41026. abort: function () { },
  41027. forceMinPriority: function () { }
  41028. };
  41029. }
  41030. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41031. var strategy_builder_Transports = runtime.Transports;
  41032. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41033. var transportClass = strategy_builder_Transports[type];
  41034. if (!transportClass) {
  41035. throw new UnsupportedTransport(type);
  41036. }
  41037. var enabled = (!config.enabledTransports ||
  41038. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41039. (!config.disabledTransports ||
  41040. arrayIndexOf(config.disabledTransports, name) === -1);
  41041. var transport;
  41042. if (enabled) {
  41043. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41044. key: config.key,
  41045. useTLS: config.useTLS,
  41046. timeline: config.timeline,
  41047. ignoreNullOrigin: config.ignoreNullOrigin
  41048. }, options));
  41049. }
  41050. else {
  41051. transport = strategy_builder_UnsupportedStrategy;
  41052. }
  41053. return transport;
  41054. };
  41055. var strategy_builder_UnsupportedStrategy = {
  41056. isSupported: function () {
  41057. return false;
  41058. },
  41059. connect: function (_, callback) {
  41060. var deferred = util.defer(function () {
  41061. callback(new UnsupportedStrategy());
  41062. });
  41063. return {
  41064. abort: function () {
  41065. deferred.ensureAborted();
  41066. },
  41067. forceMinPriority: function () { }
  41068. };
  41069. }
  41070. };
  41071. // CONCATENATED MODULE: ./src/core/config.ts
  41072. var getGlobalConfig = function () {
  41073. return {
  41074. wsHost: defaults.host,
  41075. wsPort: defaults.ws_port,
  41076. wssPort: defaults.wss_port,
  41077. wsPath: defaults.ws_path,
  41078. httpHost: defaults.sockjs_host,
  41079. httpPort: defaults.sockjs_http_port,
  41080. httpsPort: defaults.sockjs_https_port,
  41081. httpPath: defaults.sockjs_path,
  41082. statsHost: defaults.stats_host,
  41083. authEndpoint: defaults.channel_auth_endpoint,
  41084. authTransport: defaults.channel_auth_transport,
  41085. activity_timeout: defaults.activity_timeout,
  41086. pong_timeout: defaults.pong_timeout,
  41087. unavailable_timeout: defaults.unavailable_timeout
  41088. };
  41089. };
  41090. var getClusterConfig = function (clusterName) {
  41091. return {
  41092. wsHost: 'ws-' + clusterName + '.pusher.com',
  41093. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  41094. };
  41095. };
  41096. // CONCATENATED MODULE: ./src/core/pusher.ts
  41097. var pusher_Pusher = (function () {
  41098. function Pusher(app_key, options) {
  41099. var _this = this;
  41100. checkAppKey(app_key);
  41101. options = options || {};
  41102. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  41103. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  41104. logger.warn("You should always specify a cluster when connecting. " + suffix);
  41105. }
  41106. this.key = app_key;
  41107. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  41108. this.channels = factory.createChannels();
  41109. this.global_emitter = new dispatcher();
  41110. this.sessionID = Math.floor(Math.random() * 1000000000);
  41111. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  41112. cluster: this.config.cluster,
  41113. features: Pusher.getClientFeatures(),
  41114. params: this.config.timelineParams || {},
  41115. limit: 50,
  41116. level: timeline_level.INFO,
  41117. version: defaults.VERSION
  41118. });
  41119. if (!this.config.disableStats) {
  41120. this.timelineSender = factory.createTimelineSender(this.timeline, {
  41121. host: this.config.statsHost,
  41122. path: '/timeline/v2/' + runtime.TimelineTransport.name
  41123. });
  41124. }
  41125. var getStrategy = function (options) {
  41126. var config = extend({}, _this.config, options);
  41127. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  41128. };
  41129. this.connection = factory.createConnectionManager(this.key, extend({
  41130. getStrategy: getStrategy,
  41131. timeline: this.timeline,
  41132. activityTimeout: this.config.activity_timeout,
  41133. pongTimeout: this.config.pong_timeout,
  41134. unavailableTimeout: this.config.unavailable_timeout
  41135. }, this.config, { useTLS: this.shouldUseTLS() }));
  41136. this.connection.bind('connected', function () {
  41137. _this.subscribeAll();
  41138. if (_this.timelineSender) {
  41139. _this.timelineSender.send(_this.connection.isUsingTLS());
  41140. }
  41141. });
  41142. this.connection.bind('message', function (event) {
  41143. var eventName = event.event;
  41144. var internal = eventName.indexOf('pusher_internal:') === 0;
  41145. if (event.channel) {
  41146. var channel = _this.channel(event.channel);
  41147. if (channel) {
  41148. channel.handleEvent(event);
  41149. }
  41150. }
  41151. if (!internal) {
  41152. _this.global_emitter.emit(event.event, event.data);
  41153. }
  41154. });
  41155. this.connection.bind('connecting', function () {
  41156. _this.channels.disconnect();
  41157. });
  41158. this.connection.bind('disconnected', function () {
  41159. _this.channels.disconnect();
  41160. });
  41161. this.connection.bind('error', function (err) {
  41162. logger.warn(err);
  41163. });
  41164. Pusher.instances.push(this);
  41165. this.timeline.info({ instances: Pusher.instances.length });
  41166. if (Pusher.isReady) {
  41167. this.connect();
  41168. }
  41169. }
  41170. Pusher.ready = function () {
  41171. Pusher.isReady = true;
  41172. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  41173. Pusher.instances[i].connect();
  41174. }
  41175. };
  41176. Pusher.getClientFeatures = function () {
  41177. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  41178. return t.isSupported({});
  41179. }));
  41180. };
  41181. Pusher.prototype.channel = function (name) {
  41182. return this.channels.find(name);
  41183. };
  41184. Pusher.prototype.allChannels = function () {
  41185. return this.channels.all();
  41186. };
  41187. Pusher.prototype.connect = function () {
  41188. this.connection.connect();
  41189. if (this.timelineSender) {
  41190. if (!this.timelineSenderTimer) {
  41191. var usingTLS = this.connection.isUsingTLS();
  41192. var timelineSender = this.timelineSender;
  41193. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  41194. timelineSender.send(usingTLS);
  41195. });
  41196. }
  41197. }
  41198. };
  41199. Pusher.prototype.disconnect = function () {
  41200. this.connection.disconnect();
  41201. if (this.timelineSenderTimer) {
  41202. this.timelineSenderTimer.ensureAborted();
  41203. this.timelineSenderTimer = null;
  41204. }
  41205. };
  41206. Pusher.prototype.bind = function (event_name, callback, context) {
  41207. this.global_emitter.bind(event_name, callback, context);
  41208. return this;
  41209. };
  41210. Pusher.prototype.unbind = function (event_name, callback, context) {
  41211. this.global_emitter.unbind(event_name, callback, context);
  41212. return this;
  41213. };
  41214. Pusher.prototype.bind_global = function (callback) {
  41215. this.global_emitter.bind_global(callback);
  41216. return this;
  41217. };
  41218. Pusher.prototype.unbind_global = function (callback) {
  41219. this.global_emitter.unbind_global(callback);
  41220. return this;
  41221. };
  41222. Pusher.prototype.unbind_all = function (callback) {
  41223. this.global_emitter.unbind_all();
  41224. return this;
  41225. };
  41226. Pusher.prototype.subscribeAll = function () {
  41227. var channelName;
  41228. for (channelName in this.channels.channels) {
  41229. if (this.channels.channels.hasOwnProperty(channelName)) {
  41230. this.subscribe(channelName);
  41231. }
  41232. }
  41233. };
  41234. Pusher.prototype.subscribe = function (channel_name) {
  41235. var channel = this.channels.add(channel_name, this);
  41236. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  41237. channel.reinstateSubscription();
  41238. }
  41239. else if (!channel.subscriptionPending &&
  41240. this.connection.state === 'connected') {
  41241. channel.subscribe();
  41242. }
  41243. return channel;
  41244. };
  41245. Pusher.prototype.unsubscribe = function (channel_name) {
  41246. var channel = this.channels.find(channel_name);
  41247. if (channel && channel.subscriptionPending) {
  41248. channel.cancelSubscription();
  41249. }
  41250. else {
  41251. channel = this.channels.remove(channel_name);
  41252. if (channel && this.connection.state === 'connected') {
  41253. channel.unsubscribe();
  41254. }
  41255. }
  41256. };
  41257. Pusher.prototype.send_event = function (event_name, data, channel) {
  41258. return this.connection.send_event(event_name, data, channel);
  41259. };
  41260. Pusher.prototype.shouldUseTLS = function () {
  41261. if (runtime.getProtocol() === 'https:') {
  41262. return true;
  41263. }
  41264. else if (this.config.forceTLS === true) {
  41265. return true;
  41266. }
  41267. else {
  41268. return Boolean(this.config.encrypted);
  41269. }
  41270. };
  41271. Pusher.instances = [];
  41272. Pusher.isReady = false;
  41273. Pusher.logToConsole = false;
  41274. Pusher.Runtime = runtime;
  41275. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  41276. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  41277. Pusher.auth_callbacks = runtime.auth_callbacks;
  41278. return Pusher;
  41279. }());
  41280. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  41281. function checkAppKey(key) {
  41282. if (key === null || key === undefined) {
  41283. throw 'You must pass your app key when you instantiate Pusher.';
  41284. }
  41285. }
  41286. runtime.setup(pusher_Pusher);
  41287. /***/ })
  41288. /******/ ]);
  41289. });
  41290. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  41291. /***/ }),
  41292. /***/ "./node_modules/setimmediate/setImmediate.js":
  41293. /*!***************************************************!*\
  41294. !*** ./node_modules/setimmediate/setImmediate.js ***!
  41295. \***************************************************/
  41296. /*! no static exports found */
  41297. /***/ (function(module, exports, __webpack_require__) {
  41298. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  41299. "use strict";
  41300. if (global.setImmediate) {
  41301. return;
  41302. }
  41303. var nextHandle = 1; // Spec says greater than zero
  41304. var tasksByHandle = {};
  41305. var currentlyRunningATask = false;
  41306. var doc = global.document;
  41307. var registerImmediate;
  41308. function setImmediate(callback) {
  41309. // Callback can either be a function or a string
  41310. if (typeof callback !== "function") {
  41311. callback = new Function("" + callback);
  41312. }
  41313. // Copy function arguments
  41314. var args = new Array(arguments.length - 1);
  41315. for (var i = 0; i < args.length; i++) {
  41316. args[i] = arguments[i + 1];
  41317. }
  41318. // Store and register the task
  41319. var task = { callback: callback, args: args };
  41320. tasksByHandle[nextHandle] = task;
  41321. registerImmediate(nextHandle);
  41322. return nextHandle++;
  41323. }
  41324. function clearImmediate(handle) {
  41325. delete tasksByHandle[handle];
  41326. }
  41327. function run(task) {
  41328. var callback = task.callback;
  41329. var args = task.args;
  41330. switch (args.length) {
  41331. case 0:
  41332. callback();
  41333. break;
  41334. case 1:
  41335. callback(args[0]);
  41336. break;
  41337. case 2:
  41338. callback(args[0], args[1]);
  41339. break;
  41340. case 3:
  41341. callback(args[0], args[1], args[2]);
  41342. break;
  41343. default:
  41344. callback.apply(undefined, args);
  41345. break;
  41346. }
  41347. }
  41348. function runIfPresent(handle) {
  41349. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  41350. // So if we're currently running a task, we'll need to delay this invocation.
  41351. if (currentlyRunningATask) {
  41352. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  41353. // "too much recursion" error.
  41354. setTimeout(runIfPresent, 0, handle);
  41355. } else {
  41356. var task = tasksByHandle[handle];
  41357. if (task) {
  41358. currentlyRunningATask = true;
  41359. try {
  41360. run(task);
  41361. } finally {
  41362. clearImmediate(handle);
  41363. currentlyRunningATask = false;
  41364. }
  41365. }
  41366. }
  41367. }
  41368. function installNextTickImplementation() {
  41369. registerImmediate = function(handle) {
  41370. process.nextTick(function () { runIfPresent(handle); });
  41371. };
  41372. }
  41373. function canUsePostMessage() {
  41374. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  41375. // where `global.postMessage` means something completely different and can't be used for this purpose.
  41376. if (global.postMessage && !global.importScripts) {
  41377. var postMessageIsAsynchronous = true;
  41378. var oldOnMessage = global.onmessage;
  41379. global.onmessage = function() {
  41380. postMessageIsAsynchronous = false;
  41381. };
  41382. global.postMessage("", "*");
  41383. global.onmessage = oldOnMessage;
  41384. return postMessageIsAsynchronous;
  41385. }
  41386. }
  41387. function installPostMessageImplementation() {
  41388. // Installs an event handler on `global` for the `message` event: see
  41389. // * https://developer.mozilla.org/en/DOM/window.postMessage
  41390. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  41391. var messagePrefix = "setImmediate$" + Math.random() + "$";
  41392. var onGlobalMessage = function(event) {
  41393. if (event.source === global &&
  41394. typeof event.data === "string" &&
  41395. event.data.indexOf(messagePrefix) === 0) {
  41396. runIfPresent(+event.data.slice(messagePrefix.length));
  41397. }
  41398. };
  41399. if (global.addEventListener) {
  41400. global.addEventListener("message", onGlobalMessage, false);
  41401. } else {
  41402. global.attachEvent("onmessage", onGlobalMessage);
  41403. }
  41404. registerImmediate = function(handle) {
  41405. global.postMessage(messagePrefix + handle, "*");
  41406. };
  41407. }
  41408. function installMessageChannelImplementation() {
  41409. var channel = new MessageChannel();
  41410. channel.port1.onmessage = function(event) {
  41411. var handle = event.data;
  41412. runIfPresent(handle);
  41413. };
  41414. registerImmediate = function(handle) {
  41415. channel.port2.postMessage(handle);
  41416. };
  41417. }
  41418. function installReadyStateChangeImplementation() {
  41419. var html = doc.documentElement;
  41420. registerImmediate = function(handle) {
  41421. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  41422. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  41423. var script = doc.createElement("script");
  41424. script.onreadystatechange = function () {
  41425. runIfPresent(handle);
  41426. script.onreadystatechange = null;
  41427. html.removeChild(script);
  41428. script = null;
  41429. };
  41430. html.appendChild(script);
  41431. };
  41432. }
  41433. function installSetTimeoutImplementation() {
  41434. registerImmediate = function(handle) {
  41435. setTimeout(runIfPresent, 0, handle);
  41436. };
  41437. }
  41438. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  41439. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  41440. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  41441. // Don't get fooled by e.g. browserify environments.
  41442. if ({}.toString.call(global.process) === "[object process]") {
  41443. // For Node.js before 0.9
  41444. installNextTickImplementation();
  41445. } else if (canUsePostMessage()) {
  41446. // For non-IE10 modern browsers
  41447. installPostMessageImplementation();
  41448. } else if (global.MessageChannel) {
  41449. // For web workers, where supported
  41450. installMessageChannelImplementation();
  41451. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  41452. // For IE 6–8
  41453. installReadyStateChangeImplementation();
  41454. } else {
  41455. // For older browsers
  41456. installSetTimeoutImplementation();
  41457. }
  41458. attachTo.setImmediate = setImmediate;
  41459. attachTo.clearImmediate = clearImmediate;
  41460. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  41461. /* 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")))
  41462. /***/ }),
  41463. /***/ "./node_modules/timers-browserify/main.js":
  41464. /*!************************************************!*\
  41465. !*** ./node_modules/timers-browserify/main.js ***!
  41466. \************************************************/
  41467. /*! no static exports found */
  41468. /***/ (function(module, exports, __webpack_require__) {
  41469. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  41470. (typeof self !== "undefined" && self) ||
  41471. window;
  41472. var apply = Function.prototype.apply;
  41473. // DOM APIs, for completeness
  41474. exports.setTimeout = function() {
  41475. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  41476. };
  41477. exports.setInterval = function() {
  41478. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  41479. };
  41480. exports.clearTimeout =
  41481. exports.clearInterval = function(timeout) {
  41482. if (timeout) {
  41483. timeout.close();
  41484. }
  41485. };
  41486. function Timeout(id, clearFn) {
  41487. this._id = id;
  41488. this._clearFn = clearFn;
  41489. }
  41490. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  41491. Timeout.prototype.close = function() {
  41492. this._clearFn.call(scope, this._id);
  41493. };
  41494. // Does not start the time, just sets up the members needed.
  41495. exports.enroll = function(item, msecs) {
  41496. clearTimeout(item._idleTimeoutId);
  41497. item._idleTimeout = msecs;
  41498. };
  41499. exports.unenroll = function(item) {
  41500. clearTimeout(item._idleTimeoutId);
  41501. item._idleTimeout = -1;
  41502. };
  41503. exports._unrefActive = exports.active = function(item) {
  41504. clearTimeout(item._idleTimeoutId);
  41505. var msecs = item._idleTimeout;
  41506. if (msecs >= 0) {
  41507. item._idleTimeoutId = setTimeout(function onTimeout() {
  41508. if (item._onTimeout)
  41509. item._onTimeout();
  41510. }, msecs);
  41511. }
  41512. };
  41513. // setimmediate attaches itself to the global object
  41514. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  41515. // On some exotic environments, it's not clear which object `setimmediate` was
  41516. // able to install onto. Search each possibility in the same order as the
  41517. // `setimmediate` library.
  41518. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  41519. (typeof global !== "undefined" && global.setImmediate) ||
  41520. (this && this.setImmediate);
  41521. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  41522. (typeof global !== "undefined" && global.clearImmediate) ||
  41523. (this && this.clearImmediate);
  41524. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  41525. /***/ }),
  41526. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  41527. /*!*******************************************************************************************************************************************************************************************************************!*\
  41528. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  41529. \*******************************************************************************************************************************************************************************************************************/
  41530. /*! exports provided: render, staticRenderFns */
  41531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41532. "use strict";
  41533. __webpack_require__.r(__webpack_exports__);
  41534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41536. var render = function() {
  41537. var _vm = this
  41538. var _h = _vm.$createElement
  41539. var _c = _vm._self._c || _h
  41540. return _vm._m(0)
  41541. }
  41542. var staticRenderFns = [
  41543. function() {
  41544. var _vm = this
  41545. var _h = _vm.$createElement
  41546. var _c = _vm._self._c || _h
  41547. return _c("div", { staticClass: "container" }, [
  41548. _c("div", { staticClass: "row justify-content-center" }, [
  41549. _c("div", { staticClass: "col-md-8" }, [
  41550. _c("div", { staticClass: "card" }, [
  41551. _c("div", { staticClass: "card-header" }, [
  41552. _vm._v("Example Component")
  41553. ]),
  41554. _vm._v(" "),
  41555. _c("div", { staticClass: "card-body" }, [
  41556. _vm._v(
  41557. "\n I'm an example component.\n "
  41558. )
  41559. ])
  41560. ])
  41561. ])
  41562. ])
  41563. ])
  41564. }
  41565. ]
  41566. render._withStripped = true
  41567. /***/ }),
  41568. /***/ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&":
  41569. /*!***********************************************************************************************************************************************************************************************************!*\
  41570. !*** ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e& ***!
  41571. \***********************************************************************************************************************************************************************************************************/
  41572. /*! exports provided: render, staticRenderFns */
  41573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41574. "use strict";
  41575. __webpack_require__.r(__webpack_exports__);
  41576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  41577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  41578. var render = function() {
  41579. var _vm = this
  41580. var _h = _vm.$createElement
  41581. var _c = _vm._self._c || _h
  41582. return _c("div", { staticClass: "list-items" }, [
  41583. _vm._v("\r\n Problem Description: "),
  41584. _c("div", { domProps: { textContent: _vm._s(this.probdesc) } }),
  41585. _vm._v("\r\n Suggested Solution: "),
  41586. _c("div", { domProps: { textContent: _vm._s(this.suggested) } })
  41587. ])
  41588. }
  41589. var staticRenderFns = []
  41590. render._withStripped = true
  41591. /***/ }),
  41592. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  41593. /*!********************************************************************!*\
  41594. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  41595. \********************************************************************/
  41596. /*! exports provided: default */
  41597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41598. "use strict";
  41599. __webpack_require__.r(__webpack_exports__);
  41600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  41601. /* globals __VUE_SSR_CONTEXT__ */
  41602. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  41603. // This module is a runtime utility for cleaner component module output and will
  41604. // be included in the final webpack user bundle.
  41605. function normalizeComponent (
  41606. scriptExports,
  41607. render,
  41608. staticRenderFns,
  41609. functionalTemplate,
  41610. injectStyles,
  41611. scopeId,
  41612. moduleIdentifier, /* server only */
  41613. shadowMode /* vue-cli only */
  41614. ) {
  41615. // Vue.extend constructor export interop
  41616. var options = typeof scriptExports === 'function'
  41617. ? scriptExports.options
  41618. : scriptExports
  41619. // render functions
  41620. if (render) {
  41621. options.render = render
  41622. options.staticRenderFns = staticRenderFns
  41623. options._compiled = true
  41624. }
  41625. // functional template
  41626. if (functionalTemplate) {
  41627. options.functional = true
  41628. }
  41629. // scopedId
  41630. if (scopeId) {
  41631. options._scopeId = 'data-v-' + scopeId
  41632. }
  41633. var hook
  41634. if (moduleIdentifier) { // server build
  41635. hook = function (context) {
  41636. // 2.3 injection
  41637. context =
  41638. context || // cached call
  41639. (this.$vnode && this.$vnode.ssrContext) || // stateful
  41640. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  41641. // 2.2 with runInNewContext: true
  41642. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  41643. context = __VUE_SSR_CONTEXT__
  41644. }
  41645. // inject component styles
  41646. if (injectStyles) {
  41647. injectStyles.call(this, context)
  41648. }
  41649. // register component module identifier for async chunk inferrence
  41650. if (context && context._registeredComponents) {
  41651. context._registeredComponents.add(moduleIdentifier)
  41652. }
  41653. }
  41654. // used by ssr in case component is cached and beforeCreate
  41655. // never gets called
  41656. options._ssrRegister = hook
  41657. } else if (injectStyles) {
  41658. hook = shadowMode
  41659. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  41660. : injectStyles
  41661. }
  41662. if (hook) {
  41663. if (options.functional) {
  41664. // for template-only hot-reload because in that case the render fn doesn't
  41665. // go through the normalizer
  41666. options._injectStyles = hook
  41667. // register for functioal component in vue file
  41668. var originalRender = options.render
  41669. options.render = function renderWithStyleInjection (h, context) {
  41670. hook.call(context)
  41671. return originalRender(h, context)
  41672. }
  41673. } else {
  41674. // inject component registration as beforeCreate hook
  41675. var existing = options.beforeCreate
  41676. options.beforeCreate = existing
  41677. ? [].concat(existing, hook)
  41678. : [hook]
  41679. }
  41680. }
  41681. return {
  41682. exports: scriptExports,
  41683. options: options
  41684. }
  41685. }
  41686. /***/ }),
  41687. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  41688. /*!*************************************************!*\
  41689. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  41690. \*************************************************/
  41691. /*! no static exports found */
  41692. /***/ (function(module, exports, __webpack_require__) {
  41693. "use strict";
  41694. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  41695. * Vue.js v2.6.11
  41696. * (c) 2014-2019 Evan You
  41697. * Released under the MIT License.
  41698. */
  41699. /* */
  41700. var emptyObject = Object.freeze({});
  41701. // These helpers produce better VM code in JS engines due to their
  41702. // explicitness and function inlining.
  41703. function isUndef (v) {
  41704. return v === undefined || v === null
  41705. }
  41706. function isDef (v) {
  41707. return v !== undefined && v !== null
  41708. }
  41709. function isTrue (v) {
  41710. return v === true
  41711. }
  41712. function isFalse (v) {
  41713. return v === false
  41714. }
  41715. /**
  41716. * Check if value is primitive.
  41717. */
  41718. function isPrimitive (value) {
  41719. return (
  41720. typeof value === 'string' ||
  41721. typeof value === 'number' ||
  41722. // $flow-disable-line
  41723. typeof value === 'symbol' ||
  41724. typeof value === 'boolean'
  41725. )
  41726. }
  41727. /**
  41728. * Quick object check - this is primarily used to tell
  41729. * Objects from primitive values when we know the value
  41730. * is a JSON-compliant type.
  41731. */
  41732. function isObject (obj) {
  41733. return obj !== null && typeof obj === 'object'
  41734. }
  41735. /**
  41736. * Get the raw type string of a value, e.g., [object Object].
  41737. */
  41738. var _toString = Object.prototype.toString;
  41739. function toRawType (value) {
  41740. return _toString.call(value).slice(8, -1)
  41741. }
  41742. /**
  41743. * Strict object type check. Only returns true
  41744. * for plain JavaScript objects.
  41745. */
  41746. function isPlainObject (obj) {
  41747. return _toString.call(obj) === '[object Object]'
  41748. }
  41749. function isRegExp (v) {
  41750. return _toString.call(v) === '[object RegExp]'
  41751. }
  41752. /**
  41753. * Check if val is a valid array index.
  41754. */
  41755. function isValidArrayIndex (val) {
  41756. var n = parseFloat(String(val));
  41757. return n >= 0 && Math.floor(n) === n && isFinite(val)
  41758. }
  41759. function isPromise (val) {
  41760. return (
  41761. isDef(val) &&
  41762. typeof val.then === 'function' &&
  41763. typeof val.catch === 'function'
  41764. )
  41765. }
  41766. /**
  41767. * Convert a value to a string that is actually rendered.
  41768. */
  41769. function toString (val) {
  41770. return val == null
  41771. ? ''
  41772. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  41773. ? JSON.stringify(val, null, 2)
  41774. : String(val)
  41775. }
  41776. /**
  41777. * Convert an input value to a number for persistence.
  41778. * If the conversion fails, return original string.
  41779. */
  41780. function toNumber (val) {
  41781. var n = parseFloat(val);
  41782. return isNaN(n) ? val : n
  41783. }
  41784. /**
  41785. * Make a map and return a function for checking if a key
  41786. * is in that map.
  41787. */
  41788. function makeMap (
  41789. str,
  41790. expectsLowerCase
  41791. ) {
  41792. var map = Object.create(null);
  41793. var list = str.split(',');
  41794. for (var i = 0; i < list.length; i++) {
  41795. map[list[i]] = true;
  41796. }
  41797. return expectsLowerCase
  41798. ? function (val) { return map[val.toLowerCase()]; }
  41799. : function (val) { return map[val]; }
  41800. }
  41801. /**
  41802. * Check if a tag is a built-in tag.
  41803. */
  41804. var isBuiltInTag = makeMap('slot,component', true);
  41805. /**
  41806. * Check if an attribute is a reserved attribute.
  41807. */
  41808. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  41809. /**
  41810. * Remove an item from an array.
  41811. */
  41812. function remove (arr, item) {
  41813. if (arr.length) {
  41814. var index = arr.indexOf(item);
  41815. if (index > -1) {
  41816. return arr.splice(index, 1)
  41817. }
  41818. }
  41819. }
  41820. /**
  41821. * Check whether an object has the property.
  41822. */
  41823. var hasOwnProperty = Object.prototype.hasOwnProperty;
  41824. function hasOwn (obj, key) {
  41825. return hasOwnProperty.call(obj, key)
  41826. }
  41827. /**
  41828. * Create a cached version of a pure function.
  41829. */
  41830. function cached (fn) {
  41831. var cache = Object.create(null);
  41832. return (function cachedFn (str) {
  41833. var hit = cache[str];
  41834. return hit || (cache[str] = fn(str))
  41835. })
  41836. }
  41837. /**
  41838. * Camelize a hyphen-delimited string.
  41839. */
  41840. var camelizeRE = /-(\w)/g;
  41841. var camelize = cached(function (str) {
  41842. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  41843. });
  41844. /**
  41845. * Capitalize a string.
  41846. */
  41847. var capitalize = cached(function (str) {
  41848. return str.charAt(0).toUpperCase() + str.slice(1)
  41849. });
  41850. /**
  41851. * Hyphenate a camelCase string.
  41852. */
  41853. var hyphenateRE = /\B([A-Z])/g;
  41854. var hyphenate = cached(function (str) {
  41855. return str.replace(hyphenateRE, '-$1').toLowerCase()
  41856. });
  41857. /**
  41858. * Simple bind polyfill for environments that do not support it,
  41859. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  41860. * since native bind is now performant enough in most browsers.
  41861. * But removing it would mean breaking code that was able to run in
  41862. * PhantomJS 1.x, so this must be kept for backward compatibility.
  41863. */
  41864. /* istanbul ignore next */
  41865. function polyfillBind (fn, ctx) {
  41866. function boundFn (a) {
  41867. var l = arguments.length;
  41868. return l
  41869. ? l > 1
  41870. ? fn.apply(ctx, arguments)
  41871. : fn.call(ctx, a)
  41872. : fn.call(ctx)
  41873. }
  41874. boundFn._length = fn.length;
  41875. return boundFn
  41876. }
  41877. function nativeBind (fn, ctx) {
  41878. return fn.bind(ctx)
  41879. }
  41880. var bind = Function.prototype.bind
  41881. ? nativeBind
  41882. : polyfillBind;
  41883. /**
  41884. * Convert an Array-like object to a real Array.
  41885. */
  41886. function toArray (list, start) {
  41887. start = start || 0;
  41888. var i = list.length - start;
  41889. var ret = new Array(i);
  41890. while (i--) {
  41891. ret[i] = list[i + start];
  41892. }
  41893. return ret
  41894. }
  41895. /**
  41896. * Mix properties into target object.
  41897. */
  41898. function extend (to, _from) {
  41899. for (var key in _from) {
  41900. to[key] = _from[key];
  41901. }
  41902. return to
  41903. }
  41904. /**
  41905. * Merge an Array of Objects into a single Object.
  41906. */
  41907. function toObject (arr) {
  41908. var res = {};
  41909. for (var i = 0; i < arr.length; i++) {
  41910. if (arr[i]) {
  41911. extend(res, arr[i]);
  41912. }
  41913. }
  41914. return res
  41915. }
  41916. /* eslint-disable no-unused-vars */
  41917. /**
  41918. * Perform no operation.
  41919. * Stubbing args to make Flow happy without leaving useless transpiled code
  41920. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  41921. */
  41922. function noop (a, b, c) {}
  41923. /**
  41924. * Always return false.
  41925. */
  41926. var no = function (a, b, c) { return false; };
  41927. /* eslint-enable no-unused-vars */
  41928. /**
  41929. * Return the same value.
  41930. */
  41931. var identity = function (_) { return _; };
  41932. /**
  41933. * Generate a string containing static keys from compiler modules.
  41934. */
  41935. function genStaticKeys (modules) {
  41936. return modules.reduce(function (keys, m) {
  41937. return keys.concat(m.staticKeys || [])
  41938. }, []).join(',')
  41939. }
  41940. /**
  41941. * Check if two values are loosely equal - that is,
  41942. * if they are plain objects, do they have the same shape?
  41943. */
  41944. function looseEqual (a, b) {
  41945. if (a === b) { return true }
  41946. var isObjectA = isObject(a);
  41947. var isObjectB = isObject(b);
  41948. if (isObjectA && isObjectB) {
  41949. try {
  41950. var isArrayA = Array.isArray(a);
  41951. var isArrayB = Array.isArray(b);
  41952. if (isArrayA && isArrayB) {
  41953. return a.length === b.length && a.every(function (e, i) {
  41954. return looseEqual(e, b[i])
  41955. })
  41956. } else if (a instanceof Date && b instanceof Date) {
  41957. return a.getTime() === b.getTime()
  41958. } else if (!isArrayA && !isArrayB) {
  41959. var keysA = Object.keys(a);
  41960. var keysB = Object.keys(b);
  41961. return keysA.length === keysB.length && keysA.every(function (key) {
  41962. return looseEqual(a[key], b[key])
  41963. })
  41964. } else {
  41965. /* istanbul ignore next */
  41966. return false
  41967. }
  41968. } catch (e) {
  41969. /* istanbul ignore next */
  41970. return false
  41971. }
  41972. } else if (!isObjectA && !isObjectB) {
  41973. return String(a) === String(b)
  41974. } else {
  41975. return false
  41976. }
  41977. }
  41978. /**
  41979. * Return the first index at which a loosely equal value can be
  41980. * found in the array (if value is a plain object, the array must
  41981. * contain an object of the same shape), or -1 if it is not present.
  41982. */
  41983. function looseIndexOf (arr, val) {
  41984. for (var i = 0; i < arr.length; i++) {
  41985. if (looseEqual(arr[i], val)) { return i }
  41986. }
  41987. return -1
  41988. }
  41989. /**
  41990. * Ensure a function is called only once.
  41991. */
  41992. function once (fn) {
  41993. var called = false;
  41994. return function () {
  41995. if (!called) {
  41996. called = true;
  41997. fn.apply(this, arguments);
  41998. }
  41999. }
  42000. }
  42001. var SSR_ATTR = 'data-server-rendered';
  42002. var ASSET_TYPES = [
  42003. 'component',
  42004. 'directive',
  42005. 'filter'
  42006. ];
  42007. var LIFECYCLE_HOOKS = [
  42008. 'beforeCreate',
  42009. 'created',
  42010. 'beforeMount',
  42011. 'mounted',
  42012. 'beforeUpdate',
  42013. 'updated',
  42014. 'beforeDestroy',
  42015. 'destroyed',
  42016. 'activated',
  42017. 'deactivated',
  42018. 'errorCaptured',
  42019. 'serverPrefetch'
  42020. ];
  42021. /* */
  42022. var config = ({
  42023. /**
  42024. * Option merge strategies (used in core/util/options)
  42025. */
  42026. // $flow-disable-line
  42027. optionMergeStrategies: Object.create(null),
  42028. /**
  42029. * Whether to suppress warnings.
  42030. */
  42031. silent: false,
  42032. /**
  42033. * Show production mode tip message on boot?
  42034. */
  42035. productionTip: "development" !== 'production',
  42036. /**
  42037. * Whether to enable devtools
  42038. */
  42039. devtools: "development" !== 'production',
  42040. /**
  42041. * Whether to record perf
  42042. */
  42043. performance: false,
  42044. /**
  42045. * Error handler for watcher errors
  42046. */
  42047. errorHandler: null,
  42048. /**
  42049. * Warn handler for watcher warns
  42050. */
  42051. warnHandler: null,
  42052. /**
  42053. * Ignore certain custom elements
  42054. */
  42055. ignoredElements: [],
  42056. /**
  42057. * Custom user key aliases for v-on
  42058. */
  42059. // $flow-disable-line
  42060. keyCodes: Object.create(null),
  42061. /**
  42062. * Check if a tag is reserved so that it cannot be registered as a
  42063. * component. This is platform-dependent and may be overwritten.
  42064. */
  42065. isReservedTag: no,
  42066. /**
  42067. * Check if an attribute is reserved so that it cannot be used as a component
  42068. * prop. This is platform-dependent and may be overwritten.
  42069. */
  42070. isReservedAttr: no,
  42071. /**
  42072. * Check if a tag is an unknown element.
  42073. * Platform-dependent.
  42074. */
  42075. isUnknownElement: no,
  42076. /**
  42077. * Get the namespace of an element
  42078. */
  42079. getTagNamespace: noop,
  42080. /**
  42081. * Parse the real tag name for the specific platform.
  42082. */
  42083. parsePlatformTagName: identity,
  42084. /**
  42085. * Check if an attribute must be bound using property, e.g. value
  42086. * Platform-dependent.
  42087. */
  42088. mustUseProp: no,
  42089. /**
  42090. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  42091. * This will significantly reduce performance if set to false.
  42092. */
  42093. async: true,
  42094. /**
  42095. * Exposed for legacy reasons
  42096. */
  42097. _lifecycleHooks: LIFECYCLE_HOOKS
  42098. });
  42099. /* */
  42100. /**
  42101. * unicode letters used for parsing html tags, component names and property paths.
  42102. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  42103. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  42104. */
  42105. 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/;
  42106. /**
  42107. * Check if a string starts with $ or _
  42108. */
  42109. function isReserved (str) {
  42110. var c = (str + '').charCodeAt(0);
  42111. return c === 0x24 || c === 0x5F
  42112. }
  42113. /**
  42114. * Define a property.
  42115. */
  42116. function def (obj, key, val, enumerable) {
  42117. Object.defineProperty(obj, key, {
  42118. value: val,
  42119. enumerable: !!enumerable,
  42120. writable: true,
  42121. configurable: true
  42122. });
  42123. }
  42124. /**
  42125. * Parse simple path.
  42126. */
  42127. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  42128. function parsePath (path) {
  42129. if (bailRE.test(path)) {
  42130. return
  42131. }
  42132. var segments = path.split('.');
  42133. return function (obj) {
  42134. for (var i = 0; i < segments.length; i++) {
  42135. if (!obj) { return }
  42136. obj = obj[segments[i]];
  42137. }
  42138. return obj
  42139. }
  42140. }
  42141. /* */
  42142. // can we use __proto__?
  42143. var hasProto = '__proto__' in {};
  42144. // Browser environment sniffing
  42145. var inBrowser = typeof window !== 'undefined';
  42146. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  42147. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  42148. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  42149. var isIE = UA && /msie|trident/.test(UA);
  42150. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  42151. var isEdge = UA && UA.indexOf('edge/') > 0;
  42152. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  42153. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  42154. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  42155. var isPhantomJS = UA && /phantomjs/.test(UA);
  42156. var isFF = UA && UA.match(/firefox\/(\d+)/);
  42157. // Firefox has a "watch" function on Object.prototype...
  42158. var nativeWatch = ({}).watch;
  42159. var supportsPassive = false;
  42160. if (inBrowser) {
  42161. try {
  42162. var opts = {};
  42163. Object.defineProperty(opts, 'passive', ({
  42164. get: function get () {
  42165. /* istanbul ignore next */
  42166. supportsPassive = true;
  42167. }
  42168. })); // https://github.com/facebook/flow/issues/285
  42169. window.addEventListener('test-passive', null, opts);
  42170. } catch (e) {}
  42171. }
  42172. // this needs to be lazy-evaled because vue may be required before
  42173. // vue-server-renderer can set VUE_ENV
  42174. var _isServer;
  42175. var isServerRendering = function () {
  42176. if (_isServer === undefined) {
  42177. /* istanbul ignore if */
  42178. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  42179. // detect presence of vue-server-renderer and avoid
  42180. // Webpack shimming the process
  42181. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  42182. } else {
  42183. _isServer = false;
  42184. }
  42185. }
  42186. return _isServer
  42187. };
  42188. // detect devtools
  42189. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  42190. /* istanbul ignore next */
  42191. function isNative (Ctor) {
  42192. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  42193. }
  42194. var hasSymbol =
  42195. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  42196. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  42197. var _Set;
  42198. /* istanbul ignore if */ // $flow-disable-line
  42199. if (typeof Set !== 'undefined' && isNative(Set)) {
  42200. // use native Set when available.
  42201. _Set = Set;
  42202. } else {
  42203. // a non-standard Set polyfill that only works with primitive keys.
  42204. _Set = /*@__PURE__*/(function () {
  42205. function Set () {
  42206. this.set = Object.create(null);
  42207. }
  42208. Set.prototype.has = function has (key) {
  42209. return this.set[key] === true
  42210. };
  42211. Set.prototype.add = function add (key) {
  42212. this.set[key] = true;
  42213. };
  42214. Set.prototype.clear = function clear () {
  42215. this.set = Object.create(null);
  42216. };
  42217. return Set;
  42218. }());
  42219. }
  42220. /* */
  42221. var warn = noop;
  42222. var tip = noop;
  42223. var generateComponentTrace = (noop); // work around flow check
  42224. var formatComponentName = (noop);
  42225. {
  42226. var hasConsole = typeof console !== 'undefined';
  42227. var classifyRE = /(?:^|[-_])(\w)/g;
  42228. var classify = function (str) { return str
  42229. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  42230. .replace(/[-_]/g, ''); };
  42231. warn = function (msg, vm) {
  42232. var trace = vm ? generateComponentTrace(vm) : '';
  42233. if (config.warnHandler) {
  42234. config.warnHandler.call(null, msg, vm, trace);
  42235. } else if (hasConsole && (!config.silent)) {
  42236. console.error(("[Vue warn]: " + msg + trace));
  42237. }
  42238. };
  42239. tip = function (msg, vm) {
  42240. if (hasConsole && (!config.silent)) {
  42241. console.warn("[Vue tip]: " + msg + (
  42242. vm ? generateComponentTrace(vm) : ''
  42243. ));
  42244. }
  42245. };
  42246. formatComponentName = function (vm, includeFile) {
  42247. if (vm.$root === vm) {
  42248. return '<Root>'
  42249. }
  42250. var options = typeof vm === 'function' && vm.cid != null
  42251. ? vm.options
  42252. : vm._isVue
  42253. ? vm.$options || vm.constructor.options
  42254. : vm;
  42255. var name = options.name || options._componentTag;
  42256. var file = options.__file;
  42257. if (!name && file) {
  42258. var match = file.match(/([^/\\]+)\.vue$/);
  42259. name = match && match[1];
  42260. }
  42261. return (
  42262. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  42263. (file && includeFile !== false ? (" at " + file) : '')
  42264. )
  42265. };
  42266. var repeat = function (str, n) {
  42267. var res = '';
  42268. while (n) {
  42269. if (n % 2 === 1) { res += str; }
  42270. if (n > 1) { str += str; }
  42271. n >>= 1;
  42272. }
  42273. return res
  42274. };
  42275. generateComponentTrace = function (vm) {
  42276. if (vm._isVue && vm.$parent) {
  42277. var tree = [];
  42278. var currentRecursiveSequence = 0;
  42279. while (vm) {
  42280. if (tree.length > 0) {
  42281. var last = tree[tree.length - 1];
  42282. if (last.constructor === vm.constructor) {
  42283. currentRecursiveSequence++;
  42284. vm = vm.$parent;
  42285. continue
  42286. } else if (currentRecursiveSequence > 0) {
  42287. tree[tree.length - 1] = [last, currentRecursiveSequence];
  42288. currentRecursiveSequence = 0;
  42289. }
  42290. }
  42291. tree.push(vm);
  42292. vm = vm.$parent;
  42293. }
  42294. return '\n\nfound in\n\n' + tree
  42295. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  42296. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  42297. : formatComponentName(vm))); })
  42298. .join('\n')
  42299. } else {
  42300. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  42301. }
  42302. };
  42303. }
  42304. /* */
  42305. var uid = 0;
  42306. /**
  42307. * A dep is an observable that can have multiple
  42308. * directives subscribing to it.
  42309. */
  42310. var Dep = function Dep () {
  42311. this.id = uid++;
  42312. this.subs = [];
  42313. };
  42314. Dep.prototype.addSub = function addSub (sub) {
  42315. this.subs.push(sub);
  42316. };
  42317. Dep.prototype.removeSub = function removeSub (sub) {
  42318. remove(this.subs, sub);
  42319. };
  42320. Dep.prototype.depend = function depend () {
  42321. if (Dep.target) {
  42322. Dep.target.addDep(this);
  42323. }
  42324. };
  42325. Dep.prototype.notify = function notify () {
  42326. // stabilize the subscriber list first
  42327. var subs = this.subs.slice();
  42328. if (!config.async) {
  42329. // subs aren't sorted in scheduler if not running async
  42330. // we need to sort them now to make sure they fire in correct
  42331. // order
  42332. subs.sort(function (a, b) { return a.id - b.id; });
  42333. }
  42334. for (var i = 0, l = subs.length; i < l; i++) {
  42335. subs[i].update();
  42336. }
  42337. };
  42338. // The current target watcher being evaluated.
  42339. // This is globally unique because only one watcher
  42340. // can be evaluated at a time.
  42341. Dep.target = null;
  42342. var targetStack = [];
  42343. function pushTarget (target) {
  42344. targetStack.push(target);
  42345. Dep.target = target;
  42346. }
  42347. function popTarget () {
  42348. targetStack.pop();
  42349. Dep.target = targetStack[targetStack.length - 1];
  42350. }
  42351. /* */
  42352. var VNode = function VNode (
  42353. tag,
  42354. data,
  42355. children,
  42356. text,
  42357. elm,
  42358. context,
  42359. componentOptions,
  42360. asyncFactory
  42361. ) {
  42362. this.tag = tag;
  42363. this.data = data;
  42364. this.children = children;
  42365. this.text = text;
  42366. this.elm = elm;
  42367. this.ns = undefined;
  42368. this.context = context;
  42369. this.fnContext = undefined;
  42370. this.fnOptions = undefined;
  42371. this.fnScopeId = undefined;
  42372. this.key = data && data.key;
  42373. this.componentOptions = componentOptions;
  42374. this.componentInstance = undefined;
  42375. this.parent = undefined;
  42376. this.raw = false;
  42377. this.isStatic = false;
  42378. this.isRootInsert = true;
  42379. this.isComment = false;
  42380. this.isCloned = false;
  42381. this.isOnce = false;
  42382. this.asyncFactory = asyncFactory;
  42383. this.asyncMeta = undefined;
  42384. this.isAsyncPlaceholder = false;
  42385. };
  42386. var prototypeAccessors = { child: { configurable: true } };
  42387. // DEPRECATED: alias for componentInstance for backwards compat.
  42388. /* istanbul ignore next */
  42389. prototypeAccessors.child.get = function () {
  42390. return this.componentInstance
  42391. };
  42392. Object.defineProperties( VNode.prototype, prototypeAccessors );
  42393. var createEmptyVNode = function (text) {
  42394. if ( text === void 0 ) text = '';
  42395. var node = new VNode();
  42396. node.text = text;
  42397. node.isComment = true;
  42398. return node
  42399. };
  42400. function createTextVNode (val) {
  42401. return new VNode(undefined, undefined, undefined, String(val))
  42402. }
  42403. // optimized shallow clone
  42404. // used for static nodes and slot nodes because they may be reused across
  42405. // multiple renders, cloning them avoids errors when DOM manipulations rely
  42406. // on their elm reference.
  42407. function cloneVNode (vnode) {
  42408. var cloned = new VNode(
  42409. vnode.tag,
  42410. vnode.data,
  42411. // #7975
  42412. // clone children array to avoid mutating original in case of cloning
  42413. // a child.
  42414. vnode.children && vnode.children.slice(),
  42415. vnode.text,
  42416. vnode.elm,
  42417. vnode.context,
  42418. vnode.componentOptions,
  42419. vnode.asyncFactory
  42420. );
  42421. cloned.ns = vnode.ns;
  42422. cloned.isStatic = vnode.isStatic;
  42423. cloned.key = vnode.key;
  42424. cloned.isComment = vnode.isComment;
  42425. cloned.fnContext = vnode.fnContext;
  42426. cloned.fnOptions = vnode.fnOptions;
  42427. cloned.fnScopeId = vnode.fnScopeId;
  42428. cloned.asyncMeta = vnode.asyncMeta;
  42429. cloned.isCloned = true;
  42430. return cloned
  42431. }
  42432. /*
  42433. * not type checking this file because flow doesn't play well with
  42434. * dynamically accessing methods on Array prototype
  42435. */
  42436. var arrayProto = Array.prototype;
  42437. var arrayMethods = Object.create(arrayProto);
  42438. var methodsToPatch = [
  42439. 'push',
  42440. 'pop',
  42441. 'shift',
  42442. 'unshift',
  42443. 'splice',
  42444. 'sort',
  42445. 'reverse'
  42446. ];
  42447. /**
  42448. * Intercept mutating methods and emit events
  42449. */
  42450. methodsToPatch.forEach(function (method) {
  42451. // cache original method
  42452. var original = arrayProto[method];
  42453. def(arrayMethods, method, function mutator () {
  42454. var args = [], len = arguments.length;
  42455. while ( len-- ) args[ len ] = arguments[ len ];
  42456. var result = original.apply(this, args);
  42457. var ob = this.__ob__;
  42458. var inserted;
  42459. switch (method) {
  42460. case 'push':
  42461. case 'unshift':
  42462. inserted = args;
  42463. break
  42464. case 'splice':
  42465. inserted = args.slice(2);
  42466. break
  42467. }
  42468. if (inserted) { ob.observeArray(inserted); }
  42469. // notify change
  42470. ob.dep.notify();
  42471. return result
  42472. });
  42473. });
  42474. /* */
  42475. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  42476. /**
  42477. * In some cases we may want to disable observation inside a component's
  42478. * update computation.
  42479. */
  42480. var shouldObserve = true;
  42481. function toggleObserving (value) {
  42482. shouldObserve = value;
  42483. }
  42484. /**
  42485. * Observer class that is attached to each observed
  42486. * object. Once attached, the observer converts the target
  42487. * object's property keys into getter/setters that
  42488. * collect dependencies and dispatch updates.
  42489. */
  42490. var Observer = function Observer (value) {
  42491. this.value = value;
  42492. this.dep = new Dep();
  42493. this.vmCount = 0;
  42494. def(value, '__ob__', this);
  42495. if (Array.isArray(value)) {
  42496. if (hasProto) {
  42497. protoAugment(value, arrayMethods);
  42498. } else {
  42499. copyAugment(value, arrayMethods, arrayKeys);
  42500. }
  42501. this.observeArray(value);
  42502. } else {
  42503. this.walk(value);
  42504. }
  42505. };
  42506. /**
  42507. * Walk through all properties and convert them into
  42508. * getter/setters. This method should only be called when
  42509. * value type is Object.
  42510. */
  42511. Observer.prototype.walk = function walk (obj) {
  42512. var keys = Object.keys(obj);
  42513. for (var i = 0; i < keys.length; i++) {
  42514. defineReactive$$1(obj, keys[i]);
  42515. }
  42516. };
  42517. /**
  42518. * Observe a list of Array items.
  42519. */
  42520. Observer.prototype.observeArray = function observeArray (items) {
  42521. for (var i = 0, l = items.length; i < l; i++) {
  42522. observe(items[i]);
  42523. }
  42524. };
  42525. // helpers
  42526. /**
  42527. * Augment a target Object or Array by intercepting
  42528. * the prototype chain using __proto__
  42529. */
  42530. function protoAugment (target, src) {
  42531. /* eslint-disable no-proto */
  42532. target.__proto__ = src;
  42533. /* eslint-enable no-proto */
  42534. }
  42535. /**
  42536. * Augment a target Object or Array by defining
  42537. * hidden properties.
  42538. */
  42539. /* istanbul ignore next */
  42540. function copyAugment (target, src, keys) {
  42541. for (var i = 0, l = keys.length; i < l; i++) {
  42542. var key = keys[i];
  42543. def(target, key, src[key]);
  42544. }
  42545. }
  42546. /**
  42547. * Attempt to create an observer instance for a value,
  42548. * returns the new observer if successfully observed,
  42549. * or the existing observer if the value already has one.
  42550. */
  42551. function observe (value, asRootData) {
  42552. if (!isObject(value) || value instanceof VNode) {
  42553. return
  42554. }
  42555. var ob;
  42556. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  42557. ob = value.__ob__;
  42558. } else if (
  42559. shouldObserve &&
  42560. !isServerRendering() &&
  42561. (Array.isArray(value) || isPlainObject(value)) &&
  42562. Object.isExtensible(value) &&
  42563. !value._isVue
  42564. ) {
  42565. ob = new Observer(value);
  42566. }
  42567. if (asRootData && ob) {
  42568. ob.vmCount++;
  42569. }
  42570. return ob
  42571. }
  42572. /**
  42573. * Define a reactive property on an Object.
  42574. */
  42575. function defineReactive$$1 (
  42576. obj,
  42577. key,
  42578. val,
  42579. customSetter,
  42580. shallow
  42581. ) {
  42582. var dep = new Dep();
  42583. var property = Object.getOwnPropertyDescriptor(obj, key);
  42584. if (property && property.configurable === false) {
  42585. return
  42586. }
  42587. // cater for pre-defined getter/setters
  42588. var getter = property && property.get;
  42589. var setter = property && property.set;
  42590. if ((!getter || setter) && arguments.length === 2) {
  42591. val = obj[key];
  42592. }
  42593. var childOb = !shallow && observe(val);
  42594. Object.defineProperty(obj, key, {
  42595. enumerable: true,
  42596. configurable: true,
  42597. get: function reactiveGetter () {
  42598. var value = getter ? getter.call(obj) : val;
  42599. if (Dep.target) {
  42600. dep.depend();
  42601. if (childOb) {
  42602. childOb.dep.depend();
  42603. if (Array.isArray(value)) {
  42604. dependArray(value);
  42605. }
  42606. }
  42607. }
  42608. return value
  42609. },
  42610. set: function reactiveSetter (newVal) {
  42611. var value = getter ? getter.call(obj) : val;
  42612. /* eslint-disable no-self-compare */
  42613. if (newVal === value || (newVal !== newVal && value !== value)) {
  42614. return
  42615. }
  42616. /* eslint-enable no-self-compare */
  42617. if (customSetter) {
  42618. customSetter();
  42619. }
  42620. // #7981: for accessor properties without setter
  42621. if (getter && !setter) { return }
  42622. if (setter) {
  42623. setter.call(obj, newVal);
  42624. } else {
  42625. val = newVal;
  42626. }
  42627. childOb = !shallow && observe(newVal);
  42628. dep.notify();
  42629. }
  42630. });
  42631. }
  42632. /**
  42633. * Set a property on an object. Adds the new property and
  42634. * triggers change notification if the property doesn't
  42635. * already exist.
  42636. */
  42637. function set (target, key, val) {
  42638. if (isUndef(target) || isPrimitive(target)
  42639. ) {
  42640. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  42641. }
  42642. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42643. target.length = Math.max(target.length, key);
  42644. target.splice(key, 1, val);
  42645. return val
  42646. }
  42647. if (key in target && !(key in Object.prototype)) {
  42648. target[key] = val;
  42649. return val
  42650. }
  42651. var ob = (target).__ob__;
  42652. if (target._isVue || (ob && ob.vmCount)) {
  42653. warn(
  42654. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  42655. 'at runtime - declare it upfront in the data option.'
  42656. );
  42657. return val
  42658. }
  42659. if (!ob) {
  42660. target[key] = val;
  42661. return val
  42662. }
  42663. defineReactive$$1(ob.value, key, val);
  42664. ob.dep.notify();
  42665. return val
  42666. }
  42667. /**
  42668. * Delete a property and trigger change if necessary.
  42669. */
  42670. function del (target, key) {
  42671. if (isUndef(target) || isPrimitive(target)
  42672. ) {
  42673. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  42674. }
  42675. if (Array.isArray(target) && isValidArrayIndex(key)) {
  42676. target.splice(key, 1);
  42677. return
  42678. }
  42679. var ob = (target).__ob__;
  42680. if (target._isVue || (ob && ob.vmCount)) {
  42681. warn(
  42682. 'Avoid deleting properties on a Vue instance or its root $data ' +
  42683. '- just set it to null.'
  42684. );
  42685. return
  42686. }
  42687. if (!hasOwn(target, key)) {
  42688. return
  42689. }
  42690. delete target[key];
  42691. if (!ob) {
  42692. return
  42693. }
  42694. ob.dep.notify();
  42695. }
  42696. /**
  42697. * Collect dependencies on array elements when the array is touched, since
  42698. * we cannot intercept array element access like property getters.
  42699. */
  42700. function dependArray (value) {
  42701. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  42702. e = value[i];
  42703. e && e.__ob__ && e.__ob__.dep.depend();
  42704. if (Array.isArray(e)) {
  42705. dependArray(e);
  42706. }
  42707. }
  42708. }
  42709. /* */
  42710. /**
  42711. * Option overwriting strategies are functions that handle
  42712. * how to merge a parent option value and a child option
  42713. * value into the final value.
  42714. */
  42715. var strats = config.optionMergeStrategies;
  42716. /**
  42717. * Options with restrictions
  42718. */
  42719. {
  42720. strats.el = strats.propsData = function (parent, child, vm, key) {
  42721. if (!vm) {
  42722. warn(
  42723. "option \"" + key + "\" can only be used during instance " +
  42724. 'creation with the `new` keyword.'
  42725. );
  42726. }
  42727. return defaultStrat(parent, child)
  42728. };
  42729. }
  42730. /**
  42731. * Helper that recursively merges two data objects together.
  42732. */
  42733. function mergeData (to, from) {
  42734. if (!from) { return to }
  42735. var key, toVal, fromVal;
  42736. var keys = hasSymbol
  42737. ? Reflect.ownKeys(from)
  42738. : Object.keys(from);
  42739. for (var i = 0; i < keys.length; i++) {
  42740. key = keys[i];
  42741. // in case the object is already observed...
  42742. if (key === '__ob__') { continue }
  42743. toVal = to[key];
  42744. fromVal = from[key];
  42745. if (!hasOwn(to, key)) {
  42746. set(to, key, fromVal);
  42747. } else if (
  42748. toVal !== fromVal &&
  42749. isPlainObject(toVal) &&
  42750. isPlainObject(fromVal)
  42751. ) {
  42752. mergeData(toVal, fromVal);
  42753. }
  42754. }
  42755. return to
  42756. }
  42757. /**
  42758. * Data
  42759. */
  42760. function mergeDataOrFn (
  42761. parentVal,
  42762. childVal,
  42763. vm
  42764. ) {
  42765. if (!vm) {
  42766. // in a Vue.extend merge, both should be functions
  42767. if (!childVal) {
  42768. return parentVal
  42769. }
  42770. if (!parentVal) {
  42771. return childVal
  42772. }
  42773. // when parentVal & childVal are both present,
  42774. // we need to return a function that returns the
  42775. // merged result of both functions... no need to
  42776. // check if parentVal is a function here because
  42777. // it has to be a function to pass previous merges.
  42778. return function mergedDataFn () {
  42779. return mergeData(
  42780. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  42781. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  42782. )
  42783. }
  42784. } else {
  42785. return function mergedInstanceDataFn () {
  42786. // instance merge
  42787. var instanceData = typeof childVal === 'function'
  42788. ? childVal.call(vm, vm)
  42789. : childVal;
  42790. var defaultData = typeof parentVal === 'function'
  42791. ? parentVal.call(vm, vm)
  42792. : parentVal;
  42793. if (instanceData) {
  42794. return mergeData(instanceData, defaultData)
  42795. } else {
  42796. return defaultData
  42797. }
  42798. }
  42799. }
  42800. }
  42801. strats.data = function (
  42802. parentVal,
  42803. childVal,
  42804. vm
  42805. ) {
  42806. if (!vm) {
  42807. if (childVal && typeof childVal !== 'function') {
  42808. warn(
  42809. 'The "data" option should be a function ' +
  42810. 'that returns a per-instance value in component ' +
  42811. 'definitions.',
  42812. vm
  42813. );
  42814. return parentVal
  42815. }
  42816. return mergeDataOrFn(parentVal, childVal)
  42817. }
  42818. return mergeDataOrFn(parentVal, childVal, vm)
  42819. };
  42820. /**
  42821. * Hooks and props are merged as arrays.
  42822. */
  42823. function mergeHook (
  42824. parentVal,
  42825. childVal
  42826. ) {
  42827. var res = childVal
  42828. ? parentVal
  42829. ? parentVal.concat(childVal)
  42830. : Array.isArray(childVal)
  42831. ? childVal
  42832. : [childVal]
  42833. : parentVal;
  42834. return res
  42835. ? dedupeHooks(res)
  42836. : res
  42837. }
  42838. function dedupeHooks (hooks) {
  42839. var res = [];
  42840. for (var i = 0; i < hooks.length; i++) {
  42841. if (res.indexOf(hooks[i]) === -1) {
  42842. res.push(hooks[i]);
  42843. }
  42844. }
  42845. return res
  42846. }
  42847. LIFECYCLE_HOOKS.forEach(function (hook) {
  42848. strats[hook] = mergeHook;
  42849. });
  42850. /**
  42851. * Assets
  42852. *
  42853. * When a vm is present (instance creation), we need to do
  42854. * a three-way merge between constructor options, instance
  42855. * options and parent options.
  42856. */
  42857. function mergeAssets (
  42858. parentVal,
  42859. childVal,
  42860. vm,
  42861. key
  42862. ) {
  42863. var res = Object.create(parentVal || null);
  42864. if (childVal) {
  42865. assertObjectType(key, childVal, vm);
  42866. return extend(res, childVal)
  42867. } else {
  42868. return res
  42869. }
  42870. }
  42871. ASSET_TYPES.forEach(function (type) {
  42872. strats[type + 's'] = mergeAssets;
  42873. });
  42874. /**
  42875. * Watchers.
  42876. *
  42877. * Watchers hashes should not overwrite one
  42878. * another, so we merge them as arrays.
  42879. */
  42880. strats.watch = function (
  42881. parentVal,
  42882. childVal,
  42883. vm,
  42884. key
  42885. ) {
  42886. // work around Firefox's Object.prototype.watch...
  42887. if (parentVal === nativeWatch) { parentVal = undefined; }
  42888. if (childVal === nativeWatch) { childVal = undefined; }
  42889. /* istanbul ignore if */
  42890. if (!childVal) { return Object.create(parentVal || null) }
  42891. {
  42892. assertObjectType(key, childVal, vm);
  42893. }
  42894. if (!parentVal) { return childVal }
  42895. var ret = {};
  42896. extend(ret, parentVal);
  42897. for (var key$1 in childVal) {
  42898. var parent = ret[key$1];
  42899. var child = childVal[key$1];
  42900. if (parent && !Array.isArray(parent)) {
  42901. parent = [parent];
  42902. }
  42903. ret[key$1] = parent
  42904. ? parent.concat(child)
  42905. : Array.isArray(child) ? child : [child];
  42906. }
  42907. return ret
  42908. };
  42909. /**
  42910. * Other object hashes.
  42911. */
  42912. strats.props =
  42913. strats.methods =
  42914. strats.inject =
  42915. strats.computed = function (
  42916. parentVal,
  42917. childVal,
  42918. vm,
  42919. key
  42920. ) {
  42921. if (childVal && "development" !== 'production') {
  42922. assertObjectType(key, childVal, vm);
  42923. }
  42924. if (!parentVal) { return childVal }
  42925. var ret = Object.create(null);
  42926. extend(ret, parentVal);
  42927. if (childVal) { extend(ret, childVal); }
  42928. return ret
  42929. };
  42930. strats.provide = mergeDataOrFn;
  42931. /**
  42932. * Default strategy.
  42933. */
  42934. var defaultStrat = function (parentVal, childVal) {
  42935. return childVal === undefined
  42936. ? parentVal
  42937. : childVal
  42938. };
  42939. /**
  42940. * Validate component names
  42941. */
  42942. function checkComponents (options) {
  42943. for (var key in options.components) {
  42944. validateComponentName(key);
  42945. }
  42946. }
  42947. function validateComponentName (name) {
  42948. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  42949. warn(
  42950. 'Invalid component name: "' + name + '". Component names ' +
  42951. 'should conform to valid custom element name in html5 specification.'
  42952. );
  42953. }
  42954. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  42955. warn(
  42956. 'Do not use built-in or reserved HTML elements as component ' +
  42957. 'id: ' + name
  42958. );
  42959. }
  42960. }
  42961. /**
  42962. * Ensure all props option syntax are normalized into the
  42963. * Object-based format.
  42964. */
  42965. function normalizeProps (options, vm) {
  42966. var props = options.props;
  42967. if (!props) { return }
  42968. var res = {};
  42969. var i, val, name;
  42970. if (Array.isArray(props)) {
  42971. i = props.length;
  42972. while (i--) {
  42973. val = props[i];
  42974. if (typeof val === 'string') {
  42975. name = camelize(val);
  42976. res[name] = { type: null };
  42977. } else {
  42978. warn('props must be strings when using array syntax.');
  42979. }
  42980. }
  42981. } else if (isPlainObject(props)) {
  42982. for (var key in props) {
  42983. val = props[key];
  42984. name = camelize(key);
  42985. res[name] = isPlainObject(val)
  42986. ? val
  42987. : { type: val };
  42988. }
  42989. } else {
  42990. warn(
  42991. "Invalid value for option \"props\": expected an Array or an Object, " +
  42992. "but got " + (toRawType(props)) + ".",
  42993. vm
  42994. );
  42995. }
  42996. options.props = res;
  42997. }
  42998. /**
  42999. * Normalize all injections into Object-based format
  43000. */
  43001. function normalizeInject (options, vm) {
  43002. var inject = options.inject;
  43003. if (!inject) { return }
  43004. var normalized = options.inject = {};
  43005. if (Array.isArray(inject)) {
  43006. for (var i = 0; i < inject.length; i++) {
  43007. normalized[inject[i]] = { from: inject[i] };
  43008. }
  43009. } else if (isPlainObject(inject)) {
  43010. for (var key in inject) {
  43011. var val = inject[key];
  43012. normalized[key] = isPlainObject(val)
  43013. ? extend({ from: key }, val)
  43014. : { from: val };
  43015. }
  43016. } else {
  43017. warn(
  43018. "Invalid value for option \"inject\": expected an Array or an Object, " +
  43019. "but got " + (toRawType(inject)) + ".",
  43020. vm
  43021. );
  43022. }
  43023. }
  43024. /**
  43025. * Normalize raw function directives into object format.
  43026. */
  43027. function normalizeDirectives (options) {
  43028. var dirs = options.directives;
  43029. if (dirs) {
  43030. for (var key in dirs) {
  43031. var def$$1 = dirs[key];
  43032. if (typeof def$$1 === 'function') {
  43033. dirs[key] = { bind: def$$1, update: def$$1 };
  43034. }
  43035. }
  43036. }
  43037. }
  43038. function assertObjectType (name, value, vm) {
  43039. if (!isPlainObject(value)) {
  43040. warn(
  43041. "Invalid value for option \"" + name + "\": expected an Object, " +
  43042. "but got " + (toRawType(value)) + ".",
  43043. vm
  43044. );
  43045. }
  43046. }
  43047. /**
  43048. * Merge two option objects into a new one.
  43049. * Core utility used in both instantiation and inheritance.
  43050. */
  43051. function mergeOptions (
  43052. parent,
  43053. child,
  43054. vm
  43055. ) {
  43056. {
  43057. checkComponents(child);
  43058. }
  43059. if (typeof child === 'function') {
  43060. child = child.options;
  43061. }
  43062. normalizeProps(child, vm);
  43063. normalizeInject(child, vm);
  43064. normalizeDirectives(child);
  43065. // Apply extends and mixins on the child options,
  43066. // but only if it is a raw options object that isn't
  43067. // the result of another mergeOptions call.
  43068. // Only merged options has the _base property.
  43069. if (!child._base) {
  43070. if (child.extends) {
  43071. parent = mergeOptions(parent, child.extends, vm);
  43072. }
  43073. if (child.mixins) {
  43074. for (var i = 0, l = child.mixins.length; i < l; i++) {
  43075. parent = mergeOptions(parent, child.mixins[i], vm);
  43076. }
  43077. }
  43078. }
  43079. var options = {};
  43080. var key;
  43081. for (key in parent) {
  43082. mergeField(key);
  43083. }
  43084. for (key in child) {
  43085. if (!hasOwn(parent, key)) {
  43086. mergeField(key);
  43087. }
  43088. }
  43089. function mergeField (key) {
  43090. var strat = strats[key] || defaultStrat;
  43091. options[key] = strat(parent[key], child[key], vm, key);
  43092. }
  43093. return options
  43094. }
  43095. /**
  43096. * Resolve an asset.
  43097. * This function is used because child instances need access
  43098. * to assets defined in its ancestor chain.
  43099. */
  43100. function resolveAsset (
  43101. options,
  43102. type,
  43103. id,
  43104. warnMissing
  43105. ) {
  43106. /* istanbul ignore if */
  43107. if (typeof id !== 'string') {
  43108. return
  43109. }
  43110. var assets = options[type];
  43111. // check local registration variations first
  43112. if (hasOwn(assets, id)) { return assets[id] }
  43113. var camelizedId = camelize(id);
  43114. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  43115. var PascalCaseId = capitalize(camelizedId);
  43116. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  43117. // fallback to prototype chain
  43118. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  43119. if (warnMissing && !res) {
  43120. warn(
  43121. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  43122. options
  43123. );
  43124. }
  43125. return res
  43126. }
  43127. /* */
  43128. function validateProp (
  43129. key,
  43130. propOptions,
  43131. propsData,
  43132. vm
  43133. ) {
  43134. var prop = propOptions[key];
  43135. var absent = !hasOwn(propsData, key);
  43136. var value = propsData[key];
  43137. // boolean casting
  43138. var booleanIndex = getTypeIndex(Boolean, prop.type);
  43139. if (booleanIndex > -1) {
  43140. if (absent && !hasOwn(prop, 'default')) {
  43141. value = false;
  43142. } else if (value === '' || value === hyphenate(key)) {
  43143. // only cast empty string / same name to boolean if
  43144. // boolean has higher priority
  43145. var stringIndex = getTypeIndex(String, prop.type);
  43146. if (stringIndex < 0 || booleanIndex < stringIndex) {
  43147. value = true;
  43148. }
  43149. }
  43150. }
  43151. // check default value
  43152. if (value === undefined) {
  43153. value = getPropDefaultValue(vm, prop, key);
  43154. // since the default value is a fresh copy,
  43155. // make sure to observe it.
  43156. var prevShouldObserve = shouldObserve;
  43157. toggleObserving(true);
  43158. observe(value);
  43159. toggleObserving(prevShouldObserve);
  43160. }
  43161. {
  43162. assertProp(prop, key, value, vm, absent);
  43163. }
  43164. return value
  43165. }
  43166. /**
  43167. * Get the default value of a prop.
  43168. */
  43169. function getPropDefaultValue (vm, prop, key) {
  43170. // no default, return undefined
  43171. if (!hasOwn(prop, 'default')) {
  43172. return undefined
  43173. }
  43174. var def = prop.default;
  43175. // warn against non-factory defaults for Object & Array
  43176. if (isObject(def)) {
  43177. warn(
  43178. 'Invalid default value for prop "' + key + '": ' +
  43179. 'Props with type Object/Array must use a factory function ' +
  43180. 'to return the default value.',
  43181. vm
  43182. );
  43183. }
  43184. // the raw prop value was also undefined from previous render,
  43185. // return previous default value to avoid unnecessary watcher trigger
  43186. if (vm && vm.$options.propsData &&
  43187. vm.$options.propsData[key] === undefined &&
  43188. vm._props[key] !== undefined
  43189. ) {
  43190. return vm._props[key]
  43191. }
  43192. // call factory function for non-Function types
  43193. // a value is Function if its prototype is function even across different execution context
  43194. return typeof def === 'function' && getType(prop.type) !== 'Function'
  43195. ? def.call(vm)
  43196. : def
  43197. }
  43198. /**
  43199. * Assert whether a prop is valid.
  43200. */
  43201. function assertProp (
  43202. prop,
  43203. name,
  43204. value,
  43205. vm,
  43206. absent
  43207. ) {
  43208. if (prop.required && absent) {
  43209. warn(
  43210. 'Missing required prop: "' + name + '"',
  43211. vm
  43212. );
  43213. return
  43214. }
  43215. if (value == null && !prop.required) {
  43216. return
  43217. }
  43218. var type = prop.type;
  43219. var valid = !type || type === true;
  43220. var expectedTypes = [];
  43221. if (type) {
  43222. if (!Array.isArray(type)) {
  43223. type = [type];
  43224. }
  43225. for (var i = 0; i < type.length && !valid; i++) {
  43226. var assertedType = assertType(value, type[i]);
  43227. expectedTypes.push(assertedType.expectedType || '');
  43228. valid = assertedType.valid;
  43229. }
  43230. }
  43231. if (!valid) {
  43232. warn(
  43233. getInvalidTypeMessage(name, value, expectedTypes),
  43234. vm
  43235. );
  43236. return
  43237. }
  43238. var validator = prop.validator;
  43239. if (validator) {
  43240. if (!validator(value)) {
  43241. warn(
  43242. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  43243. vm
  43244. );
  43245. }
  43246. }
  43247. }
  43248. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  43249. function assertType (value, type) {
  43250. var valid;
  43251. var expectedType = getType(type);
  43252. if (simpleCheckRE.test(expectedType)) {
  43253. var t = typeof value;
  43254. valid = t === expectedType.toLowerCase();
  43255. // for primitive wrapper objects
  43256. if (!valid && t === 'object') {
  43257. valid = value instanceof type;
  43258. }
  43259. } else if (expectedType === 'Object') {
  43260. valid = isPlainObject(value);
  43261. } else if (expectedType === 'Array') {
  43262. valid = Array.isArray(value);
  43263. } else {
  43264. valid = value instanceof type;
  43265. }
  43266. return {
  43267. valid: valid,
  43268. expectedType: expectedType
  43269. }
  43270. }
  43271. /**
  43272. * Use function string name to check built-in types,
  43273. * because a simple equality check will fail when running
  43274. * across different vms / iframes.
  43275. */
  43276. function getType (fn) {
  43277. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  43278. return match ? match[1] : ''
  43279. }
  43280. function isSameType (a, b) {
  43281. return getType(a) === getType(b)
  43282. }
  43283. function getTypeIndex (type, expectedTypes) {
  43284. if (!Array.isArray(expectedTypes)) {
  43285. return isSameType(expectedTypes, type) ? 0 : -1
  43286. }
  43287. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  43288. if (isSameType(expectedTypes[i], type)) {
  43289. return i
  43290. }
  43291. }
  43292. return -1
  43293. }
  43294. function getInvalidTypeMessage (name, value, expectedTypes) {
  43295. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  43296. " Expected " + (expectedTypes.map(capitalize).join(', '));
  43297. var expectedType = expectedTypes[0];
  43298. var receivedType = toRawType(value);
  43299. var expectedValue = styleValue(value, expectedType);
  43300. var receivedValue = styleValue(value, receivedType);
  43301. // check if we need to specify expected value
  43302. if (expectedTypes.length === 1 &&
  43303. isExplicable(expectedType) &&
  43304. !isBoolean(expectedType, receivedType)) {
  43305. message += " with value " + expectedValue;
  43306. }
  43307. message += ", got " + receivedType + " ";
  43308. // check if we need to specify received value
  43309. if (isExplicable(receivedType)) {
  43310. message += "with value " + receivedValue + ".";
  43311. }
  43312. return message
  43313. }
  43314. function styleValue (value, type) {
  43315. if (type === 'String') {
  43316. return ("\"" + value + "\"")
  43317. } else if (type === 'Number') {
  43318. return ("" + (Number(value)))
  43319. } else {
  43320. return ("" + value)
  43321. }
  43322. }
  43323. function isExplicable (value) {
  43324. var explicitTypes = ['string', 'number', 'boolean'];
  43325. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  43326. }
  43327. function isBoolean () {
  43328. var args = [], len = arguments.length;
  43329. while ( len-- ) args[ len ] = arguments[ len ];
  43330. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  43331. }
  43332. /* */
  43333. function handleError (err, vm, info) {
  43334. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  43335. // See: https://github.com/vuejs/vuex/issues/1505
  43336. pushTarget();
  43337. try {
  43338. if (vm) {
  43339. var cur = vm;
  43340. while ((cur = cur.$parent)) {
  43341. var hooks = cur.$options.errorCaptured;
  43342. if (hooks) {
  43343. for (var i = 0; i < hooks.length; i++) {
  43344. try {
  43345. var capture = hooks[i].call(cur, err, vm, info) === false;
  43346. if (capture) { return }
  43347. } catch (e) {
  43348. globalHandleError(e, cur, 'errorCaptured hook');
  43349. }
  43350. }
  43351. }
  43352. }
  43353. }
  43354. globalHandleError(err, vm, info);
  43355. } finally {
  43356. popTarget();
  43357. }
  43358. }
  43359. function invokeWithErrorHandling (
  43360. handler,
  43361. context,
  43362. args,
  43363. vm,
  43364. info
  43365. ) {
  43366. var res;
  43367. try {
  43368. res = args ? handler.apply(context, args) : handler.call(context);
  43369. if (res && !res._isVue && isPromise(res) && !res._handled) {
  43370. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  43371. // issue #9511
  43372. // avoid catch triggering multiple times when nested calls
  43373. res._handled = true;
  43374. }
  43375. } catch (e) {
  43376. handleError(e, vm, info);
  43377. }
  43378. return res
  43379. }
  43380. function globalHandleError (err, vm, info) {
  43381. if (config.errorHandler) {
  43382. try {
  43383. return config.errorHandler.call(null, err, vm, info)
  43384. } catch (e) {
  43385. // if the user intentionally throws the original error in the handler,
  43386. // do not log it twice
  43387. if (e !== err) {
  43388. logError(e, null, 'config.errorHandler');
  43389. }
  43390. }
  43391. }
  43392. logError(err, vm, info);
  43393. }
  43394. function logError (err, vm, info) {
  43395. {
  43396. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  43397. }
  43398. /* istanbul ignore else */
  43399. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  43400. console.error(err);
  43401. } else {
  43402. throw err
  43403. }
  43404. }
  43405. /* */
  43406. var isUsingMicroTask = false;
  43407. var callbacks = [];
  43408. var pending = false;
  43409. function flushCallbacks () {
  43410. pending = false;
  43411. var copies = callbacks.slice(0);
  43412. callbacks.length = 0;
  43413. for (var i = 0; i < copies.length; i++) {
  43414. copies[i]();
  43415. }
  43416. }
  43417. // Here we have async deferring wrappers using microtasks.
  43418. // In 2.5 we used (macro) tasks (in combination with microtasks).
  43419. // However, it has subtle problems when state is changed right before repaint
  43420. // (e.g. #6813, out-in transitions).
  43421. // Also, using (macro) tasks in event handler would cause some weird behaviors
  43422. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  43423. // So we now use microtasks everywhere, again.
  43424. // A major drawback of this tradeoff is that there are some scenarios
  43425. // where microtasks have too high a priority and fire in between supposedly
  43426. // sequential events (e.g. #4521, #6690, which have workarounds)
  43427. // or even between bubbling of the same event (#6566).
  43428. var timerFunc;
  43429. // The nextTick behavior leverages the microtask queue, which can be accessed
  43430. // via either native Promise.then or MutationObserver.
  43431. // MutationObserver has wider support, however it is seriously bugged in
  43432. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  43433. // completely stops working after triggering a few times... so, if native
  43434. // Promise is available, we will use it:
  43435. /* istanbul ignore next, $flow-disable-line */
  43436. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  43437. var p = Promise.resolve();
  43438. timerFunc = function () {
  43439. p.then(flushCallbacks);
  43440. // In problematic UIWebViews, Promise.then doesn't completely break, but
  43441. // it can get stuck in a weird state where callbacks are pushed into the
  43442. // microtask queue but the queue isn't being flushed, until the browser
  43443. // needs to do some other work, e.g. handle a timer. Therefore we can
  43444. // "force" the microtask queue to be flushed by adding an empty timer.
  43445. if (isIOS) { setTimeout(noop); }
  43446. };
  43447. isUsingMicroTask = true;
  43448. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  43449. isNative(MutationObserver) ||
  43450. // PhantomJS and iOS 7.x
  43451. MutationObserver.toString() === '[object MutationObserverConstructor]'
  43452. )) {
  43453. // Use MutationObserver where native Promise is not available,
  43454. // e.g. PhantomJS, iOS7, Android 4.4
  43455. // (#6466 MutationObserver is unreliable in IE11)
  43456. var counter = 1;
  43457. var observer = new MutationObserver(flushCallbacks);
  43458. var textNode = document.createTextNode(String(counter));
  43459. observer.observe(textNode, {
  43460. characterData: true
  43461. });
  43462. timerFunc = function () {
  43463. counter = (counter + 1) % 2;
  43464. textNode.data = String(counter);
  43465. };
  43466. isUsingMicroTask = true;
  43467. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  43468. // Fallback to setImmediate.
  43469. // Technically it leverages the (macro) task queue,
  43470. // but it is still a better choice than setTimeout.
  43471. timerFunc = function () {
  43472. setImmediate(flushCallbacks);
  43473. };
  43474. } else {
  43475. // Fallback to setTimeout.
  43476. timerFunc = function () {
  43477. setTimeout(flushCallbacks, 0);
  43478. };
  43479. }
  43480. function nextTick (cb, ctx) {
  43481. var _resolve;
  43482. callbacks.push(function () {
  43483. if (cb) {
  43484. try {
  43485. cb.call(ctx);
  43486. } catch (e) {
  43487. handleError(e, ctx, 'nextTick');
  43488. }
  43489. } else if (_resolve) {
  43490. _resolve(ctx);
  43491. }
  43492. });
  43493. if (!pending) {
  43494. pending = true;
  43495. timerFunc();
  43496. }
  43497. // $flow-disable-line
  43498. if (!cb && typeof Promise !== 'undefined') {
  43499. return new Promise(function (resolve) {
  43500. _resolve = resolve;
  43501. })
  43502. }
  43503. }
  43504. /* */
  43505. var mark;
  43506. var measure;
  43507. {
  43508. var perf = inBrowser && window.performance;
  43509. /* istanbul ignore if */
  43510. if (
  43511. perf &&
  43512. perf.mark &&
  43513. perf.measure &&
  43514. perf.clearMarks &&
  43515. perf.clearMeasures
  43516. ) {
  43517. mark = function (tag) { return perf.mark(tag); };
  43518. measure = function (name, startTag, endTag) {
  43519. perf.measure(name, startTag, endTag);
  43520. perf.clearMarks(startTag);
  43521. perf.clearMarks(endTag);
  43522. // perf.clearMeasures(name)
  43523. };
  43524. }
  43525. }
  43526. /* not type checking this file because flow doesn't play well with Proxy */
  43527. var initProxy;
  43528. {
  43529. var allowedGlobals = makeMap(
  43530. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  43531. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  43532. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  43533. 'require' // for Webpack/Browserify
  43534. );
  43535. var warnNonPresent = function (target, key) {
  43536. warn(
  43537. "Property or method \"" + key + "\" is not defined on the instance but " +
  43538. 'referenced during render. Make sure that this property is reactive, ' +
  43539. 'either in the data option, or for class-based components, by ' +
  43540. 'initializing the property. ' +
  43541. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  43542. target
  43543. );
  43544. };
  43545. var warnReservedPrefix = function (target, key) {
  43546. warn(
  43547. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  43548. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  43549. 'prevent conflicts with Vue internals. ' +
  43550. 'See: https://vuejs.org/v2/api/#data',
  43551. target
  43552. );
  43553. };
  43554. var hasProxy =
  43555. typeof Proxy !== 'undefined' && isNative(Proxy);
  43556. if (hasProxy) {
  43557. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  43558. config.keyCodes = new Proxy(config.keyCodes, {
  43559. set: function set (target, key, value) {
  43560. if (isBuiltInModifier(key)) {
  43561. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  43562. return false
  43563. } else {
  43564. target[key] = value;
  43565. return true
  43566. }
  43567. }
  43568. });
  43569. }
  43570. var hasHandler = {
  43571. has: function has (target, key) {
  43572. var has = key in target;
  43573. var isAllowed = allowedGlobals(key) ||
  43574. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  43575. if (!has && !isAllowed) {
  43576. if (key in target.$data) { warnReservedPrefix(target, key); }
  43577. else { warnNonPresent(target, key); }
  43578. }
  43579. return has || !isAllowed
  43580. }
  43581. };
  43582. var getHandler = {
  43583. get: function get (target, key) {
  43584. if (typeof key === 'string' && !(key in target)) {
  43585. if (key in target.$data) { warnReservedPrefix(target, key); }
  43586. else { warnNonPresent(target, key); }
  43587. }
  43588. return target[key]
  43589. }
  43590. };
  43591. initProxy = function initProxy (vm) {
  43592. if (hasProxy) {
  43593. // determine which proxy handler to use
  43594. var options = vm.$options;
  43595. var handlers = options.render && options.render._withStripped
  43596. ? getHandler
  43597. : hasHandler;
  43598. vm._renderProxy = new Proxy(vm, handlers);
  43599. } else {
  43600. vm._renderProxy = vm;
  43601. }
  43602. };
  43603. }
  43604. /* */
  43605. var seenObjects = new _Set();
  43606. /**
  43607. * Recursively traverse an object to evoke all converted
  43608. * getters, so that every nested property inside the object
  43609. * is collected as a "deep" dependency.
  43610. */
  43611. function traverse (val) {
  43612. _traverse(val, seenObjects);
  43613. seenObjects.clear();
  43614. }
  43615. function _traverse (val, seen) {
  43616. var i, keys;
  43617. var isA = Array.isArray(val);
  43618. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  43619. return
  43620. }
  43621. if (val.__ob__) {
  43622. var depId = val.__ob__.dep.id;
  43623. if (seen.has(depId)) {
  43624. return
  43625. }
  43626. seen.add(depId);
  43627. }
  43628. if (isA) {
  43629. i = val.length;
  43630. while (i--) { _traverse(val[i], seen); }
  43631. } else {
  43632. keys = Object.keys(val);
  43633. i = keys.length;
  43634. while (i--) { _traverse(val[keys[i]], seen); }
  43635. }
  43636. }
  43637. /* */
  43638. var normalizeEvent = cached(function (name) {
  43639. var passive = name.charAt(0) === '&';
  43640. name = passive ? name.slice(1) : name;
  43641. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  43642. name = once$$1 ? name.slice(1) : name;
  43643. var capture = name.charAt(0) === '!';
  43644. name = capture ? name.slice(1) : name;
  43645. return {
  43646. name: name,
  43647. once: once$$1,
  43648. capture: capture,
  43649. passive: passive
  43650. }
  43651. });
  43652. function createFnInvoker (fns, vm) {
  43653. function invoker () {
  43654. var arguments$1 = arguments;
  43655. var fns = invoker.fns;
  43656. if (Array.isArray(fns)) {
  43657. var cloned = fns.slice();
  43658. for (var i = 0; i < cloned.length; i++) {
  43659. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  43660. }
  43661. } else {
  43662. // return handler return value for single handlers
  43663. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  43664. }
  43665. }
  43666. invoker.fns = fns;
  43667. return invoker
  43668. }
  43669. function updateListeners (
  43670. on,
  43671. oldOn,
  43672. add,
  43673. remove$$1,
  43674. createOnceHandler,
  43675. vm
  43676. ) {
  43677. var name, def$$1, cur, old, event;
  43678. for (name in on) {
  43679. def$$1 = cur = on[name];
  43680. old = oldOn[name];
  43681. event = normalizeEvent(name);
  43682. if (isUndef(cur)) {
  43683. warn(
  43684. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  43685. vm
  43686. );
  43687. } else if (isUndef(old)) {
  43688. if (isUndef(cur.fns)) {
  43689. cur = on[name] = createFnInvoker(cur, vm);
  43690. }
  43691. if (isTrue(event.once)) {
  43692. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  43693. }
  43694. add(event.name, cur, event.capture, event.passive, event.params);
  43695. } else if (cur !== old) {
  43696. old.fns = cur;
  43697. on[name] = old;
  43698. }
  43699. }
  43700. for (name in oldOn) {
  43701. if (isUndef(on[name])) {
  43702. event = normalizeEvent(name);
  43703. remove$$1(event.name, oldOn[name], event.capture);
  43704. }
  43705. }
  43706. }
  43707. /* */
  43708. function mergeVNodeHook (def, hookKey, hook) {
  43709. if (def instanceof VNode) {
  43710. def = def.data.hook || (def.data.hook = {});
  43711. }
  43712. var invoker;
  43713. var oldHook = def[hookKey];
  43714. function wrappedHook () {
  43715. hook.apply(this, arguments);
  43716. // important: remove merged hook to ensure it's called only once
  43717. // and prevent memory leak
  43718. remove(invoker.fns, wrappedHook);
  43719. }
  43720. if (isUndef(oldHook)) {
  43721. // no existing hook
  43722. invoker = createFnInvoker([wrappedHook]);
  43723. } else {
  43724. /* istanbul ignore if */
  43725. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  43726. // already a merged invoker
  43727. invoker = oldHook;
  43728. invoker.fns.push(wrappedHook);
  43729. } else {
  43730. // existing plain hook
  43731. invoker = createFnInvoker([oldHook, wrappedHook]);
  43732. }
  43733. }
  43734. invoker.merged = true;
  43735. def[hookKey] = invoker;
  43736. }
  43737. /* */
  43738. function extractPropsFromVNodeData (
  43739. data,
  43740. Ctor,
  43741. tag
  43742. ) {
  43743. // we are only extracting raw values here.
  43744. // validation and default values are handled in the child
  43745. // component itself.
  43746. var propOptions = Ctor.options.props;
  43747. if (isUndef(propOptions)) {
  43748. return
  43749. }
  43750. var res = {};
  43751. var attrs = data.attrs;
  43752. var props = data.props;
  43753. if (isDef(attrs) || isDef(props)) {
  43754. for (var key in propOptions) {
  43755. var altKey = hyphenate(key);
  43756. {
  43757. var keyInLowerCase = key.toLowerCase();
  43758. if (
  43759. key !== keyInLowerCase &&
  43760. attrs && hasOwn(attrs, keyInLowerCase)
  43761. ) {
  43762. tip(
  43763. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  43764. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  43765. " \"" + key + "\". " +
  43766. "Note that HTML attributes are case-insensitive and camelCased " +
  43767. "props need to use their kebab-case equivalents when using in-DOM " +
  43768. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  43769. );
  43770. }
  43771. }
  43772. checkProp(res, props, key, altKey, true) ||
  43773. checkProp(res, attrs, key, altKey, false);
  43774. }
  43775. }
  43776. return res
  43777. }
  43778. function checkProp (
  43779. res,
  43780. hash,
  43781. key,
  43782. altKey,
  43783. preserve
  43784. ) {
  43785. if (isDef(hash)) {
  43786. if (hasOwn(hash, key)) {
  43787. res[key] = hash[key];
  43788. if (!preserve) {
  43789. delete hash[key];
  43790. }
  43791. return true
  43792. } else if (hasOwn(hash, altKey)) {
  43793. res[key] = hash[altKey];
  43794. if (!preserve) {
  43795. delete hash[altKey];
  43796. }
  43797. return true
  43798. }
  43799. }
  43800. return false
  43801. }
  43802. /* */
  43803. // The template compiler attempts to minimize the need for normalization by
  43804. // statically analyzing the template at compile time.
  43805. //
  43806. // For plain HTML markup, normalization can be completely skipped because the
  43807. // generated render function is guaranteed to return Array<VNode>. There are
  43808. // two cases where extra normalization is needed:
  43809. // 1. When the children contains components - because a functional component
  43810. // may return an Array instead of a single root. In this case, just a simple
  43811. // normalization is needed - if any child is an Array, we flatten the whole
  43812. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  43813. // because functional components already normalize their own children.
  43814. function simpleNormalizeChildren (children) {
  43815. for (var i = 0; i < children.length; i++) {
  43816. if (Array.isArray(children[i])) {
  43817. return Array.prototype.concat.apply([], children)
  43818. }
  43819. }
  43820. return children
  43821. }
  43822. // 2. When the children contains constructs that always generated nested Arrays,
  43823. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  43824. // with hand-written render functions / JSX. In such cases a full normalization
  43825. // is needed to cater to all possible types of children values.
  43826. function normalizeChildren (children) {
  43827. return isPrimitive(children)
  43828. ? [createTextVNode(children)]
  43829. : Array.isArray(children)
  43830. ? normalizeArrayChildren(children)
  43831. : undefined
  43832. }
  43833. function isTextNode (node) {
  43834. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  43835. }
  43836. function normalizeArrayChildren (children, nestedIndex) {
  43837. var res = [];
  43838. var i, c, lastIndex, last;
  43839. for (i = 0; i < children.length; i++) {
  43840. c = children[i];
  43841. if (isUndef(c) || typeof c === 'boolean') { continue }
  43842. lastIndex = res.length - 1;
  43843. last = res[lastIndex];
  43844. // nested
  43845. if (Array.isArray(c)) {
  43846. if (c.length > 0) {
  43847. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  43848. // merge adjacent text nodes
  43849. if (isTextNode(c[0]) && isTextNode(last)) {
  43850. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  43851. c.shift();
  43852. }
  43853. res.push.apply(res, c);
  43854. }
  43855. } else if (isPrimitive(c)) {
  43856. if (isTextNode(last)) {
  43857. // merge adjacent text nodes
  43858. // this is necessary for SSR hydration because text nodes are
  43859. // essentially merged when rendered to HTML strings
  43860. res[lastIndex] = createTextVNode(last.text + c);
  43861. } else if (c !== '') {
  43862. // convert primitive to vnode
  43863. res.push(createTextVNode(c));
  43864. }
  43865. } else {
  43866. if (isTextNode(c) && isTextNode(last)) {
  43867. // merge adjacent text nodes
  43868. res[lastIndex] = createTextVNode(last.text + c.text);
  43869. } else {
  43870. // default key for nested array children (likely generated by v-for)
  43871. if (isTrue(children._isVList) &&
  43872. isDef(c.tag) &&
  43873. isUndef(c.key) &&
  43874. isDef(nestedIndex)) {
  43875. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  43876. }
  43877. res.push(c);
  43878. }
  43879. }
  43880. }
  43881. return res
  43882. }
  43883. /* */
  43884. function initProvide (vm) {
  43885. var provide = vm.$options.provide;
  43886. if (provide) {
  43887. vm._provided = typeof provide === 'function'
  43888. ? provide.call(vm)
  43889. : provide;
  43890. }
  43891. }
  43892. function initInjections (vm) {
  43893. var result = resolveInject(vm.$options.inject, vm);
  43894. if (result) {
  43895. toggleObserving(false);
  43896. Object.keys(result).forEach(function (key) {
  43897. /* istanbul ignore else */
  43898. {
  43899. defineReactive$$1(vm, key, result[key], function () {
  43900. warn(
  43901. "Avoid mutating an injected value directly since the changes will be " +
  43902. "overwritten whenever the provided component re-renders. " +
  43903. "injection being mutated: \"" + key + "\"",
  43904. vm
  43905. );
  43906. });
  43907. }
  43908. });
  43909. toggleObserving(true);
  43910. }
  43911. }
  43912. function resolveInject (inject, vm) {
  43913. if (inject) {
  43914. // inject is :any because flow is not smart enough to figure out cached
  43915. var result = Object.create(null);
  43916. var keys = hasSymbol
  43917. ? Reflect.ownKeys(inject)
  43918. : Object.keys(inject);
  43919. for (var i = 0; i < keys.length; i++) {
  43920. var key = keys[i];
  43921. // #6574 in case the inject object is observed...
  43922. if (key === '__ob__') { continue }
  43923. var provideKey = inject[key].from;
  43924. var source = vm;
  43925. while (source) {
  43926. if (source._provided && hasOwn(source._provided, provideKey)) {
  43927. result[key] = source._provided[provideKey];
  43928. break
  43929. }
  43930. source = source.$parent;
  43931. }
  43932. if (!source) {
  43933. if ('default' in inject[key]) {
  43934. var provideDefault = inject[key].default;
  43935. result[key] = typeof provideDefault === 'function'
  43936. ? provideDefault.call(vm)
  43937. : provideDefault;
  43938. } else {
  43939. warn(("Injection \"" + key + "\" not found"), vm);
  43940. }
  43941. }
  43942. }
  43943. return result
  43944. }
  43945. }
  43946. /* */
  43947. /**
  43948. * Runtime helper for resolving raw children VNodes into a slot object.
  43949. */
  43950. function resolveSlots (
  43951. children,
  43952. context
  43953. ) {
  43954. if (!children || !children.length) {
  43955. return {}
  43956. }
  43957. var slots = {};
  43958. for (var i = 0, l = children.length; i < l; i++) {
  43959. var child = children[i];
  43960. var data = child.data;
  43961. // remove slot attribute if the node is resolved as a Vue slot node
  43962. if (data && data.attrs && data.attrs.slot) {
  43963. delete data.attrs.slot;
  43964. }
  43965. // named slots should only be respected if the vnode was rendered in the
  43966. // same context.
  43967. if ((child.context === context || child.fnContext === context) &&
  43968. data && data.slot != null
  43969. ) {
  43970. var name = data.slot;
  43971. var slot = (slots[name] || (slots[name] = []));
  43972. if (child.tag === 'template') {
  43973. slot.push.apply(slot, child.children || []);
  43974. } else {
  43975. slot.push(child);
  43976. }
  43977. } else {
  43978. (slots.default || (slots.default = [])).push(child);
  43979. }
  43980. }
  43981. // ignore slots that contains only whitespace
  43982. for (var name$1 in slots) {
  43983. if (slots[name$1].every(isWhitespace)) {
  43984. delete slots[name$1];
  43985. }
  43986. }
  43987. return slots
  43988. }
  43989. function isWhitespace (node) {
  43990. return (node.isComment && !node.asyncFactory) || node.text === ' '
  43991. }
  43992. /* */
  43993. function normalizeScopedSlots (
  43994. slots,
  43995. normalSlots,
  43996. prevSlots
  43997. ) {
  43998. var res;
  43999. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  44000. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  44001. var key = slots && slots.$key;
  44002. if (!slots) {
  44003. res = {};
  44004. } else if (slots._normalized) {
  44005. // fast path 1: child component re-render only, parent did not change
  44006. return slots._normalized
  44007. } else if (
  44008. isStable &&
  44009. prevSlots &&
  44010. prevSlots !== emptyObject &&
  44011. key === prevSlots.$key &&
  44012. !hasNormalSlots &&
  44013. !prevSlots.$hasNormal
  44014. ) {
  44015. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  44016. // only need to normalize once
  44017. return prevSlots
  44018. } else {
  44019. res = {};
  44020. for (var key$1 in slots) {
  44021. if (slots[key$1] && key$1[0] !== '$') {
  44022. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  44023. }
  44024. }
  44025. }
  44026. // expose normal slots on scopedSlots
  44027. for (var key$2 in normalSlots) {
  44028. if (!(key$2 in res)) {
  44029. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  44030. }
  44031. }
  44032. // avoriaz seems to mock a non-extensible $scopedSlots object
  44033. // and when that is passed down this would cause an error
  44034. if (slots && Object.isExtensible(slots)) {
  44035. (slots)._normalized = res;
  44036. }
  44037. def(res, '$stable', isStable);
  44038. def(res, '$key', key);
  44039. def(res, '$hasNormal', hasNormalSlots);
  44040. return res
  44041. }
  44042. function normalizeScopedSlot(normalSlots, key, fn) {
  44043. var normalized = function () {
  44044. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  44045. res = res && typeof res === 'object' && !Array.isArray(res)
  44046. ? [res] // single vnode
  44047. : normalizeChildren(res);
  44048. return res && (
  44049. res.length === 0 ||
  44050. (res.length === 1 && res[0].isComment) // #9658
  44051. ) ? undefined
  44052. : res
  44053. };
  44054. // this is a slot using the new v-slot syntax without scope. although it is
  44055. // compiled as a scoped slot, render fn users would expect it to be present
  44056. // on this.$slots because the usage is semantically a normal slot.
  44057. if (fn.proxy) {
  44058. Object.defineProperty(normalSlots, key, {
  44059. get: normalized,
  44060. enumerable: true,
  44061. configurable: true
  44062. });
  44063. }
  44064. return normalized
  44065. }
  44066. function proxyNormalSlot(slots, key) {
  44067. return function () { return slots[key]; }
  44068. }
  44069. /* */
  44070. /**
  44071. * Runtime helper for rendering v-for lists.
  44072. */
  44073. function renderList (
  44074. val,
  44075. render
  44076. ) {
  44077. var ret, i, l, keys, key;
  44078. if (Array.isArray(val) || typeof val === 'string') {
  44079. ret = new Array(val.length);
  44080. for (i = 0, l = val.length; i < l; i++) {
  44081. ret[i] = render(val[i], i);
  44082. }
  44083. } else if (typeof val === 'number') {
  44084. ret = new Array(val);
  44085. for (i = 0; i < val; i++) {
  44086. ret[i] = render(i + 1, i);
  44087. }
  44088. } else if (isObject(val)) {
  44089. if (hasSymbol && val[Symbol.iterator]) {
  44090. ret = [];
  44091. var iterator = val[Symbol.iterator]();
  44092. var result = iterator.next();
  44093. while (!result.done) {
  44094. ret.push(render(result.value, ret.length));
  44095. result = iterator.next();
  44096. }
  44097. } else {
  44098. keys = Object.keys(val);
  44099. ret = new Array(keys.length);
  44100. for (i = 0, l = keys.length; i < l; i++) {
  44101. key = keys[i];
  44102. ret[i] = render(val[key], key, i);
  44103. }
  44104. }
  44105. }
  44106. if (!isDef(ret)) {
  44107. ret = [];
  44108. }
  44109. (ret)._isVList = true;
  44110. return ret
  44111. }
  44112. /* */
  44113. /**
  44114. * Runtime helper for rendering <slot>
  44115. */
  44116. function renderSlot (
  44117. name,
  44118. fallback,
  44119. props,
  44120. bindObject
  44121. ) {
  44122. var scopedSlotFn = this.$scopedSlots[name];
  44123. var nodes;
  44124. if (scopedSlotFn) { // scoped slot
  44125. props = props || {};
  44126. if (bindObject) {
  44127. if (!isObject(bindObject)) {
  44128. warn(
  44129. 'slot v-bind without argument expects an Object',
  44130. this
  44131. );
  44132. }
  44133. props = extend(extend({}, bindObject), props);
  44134. }
  44135. nodes = scopedSlotFn(props) || fallback;
  44136. } else {
  44137. nodes = this.$slots[name] || fallback;
  44138. }
  44139. var target = props && props.slot;
  44140. if (target) {
  44141. return this.$createElement('template', { slot: target }, nodes)
  44142. } else {
  44143. return nodes
  44144. }
  44145. }
  44146. /* */
  44147. /**
  44148. * Runtime helper for resolving filters
  44149. */
  44150. function resolveFilter (id) {
  44151. return resolveAsset(this.$options, 'filters', id, true) || identity
  44152. }
  44153. /* */
  44154. function isKeyNotMatch (expect, actual) {
  44155. if (Array.isArray(expect)) {
  44156. return expect.indexOf(actual) === -1
  44157. } else {
  44158. return expect !== actual
  44159. }
  44160. }
  44161. /**
  44162. * Runtime helper for checking keyCodes from config.
  44163. * exposed as Vue.prototype._k
  44164. * passing in eventKeyName as last argument separately for backwards compat
  44165. */
  44166. function checkKeyCodes (
  44167. eventKeyCode,
  44168. key,
  44169. builtInKeyCode,
  44170. eventKeyName,
  44171. builtInKeyName
  44172. ) {
  44173. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  44174. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  44175. return isKeyNotMatch(builtInKeyName, eventKeyName)
  44176. } else if (mappedKeyCode) {
  44177. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  44178. } else if (eventKeyName) {
  44179. return hyphenate(eventKeyName) !== key
  44180. }
  44181. }
  44182. /* */
  44183. /**
  44184. * Runtime helper for merging v-bind="object" into a VNode's data.
  44185. */
  44186. function bindObjectProps (
  44187. data,
  44188. tag,
  44189. value,
  44190. asProp,
  44191. isSync
  44192. ) {
  44193. if (value) {
  44194. if (!isObject(value)) {
  44195. warn(
  44196. 'v-bind without argument expects an Object or Array value',
  44197. this
  44198. );
  44199. } else {
  44200. if (Array.isArray(value)) {
  44201. value = toObject(value);
  44202. }
  44203. var hash;
  44204. var loop = function ( key ) {
  44205. if (
  44206. key === 'class' ||
  44207. key === 'style' ||
  44208. isReservedAttribute(key)
  44209. ) {
  44210. hash = data;
  44211. } else {
  44212. var type = data.attrs && data.attrs.type;
  44213. hash = asProp || config.mustUseProp(tag, type, key)
  44214. ? data.domProps || (data.domProps = {})
  44215. : data.attrs || (data.attrs = {});
  44216. }
  44217. var camelizedKey = camelize(key);
  44218. var hyphenatedKey = hyphenate(key);
  44219. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  44220. hash[key] = value[key];
  44221. if (isSync) {
  44222. var on = data.on || (data.on = {});
  44223. on[("update:" + key)] = function ($event) {
  44224. value[key] = $event;
  44225. };
  44226. }
  44227. }
  44228. };
  44229. for (var key in value) loop( key );
  44230. }
  44231. }
  44232. return data
  44233. }
  44234. /* */
  44235. /**
  44236. * Runtime helper for rendering static trees.
  44237. */
  44238. function renderStatic (
  44239. index,
  44240. isInFor
  44241. ) {
  44242. var cached = this._staticTrees || (this._staticTrees = []);
  44243. var tree = cached[index];
  44244. // if has already-rendered static tree and not inside v-for,
  44245. // we can reuse the same tree.
  44246. if (tree && !isInFor) {
  44247. return tree
  44248. }
  44249. // otherwise, render a fresh tree.
  44250. tree = cached[index] = this.$options.staticRenderFns[index].call(
  44251. this._renderProxy,
  44252. null,
  44253. this // for render fns generated for functional component templates
  44254. );
  44255. markStatic(tree, ("__static__" + index), false);
  44256. return tree
  44257. }
  44258. /**
  44259. * Runtime helper for v-once.
  44260. * Effectively it means marking the node as static with a unique key.
  44261. */
  44262. function markOnce (
  44263. tree,
  44264. index,
  44265. key
  44266. ) {
  44267. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  44268. return tree
  44269. }
  44270. function markStatic (
  44271. tree,
  44272. key,
  44273. isOnce
  44274. ) {
  44275. if (Array.isArray(tree)) {
  44276. for (var i = 0; i < tree.length; i++) {
  44277. if (tree[i] && typeof tree[i] !== 'string') {
  44278. markStaticNode(tree[i], (key + "_" + i), isOnce);
  44279. }
  44280. }
  44281. } else {
  44282. markStaticNode(tree, key, isOnce);
  44283. }
  44284. }
  44285. function markStaticNode (node, key, isOnce) {
  44286. node.isStatic = true;
  44287. node.key = key;
  44288. node.isOnce = isOnce;
  44289. }
  44290. /* */
  44291. function bindObjectListeners (data, value) {
  44292. if (value) {
  44293. if (!isPlainObject(value)) {
  44294. warn(
  44295. 'v-on without argument expects an Object value',
  44296. this
  44297. );
  44298. } else {
  44299. var on = data.on = data.on ? extend({}, data.on) : {};
  44300. for (var key in value) {
  44301. var existing = on[key];
  44302. var ours = value[key];
  44303. on[key] = existing ? [].concat(existing, ours) : ours;
  44304. }
  44305. }
  44306. }
  44307. return data
  44308. }
  44309. /* */
  44310. function resolveScopedSlots (
  44311. fns, // see flow/vnode
  44312. res,
  44313. // the following are added in 2.6
  44314. hasDynamicKeys,
  44315. contentHashKey
  44316. ) {
  44317. res = res || { $stable: !hasDynamicKeys };
  44318. for (var i = 0; i < fns.length; i++) {
  44319. var slot = fns[i];
  44320. if (Array.isArray(slot)) {
  44321. resolveScopedSlots(slot, res, hasDynamicKeys);
  44322. } else if (slot) {
  44323. // marker for reverse proxying v-slot without scope on this.$slots
  44324. if (slot.proxy) {
  44325. slot.fn.proxy = true;
  44326. }
  44327. res[slot.key] = slot.fn;
  44328. }
  44329. }
  44330. if (contentHashKey) {
  44331. (res).$key = contentHashKey;
  44332. }
  44333. return res
  44334. }
  44335. /* */
  44336. function bindDynamicKeys (baseObj, values) {
  44337. for (var i = 0; i < values.length; i += 2) {
  44338. var key = values[i];
  44339. if (typeof key === 'string' && key) {
  44340. baseObj[values[i]] = values[i + 1];
  44341. } else if (key !== '' && key !== null) {
  44342. // null is a special value for explicitly removing a binding
  44343. warn(
  44344. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  44345. this
  44346. );
  44347. }
  44348. }
  44349. return baseObj
  44350. }
  44351. // helper to dynamically append modifier runtime markers to event names.
  44352. // ensure only append when value is already string, otherwise it will be cast
  44353. // to string and cause the type check to miss.
  44354. function prependModifier (value, symbol) {
  44355. return typeof value === 'string' ? symbol + value : value
  44356. }
  44357. /* */
  44358. function installRenderHelpers (target) {
  44359. target._o = markOnce;
  44360. target._n = toNumber;
  44361. target._s = toString;
  44362. target._l = renderList;
  44363. target._t = renderSlot;
  44364. target._q = looseEqual;
  44365. target._i = looseIndexOf;
  44366. target._m = renderStatic;
  44367. target._f = resolveFilter;
  44368. target._k = checkKeyCodes;
  44369. target._b = bindObjectProps;
  44370. target._v = createTextVNode;
  44371. target._e = createEmptyVNode;
  44372. target._u = resolveScopedSlots;
  44373. target._g = bindObjectListeners;
  44374. target._d = bindDynamicKeys;
  44375. target._p = prependModifier;
  44376. }
  44377. /* */
  44378. function FunctionalRenderContext (
  44379. data,
  44380. props,
  44381. children,
  44382. parent,
  44383. Ctor
  44384. ) {
  44385. var this$1 = this;
  44386. var options = Ctor.options;
  44387. // ensure the createElement function in functional components
  44388. // gets a unique context - this is necessary for correct named slot check
  44389. var contextVm;
  44390. if (hasOwn(parent, '_uid')) {
  44391. contextVm = Object.create(parent);
  44392. // $flow-disable-line
  44393. contextVm._original = parent;
  44394. } else {
  44395. // the context vm passed in is a functional context as well.
  44396. // in this case we want to make sure we are able to get a hold to the
  44397. // real context instance.
  44398. contextVm = parent;
  44399. // $flow-disable-line
  44400. parent = parent._original;
  44401. }
  44402. var isCompiled = isTrue(options._compiled);
  44403. var needNormalization = !isCompiled;
  44404. this.data = data;
  44405. this.props = props;
  44406. this.children = children;
  44407. this.parent = parent;
  44408. this.listeners = data.on || emptyObject;
  44409. this.injections = resolveInject(options.inject, parent);
  44410. this.slots = function () {
  44411. if (!this$1.$slots) {
  44412. normalizeScopedSlots(
  44413. data.scopedSlots,
  44414. this$1.$slots = resolveSlots(children, parent)
  44415. );
  44416. }
  44417. return this$1.$slots
  44418. };
  44419. Object.defineProperty(this, 'scopedSlots', ({
  44420. enumerable: true,
  44421. get: function get () {
  44422. return normalizeScopedSlots(data.scopedSlots, this.slots())
  44423. }
  44424. }));
  44425. // support for compiled functional template
  44426. if (isCompiled) {
  44427. // exposing $options for renderStatic()
  44428. this.$options = options;
  44429. // pre-resolve slots for renderSlot()
  44430. this.$slots = this.slots();
  44431. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  44432. }
  44433. if (options._scopeId) {
  44434. this._c = function (a, b, c, d) {
  44435. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  44436. if (vnode && !Array.isArray(vnode)) {
  44437. vnode.fnScopeId = options._scopeId;
  44438. vnode.fnContext = parent;
  44439. }
  44440. return vnode
  44441. };
  44442. } else {
  44443. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  44444. }
  44445. }
  44446. installRenderHelpers(FunctionalRenderContext.prototype);
  44447. function createFunctionalComponent (
  44448. Ctor,
  44449. propsData,
  44450. data,
  44451. contextVm,
  44452. children
  44453. ) {
  44454. var options = Ctor.options;
  44455. var props = {};
  44456. var propOptions = options.props;
  44457. if (isDef(propOptions)) {
  44458. for (var key in propOptions) {
  44459. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  44460. }
  44461. } else {
  44462. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  44463. if (isDef(data.props)) { mergeProps(props, data.props); }
  44464. }
  44465. var renderContext = new FunctionalRenderContext(
  44466. data,
  44467. props,
  44468. children,
  44469. contextVm,
  44470. Ctor
  44471. );
  44472. var vnode = options.render.call(null, renderContext._c, renderContext);
  44473. if (vnode instanceof VNode) {
  44474. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  44475. } else if (Array.isArray(vnode)) {
  44476. var vnodes = normalizeChildren(vnode) || [];
  44477. var res = new Array(vnodes.length);
  44478. for (var i = 0; i < vnodes.length; i++) {
  44479. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  44480. }
  44481. return res
  44482. }
  44483. }
  44484. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  44485. // #7817 clone node before setting fnContext, otherwise if the node is reused
  44486. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  44487. // that should not be matched to match.
  44488. var clone = cloneVNode(vnode);
  44489. clone.fnContext = contextVm;
  44490. clone.fnOptions = options;
  44491. {
  44492. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  44493. }
  44494. if (data.slot) {
  44495. (clone.data || (clone.data = {})).slot = data.slot;
  44496. }
  44497. return clone
  44498. }
  44499. function mergeProps (to, from) {
  44500. for (var key in from) {
  44501. to[camelize(key)] = from[key];
  44502. }
  44503. }
  44504. /* */
  44505. /* */
  44506. /* */
  44507. /* */
  44508. // inline hooks to be invoked on component VNodes during patch
  44509. var componentVNodeHooks = {
  44510. init: function init (vnode, hydrating) {
  44511. if (
  44512. vnode.componentInstance &&
  44513. !vnode.componentInstance._isDestroyed &&
  44514. vnode.data.keepAlive
  44515. ) {
  44516. // kept-alive components, treat as a patch
  44517. var mountedNode = vnode; // work around flow
  44518. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  44519. } else {
  44520. var child = vnode.componentInstance = createComponentInstanceForVnode(
  44521. vnode,
  44522. activeInstance
  44523. );
  44524. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  44525. }
  44526. },
  44527. prepatch: function prepatch (oldVnode, vnode) {
  44528. var options = vnode.componentOptions;
  44529. var child = vnode.componentInstance = oldVnode.componentInstance;
  44530. updateChildComponent(
  44531. child,
  44532. options.propsData, // updated props
  44533. options.listeners, // updated listeners
  44534. vnode, // new parent vnode
  44535. options.children // new children
  44536. );
  44537. },
  44538. insert: function insert (vnode) {
  44539. var context = vnode.context;
  44540. var componentInstance = vnode.componentInstance;
  44541. if (!componentInstance._isMounted) {
  44542. componentInstance._isMounted = true;
  44543. callHook(componentInstance, 'mounted');
  44544. }
  44545. if (vnode.data.keepAlive) {
  44546. if (context._isMounted) {
  44547. // vue-router#1212
  44548. // During updates, a kept-alive component's child components may
  44549. // change, so directly walking the tree here may call activated hooks
  44550. // on incorrect children. Instead we push them into a queue which will
  44551. // be processed after the whole patch process ended.
  44552. queueActivatedComponent(componentInstance);
  44553. } else {
  44554. activateChildComponent(componentInstance, true /* direct */);
  44555. }
  44556. }
  44557. },
  44558. destroy: function destroy (vnode) {
  44559. var componentInstance = vnode.componentInstance;
  44560. if (!componentInstance._isDestroyed) {
  44561. if (!vnode.data.keepAlive) {
  44562. componentInstance.$destroy();
  44563. } else {
  44564. deactivateChildComponent(componentInstance, true /* direct */);
  44565. }
  44566. }
  44567. }
  44568. };
  44569. var hooksToMerge = Object.keys(componentVNodeHooks);
  44570. function createComponent (
  44571. Ctor,
  44572. data,
  44573. context,
  44574. children,
  44575. tag
  44576. ) {
  44577. if (isUndef(Ctor)) {
  44578. return
  44579. }
  44580. var baseCtor = context.$options._base;
  44581. // plain options object: turn it into a constructor
  44582. if (isObject(Ctor)) {
  44583. Ctor = baseCtor.extend(Ctor);
  44584. }
  44585. // if at this stage it's not a constructor or an async component factory,
  44586. // reject.
  44587. if (typeof Ctor !== 'function') {
  44588. {
  44589. warn(("Invalid Component definition: " + (String(Ctor))), context);
  44590. }
  44591. return
  44592. }
  44593. // async component
  44594. var asyncFactory;
  44595. if (isUndef(Ctor.cid)) {
  44596. asyncFactory = Ctor;
  44597. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  44598. if (Ctor === undefined) {
  44599. // return a placeholder node for async component, which is rendered
  44600. // as a comment node but preserves all the raw information for the node.
  44601. // the information will be used for async server-rendering and hydration.
  44602. return createAsyncPlaceholder(
  44603. asyncFactory,
  44604. data,
  44605. context,
  44606. children,
  44607. tag
  44608. )
  44609. }
  44610. }
  44611. data = data || {};
  44612. // resolve constructor options in case global mixins are applied after
  44613. // component constructor creation
  44614. resolveConstructorOptions(Ctor);
  44615. // transform component v-model data into props & events
  44616. if (isDef(data.model)) {
  44617. transformModel(Ctor.options, data);
  44618. }
  44619. // extract props
  44620. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  44621. // functional component
  44622. if (isTrue(Ctor.options.functional)) {
  44623. return createFunctionalComponent(Ctor, propsData, data, context, children)
  44624. }
  44625. // extract listeners, since these needs to be treated as
  44626. // child component listeners instead of DOM listeners
  44627. var listeners = data.on;
  44628. // replace with listeners with .native modifier
  44629. // so it gets processed during parent component patch.
  44630. data.on = data.nativeOn;
  44631. if (isTrue(Ctor.options.abstract)) {
  44632. // abstract components do not keep anything
  44633. // other than props & listeners & slot
  44634. // work around flow
  44635. var slot = data.slot;
  44636. data = {};
  44637. if (slot) {
  44638. data.slot = slot;
  44639. }
  44640. }
  44641. // install component management hooks onto the placeholder node
  44642. installComponentHooks(data);
  44643. // return a placeholder vnode
  44644. var name = Ctor.options.name || tag;
  44645. var vnode = new VNode(
  44646. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  44647. data, undefined, undefined, undefined, context,
  44648. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  44649. asyncFactory
  44650. );
  44651. return vnode
  44652. }
  44653. function createComponentInstanceForVnode (
  44654. vnode, // we know it's MountedComponentVNode but flow doesn't
  44655. parent // activeInstance in lifecycle state
  44656. ) {
  44657. var options = {
  44658. _isComponent: true,
  44659. _parentVnode: vnode,
  44660. parent: parent
  44661. };
  44662. // check inline-template render functions
  44663. var inlineTemplate = vnode.data.inlineTemplate;
  44664. if (isDef(inlineTemplate)) {
  44665. options.render = inlineTemplate.render;
  44666. options.staticRenderFns = inlineTemplate.staticRenderFns;
  44667. }
  44668. return new vnode.componentOptions.Ctor(options)
  44669. }
  44670. function installComponentHooks (data) {
  44671. var hooks = data.hook || (data.hook = {});
  44672. for (var i = 0; i < hooksToMerge.length; i++) {
  44673. var key = hooksToMerge[i];
  44674. var existing = hooks[key];
  44675. var toMerge = componentVNodeHooks[key];
  44676. if (existing !== toMerge && !(existing && existing._merged)) {
  44677. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  44678. }
  44679. }
  44680. }
  44681. function mergeHook$1 (f1, f2) {
  44682. var merged = function (a, b) {
  44683. // flow complains about extra args which is why we use any
  44684. f1(a, b);
  44685. f2(a, b);
  44686. };
  44687. merged._merged = true;
  44688. return merged
  44689. }
  44690. // transform component v-model info (value and callback) into
  44691. // prop and event handler respectively.
  44692. function transformModel (options, data) {
  44693. var prop = (options.model && options.model.prop) || 'value';
  44694. var event = (options.model && options.model.event) || 'input'
  44695. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  44696. var on = data.on || (data.on = {});
  44697. var existing = on[event];
  44698. var callback = data.model.callback;
  44699. if (isDef(existing)) {
  44700. if (
  44701. Array.isArray(existing)
  44702. ? existing.indexOf(callback) === -1
  44703. : existing !== callback
  44704. ) {
  44705. on[event] = [callback].concat(existing);
  44706. }
  44707. } else {
  44708. on[event] = callback;
  44709. }
  44710. }
  44711. /* */
  44712. var SIMPLE_NORMALIZE = 1;
  44713. var ALWAYS_NORMALIZE = 2;
  44714. // wrapper function for providing a more flexible interface
  44715. // without getting yelled at by flow
  44716. function createElement (
  44717. context,
  44718. tag,
  44719. data,
  44720. children,
  44721. normalizationType,
  44722. alwaysNormalize
  44723. ) {
  44724. if (Array.isArray(data) || isPrimitive(data)) {
  44725. normalizationType = children;
  44726. children = data;
  44727. data = undefined;
  44728. }
  44729. if (isTrue(alwaysNormalize)) {
  44730. normalizationType = ALWAYS_NORMALIZE;
  44731. }
  44732. return _createElement(context, tag, data, children, normalizationType)
  44733. }
  44734. function _createElement (
  44735. context,
  44736. tag,
  44737. data,
  44738. children,
  44739. normalizationType
  44740. ) {
  44741. if (isDef(data) && isDef((data).__ob__)) {
  44742. warn(
  44743. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  44744. 'Always create fresh vnode data objects in each render!',
  44745. context
  44746. );
  44747. return createEmptyVNode()
  44748. }
  44749. // object syntax in v-bind
  44750. if (isDef(data) && isDef(data.is)) {
  44751. tag = data.is;
  44752. }
  44753. if (!tag) {
  44754. // in case of component :is set to falsy value
  44755. return createEmptyVNode()
  44756. }
  44757. // warn against non-primitive key
  44758. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  44759. ) {
  44760. {
  44761. warn(
  44762. 'Avoid using non-primitive value as key, ' +
  44763. 'use string/number value instead.',
  44764. context
  44765. );
  44766. }
  44767. }
  44768. // support single function children as default scoped slot
  44769. if (Array.isArray(children) &&
  44770. typeof children[0] === 'function'
  44771. ) {
  44772. data = data || {};
  44773. data.scopedSlots = { default: children[0] };
  44774. children.length = 0;
  44775. }
  44776. if (normalizationType === ALWAYS_NORMALIZE) {
  44777. children = normalizeChildren(children);
  44778. } else if (normalizationType === SIMPLE_NORMALIZE) {
  44779. children = simpleNormalizeChildren(children);
  44780. }
  44781. var vnode, ns;
  44782. if (typeof tag === 'string') {
  44783. var Ctor;
  44784. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  44785. if (config.isReservedTag(tag)) {
  44786. // platform built-in elements
  44787. if (isDef(data) && isDef(data.nativeOn)) {
  44788. warn(
  44789. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  44790. context
  44791. );
  44792. }
  44793. vnode = new VNode(
  44794. config.parsePlatformTagName(tag), data, children,
  44795. undefined, undefined, context
  44796. );
  44797. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  44798. // component
  44799. vnode = createComponent(Ctor, data, context, children, tag);
  44800. } else {
  44801. // unknown or unlisted namespaced elements
  44802. // check at runtime because it may get assigned a namespace when its
  44803. // parent normalizes children
  44804. vnode = new VNode(
  44805. tag, data, children,
  44806. undefined, undefined, context
  44807. );
  44808. }
  44809. } else {
  44810. // direct component options / constructor
  44811. vnode = createComponent(tag, data, context, children);
  44812. }
  44813. if (Array.isArray(vnode)) {
  44814. return vnode
  44815. } else if (isDef(vnode)) {
  44816. if (isDef(ns)) { applyNS(vnode, ns); }
  44817. if (isDef(data)) { registerDeepBindings(data); }
  44818. return vnode
  44819. } else {
  44820. return createEmptyVNode()
  44821. }
  44822. }
  44823. function applyNS (vnode, ns, force) {
  44824. vnode.ns = ns;
  44825. if (vnode.tag === 'foreignObject') {
  44826. // use default namespace inside foreignObject
  44827. ns = undefined;
  44828. force = true;
  44829. }
  44830. if (isDef(vnode.children)) {
  44831. for (var i = 0, l = vnode.children.length; i < l; i++) {
  44832. var child = vnode.children[i];
  44833. if (isDef(child.tag) && (
  44834. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  44835. applyNS(child, ns, force);
  44836. }
  44837. }
  44838. }
  44839. }
  44840. // ref #5318
  44841. // necessary to ensure parent re-render when deep bindings like :style and
  44842. // :class are used on slot nodes
  44843. function registerDeepBindings (data) {
  44844. if (isObject(data.style)) {
  44845. traverse(data.style);
  44846. }
  44847. if (isObject(data.class)) {
  44848. traverse(data.class);
  44849. }
  44850. }
  44851. /* */
  44852. function initRender (vm) {
  44853. vm._vnode = null; // the root of the child tree
  44854. vm._staticTrees = null; // v-once cached trees
  44855. var options = vm.$options;
  44856. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  44857. var renderContext = parentVnode && parentVnode.context;
  44858. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  44859. vm.$scopedSlots = emptyObject;
  44860. // bind the createElement fn to this instance
  44861. // so that we get proper render context inside it.
  44862. // args order: tag, data, children, normalizationType, alwaysNormalize
  44863. // internal version is used by render functions compiled from templates
  44864. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  44865. // normalization is always applied for the public version, used in
  44866. // user-written render functions.
  44867. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  44868. // $attrs & $listeners are exposed for easier HOC creation.
  44869. // they need to be reactive so that HOCs using them are always updated
  44870. var parentData = parentVnode && parentVnode.data;
  44871. /* istanbul ignore else */
  44872. {
  44873. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  44874. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  44875. }, true);
  44876. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  44877. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  44878. }, true);
  44879. }
  44880. }
  44881. var currentRenderingInstance = null;
  44882. function renderMixin (Vue) {
  44883. // install runtime convenience helpers
  44884. installRenderHelpers(Vue.prototype);
  44885. Vue.prototype.$nextTick = function (fn) {
  44886. return nextTick(fn, this)
  44887. };
  44888. Vue.prototype._render = function () {
  44889. var vm = this;
  44890. var ref = vm.$options;
  44891. var render = ref.render;
  44892. var _parentVnode = ref._parentVnode;
  44893. if (_parentVnode) {
  44894. vm.$scopedSlots = normalizeScopedSlots(
  44895. _parentVnode.data.scopedSlots,
  44896. vm.$slots,
  44897. vm.$scopedSlots
  44898. );
  44899. }
  44900. // set parent vnode. this allows render functions to have access
  44901. // to the data on the placeholder node.
  44902. vm.$vnode = _parentVnode;
  44903. // render self
  44904. var vnode;
  44905. try {
  44906. // There's no need to maintain a stack because all render fns are called
  44907. // separately from one another. Nested component's render fns are called
  44908. // when parent component is patched.
  44909. currentRenderingInstance = vm;
  44910. vnode = render.call(vm._renderProxy, vm.$createElement);
  44911. } catch (e) {
  44912. handleError(e, vm, "render");
  44913. // return error render result,
  44914. // or previous vnode to prevent render error causing blank component
  44915. /* istanbul ignore else */
  44916. if (vm.$options.renderError) {
  44917. try {
  44918. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  44919. } catch (e) {
  44920. handleError(e, vm, "renderError");
  44921. vnode = vm._vnode;
  44922. }
  44923. } else {
  44924. vnode = vm._vnode;
  44925. }
  44926. } finally {
  44927. currentRenderingInstance = null;
  44928. }
  44929. // if the returned array contains only a single node, allow it
  44930. if (Array.isArray(vnode) && vnode.length === 1) {
  44931. vnode = vnode[0];
  44932. }
  44933. // return empty vnode in case the render function errored out
  44934. if (!(vnode instanceof VNode)) {
  44935. if (Array.isArray(vnode)) {
  44936. warn(
  44937. 'Multiple root nodes returned from render function. Render function ' +
  44938. 'should return a single root node.',
  44939. vm
  44940. );
  44941. }
  44942. vnode = createEmptyVNode();
  44943. }
  44944. // set parent
  44945. vnode.parent = _parentVnode;
  44946. return vnode
  44947. };
  44948. }
  44949. /* */
  44950. function ensureCtor (comp, base) {
  44951. if (
  44952. comp.__esModule ||
  44953. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  44954. ) {
  44955. comp = comp.default;
  44956. }
  44957. return isObject(comp)
  44958. ? base.extend(comp)
  44959. : comp
  44960. }
  44961. function createAsyncPlaceholder (
  44962. factory,
  44963. data,
  44964. context,
  44965. children,
  44966. tag
  44967. ) {
  44968. var node = createEmptyVNode();
  44969. node.asyncFactory = factory;
  44970. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  44971. return node
  44972. }
  44973. function resolveAsyncComponent (
  44974. factory,
  44975. baseCtor
  44976. ) {
  44977. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  44978. return factory.errorComp
  44979. }
  44980. if (isDef(factory.resolved)) {
  44981. return factory.resolved
  44982. }
  44983. var owner = currentRenderingInstance;
  44984. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  44985. // already pending
  44986. factory.owners.push(owner);
  44987. }
  44988. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  44989. return factory.loadingComp
  44990. }
  44991. if (owner && !isDef(factory.owners)) {
  44992. var owners = factory.owners = [owner];
  44993. var sync = true;
  44994. var timerLoading = null;
  44995. var timerTimeout = null
  44996. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  44997. var forceRender = function (renderCompleted) {
  44998. for (var i = 0, l = owners.length; i < l; i++) {
  44999. (owners[i]).$forceUpdate();
  45000. }
  45001. if (renderCompleted) {
  45002. owners.length = 0;
  45003. if (timerLoading !== null) {
  45004. clearTimeout(timerLoading);
  45005. timerLoading = null;
  45006. }
  45007. if (timerTimeout !== null) {
  45008. clearTimeout(timerTimeout);
  45009. timerTimeout = null;
  45010. }
  45011. }
  45012. };
  45013. var resolve = once(function (res) {
  45014. // cache resolved
  45015. factory.resolved = ensureCtor(res, baseCtor);
  45016. // invoke callbacks only if this is not a synchronous resolve
  45017. // (async resolves are shimmed as synchronous during SSR)
  45018. if (!sync) {
  45019. forceRender(true);
  45020. } else {
  45021. owners.length = 0;
  45022. }
  45023. });
  45024. var reject = once(function (reason) {
  45025. warn(
  45026. "Failed to resolve async component: " + (String(factory)) +
  45027. (reason ? ("\nReason: " + reason) : '')
  45028. );
  45029. if (isDef(factory.errorComp)) {
  45030. factory.error = true;
  45031. forceRender(true);
  45032. }
  45033. });
  45034. var res = factory(resolve, reject);
  45035. if (isObject(res)) {
  45036. if (isPromise(res)) {
  45037. // () => Promise
  45038. if (isUndef(factory.resolved)) {
  45039. res.then(resolve, reject);
  45040. }
  45041. } else if (isPromise(res.component)) {
  45042. res.component.then(resolve, reject);
  45043. if (isDef(res.error)) {
  45044. factory.errorComp = ensureCtor(res.error, baseCtor);
  45045. }
  45046. if (isDef(res.loading)) {
  45047. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  45048. if (res.delay === 0) {
  45049. factory.loading = true;
  45050. } else {
  45051. timerLoading = setTimeout(function () {
  45052. timerLoading = null;
  45053. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  45054. factory.loading = true;
  45055. forceRender(false);
  45056. }
  45057. }, res.delay || 200);
  45058. }
  45059. }
  45060. if (isDef(res.timeout)) {
  45061. timerTimeout = setTimeout(function () {
  45062. timerTimeout = null;
  45063. if (isUndef(factory.resolved)) {
  45064. reject(
  45065. "timeout (" + (res.timeout) + "ms)"
  45066. );
  45067. }
  45068. }, res.timeout);
  45069. }
  45070. }
  45071. }
  45072. sync = false;
  45073. // return in case resolved synchronously
  45074. return factory.loading
  45075. ? factory.loadingComp
  45076. : factory.resolved
  45077. }
  45078. }
  45079. /* */
  45080. function isAsyncPlaceholder (node) {
  45081. return node.isComment && node.asyncFactory
  45082. }
  45083. /* */
  45084. function getFirstComponentChild (children) {
  45085. if (Array.isArray(children)) {
  45086. for (var i = 0; i < children.length; i++) {
  45087. var c = children[i];
  45088. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  45089. return c
  45090. }
  45091. }
  45092. }
  45093. }
  45094. /* */
  45095. /* */
  45096. function initEvents (vm) {
  45097. vm._events = Object.create(null);
  45098. vm._hasHookEvent = false;
  45099. // init parent attached events
  45100. var listeners = vm.$options._parentListeners;
  45101. if (listeners) {
  45102. updateComponentListeners(vm, listeners);
  45103. }
  45104. }
  45105. var target;
  45106. function add (event, fn) {
  45107. target.$on(event, fn);
  45108. }
  45109. function remove$1 (event, fn) {
  45110. target.$off(event, fn);
  45111. }
  45112. function createOnceHandler (event, fn) {
  45113. var _target = target;
  45114. return function onceHandler () {
  45115. var res = fn.apply(null, arguments);
  45116. if (res !== null) {
  45117. _target.$off(event, onceHandler);
  45118. }
  45119. }
  45120. }
  45121. function updateComponentListeners (
  45122. vm,
  45123. listeners,
  45124. oldListeners
  45125. ) {
  45126. target = vm;
  45127. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  45128. target = undefined;
  45129. }
  45130. function eventsMixin (Vue) {
  45131. var hookRE = /^hook:/;
  45132. Vue.prototype.$on = function (event, fn) {
  45133. var vm = this;
  45134. if (Array.isArray(event)) {
  45135. for (var i = 0, l = event.length; i < l; i++) {
  45136. vm.$on(event[i], fn);
  45137. }
  45138. } else {
  45139. (vm._events[event] || (vm._events[event] = [])).push(fn);
  45140. // optimize hook:event cost by using a boolean flag marked at registration
  45141. // instead of a hash lookup
  45142. if (hookRE.test(event)) {
  45143. vm._hasHookEvent = true;
  45144. }
  45145. }
  45146. return vm
  45147. };
  45148. Vue.prototype.$once = function (event, fn) {
  45149. var vm = this;
  45150. function on () {
  45151. vm.$off(event, on);
  45152. fn.apply(vm, arguments);
  45153. }
  45154. on.fn = fn;
  45155. vm.$on(event, on);
  45156. return vm
  45157. };
  45158. Vue.prototype.$off = function (event, fn) {
  45159. var vm = this;
  45160. // all
  45161. if (!arguments.length) {
  45162. vm._events = Object.create(null);
  45163. return vm
  45164. }
  45165. // array of events
  45166. if (Array.isArray(event)) {
  45167. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  45168. vm.$off(event[i$1], fn);
  45169. }
  45170. return vm
  45171. }
  45172. // specific event
  45173. var cbs = vm._events[event];
  45174. if (!cbs) {
  45175. return vm
  45176. }
  45177. if (!fn) {
  45178. vm._events[event] = null;
  45179. return vm
  45180. }
  45181. // specific handler
  45182. var cb;
  45183. var i = cbs.length;
  45184. while (i--) {
  45185. cb = cbs[i];
  45186. if (cb === fn || cb.fn === fn) {
  45187. cbs.splice(i, 1);
  45188. break
  45189. }
  45190. }
  45191. return vm
  45192. };
  45193. Vue.prototype.$emit = function (event) {
  45194. var vm = this;
  45195. {
  45196. var lowerCaseEvent = event.toLowerCase();
  45197. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  45198. tip(
  45199. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  45200. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  45201. "Note that HTML attributes are case-insensitive and you cannot use " +
  45202. "v-on to listen to camelCase events when using in-DOM templates. " +
  45203. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  45204. );
  45205. }
  45206. }
  45207. var cbs = vm._events[event];
  45208. if (cbs) {
  45209. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  45210. var args = toArray(arguments, 1);
  45211. var info = "event handler for \"" + event + "\"";
  45212. for (var i = 0, l = cbs.length; i < l; i++) {
  45213. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  45214. }
  45215. }
  45216. return vm
  45217. };
  45218. }
  45219. /* */
  45220. var activeInstance = null;
  45221. var isUpdatingChildComponent = false;
  45222. function setActiveInstance(vm) {
  45223. var prevActiveInstance = activeInstance;
  45224. activeInstance = vm;
  45225. return function () {
  45226. activeInstance = prevActiveInstance;
  45227. }
  45228. }
  45229. function initLifecycle (vm) {
  45230. var options = vm.$options;
  45231. // locate first non-abstract parent
  45232. var parent = options.parent;
  45233. if (parent && !options.abstract) {
  45234. while (parent.$options.abstract && parent.$parent) {
  45235. parent = parent.$parent;
  45236. }
  45237. parent.$children.push(vm);
  45238. }
  45239. vm.$parent = parent;
  45240. vm.$root = parent ? parent.$root : vm;
  45241. vm.$children = [];
  45242. vm.$refs = {};
  45243. vm._watcher = null;
  45244. vm._inactive = null;
  45245. vm._directInactive = false;
  45246. vm._isMounted = false;
  45247. vm._isDestroyed = false;
  45248. vm._isBeingDestroyed = false;
  45249. }
  45250. function lifecycleMixin (Vue) {
  45251. Vue.prototype._update = function (vnode, hydrating) {
  45252. var vm = this;
  45253. var prevEl = vm.$el;
  45254. var prevVnode = vm._vnode;
  45255. var restoreActiveInstance = setActiveInstance(vm);
  45256. vm._vnode = vnode;
  45257. // Vue.prototype.__patch__ is injected in entry points
  45258. // based on the rendering backend used.
  45259. if (!prevVnode) {
  45260. // initial render
  45261. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  45262. } else {
  45263. // updates
  45264. vm.$el = vm.__patch__(prevVnode, vnode);
  45265. }
  45266. restoreActiveInstance();
  45267. // update __vue__ reference
  45268. if (prevEl) {
  45269. prevEl.__vue__ = null;
  45270. }
  45271. if (vm.$el) {
  45272. vm.$el.__vue__ = vm;
  45273. }
  45274. // if parent is an HOC, update its $el as well
  45275. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  45276. vm.$parent.$el = vm.$el;
  45277. }
  45278. // updated hook is called by the scheduler to ensure that children are
  45279. // updated in a parent's updated hook.
  45280. };
  45281. Vue.prototype.$forceUpdate = function () {
  45282. var vm = this;
  45283. if (vm._watcher) {
  45284. vm._watcher.update();
  45285. }
  45286. };
  45287. Vue.prototype.$destroy = function () {
  45288. var vm = this;
  45289. if (vm._isBeingDestroyed) {
  45290. return
  45291. }
  45292. callHook(vm, 'beforeDestroy');
  45293. vm._isBeingDestroyed = true;
  45294. // remove self from parent
  45295. var parent = vm.$parent;
  45296. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  45297. remove(parent.$children, vm);
  45298. }
  45299. // teardown watchers
  45300. if (vm._watcher) {
  45301. vm._watcher.teardown();
  45302. }
  45303. var i = vm._watchers.length;
  45304. while (i--) {
  45305. vm._watchers[i].teardown();
  45306. }
  45307. // remove reference from data ob
  45308. // frozen object may not have observer.
  45309. if (vm._data.__ob__) {
  45310. vm._data.__ob__.vmCount--;
  45311. }
  45312. // call the last hook...
  45313. vm._isDestroyed = true;
  45314. // invoke destroy hooks on current rendered tree
  45315. vm.__patch__(vm._vnode, null);
  45316. // fire destroyed hook
  45317. callHook(vm, 'destroyed');
  45318. // turn off all instance listeners.
  45319. vm.$off();
  45320. // remove __vue__ reference
  45321. if (vm.$el) {
  45322. vm.$el.__vue__ = null;
  45323. }
  45324. // release circular reference (#6759)
  45325. if (vm.$vnode) {
  45326. vm.$vnode.parent = null;
  45327. }
  45328. };
  45329. }
  45330. function mountComponent (
  45331. vm,
  45332. el,
  45333. hydrating
  45334. ) {
  45335. vm.$el = el;
  45336. if (!vm.$options.render) {
  45337. vm.$options.render = createEmptyVNode;
  45338. {
  45339. /* istanbul ignore if */
  45340. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  45341. vm.$options.el || el) {
  45342. warn(
  45343. 'You are using the runtime-only build of Vue where the template ' +
  45344. 'compiler is not available. Either pre-compile the templates into ' +
  45345. 'render functions, or use the compiler-included build.',
  45346. vm
  45347. );
  45348. } else {
  45349. warn(
  45350. 'Failed to mount component: template or render function not defined.',
  45351. vm
  45352. );
  45353. }
  45354. }
  45355. }
  45356. callHook(vm, 'beforeMount');
  45357. var updateComponent;
  45358. /* istanbul ignore if */
  45359. if (config.performance && mark) {
  45360. updateComponent = function () {
  45361. var name = vm._name;
  45362. var id = vm._uid;
  45363. var startTag = "vue-perf-start:" + id;
  45364. var endTag = "vue-perf-end:" + id;
  45365. mark(startTag);
  45366. var vnode = vm._render();
  45367. mark(endTag);
  45368. measure(("vue " + name + " render"), startTag, endTag);
  45369. mark(startTag);
  45370. vm._update(vnode, hydrating);
  45371. mark(endTag);
  45372. measure(("vue " + name + " patch"), startTag, endTag);
  45373. };
  45374. } else {
  45375. updateComponent = function () {
  45376. vm._update(vm._render(), hydrating);
  45377. };
  45378. }
  45379. // we set this to vm._watcher inside the watcher's constructor
  45380. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  45381. // component's mounted hook), which relies on vm._watcher being already defined
  45382. new Watcher(vm, updateComponent, noop, {
  45383. before: function before () {
  45384. if (vm._isMounted && !vm._isDestroyed) {
  45385. callHook(vm, 'beforeUpdate');
  45386. }
  45387. }
  45388. }, true /* isRenderWatcher */);
  45389. hydrating = false;
  45390. // manually mounted instance, call mounted on self
  45391. // mounted is called for render-created child components in its inserted hook
  45392. if (vm.$vnode == null) {
  45393. vm._isMounted = true;
  45394. callHook(vm, 'mounted');
  45395. }
  45396. return vm
  45397. }
  45398. function updateChildComponent (
  45399. vm,
  45400. propsData,
  45401. listeners,
  45402. parentVnode,
  45403. renderChildren
  45404. ) {
  45405. {
  45406. isUpdatingChildComponent = true;
  45407. }
  45408. // determine whether component has slot children
  45409. // we need to do this before overwriting $options._renderChildren.
  45410. // check if there are dynamic scopedSlots (hand-written or compiled but with
  45411. // dynamic slot names). Static scoped slots compiled from template has the
  45412. // "$stable" marker.
  45413. var newScopedSlots = parentVnode.data.scopedSlots;
  45414. var oldScopedSlots = vm.$scopedSlots;
  45415. var hasDynamicScopedSlot = !!(
  45416. (newScopedSlots && !newScopedSlots.$stable) ||
  45417. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  45418. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  45419. );
  45420. // Any static slot children from the parent may have changed during parent's
  45421. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  45422. // update is necessary to ensure correctness.
  45423. var needsForceUpdate = !!(
  45424. renderChildren || // has new static slots
  45425. vm.$options._renderChildren || // has old static slots
  45426. hasDynamicScopedSlot
  45427. );
  45428. vm.$options._parentVnode = parentVnode;
  45429. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  45430. if (vm._vnode) { // update child tree's parent
  45431. vm._vnode.parent = parentVnode;
  45432. }
  45433. vm.$options._renderChildren = renderChildren;
  45434. // update $attrs and $listeners hash
  45435. // these are also reactive so they may trigger child update if the child
  45436. // used them during render
  45437. vm.$attrs = parentVnode.data.attrs || emptyObject;
  45438. vm.$listeners = listeners || emptyObject;
  45439. // update props
  45440. if (propsData && vm.$options.props) {
  45441. toggleObserving(false);
  45442. var props = vm._props;
  45443. var propKeys = vm.$options._propKeys || [];
  45444. for (var i = 0; i < propKeys.length; i++) {
  45445. var key = propKeys[i];
  45446. var propOptions = vm.$options.props; // wtf flow?
  45447. props[key] = validateProp(key, propOptions, propsData, vm);
  45448. }
  45449. toggleObserving(true);
  45450. // keep a copy of raw propsData
  45451. vm.$options.propsData = propsData;
  45452. }
  45453. // update listeners
  45454. listeners = listeners || emptyObject;
  45455. var oldListeners = vm.$options._parentListeners;
  45456. vm.$options._parentListeners = listeners;
  45457. updateComponentListeners(vm, listeners, oldListeners);
  45458. // resolve slots + force update if has children
  45459. if (needsForceUpdate) {
  45460. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  45461. vm.$forceUpdate();
  45462. }
  45463. {
  45464. isUpdatingChildComponent = false;
  45465. }
  45466. }
  45467. function isInInactiveTree (vm) {
  45468. while (vm && (vm = vm.$parent)) {
  45469. if (vm._inactive) { return true }
  45470. }
  45471. return false
  45472. }
  45473. function activateChildComponent (vm, direct) {
  45474. if (direct) {
  45475. vm._directInactive = false;
  45476. if (isInInactiveTree(vm)) {
  45477. return
  45478. }
  45479. } else if (vm._directInactive) {
  45480. return
  45481. }
  45482. if (vm._inactive || vm._inactive === null) {
  45483. vm._inactive = false;
  45484. for (var i = 0; i < vm.$children.length; i++) {
  45485. activateChildComponent(vm.$children[i]);
  45486. }
  45487. callHook(vm, 'activated');
  45488. }
  45489. }
  45490. function deactivateChildComponent (vm, direct) {
  45491. if (direct) {
  45492. vm._directInactive = true;
  45493. if (isInInactiveTree(vm)) {
  45494. return
  45495. }
  45496. }
  45497. if (!vm._inactive) {
  45498. vm._inactive = true;
  45499. for (var i = 0; i < vm.$children.length; i++) {
  45500. deactivateChildComponent(vm.$children[i]);
  45501. }
  45502. callHook(vm, 'deactivated');
  45503. }
  45504. }
  45505. function callHook (vm, hook) {
  45506. // #7573 disable dep collection when invoking lifecycle hooks
  45507. pushTarget();
  45508. var handlers = vm.$options[hook];
  45509. var info = hook + " hook";
  45510. if (handlers) {
  45511. for (var i = 0, j = handlers.length; i < j; i++) {
  45512. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  45513. }
  45514. }
  45515. if (vm._hasHookEvent) {
  45516. vm.$emit('hook:' + hook);
  45517. }
  45518. popTarget();
  45519. }
  45520. /* */
  45521. var MAX_UPDATE_COUNT = 100;
  45522. var queue = [];
  45523. var activatedChildren = [];
  45524. var has = {};
  45525. var circular = {};
  45526. var waiting = false;
  45527. var flushing = false;
  45528. var index = 0;
  45529. /**
  45530. * Reset the scheduler's state.
  45531. */
  45532. function resetSchedulerState () {
  45533. index = queue.length = activatedChildren.length = 0;
  45534. has = {};
  45535. {
  45536. circular = {};
  45537. }
  45538. waiting = flushing = false;
  45539. }
  45540. // Async edge case #6566 requires saving the timestamp when event listeners are
  45541. // attached. However, calling performance.now() has a perf overhead especially
  45542. // if the page has thousands of event listeners. Instead, we take a timestamp
  45543. // every time the scheduler flushes and use that for all event listeners
  45544. // attached during that flush.
  45545. var currentFlushTimestamp = 0;
  45546. // Async edge case fix requires storing an event listener's attach timestamp.
  45547. var getNow = Date.now;
  45548. // Determine what event timestamp the browser is using. Annoyingly, the
  45549. // timestamp can either be hi-res (relative to page load) or low-res
  45550. // (relative to UNIX epoch), so in order to compare time we have to use the
  45551. // same timestamp type when saving the flush timestamp.
  45552. // All IE versions use low-res event timestamps, and have problematic clock
  45553. // implementations (#9632)
  45554. if (inBrowser && !isIE) {
  45555. var performance = window.performance;
  45556. if (
  45557. performance &&
  45558. typeof performance.now === 'function' &&
  45559. getNow() > document.createEvent('Event').timeStamp
  45560. ) {
  45561. // if the event timestamp, although evaluated AFTER the Date.now(), is
  45562. // smaller than it, it means the event is using a hi-res timestamp,
  45563. // and we need to use the hi-res version for event listener timestamps as
  45564. // well.
  45565. getNow = function () { return performance.now(); };
  45566. }
  45567. }
  45568. /**
  45569. * Flush both queues and run the watchers.
  45570. */
  45571. function flushSchedulerQueue () {
  45572. currentFlushTimestamp = getNow();
  45573. flushing = true;
  45574. var watcher, id;
  45575. // Sort queue before flush.
  45576. // This ensures that:
  45577. // 1. Components are updated from parent to child. (because parent is always
  45578. // created before the child)
  45579. // 2. A component's user watchers are run before its render watcher (because
  45580. // user watchers are created before the render watcher)
  45581. // 3. If a component is destroyed during a parent component's watcher run,
  45582. // its watchers can be skipped.
  45583. queue.sort(function (a, b) { return a.id - b.id; });
  45584. // do not cache length because more watchers might be pushed
  45585. // as we run existing watchers
  45586. for (index = 0; index < queue.length; index++) {
  45587. watcher = queue[index];
  45588. if (watcher.before) {
  45589. watcher.before();
  45590. }
  45591. id = watcher.id;
  45592. has[id] = null;
  45593. watcher.run();
  45594. // in dev build, check and stop circular updates.
  45595. if (has[id] != null) {
  45596. circular[id] = (circular[id] || 0) + 1;
  45597. if (circular[id] > MAX_UPDATE_COUNT) {
  45598. warn(
  45599. 'You may have an infinite update loop ' + (
  45600. watcher.user
  45601. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  45602. : "in a component render function."
  45603. ),
  45604. watcher.vm
  45605. );
  45606. break
  45607. }
  45608. }
  45609. }
  45610. // keep copies of post queues before resetting state
  45611. var activatedQueue = activatedChildren.slice();
  45612. var updatedQueue = queue.slice();
  45613. resetSchedulerState();
  45614. // call component updated and activated hooks
  45615. callActivatedHooks(activatedQueue);
  45616. callUpdatedHooks(updatedQueue);
  45617. // devtool hook
  45618. /* istanbul ignore if */
  45619. if (devtools && config.devtools) {
  45620. devtools.emit('flush');
  45621. }
  45622. }
  45623. function callUpdatedHooks (queue) {
  45624. var i = queue.length;
  45625. while (i--) {
  45626. var watcher = queue[i];
  45627. var vm = watcher.vm;
  45628. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  45629. callHook(vm, 'updated');
  45630. }
  45631. }
  45632. }
  45633. /**
  45634. * Queue a kept-alive component that was activated during patch.
  45635. * The queue will be processed after the entire tree has been patched.
  45636. */
  45637. function queueActivatedComponent (vm) {
  45638. // setting _inactive to false here so that a render function can
  45639. // rely on checking whether it's in an inactive tree (e.g. router-view)
  45640. vm._inactive = false;
  45641. activatedChildren.push(vm);
  45642. }
  45643. function callActivatedHooks (queue) {
  45644. for (var i = 0; i < queue.length; i++) {
  45645. queue[i]._inactive = true;
  45646. activateChildComponent(queue[i], true /* true */);
  45647. }
  45648. }
  45649. /**
  45650. * Push a watcher into the watcher queue.
  45651. * Jobs with duplicate IDs will be skipped unless it's
  45652. * pushed when the queue is being flushed.
  45653. */
  45654. function queueWatcher (watcher) {
  45655. var id = watcher.id;
  45656. if (has[id] == null) {
  45657. has[id] = true;
  45658. if (!flushing) {
  45659. queue.push(watcher);
  45660. } else {
  45661. // if already flushing, splice the watcher based on its id
  45662. // if already past its id, it will be run next immediately.
  45663. var i = queue.length - 1;
  45664. while (i > index && queue[i].id > watcher.id) {
  45665. i--;
  45666. }
  45667. queue.splice(i + 1, 0, watcher);
  45668. }
  45669. // queue the flush
  45670. if (!waiting) {
  45671. waiting = true;
  45672. if (!config.async) {
  45673. flushSchedulerQueue();
  45674. return
  45675. }
  45676. nextTick(flushSchedulerQueue);
  45677. }
  45678. }
  45679. }
  45680. /* */
  45681. var uid$2 = 0;
  45682. /**
  45683. * A watcher parses an expression, collects dependencies,
  45684. * and fires callback when the expression value changes.
  45685. * This is used for both the $watch() api and directives.
  45686. */
  45687. var Watcher = function Watcher (
  45688. vm,
  45689. expOrFn,
  45690. cb,
  45691. options,
  45692. isRenderWatcher
  45693. ) {
  45694. this.vm = vm;
  45695. if (isRenderWatcher) {
  45696. vm._watcher = this;
  45697. }
  45698. vm._watchers.push(this);
  45699. // options
  45700. if (options) {
  45701. this.deep = !!options.deep;
  45702. this.user = !!options.user;
  45703. this.lazy = !!options.lazy;
  45704. this.sync = !!options.sync;
  45705. this.before = options.before;
  45706. } else {
  45707. this.deep = this.user = this.lazy = this.sync = false;
  45708. }
  45709. this.cb = cb;
  45710. this.id = ++uid$2; // uid for batching
  45711. this.active = true;
  45712. this.dirty = this.lazy; // for lazy watchers
  45713. this.deps = [];
  45714. this.newDeps = [];
  45715. this.depIds = new _Set();
  45716. this.newDepIds = new _Set();
  45717. this.expression = expOrFn.toString();
  45718. // parse expression for getter
  45719. if (typeof expOrFn === 'function') {
  45720. this.getter = expOrFn;
  45721. } else {
  45722. this.getter = parsePath(expOrFn);
  45723. if (!this.getter) {
  45724. this.getter = noop;
  45725. warn(
  45726. "Failed watching path: \"" + expOrFn + "\" " +
  45727. 'Watcher only accepts simple dot-delimited paths. ' +
  45728. 'For full control, use a function instead.',
  45729. vm
  45730. );
  45731. }
  45732. }
  45733. this.value = this.lazy
  45734. ? undefined
  45735. : this.get();
  45736. };
  45737. /**
  45738. * Evaluate the getter, and re-collect dependencies.
  45739. */
  45740. Watcher.prototype.get = function get () {
  45741. pushTarget(this);
  45742. var value;
  45743. var vm = this.vm;
  45744. try {
  45745. value = this.getter.call(vm, vm);
  45746. } catch (e) {
  45747. if (this.user) {
  45748. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  45749. } else {
  45750. throw e
  45751. }
  45752. } finally {
  45753. // "touch" every property so they are all tracked as
  45754. // dependencies for deep watching
  45755. if (this.deep) {
  45756. traverse(value);
  45757. }
  45758. popTarget();
  45759. this.cleanupDeps();
  45760. }
  45761. return value
  45762. };
  45763. /**
  45764. * Add a dependency to this directive.
  45765. */
  45766. Watcher.prototype.addDep = function addDep (dep) {
  45767. var id = dep.id;
  45768. if (!this.newDepIds.has(id)) {
  45769. this.newDepIds.add(id);
  45770. this.newDeps.push(dep);
  45771. if (!this.depIds.has(id)) {
  45772. dep.addSub(this);
  45773. }
  45774. }
  45775. };
  45776. /**
  45777. * Clean up for dependency collection.
  45778. */
  45779. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  45780. var i = this.deps.length;
  45781. while (i--) {
  45782. var dep = this.deps[i];
  45783. if (!this.newDepIds.has(dep.id)) {
  45784. dep.removeSub(this);
  45785. }
  45786. }
  45787. var tmp = this.depIds;
  45788. this.depIds = this.newDepIds;
  45789. this.newDepIds = tmp;
  45790. this.newDepIds.clear();
  45791. tmp = this.deps;
  45792. this.deps = this.newDeps;
  45793. this.newDeps = tmp;
  45794. this.newDeps.length = 0;
  45795. };
  45796. /**
  45797. * Subscriber interface.
  45798. * Will be called when a dependency changes.
  45799. */
  45800. Watcher.prototype.update = function update () {
  45801. /* istanbul ignore else */
  45802. if (this.lazy) {
  45803. this.dirty = true;
  45804. } else if (this.sync) {
  45805. this.run();
  45806. } else {
  45807. queueWatcher(this);
  45808. }
  45809. };
  45810. /**
  45811. * Scheduler job interface.
  45812. * Will be called by the scheduler.
  45813. */
  45814. Watcher.prototype.run = function run () {
  45815. if (this.active) {
  45816. var value = this.get();
  45817. if (
  45818. value !== this.value ||
  45819. // Deep watchers and watchers on Object/Arrays should fire even
  45820. // when the value is the same, because the value may
  45821. // have mutated.
  45822. isObject(value) ||
  45823. this.deep
  45824. ) {
  45825. // set new value
  45826. var oldValue = this.value;
  45827. this.value = value;
  45828. if (this.user) {
  45829. try {
  45830. this.cb.call(this.vm, value, oldValue);
  45831. } catch (e) {
  45832. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  45833. }
  45834. } else {
  45835. this.cb.call(this.vm, value, oldValue);
  45836. }
  45837. }
  45838. }
  45839. };
  45840. /**
  45841. * Evaluate the value of the watcher.
  45842. * This only gets called for lazy watchers.
  45843. */
  45844. Watcher.prototype.evaluate = function evaluate () {
  45845. this.value = this.get();
  45846. this.dirty = false;
  45847. };
  45848. /**
  45849. * Depend on all deps collected by this watcher.
  45850. */
  45851. Watcher.prototype.depend = function depend () {
  45852. var i = this.deps.length;
  45853. while (i--) {
  45854. this.deps[i].depend();
  45855. }
  45856. };
  45857. /**
  45858. * Remove self from all dependencies' subscriber list.
  45859. */
  45860. Watcher.prototype.teardown = function teardown () {
  45861. if (this.active) {
  45862. // remove self from vm's watcher list
  45863. // this is a somewhat expensive operation so we skip it
  45864. // if the vm is being destroyed.
  45865. if (!this.vm._isBeingDestroyed) {
  45866. remove(this.vm._watchers, this);
  45867. }
  45868. var i = this.deps.length;
  45869. while (i--) {
  45870. this.deps[i].removeSub(this);
  45871. }
  45872. this.active = false;
  45873. }
  45874. };
  45875. /* */
  45876. var sharedPropertyDefinition = {
  45877. enumerable: true,
  45878. configurable: true,
  45879. get: noop,
  45880. set: noop
  45881. };
  45882. function proxy (target, sourceKey, key) {
  45883. sharedPropertyDefinition.get = function proxyGetter () {
  45884. return this[sourceKey][key]
  45885. };
  45886. sharedPropertyDefinition.set = function proxySetter (val) {
  45887. this[sourceKey][key] = val;
  45888. };
  45889. Object.defineProperty(target, key, sharedPropertyDefinition);
  45890. }
  45891. function initState (vm) {
  45892. vm._watchers = [];
  45893. var opts = vm.$options;
  45894. if (opts.props) { initProps(vm, opts.props); }
  45895. if (opts.methods) { initMethods(vm, opts.methods); }
  45896. if (opts.data) {
  45897. initData(vm);
  45898. } else {
  45899. observe(vm._data = {}, true /* asRootData */);
  45900. }
  45901. if (opts.computed) { initComputed(vm, opts.computed); }
  45902. if (opts.watch && opts.watch !== nativeWatch) {
  45903. initWatch(vm, opts.watch);
  45904. }
  45905. }
  45906. function initProps (vm, propsOptions) {
  45907. var propsData = vm.$options.propsData || {};
  45908. var props = vm._props = {};
  45909. // cache prop keys so that future props updates can iterate using Array
  45910. // instead of dynamic object key enumeration.
  45911. var keys = vm.$options._propKeys = [];
  45912. var isRoot = !vm.$parent;
  45913. // root instance props should be converted
  45914. if (!isRoot) {
  45915. toggleObserving(false);
  45916. }
  45917. var loop = function ( key ) {
  45918. keys.push(key);
  45919. var value = validateProp(key, propsOptions, propsData, vm);
  45920. /* istanbul ignore else */
  45921. {
  45922. var hyphenatedKey = hyphenate(key);
  45923. if (isReservedAttribute(hyphenatedKey) ||
  45924. config.isReservedAttr(hyphenatedKey)) {
  45925. warn(
  45926. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  45927. vm
  45928. );
  45929. }
  45930. defineReactive$$1(props, key, value, function () {
  45931. if (!isRoot && !isUpdatingChildComponent) {
  45932. warn(
  45933. "Avoid mutating a prop directly since the value will be " +
  45934. "overwritten whenever the parent component re-renders. " +
  45935. "Instead, use a data or computed property based on the prop's " +
  45936. "value. Prop being mutated: \"" + key + "\"",
  45937. vm
  45938. );
  45939. }
  45940. });
  45941. }
  45942. // static props are already proxied on the component's prototype
  45943. // during Vue.extend(). We only need to proxy props defined at
  45944. // instantiation here.
  45945. if (!(key in vm)) {
  45946. proxy(vm, "_props", key);
  45947. }
  45948. };
  45949. for (var key in propsOptions) loop( key );
  45950. toggleObserving(true);
  45951. }
  45952. function initData (vm) {
  45953. var data = vm.$options.data;
  45954. data = vm._data = typeof data === 'function'
  45955. ? getData(data, vm)
  45956. : data || {};
  45957. if (!isPlainObject(data)) {
  45958. data = {};
  45959. warn(
  45960. 'data functions should return an object:\n' +
  45961. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  45962. vm
  45963. );
  45964. }
  45965. // proxy data on instance
  45966. var keys = Object.keys(data);
  45967. var props = vm.$options.props;
  45968. var methods = vm.$options.methods;
  45969. var i = keys.length;
  45970. while (i--) {
  45971. var key = keys[i];
  45972. {
  45973. if (methods && hasOwn(methods, key)) {
  45974. warn(
  45975. ("Method \"" + key + "\" has already been defined as a data property."),
  45976. vm
  45977. );
  45978. }
  45979. }
  45980. if (props && hasOwn(props, key)) {
  45981. warn(
  45982. "The data property \"" + key + "\" is already declared as a prop. " +
  45983. "Use prop default value instead.",
  45984. vm
  45985. );
  45986. } else if (!isReserved(key)) {
  45987. proxy(vm, "_data", key);
  45988. }
  45989. }
  45990. // observe data
  45991. observe(data, true /* asRootData */);
  45992. }
  45993. function getData (data, vm) {
  45994. // #7573 disable dep collection when invoking data getters
  45995. pushTarget();
  45996. try {
  45997. return data.call(vm, vm)
  45998. } catch (e) {
  45999. handleError(e, vm, "data()");
  46000. return {}
  46001. } finally {
  46002. popTarget();
  46003. }
  46004. }
  46005. var computedWatcherOptions = { lazy: true };
  46006. function initComputed (vm, computed) {
  46007. // $flow-disable-line
  46008. var watchers = vm._computedWatchers = Object.create(null);
  46009. // computed properties are just getters during SSR
  46010. var isSSR = isServerRendering();
  46011. for (var key in computed) {
  46012. var userDef = computed[key];
  46013. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  46014. if (getter == null) {
  46015. warn(
  46016. ("Getter is missing for computed property \"" + key + "\"."),
  46017. vm
  46018. );
  46019. }
  46020. if (!isSSR) {
  46021. // create internal watcher for the computed property.
  46022. watchers[key] = new Watcher(
  46023. vm,
  46024. getter || noop,
  46025. noop,
  46026. computedWatcherOptions
  46027. );
  46028. }
  46029. // component-defined computed properties are already defined on the
  46030. // component prototype. We only need to define computed properties defined
  46031. // at instantiation here.
  46032. if (!(key in vm)) {
  46033. defineComputed(vm, key, userDef);
  46034. } else {
  46035. if (key in vm.$data) {
  46036. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  46037. } else if (vm.$options.props && key in vm.$options.props) {
  46038. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  46039. }
  46040. }
  46041. }
  46042. }
  46043. function defineComputed (
  46044. target,
  46045. key,
  46046. userDef
  46047. ) {
  46048. var shouldCache = !isServerRendering();
  46049. if (typeof userDef === 'function') {
  46050. sharedPropertyDefinition.get = shouldCache
  46051. ? createComputedGetter(key)
  46052. : createGetterInvoker(userDef);
  46053. sharedPropertyDefinition.set = noop;
  46054. } else {
  46055. sharedPropertyDefinition.get = userDef.get
  46056. ? shouldCache && userDef.cache !== false
  46057. ? createComputedGetter(key)
  46058. : createGetterInvoker(userDef.get)
  46059. : noop;
  46060. sharedPropertyDefinition.set = userDef.set || noop;
  46061. }
  46062. if (sharedPropertyDefinition.set === noop) {
  46063. sharedPropertyDefinition.set = function () {
  46064. warn(
  46065. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  46066. this
  46067. );
  46068. };
  46069. }
  46070. Object.defineProperty(target, key, sharedPropertyDefinition);
  46071. }
  46072. function createComputedGetter (key) {
  46073. return function computedGetter () {
  46074. var watcher = this._computedWatchers && this._computedWatchers[key];
  46075. if (watcher) {
  46076. if (watcher.dirty) {
  46077. watcher.evaluate();
  46078. }
  46079. if (Dep.target) {
  46080. watcher.depend();
  46081. }
  46082. return watcher.value
  46083. }
  46084. }
  46085. }
  46086. function createGetterInvoker(fn) {
  46087. return function computedGetter () {
  46088. return fn.call(this, this)
  46089. }
  46090. }
  46091. function initMethods (vm, methods) {
  46092. var props = vm.$options.props;
  46093. for (var key in methods) {
  46094. {
  46095. if (typeof methods[key] !== 'function') {
  46096. warn(
  46097. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  46098. "Did you reference the function correctly?",
  46099. vm
  46100. );
  46101. }
  46102. if (props && hasOwn(props, key)) {
  46103. warn(
  46104. ("Method \"" + key + "\" has already been defined as a prop."),
  46105. vm
  46106. );
  46107. }
  46108. if ((key in vm) && isReserved(key)) {
  46109. warn(
  46110. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  46111. "Avoid defining component methods that start with _ or $."
  46112. );
  46113. }
  46114. }
  46115. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  46116. }
  46117. }
  46118. function initWatch (vm, watch) {
  46119. for (var key in watch) {
  46120. var handler = watch[key];
  46121. if (Array.isArray(handler)) {
  46122. for (var i = 0; i < handler.length; i++) {
  46123. createWatcher(vm, key, handler[i]);
  46124. }
  46125. } else {
  46126. createWatcher(vm, key, handler);
  46127. }
  46128. }
  46129. }
  46130. function createWatcher (
  46131. vm,
  46132. expOrFn,
  46133. handler,
  46134. options
  46135. ) {
  46136. if (isPlainObject(handler)) {
  46137. options = handler;
  46138. handler = handler.handler;
  46139. }
  46140. if (typeof handler === 'string') {
  46141. handler = vm[handler];
  46142. }
  46143. return vm.$watch(expOrFn, handler, options)
  46144. }
  46145. function stateMixin (Vue) {
  46146. // flow somehow has problems with directly declared definition object
  46147. // when using Object.defineProperty, so we have to procedurally build up
  46148. // the object here.
  46149. var dataDef = {};
  46150. dataDef.get = function () { return this._data };
  46151. var propsDef = {};
  46152. propsDef.get = function () { return this._props };
  46153. {
  46154. dataDef.set = function () {
  46155. warn(
  46156. 'Avoid replacing instance root $data. ' +
  46157. 'Use nested data properties instead.',
  46158. this
  46159. );
  46160. };
  46161. propsDef.set = function () {
  46162. warn("$props is readonly.", this);
  46163. };
  46164. }
  46165. Object.defineProperty(Vue.prototype, '$data', dataDef);
  46166. Object.defineProperty(Vue.prototype, '$props', propsDef);
  46167. Vue.prototype.$set = set;
  46168. Vue.prototype.$delete = del;
  46169. Vue.prototype.$watch = function (
  46170. expOrFn,
  46171. cb,
  46172. options
  46173. ) {
  46174. var vm = this;
  46175. if (isPlainObject(cb)) {
  46176. return createWatcher(vm, expOrFn, cb, options)
  46177. }
  46178. options = options || {};
  46179. options.user = true;
  46180. var watcher = new Watcher(vm, expOrFn, cb, options);
  46181. if (options.immediate) {
  46182. try {
  46183. cb.call(vm, watcher.value);
  46184. } catch (error) {
  46185. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  46186. }
  46187. }
  46188. return function unwatchFn () {
  46189. watcher.teardown();
  46190. }
  46191. };
  46192. }
  46193. /* */
  46194. var uid$3 = 0;
  46195. function initMixin (Vue) {
  46196. Vue.prototype._init = function (options) {
  46197. var vm = this;
  46198. // a uid
  46199. vm._uid = uid$3++;
  46200. var startTag, endTag;
  46201. /* istanbul ignore if */
  46202. if (config.performance && mark) {
  46203. startTag = "vue-perf-start:" + (vm._uid);
  46204. endTag = "vue-perf-end:" + (vm._uid);
  46205. mark(startTag);
  46206. }
  46207. // a flag to avoid this being observed
  46208. vm._isVue = true;
  46209. // merge options
  46210. if (options && options._isComponent) {
  46211. // optimize internal component instantiation
  46212. // since dynamic options merging is pretty slow, and none of the
  46213. // internal component options needs special treatment.
  46214. initInternalComponent(vm, options);
  46215. } else {
  46216. vm.$options = mergeOptions(
  46217. resolveConstructorOptions(vm.constructor),
  46218. options || {},
  46219. vm
  46220. );
  46221. }
  46222. /* istanbul ignore else */
  46223. {
  46224. initProxy(vm);
  46225. }
  46226. // expose real self
  46227. vm._self = vm;
  46228. initLifecycle(vm);
  46229. initEvents(vm);
  46230. initRender(vm);
  46231. callHook(vm, 'beforeCreate');
  46232. initInjections(vm); // resolve injections before data/props
  46233. initState(vm);
  46234. initProvide(vm); // resolve provide after data/props
  46235. callHook(vm, 'created');
  46236. /* istanbul ignore if */
  46237. if (config.performance && mark) {
  46238. vm._name = formatComponentName(vm, false);
  46239. mark(endTag);
  46240. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  46241. }
  46242. if (vm.$options.el) {
  46243. vm.$mount(vm.$options.el);
  46244. }
  46245. };
  46246. }
  46247. function initInternalComponent (vm, options) {
  46248. var opts = vm.$options = Object.create(vm.constructor.options);
  46249. // doing this because it's faster than dynamic enumeration.
  46250. var parentVnode = options._parentVnode;
  46251. opts.parent = options.parent;
  46252. opts._parentVnode = parentVnode;
  46253. var vnodeComponentOptions = parentVnode.componentOptions;
  46254. opts.propsData = vnodeComponentOptions.propsData;
  46255. opts._parentListeners = vnodeComponentOptions.listeners;
  46256. opts._renderChildren = vnodeComponentOptions.children;
  46257. opts._componentTag = vnodeComponentOptions.tag;
  46258. if (options.render) {
  46259. opts.render = options.render;
  46260. opts.staticRenderFns = options.staticRenderFns;
  46261. }
  46262. }
  46263. function resolveConstructorOptions (Ctor) {
  46264. var options = Ctor.options;
  46265. if (Ctor.super) {
  46266. var superOptions = resolveConstructorOptions(Ctor.super);
  46267. var cachedSuperOptions = Ctor.superOptions;
  46268. if (superOptions !== cachedSuperOptions) {
  46269. // super option changed,
  46270. // need to resolve new options.
  46271. Ctor.superOptions = superOptions;
  46272. // check if there are any late-modified/attached options (#4976)
  46273. var modifiedOptions = resolveModifiedOptions(Ctor);
  46274. // update base extend options
  46275. if (modifiedOptions) {
  46276. extend(Ctor.extendOptions, modifiedOptions);
  46277. }
  46278. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  46279. if (options.name) {
  46280. options.components[options.name] = Ctor;
  46281. }
  46282. }
  46283. }
  46284. return options
  46285. }
  46286. function resolveModifiedOptions (Ctor) {
  46287. var modified;
  46288. var latest = Ctor.options;
  46289. var sealed = Ctor.sealedOptions;
  46290. for (var key in latest) {
  46291. if (latest[key] !== sealed[key]) {
  46292. if (!modified) { modified = {}; }
  46293. modified[key] = latest[key];
  46294. }
  46295. }
  46296. return modified
  46297. }
  46298. function Vue (options) {
  46299. if (!(this instanceof Vue)
  46300. ) {
  46301. warn('Vue is a constructor and should be called with the `new` keyword');
  46302. }
  46303. this._init(options);
  46304. }
  46305. initMixin(Vue);
  46306. stateMixin(Vue);
  46307. eventsMixin(Vue);
  46308. lifecycleMixin(Vue);
  46309. renderMixin(Vue);
  46310. /* */
  46311. function initUse (Vue) {
  46312. Vue.use = function (plugin) {
  46313. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  46314. if (installedPlugins.indexOf(plugin) > -1) {
  46315. return this
  46316. }
  46317. // additional parameters
  46318. var args = toArray(arguments, 1);
  46319. args.unshift(this);
  46320. if (typeof plugin.install === 'function') {
  46321. plugin.install.apply(plugin, args);
  46322. } else if (typeof plugin === 'function') {
  46323. plugin.apply(null, args);
  46324. }
  46325. installedPlugins.push(plugin);
  46326. return this
  46327. };
  46328. }
  46329. /* */
  46330. function initMixin$1 (Vue) {
  46331. Vue.mixin = function (mixin) {
  46332. this.options = mergeOptions(this.options, mixin);
  46333. return this
  46334. };
  46335. }
  46336. /* */
  46337. function initExtend (Vue) {
  46338. /**
  46339. * Each instance constructor, including Vue, has a unique
  46340. * cid. This enables us to create wrapped "child
  46341. * constructors" for prototypal inheritance and cache them.
  46342. */
  46343. Vue.cid = 0;
  46344. var cid = 1;
  46345. /**
  46346. * Class inheritance
  46347. */
  46348. Vue.extend = function (extendOptions) {
  46349. extendOptions = extendOptions || {};
  46350. var Super = this;
  46351. var SuperId = Super.cid;
  46352. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  46353. if (cachedCtors[SuperId]) {
  46354. return cachedCtors[SuperId]
  46355. }
  46356. var name = extendOptions.name || Super.options.name;
  46357. if (name) {
  46358. validateComponentName(name);
  46359. }
  46360. var Sub = function VueComponent (options) {
  46361. this._init(options);
  46362. };
  46363. Sub.prototype = Object.create(Super.prototype);
  46364. Sub.prototype.constructor = Sub;
  46365. Sub.cid = cid++;
  46366. Sub.options = mergeOptions(
  46367. Super.options,
  46368. extendOptions
  46369. );
  46370. Sub['super'] = Super;
  46371. // For props and computed properties, we define the proxy getters on
  46372. // the Vue instances at extension time, on the extended prototype. This
  46373. // avoids Object.defineProperty calls for each instance created.
  46374. if (Sub.options.props) {
  46375. initProps$1(Sub);
  46376. }
  46377. if (Sub.options.computed) {
  46378. initComputed$1(Sub);
  46379. }
  46380. // allow further extension/mixin/plugin usage
  46381. Sub.extend = Super.extend;
  46382. Sub.mixin = Super.mixin;
  46383. Sub.use = Super.use;
  46384. // create asset registers, so extended classes
  46385. // can have their private assets too.
  46386. ASSET_TYPES.forEach(function (type) {
  46387. Sub[type] = Super[type];
  46388. });
  46389. // enable recursive self-lookup
  46390. if (name) {
  46391. Sub.options.components[name] = Sub;
  46392. }
  46393. // keep a reference to the super options at extension time.
  46394. // later at instantiation we can check if Super's options have
  46395. // been updated.
  46396. Sub.superOptions = Super.options;
  46397. Sub.extendOptions = extendOptions;
  46398. Sub.sealedOptions = extend({}, Sub.options);
  46399. // cache constructor
  46400. cachedCtors[SuperId] = Sub;
  46401. return Sub
  46402. };
  46403. }
  46404. function initProps$1 (Comp) {
  46405. var props = Comp.options.props;
  46406. for (var key in props) {
  46407. proxy(Comp.prototype, "_props", key);
  46408. }
  46409. }
  46410. function initComputed$1 (Comp) {
  46411. var computed = Comp.options.computed;
  46412. for (var key in computed) {
  46413. defineComputed(Comp.prototype, key, computed[key]);
  46414. }
  46415. }
  46416. /* */
  46417. function initAssetRegisters (Vue) {
  46418. /**
  46419. * Create asset registration methods.
  46420. */
  46421. ASSET_TYPES.forEach(function (type) {
  46422. Vue[type] = function (
  46423. id,
  46424. definition
  46425. ) {
  46426. if (!definition) {
  46427. return this.options[type + 's'][id]
  46428. } else {
  46429. /* istanbul ignore if */
  46430. if (type === 'component') {
  46431. validateComponentName(id);
  46432. }
  46433. if (type === 'component' && isPlainObject(definition)) {
  46434. definition.name = definition.name || id;
  46435. definition = this.options._base.extend(definition);
  46436. }
  46437. if (type === 'directive' && typeof definition === 'function') {
  46438. definition = { bind: definition, update: definition };
  46439. }
  46440. this.options[type + 's'][id] = definition;
  46441. return definition
  46442. }
  46443. };
  46444. });
  46445. }
  46446. /* */
  46447. function getComponentName (opts) {
  46448. return opts && (opts.Ctor.options.name || opts.tag)
  46449. }
  46450. function matches (pattern, name) {
  46451. if (Array.isArray(pattern)) {
  46452. return pattern.indexOf(name) > -1
  46453. } else if (typeof pattern === 'string') {
  46454. return pattern.split(',').indexOf(name) > -1
  46455. } else if (isRegExp(pattern)) {
  46456. return pattern.test(name)
  46457. }
  46458. /* istanbul ignore next */
  46459. return false
  46460. }
  46461. function pruneCache (keepAliveInstance, filter) {
  46462. var cache = keepAliveInstance.cache;
  46463. var keys = keepAliveInstance.keys;
  46464. var _vnode = keepAliveInstance._vnode;
  46465. for (var key in cache) {
  46466. var cachedNode = cache[key];
  46467. if (cachedNode) {
  46468. var name = getComponentName(cachedNode.componentOptions);
  46469. if (name && !filter(name)) {
  46470. pruneCacheEntry(cache, key, keys, _vnode);
  46471. }
  46472. }
  46473. }
  46474. }
  46475. function pruneCacheEntry (
  46476. cache,
  46477. key,
  46478. keys,
  46479. current
  46480. ) {
  46481. var cached$$1 = cache[key];
  46482. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  46483. cached$$1.componentInstance.$destroy();
  46484. }
  46485. cache[key] = null;
  46486. remove(keys, key);
  46487. }
  46488. var patternTypes = [String, RegExp, Array];
  46489. var KeepAlive = {
  46490. name: 'keep-alive',
  46491. abstract: true,
  46492. props: {
  46493. include: patternTypes,
  46494. exclude: patternTypes,
  46495. max: [String, Number]
  46496. },
  46497. created: function created () {
  46498. this.cache = Object.create(null);
  46499. this.keys = [];
  46500. },
  46501. destroyed: function destroyed () {
  46502. for (var key in this.cache) {
  46503. pruneCacheEntry(this.cache, key, this.keys);
  46504. }
  46505. },
  46506. mounted: function mounted () {
  46507. var this$1 = this;
  46508. this.$watch('include', function (val) {
  46509. pruneCache(this$1, function (name) { return matches(val, name); });
  46510. });
  46511. this.$watch('exclude', function (val) {
  46512. pruneCache(this$1, function (name) { return !matches(val, name); });
  46513. });
  46514. },
  46515. render: function render () {
  46516. var slot = this.$slots.default;
  46517. var vnode = getFirstComponentChild(slot);
  46518. var componentOptions = vnode && vnode.componentOptions;
  46519. if (componentOptions) {
  46520. // check pattern
  46521. var name = getComponentName(componentOptions);
  46522. var ref = this;
  46523. var include = ref.include;
  46524. var exclude = ref.exclude;
  46525. if (
  46526. // not included
  46527. (include && (!name || !matches(include, name))) ||
  46528. // excluded
  46529. (exclude && name && matches(exclude, name))
  46530. ) {
  46531. return vnode
  46532. }
  46533. var ref$1 = this;
  46534. var cache = ref$1.cache;
  46535. var keys = ref$1.keys;
  46536. var key = vnode.key == null
  46537. // same constructor may get registered as different local components
  46538. // so cid alone is not enough (#3269)
  46539. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  46540. : vnode.key;
  46541. if (cache[key]) {
  46542. vnode.componentInstance = cache[key].componentInstance;
  46543. // make current key freshest
  46544. remove(keys, key);
  46545. keys.push(key);
  46546. } else {
  46547. cache[key] = vnode;
  46548. keys.push(key);
  46549. // prune oldest entry
  46550. if (this.max && keys.length > parseInt(this.max)) {
  46551. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  46552. }
  46553. }
  46554. vnode.data.keepAlive = true;
  46555. }
  46556. return vnode || (slot && slot[0])
  46557. }
  46558. };
  46559. var builtInComponents = {
  46560. KeepAlive: KeepAlive
  46561. };
  46562. /* */
  46563. function initGlobalAPI (Vue) {
  46564. // config
  46565. var configDef = {};
  46566. configDef.get = function () { return config; };
  46567. {
  46568. configDef.set = function () {
  46569. warn(
  46570. 'Do not replace the Vue.config object, set individual fields instead.'
  46571. );
  46572. };
  46573. }
  46574. Object.defineProperty(Vue, 'config', configDef);
  46575. // exposed util methods.
  46576. // NOTE: these are not considered part of the public API - avoid relying on
  46577. // them unless you are aware of the risk.
  46578. Vue.util = {
  46579. warn: warn,
  46580. extend: extend,
  46581. mergeOptions: mergeOptions,
  46582. defineReactive: defineReactive$$1
  46583. };
  46584. Vue.set = set;
  46585. Vue.delete = del;
  46586. Vue.nextTick = nextTick;
  46587. // 2.6 explicit observable API
  46588. Vue.observable = function (obj) {
  46589. observe(obj);
  46590. return obj
  46591. };
  46592. Vue.options = Object.create(null);
  46593. ASSET_TYPES.forEach(function (type) {
  46594. Vue.options[type + 's'] = Object.create(null);
  46595. });
  46596. // this is used to identify the "base" constructor to extend all plain-object
  46597. // components with in Weex's multi-instance scenarios.
  46598. Vue.options._base = Vue;
  46599. extend(Vue.options.components, builtInComponents);
  46600. initUse(Vue);
  46601. initMixin$1(Vue);
  46602. initExtend(Vue);
  46603. initAssetRegisters(Vue);
  46604. }
  46605. initGlobalAPI(Vue);
  46606. Object.defineProperty(Vue.prototype, '$isServer', {
  46607. get: isServerRendering
  46608. });
  46609. Object.defineProperty(Vue.prototype, '$ssrContext', {
  46610. get: function get () {
  46611. /* istanbul ignore next */
  46612. return this.$vnode && this.$vnode.ssrContext
  46613. }
  46614. });
  46615. // expose FunctionalRenderContext for ssr runtime helper installation
  46616. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  46617. value: FunctionalRenderContext
  46618. });
  46619. Vue.version = '2.6.11';
  46620. /* */
  46621. // these are reserved for web because they are directly compiled away
  46622. // during template compilation
  46623. var isReservedAttr = makeMap('style,class');
  46624. // attributes that should be using props for binding
  46625. var acceptValue = makeMap('input,textarea,option,select,progress');
  46626. var mustUseProp = function (tag, type, attr) {
  46627. return (
  46628. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  46629. (attr === 'selected' && tag === 'option') ||
  46630. (attr === 'checked' && tag === 'input') ||
  46631. (attr === 'muted' && tag === 'video')
  46632. )
  46633. };
  46634. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  46635. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  46636. var convertEnumeratedValue = function (key, value) {
  46637. return isFalsyAttrValue(value) || value === 'false'
  46638. ? 'false'
  46639. // allow arbitrary string value for contenteditable
  46640. : key === 'contenteditable' && isValidContentEditableValue(value)
  46641. ? value
  46642. : 'true'
  46643. };
  46644. var isBooleanAttr = makeMap(
  46645. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  46646. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  46647. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  46648. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  46649. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  46650. 'truespeed,typemustmatch,visible'
  46651. );
  46652. var xlinkNS = 'http://www.w3.org/1999/xlink';
  46653. var isXlink = function (name) {
  46654. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  46655. };
  46656. var getXlinkProp = function (name) {
  46657. return isXlink(name) ? name.slice(6, name.length) : ''
  46658. };
  46659. var isFalsyAttrValue = function (val) {
  46660. return val == null || val === false
  46661. };
  46662. /* */
  46663. function genClassForVnode (vnode) {
  46664. var data = vnode.data;
  46665. var parentNode = vnode;
  46666. var childNode = vnode;
  46667. while (isDef(childNode.componentInstance)) {
  46668. childNode = childNode.componentInstance._vnode;
  46669. if (childNode && childNode.data) {
  46670. data = mergeClassData(childNode.data, data);
  46671. }
  46672. }
  46673. while (isDef(parentNode = parentNode.parent)) {
  46674. if (parentNode && parentNode.data) {
  46675. data = mergeClassData(data, parentNode.data);
  46676. }
  46677. }
  46678. return renderClass(data.staticClass, data.class)
  46679. }
  46680. function mergeClassData (child, parent) {
  46681. return {
  46682. staticClass: concat(child.staticClass, parent.staticClass),
  46683. class: isDef(child.class)
  46684. ? [child.class, parent.class]
  46685. : parent.class
  46686. }
  46687. }
  46688. function renderClass (
  46689. staticClass,
  46690. dynamicClass
  46691. ) {
  46692. if (isDef(staticClass) || isDef(dynamicClass)) {
  46693. return concat(staticClass, stringifyClass(dynamicClass))
  46694. }
  46695. /* istanbul ignore next */
  46696. return ''
  46697. }
  46698. function concat (a, b) {
  46699. return a ? b ? (a + ' ' + b) : a : (b || '')
  46700. }
  46701. function stringifyClass (value) {
  46702. if (Array.isArray(value)) {
  46703. return stringifyArray(value)
  46704. }
  46705. if (isObject(value)) {
  46706. return stringifyObject(value)
  46707. }
  46708. if (typeof value === 'string') {
  46709. return value
  46710. }
  46711. /* istanbul ignore next */
  46712. return ''
  46713. }
  46714. function stringifyArray (value) {
  46715. var res = '';
  46716. var stringified;
  46717. for (var i = 0, l = value.length; i < l; i++) {
  46718. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  46719. if (res) { res += ' '; }
  46720. res += stringified;
  46721. }
  46722. }
  46723. return res
  46724. }
  46725. function stringifyObject (value) {
  46726. var res = '';
  46727. for (var key in value) {
  46728. if (value[key]) {
  46729. if (res) { res += ' '; }
  46730. res += key;
  46731. }
  46732. }
  46733. return res
  46734. }
  46735. /* */
  46736. var namespaceMap = {
  46737. svg: 'http://www.w3.org/2000/svg',
  46738. math: 'http://www.w3.org/1998/Math/MathML'
  46739. };
  46740. var isHTMLTag = makeMap(
  46741. 'html,body,base,head,link,meta,style,title,' +
  46742. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  46743. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  46744. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  46745. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  46746. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  46747. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  46748. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  46749. 'output,progress,select,textarea,' +
  46750. 'details,dialog,menu,menuitem,summary,' +
  46751. 'content,element,shadow,template,blockquote,iframe,tfoot'
  46752. );
  46753. // this map is intentionally selective, only covering SVG elements that may
  46754. // contain child elements.
  46755. var isSVG = makeMap(
  46756. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  46757. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  46758. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  46759. true
  46760. );
  46761. var isPreTag = function (tag) { return tag === 'pre'; };
  46762. var isReservedTag = function (tag) {
  46763. return isHTMLTag(tag) || isSVG(tag)
  46764. };
  46765. function getTagNamespace (tag) {
  46766. if (isSVG(tag)) {
  46767. return 'svg'
  46768. }
  46769. // basic support for MathML
  46770. // note it doesn't support other MathML elements being component roots
  46771. if (tag === 'math') {
  46772. return 'math'
  46773. }
  46774. }
  46775. var unknownElementCache = Object.create(null);
  46776. function isUnknownElement (tag) {
  46777. /* istanbul ignore if */
  46778. if (!inBrowser) {
  46779. return true
  46780. }
  46781. if (isReservedTag(tag)) {
  46782. return false
  46783. }
  46784. tag = tag.toLowerCase();
  46785. /* istanbul ignore if */
  46786. if (unknownElementCache[tag] != null) {
  46787. return unknownElementCache[tag]
  46788. }
  46789. var el = document.createElement(tag);
  46790. if (tag.indexOf('-') > -1) {
  46791. // http://stackoverflow.com/a/28210364/1070244
  46792. return (unknownElementCache[tag] = (
  46793. el.constructor === window.HTMLUnknownElement ||
  46794. el.constructor === window.HTMLElement
  46795. ))
  46796. } else {
  46797. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  46798. }
  46799. }
  46800. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  46801. /* */
  46802. /**
  46803. * Query an element selector if it's not an element already.
  46804. */
  46805. function query (el) {
  46806. if (typeof el === 'string') {
  46807. var selected = document.querySelector(el);
  46808. if (!selected) {
  46809. warn(
  46810. 'Cannot find element: ' + el
  46811. );
  46812. return document.createElement('div')
  46813. }
  46814. return selected
  46815. } else {
  46816. return el
  46817. }
  46818. }
  46819. /* */
  46820. function createElement$1 (tagName, vnode) {
  46821. var elm = document.createElement(tagName);
  46822. if (tagName !== 'select') {
  46823. return elm
  46824. }
  46825. // false or null will remove the attribute but undefined will not
  46826. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  46827. elm.setAttribute('multiple', 'multiple');
  46828. }
  46829. return elm
  46830. }
  46831. function createElementNS (namespace, tagName) {
  46832. return document.createElementNS(namespaceMap[namespace], tagName)
  46833. }
  46834. function createTextNode (text) {
  46835. return document.createTextNode(text)
  46836. }
  46837. function createComment (text) {
  46838. return document.createComment(text)
  46839. }
  46840. function insertBefore (parentNode, newNode, referenceNode) {
  46841. parentNode.insertBefore(newNode, referenceNode);
  46842. }
  46843. function removeChild (node, child) {
  46844. node.removeChild(child);
  46845. }
  46846. function appendChild (node, child) {
  46847. node.appendChild(child);
  46848. }
  46849. function parentNode (node) {
  46850. return node.parentNode
  46851. }
  46852. function nextSibling (node) {
  46853. return node.nextSibling
  46854. }
  46855. function tagName (node) {
  46856. return node.tagName
  46857. }
  46858. function setTextContent (node, text) {
  46859. node.textContent = text;
  46860. }
  46861. function setStyleScope (node, scopeId) {
  46862. node.setAttribute(scopeId, '');
  46863. }
  46864. var nodeOps = /*#__PURE__*/Object.freeze({
  46865. createElement: createElement$1,
  46866. createElementNS: createElementNS,
  46867. createTextNode: createTextNode,
  46868. createComment: createComment,
  46869. insertBefore: insertBefore,
  46870. removeChild: removeChild,
  46871. appendChild: appendChild,
  46872. parentNode: parentNode,
  46873. nextSibling: nextSibling,
  46874. tagName: tagName,
  46875. setTextContent: setTextContent,
  46876. setStyleScope: setStyleScope
  46877. });
  46878. /* */
  46879. var ref = {
  46880. create: function create (_, vnode) {
  46881. registerRef(vnode);
  46882. },
  46883. update: function update (oldVnode, vnode) {
  46884. if (oldVnode.data.ref !== vnode.data.ref) {
  46885. registerRef(oldVnode, true);
  46886. registerRef(vnode);
  46887. }
  46888. },
  46889. destroy: function destroy (vnode) {
  46890. registerRef(vnode, true);
  46891. }
  46892. };
  46893. function registerRef (vnode, isRemoval) {
  46894. var key = vnode.data.ref;
  46895. if (!isDef(key)) { return }
  46896. var vm = vnode.context;
  46897. var ref = vnode.componentInstance || vnode.elm;
  46898. var refs = vm.$refs;
  46899. if (isRemoval) {
  46900. if (Array.isArray(refs[key])) {
  46901. remove(refs[key], ref);
  46902. } else if (refs[key] === ref) {
  46903. refs[key] = undefined;
  46904. }
  46905. } else {
  46906. if (vnode.data.refInFor) {
  46907. if (!Array.isArray(refs[key])) {
  46908. refs[key] = [ref];
  46909. } else if (refs[key].indexOf(ref) < 0) {
  46910. // $flow-disable-line
  46911. refs[key].push(ref);
  46912. }
  46913. } else {
  46914. refs[key] = ref;
  46915. }
  46916. }
  46917. }
  46918. /**
  46919. * Virtual DOM patching algorithm based on Snabbdom by
  46920. * Simon Friis Vindum (@paldepind)
  46921. * Licensed under the MIT License
  46922. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  46923. *
  46924. * modified by Evan You (@yyx990803)
  46925. *
  46926. * Not type-checking this because this file is perf-critical and the cost
  46927. * of making flow understand it is not worth it.
  46928. */
  46929. var emptyNode = new VNode('', {}, []);
  46930. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  46931. function sameVnode (a, b) {
  46932. return (
  46933. a.key === b.key && (
  46934. (
  46935. a.tag === b.tag &&
  46936. a.isComment === b.isComment &&
  46937. isDef(a.data) === isDef(b.data) &&
  46938. sameInputType(a, b)
  46939. ) || (
  46940. isTrue(a.isAsyncPlaceholder) &&
  46941. a.asyncFactory === b.asyncFactory &&
  46942. isUndef(b.asyncFactory.error)
  46943. )
  46944. )
  46945. )
  46946. }
  46947. function sameInputType (a, b) {
  46948. if (a.tag !== 'input') { return true }
  46949. var i;
  46950. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  46951. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  46952. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  46953. }
  46954. function createKeyToOldIdx (children, beginIdx, endIdx) {
  46955. var i, key;
  46956. var map = {};
  46957. for (i = beginIdx; i <= endIdx; ++i) {
  46958. key = children[i].key;
  46959. if (isDef(key)) { map[key] = i; }
  46960. }
  46961. return map
  46962. }
  46963. function createPatchFunction (backend) {
  46964. var i, j;
  46965. var cbs = {};
  46966. var modules = backend.modules;
  46967. var nodeOps = backend.nodeOps;
  46968. for (i = 0; i < hooks.length; ++i) {
  46969. cbs[hooks[i]] = [];
  46970. for (j = 0; j < modules.length; ++j) {
  46971. if (isDef(modules[j][hooks[i]])) {
  46972. cbs[hooks[i]].push(modules[j][hooks[i]]);
  46973. }
  46974. }
  46975. }
  46976. function emptyNodeAt (elm) {
  46977. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  46978. }
  46979. function createRmCb (childElm, listeners) {
  46980. function remove$$1 () {
  46981. if (--remove$$1.listeners === 0) {
  46982. removeNode(childElm);
  46983. }
  46984. }
  46985. remove$$1.listeners = listeners;
  46986. return remove$$1
  46987. }
  46988. function removeNode (el) {
  46989. var parent = nodeOps.parentNode(el);
  46990. // element may have already been removed due to v-html / v-text
  46991. if (isDef(parent)) {
  46992. nodeOps.removeChild(parent, el);
  46993. }
  46994. }
  46995. function isUnknownElement$$1 (vnode, inVPre) {
  46996. return (
  46997. !inVPre &&
  46998. !vnode.ns &&
  46999. !(
  47000. config.ignoredElements.length &&
  47001. config.ignoredElements.some(function (ignore) {
  47002. return isRegExp(ignore)
  47003. ? ignore.test(vnode.tag)
  47004. : ignore === vnode.tag
  47005. })
  47006. ) &&
  47007. config.isUnknownElement(vnode.tag)
  47008. )
  47009. }
  47010. var creatingElmInVPre = 0;
  47011. function createElm (
  47012. vnode,
  47013. insertedVnodeQueue,
  47014. parentElm,
  47015. refElm,
  47016. nested,
  47017. ownerArray,
  47018. index
  47019. ) {
  47020. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47021. // This vnode was used in a previous render!
  47022. // now it's used as a new node, overwriting its elm would cause
  47023. // potential patch errors down the road when it's used as an insertion
  47024. // reference node. Instead, we clone the node on-demand before creating
  47025. // associated DOM element for it.
  47026. vnode = ownerArray[index] = cloneVNode(vnode);
  47027. }
  47028. vnode.isRootInsert = !nested; // for transition enter check
  47029. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  47030. return
  47031. }
  47032. var data = vnode.data;
  47033. var children = vnode.children;
  47034. var tag = vnode.tag;
  47035. if (isDef(tag)) {
  47036. {
  47037. if (data && data.pre) {
  47038. creatingElmInVPre++;
  47039. }
  47040. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  47041. warn(
  47042. 'Unknown custom element: <' + tag + '> - did you ' +
  47043. 'register the component correctly? For recursive components, ' +
  47044. 'make sure to provide the "name" option.',
  47045. vnode.context
  47046. );
  47047. }
  47048. }
  47049. vnode.elm = vnode.ns
  47050. ? nodeOps.createElementNS(vnode.ns, tag)
  47051. : nodeOps.createElement(tag, vnode);
  47052. setScope(vnode);
  47053. /* istanbul ignore if */
  47054. {
  47055. createChildren(vnode, children, insertedVnodeQueue);
  47056. if (isDef(data)) {
  47057. invokeCreateHooks(vnode, insertedVnodeQueue);
  47058. }
  47059. insert(parentElm, vnode.elm, refElm);
  47060. }
  47061. if (data && data.pre) {
  47062. creatingElmInVPre--;
  47063. }
  47064. } else if (isTrue(vnode.isComment)) {
  47065. vnode.elm = nodeOps.createComment(vnode.text);
  47066. insert(parentElm, vnode.elm, refElm);
  47067. } else {
  47068. vnode.elm = nodeOps.createTextNode(vnode.text);
  47069. insert(parentElm, vnode.elm, refElm);
  47070. }
  47071. }
  47072. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47073. var i = vnode.data;
  47074. if (isDef(i)) {
  47075. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  47076. if (isDef(i = i.hook) && isDef(i = i.init)) {
  47077. i(vnode, false /* hydrating */);
  47078. }
  47079. // after calling the init hook, if the vnode is a child component
  47080. // it should've created a child instance and mounted it. the child
  47081. // component also has set the placeholder vnode's elm.
  47082. // in that case we can just return the element and be done.
  47083. if (isDef(vnode.componentInstance)) {
  47084. initComponent(vnode, insertedVnodeQueue);
  47085. insert(parentElm, vnode.elm, refElm);
  47086. if (isTrue(isReactivated)) {
  47087. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  47088. }
  47089. return true
  47090. }
  47091. }
  47092. }
  47093. function initComponent (vnode, insertedVnodeQueue) {
  47094. if (isDef(vnode.data.pendingInsert)) {
  47095. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  47096. vnode.data.pendingInsert = null;
  47097. }
  47098. vnode.elm = vnode.componentInstance.$el;
  47099. if (isPatchable(vnode)) {
  47100. invokeCreateHooks(vnode, insertedVnodeQueue);
  47101. setScope(vnode);
  47102. } else {
  47103. // empty component root.
  47104. // skip all element-related modules except for ref (#3455)
  47105. registerRef(vnode);
  47106. // make sure to invoke the insert hook
  47107. insertedVnodeQueue.push(vnode);
  47108. }
  47109. }
  47110. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  47111. var i;
  47112. // hack for #4339: a reactivated component with inner transition
  47113. // does not trigger because the inner node's created hooks are not called
  47114. // again. It's not ideal to involve module-specific logic in here but
  47115. // there doesn't seem to be a better way to do it.
  47116. var innerNode = vnode;
  47117. while (innerNode.componentInstance) {
  47118. innerNode = innerNode.componentInstance._vnode;
  47119. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  47120. for (i = 0; i < cbs.activate.length; ++i) {
  47121. cbs.activate[i](emptyNode, innerNode);
  47122. }
  47123. insertedVnodeQueue.push(innerNode);
  47124. break
  47125. }
  47126. }
  47127. // unlike a newly created component,
  47128. // a reactivated keep-alive component doesn't insert itself
  47129. insert(parentElm, vnode.elm, refElm);
  47130. }
  47131. function insert (parent, elm, ref$$1) {
  47132. if (isDef(parent)) {
  47133. if (isDef(ref$$1)) {
  47134. if (nodeOps.parentNode(ref$$1) === parent) {
  47135. nodeOps.insertBefore(parent, elm, ref$$1);
  47136. }
  47137. } else {
  47138. nodeOps.appendChild(parent, elm);
  47139. }
  47140. }
  47141. }
  47142. function createChildren (vnode, children, insertedVnodeQueue) {
  47143. if (Array.isArray(children)) {
  47144. {
  47145. checkDuplicateKeys(children);
  47146. }
  47147. for (var i = 0; i < children.length; ++i) {
  47148. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  47149. }
  47150. } else if (isPrimitive(vnode.text)) {
  47151. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  47152. }
  47153. }
  47154. function isPatchable (vnode) {
  47155. while (vnode.componentInstance) {
  47156. vnode = vnode.componentInstance._vnode;
  47157. }
  47158. return isDef(vnode.tag)
  47159. }
  47160. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  47161. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47162. cbs.create[i$1](emptyNode, vnode);
  47163. }
  47164. i = vnode.data.hook; // Reuse variable
  47165. if (isDef(i)) {
  47166. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  47167. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  47168. }
  47169. }
  47170. // set scope id attribute for scoped CSS.
  47171. // this is implemented as a special case to avoid the overhead
  47172. // of going through the normal attribute patching process.
  47173. function setScope (vnode) {
  47174. var i;
  47175. if (isDef(i = vnode.fnScopeId)) {
  47176. nodeOps.setStyleScope(vnode.elm, i);
  47177. } else {
  47178. var ancestor = vnode;
  47179. while (ancestor) {
  47180. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  47181. nodeOps.setStyleScope(vnode.elm, i);
  47182. }
  47183. ancestor = ancestor.parent;
  47184. }
  47185. }
  47186. // for slot content they should also get the scopeId from the host instance.
  47187. if (isDef(i = activeInstance) &&
  47188. i !== vnode.context &&
  47189. i !== vnode.fnContext &&
  47190. isDef(i = i.$options._scopeId)
  47191. ) {
  47192. nodeOps.setStyleScope(vnode.elm, i);
  47193. }
  47194. }
  47195. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  47196. for (; startIdx <= endIdx; ++startIdx) {
  47197. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  47198. }
  47199. }
  47200. function invokeDestroyHook (vnode) {
  47201. var i, j;
  47202. var data = vnode.data;
  47203. if (isDef(data)) {
  47204. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  47205. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  47206. }
  47207. if (isDef(i = vnode.children)) {
  47208. for (j = 0; j < vnode.children.length; ++j) {
  47209. invokeDestroyHook(vnode.children[j]);
  47210. }
  47211. }
  47212. }
  47213. function removeVnodes (vnodes, startIdx, endIdx) {
  47214. for (; startIdx <= endIdx; ++startIdx) {
  47215. var ch = vnodes[startIdx];
  47216. if (isDef(ch)) {
  47217. if (isDef(ch.tag)) {
  47218. removeAndInvokeRemoveHook(ch);
  47219. invokeDestroyHook(ch);
  47220. } else { // Text node
  47221. removeNode(ch.elm);
  47222. }
  47223. }
  47224. }
  47225. }
  47226. function removeAndInvokeRemoveHook (vnode, rm) {
  47227. if (isDef(rm) || isDef(vnode.data)) {
  47228. var i;
  47229. var listeners = cbs.remove.length + 1;
  47230. if (isDef(rm)) {
  47231. // we have a recursively passed down rm callback
  47232. // increase the listeners count
  47233. rm.listeners += listeners;
  47234. } else {
  47235. // directly removing
  47236. rm = createRmCb(vnode.elm, listeners);
  47237. }
  47238. // recursively invoke hooks on child component root node
  47239. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  47240. removeAndInvokeRemoveHook(i, rm);
  47241. }
  47242. for (i = 0; i < cbs.remove.length; ++i) {
  47243. cbs.remove[i](vnode, rm);
  47244. }
  47245. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  47246. i(vnode, rm);
  47247. } else {
  47248. rm();
  47249. }
  47250. } else {
  47251. removeNode(vnode.elm);
  47252. }
  47253. }
  47254. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  47255. var oldStartIdx = 0;
  47256. var newStartIdx = 0;
  47257. var oldEndIdx = oldCh.length - 1;
  47258. var oldStartVnode = oldCh[0];
  47259. var oldEndVnode = oldCh[oldEndIdx];
  47260. var newEndIdx = newCh.length - 1;
  47261. var newStartVnode = newCh[0];
  47262. var newEndVnode = newCh[newEndIdx];
  47263. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  47264. // removeOnly is a special flag used only by <transition-group>
  47265. // to ensure removed elements stay in correct relative positions
  47266. // during leaving transitions
  47267. var canMove = !removeOnly;
  47268. {
  47269. checkDuplicateKeys(newCh);
  47270. }
  47271. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  47272. if (isUndef(oldStartVnode)) {
  47273. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  47274. } else if (isUndef(oldEndVnode)) {
  47275. oldEndVnode = oldCh[--oldEndIdx];
  47276. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  47277. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47278. oldStartVnode = oldCh[++oldStartIdx];
  47279. newStartVnode = newCh[++newStartIdx];
  47280. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  47281. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47282. oldEndVnode = oldCh[--oldEndIdx];
  47283. newEndVnode = newCh[--newEndIdx];
  47284. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  47285. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  47286. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  47287. oldStartVnode = oldCh[++oldStartIdx];
  47288. newEndVnode = newCh[--newEndIdx];
  47289. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  47290. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47291. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  47292. oldEndVnode = oldCh[--oldEndIdx];
  47293. newStartVnode = newCh[++newStartIdx];
  47294. } else {
  47295. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  47296. idxInOld = isDef(newStartVnode.key)
  47297. ? oldKeyToIdx[newStartVnode.key]
  47298. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  47299. if (isUndef(idxInOld)) { // New element
  47300. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47301. } else {
  47302. vnodeToMove = oldCh[idxInOld];
  47303. if (sameVnode(vnodeToMove, newStartVnode)) {
  47304. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  47305. oldCh[idxInOld] = undefined;
  47306. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  47307. } else {
  47308. // same key but different element. treat as new element
  47309. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  47310. }
  47311. }
  47312. newStartVnode = newCh[++newStartIdx];
  47313. }
  47314. }
  47315. if (oldStartIdx > oldEndIdx) {
  47316. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  47317. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  47318. } else if (newStartIdx > newEndIdx) {
  47319. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  47320. }
  47321. }
  47322. function checkDuplicateKeys (children) {
  47323. var seenKeys = {};
  47324. for (var i = 0; i < children.length; i++) {
  47325. var vnode = children[i];
  47326. var key = vnode.key;
  47327. if (isDef(key)) {
  47328. if (seenKeys[key]) {
  47329. warn(
  47330. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  47331. vnode.context
  47332. );
  47333. } else {
  47334. seenKeys[key] = true;
  47335. }
  47336. }
  47337. }
  47338. }
  47339. function findIdxInOld (node, oldCh, start, end) {
  47340. for (var i = start; i < end; i++) {
  47341. var c = oldCh[i];
  47342. if (isDef(c) && sameVnode(node, c)) { return i }
  47343. }
  47344. }
  47345. function patchVnode (
  47346. oldVnode,
  47347. vnode,
  47348. insertedVnodeQueue,
  47349. ownerArray,
  47350. index,
  47351. removeOnly
  47352. ) {
  47353. if (oldVnode === vnode) {
  47354. return
  47355. }
  47356. if (isDef(vnode.elm) && isDef(ownerArray)) {
  47357. // clone reused vnode
  47358. vnode = ownerArray[index] = cloneVNode(vnode);
  47359. }
  47360. var elm = vnode.elm = oldVnode.elm;
  47361. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  47362. if (isDef(vnode.asyncFactory.resolved)) {
  47363. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  47364. } else {
  47365. vnode.isAsyncPlaceholder = true;
  47366. }
  47367. return
  47368. }
  47369. // reuse element for static trees.
  47370. // note we only do this if the vnode is cloned -
  47371. // if the new node is not cloned it means the render functions have been
  47372. // reset by the hot-reload-api and we need to do a proper re-render.
  47373. if (isTrue(vnode.isStatic) &&
  47374. isTrue(oldVnode.isStatic) &&
  47375. vnode.key === oldVnode.key &&
  47376. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  47377. ) {
  47378. vnode.componentInstance = oldVnode.componentInstance;
  47379. return
  47380. }
  47381. var i;
  47382. var data = vnode.data;
  47383. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  47384. i(oldVnode, vnode);
  47385. }
  47386. var oldCh = oldVnode.children;
  47387. var ch = vnode.children;
  47388. if (isDef(data) && isPatchable(vnode)) {
  47389. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  47390. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  47391. }
  47392. if (isUndef(vnode.text)) {
  47393. if (isDef(oldCh) && isDef(ch)) {
  47394. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  47395. } else if (isDef(ch)) {
  47396. {
  47397. checkDuplicateKeys(ch);
  47398. }
  47399. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  47400. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  47401. } else if (isDef(oldCh)) {
  47402. removeVnodes(oldCh, 0, oldCh.length - 1);
  47403. } else if (isDef(oldVnode.text)) {
  47404. nodeOps.setTextContent(elm, '');
  47405. }
  47406. } else if (oldVnode.text !== vnode.text) {
  47407. nodeOps.setTextContent(elm, vnode.text);
  47408. }
  47409. if (isDef(data)) {
  47410. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  47411. }
  47412. }
  47413. function invokeInsertHook (vnode, queue, initial) {
  47414. // delay insert hooks for component root nodes, invoke them after the
  47415. // element is really inserted
  47416. if (isTrue(initial) && isDef(vnode.parent)) {
  47417. vnode.parent.data.pendingInsert = queue;
  47418. } else {
  47419. for (var i = 0; i < queue.length; ++i) {
  47420. queue[i].data.hook.insert(queue[i]);
  47421. }
  47422. }
  47423. }
  47424. var hydrationBailed = false;
  47425. // list of modules that can skip create hook during hydration because they
  47426. // are already rendered on the client or has no need for initialization
  47427. // Note: style is excluded because it relies on initial clone for future
  47428. // deep updates (#7063).
  47429. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  47430. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  47431. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  47432. var i;
  47433. var tag = vnode.tag;
  47434. var data = vnode.data;
  47435. var children = vnode.children;
  47436. inVPre = inVPre || (data && data.pre);
  47437. vnode.elm = elm;
  47438. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  47439. vnode.isAsyncPlaceholder = true;
  47440. return true
  47441. }
  47442. // assert node match
  47443. {
  47444. if (!assertNodeMatch(elm, vnode, inVPre)) {
  47445. return false
  47446. }
  47447. }
  47448. if (isDef(data)) {
  47449. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  47450. if (isDef(i = vnode.componentInstance)) {
  47451. // child component. it should have hydrated its own tree.
  47452. initComponent(vnode, insertedVnodeQueue);
  47453. return true
  47454. }
  47455. }
  47456. if (isDef(tag)) {
  47457. if (isDef(children)) {
  47458. // empty element, allow client to pick up and populate children
  47459. if (!elm.hasChildNodes()) {
  47460. createChildren(vnode, children, insertedVnodeQueue);
  47461. } else {
  47462. // v-html and domProps: innerHTML
  47463. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  47464. if (i !== elm.innerHTML) {
  47465. /* istanbul ignore if */
  47466. if (typeof console !== 'undefined' &&
  47467. !hydrationBailed
  47468. ) {
  47469. hydrationBailed = true;
  47470. console.warn('Parent: ', elm);
  47471. console.warn('server innerHTML: ', i);
  47472. console.warn('client innerHTML: ', elm.innerHTML);
  47473. }
  47474. return false
  47475. }
  47476. } else {
  47477. // iterate and compare children lists
  47478. var childrenMatch = true;
  47479. var childNode = elm.firstChild;
  47480. for (var i$1 = 0; i$1 < children.length; i$1++) {
  47481. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  47482. childrenMatch = false;
  47483. break
  47484. }
  47485. childNode = childNode.nextSibling;
  47486. }
  47487. // if childNode is not null, it means the actual childNodes list is
  47488. // longer than the virtual children list.
  47489. if (!childrenMatch || childNode) {
  47490. /* istanbul ignore if */
  47491. if (typeof console !== 'undefined' &&
  47492. !hydrationBailed
  47493. ) {
  47494. hydrationBailed = true;
  47495. console.warn('Parent: ', elm);
  47496. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  47497. }
  47498. return false
  47499. }
  47500. }
  47501. }
  47502. }
  47503. if (isDef(data)) {
  47504. var fullInvoke = false;
  47505. for (var key in data) {
  47506. if (!isRenderedModule(key)) {
  47507. fullInvoke = true;
  47508. invokeCreateHooks(vnode, insertedVnodeQueue);
  47509. break
  47510. }
  47511. }
  47512. if (!fullInvoke && data['class']) {
  47513. // ensure collecting deps for deep class bindings for future updates
  47514. traverse(data['class']);
  47515. }
  47516. }
  47517. } else if (elm.data !== vnode.text) {
  47518. elm.data = vnode.text;
  47519. }
  47520. return true
  47521. }
  47522. function assertNodeMatch (node, vnode, inVPre) {
  47523. if (isDef(vnode.tag)) {
  47524. return vnode.tag.indexOf('vue-component') === 0 || (
  47525. !isUnknownElement$$1(vnode, inVPre) &&
  47526. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  47527. )
  47528. } else {
  47529. return node.nodeType === (vnode.isComment ? 8 : 3)
  47530. }
  47531. }
  47532. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  47533. if (isUndef(vnode)) {
  47534. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  47535. return
  47536. }
  47537. var isInitialPatch = false;
  47538. var insertedVnodeQueue = [];
  47539. if (isUndef(oldVnode)) {
  47540. // empty mount (likely as component), create new root element
  47541. isInitialPatch = true;
  47542. createElm(vnode, insertedVnodeQueue);
  47543. } else {
  47544. var isRealElement = isDef(oldVnode.nodeType);
  47545. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  47546. // patch existing root node
  47547. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  47548. } else {
  47549. if (isRealElement) {
  47550. // mounting to a real element
  47551. // check if this is server-rendered content and if we can perform
  47552. // a successful hydration.
  47553. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  47554. oldVnode.removeAttribute(SSR_ATTR);
  47555. hydrating = true;
  47556. }
  47557. if (isTrue(hydrating)) {
  47558. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  47559. invokeInsertHook(vnode, insertedVnodeQueue, true);
  47560. return oldVnode
  47561. } else {
  47562. warn(
  47563. 'The client-side rendered virtual DOM tree is not matching ' +
  47564. 'server-rendered content. This is likely caused by incorrect ' +
  47565. 'HTML markup, for example nesting block-level elements inside ' +
  47566. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  47567. 'full client-side render.'
  47568. );
  47569. }
  47570. }
  47571. // either not server-rendered, or hydration failed.
  47572. // create an empty node and replace it
  47573. oldVnode = emptyNodeAt(oldVnode);
  47574. }
  47575. // replacing existing element
  47576. var oldElm = oldVnode.elm;
  47577. var parentElm = nodeOps.parentNode(oldElm);
  47578. // create new node
  47579. createElm(
  47580. vnode,
  47581. insertedVnodeQueue,
  47582. // extremely rare edge case: do not insert if old element is in a
  47583. // leaving transition. Only happens when combining transition +
  47584. // keep-alive + HOCs. (#4590)
  47585. oldElm._leaveCb ? null : parentElm,
  47586. nodeOps.nextSibling(oldElm)
  47587. );
  47588. // update parent placeholder node element, recursively
  47589. if (isDef(vnode.parent)) {
  47590. var ancestor = vnode.parent;
  47591. var patchable = isPatchable(vnode);
  47592. while (ancestor) {
  47593. for (var i = 0; i < cbs.destroy.length; ++i) {
  47594. cbs.destroy[i](ancestor);
  47595. }
  47596. ancestor.elm = vnode.elm;
  47597. if (patchable) {
  47598. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  47599. cbs.create[i$1](emptyNode, ancestor);
  47600. }
  47601. // #6513
  47602. // invoke insert hooks that may have been merged by create hooks.
  47603. // e.g. for directives that uses the "inserted" hook.
  47604. var insert = ancestor.data.hook.insert;
  47605. if (insert.merged) {
  47606. // start at index 1 to avoid re-invoking component mounted hook
  47607. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  47608. insert.fns[i$2]();
  47609. }
  47610. }
  47611. } else {
  47612. registerRef(ancestor);
  47613. }
  47614. ancestor = ancestor.parent;
  47615. }
  47616. }
  47617. // destroy old node
  47618. if (isDef(parentElm)) {
  47619. removeVnodes([oldVnode], 0, 0);
  47620. } else if (isDef(oldVnode.tag)) {
  47621. invokeDestroyHook(oldVnode);
  47622. }
  47623. }
  47624. }
  47625. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  47626. return vnode.elm
  47627. }
  47628. }
  47629. /* */
  47630. var directives = {
  47631. create: updateDirectives,
  47632. update: updateDirectives,
  47633. destroy: function unbindDirectives (vnode) {
  47634. updateDirectives(vnode, emptyNode);
  47635. }
  47636. };
  47637. function updateDirectives (oldVnode, vnode) {
  47638. if (oldVnode.data.directives || vnode.data.directives) {
  47639. _update(oldVnode, vnode);
  47640. }
  47641. }
  47642. function _update (oldVnode, vnode) {
  47643. var isCreate = oldVnode === emptyNode;
  47644. var isDestroy = vnode === emptyNode;
  47645. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  47646. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  47647. var dirsWithInsert = [];
  47648. var dirsWithPostpatch = [];
  47649. var key, oldDir, dir;
  47650. for (key in newDirs) {
  47651. oldDir = oldDirs[key];
  47652. dir = newDirs[key];
  47653. if (!oldDir) {
  47654. // new directive, bind
  47655. callHook$1(dir, 'bind', vnode, oldVnode);
  47656. if (dir.def && dir.def.inserted) {
  47657. dirsWithInsert.push(dir);
  47658. }
  47659. } else {
  47660. // existing directive, update
  47661. dir.oldValue = oldDir.value;
  47662. dir.oldArg = oldDir.arg;
  47663. callHook$1(dir, 'update', vnode, oldVnode);
  47664. if (dir.def && dir.def.componentUpdated) {
  47665. dirsWithPostpatch.push(dir);
  47666. }
  47667. }
  47668. }
  47669. if (dirsWithInsert.length) {
  47670. var callInsert = function () {
  47671. for (var i = 0; i < dirsWithInsert.length; i++) {
  47672. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  47673. }
  47674. };
  47675. if (isCreate) {
  47676. mergeVNodeHook(vnode, 'insert', callInsert);
  47677. } else {
  47678. callInsert();
  47679. }
  47680. }
  47681. if (dirsWithPostpatch.length) {
  47682. mergeVNodeHook(vnode, 'postpatch', function () {
  47683. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  47684. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  47685. }
  47686. });
  47687. }
  47688. if (!isCreate) {
  47689. for (key in oldDirs) {
  47690. if (!newDirs[key]) {
  47691. // no longer present, unbind
  47692. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  47693. }
  47694. }
  47695. }
  47696. }
  47697. var emptyModifiers = Object.create(null);
  47698. function normalizeDirectives$1 (
  47699. dirs,
  47700. vm
  47701. ) {
  47702. var res = Object.create(null);
  47703. if (!dirs) {
  47704. // $flow-disable-line
  47705. return res
  47706. }
  47707. var i, dir;
  47708. for (i = 0; i < dirs.length; i++) {
  47709. dir = dirs[i];
  47710. if (!dir.modifiers) {
  47711. // $flow-disable-line
  47712. dir.modifiers = emptyModifiers;
  47713. }
  47714. res[getRawDirName(dir)] = dir;
  47715. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  47716. }
  47717. // $flow-disable-line
  47718. return res
  47719. }
  47720. function getRawDirName (dir) {
  47721. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  47722. }
  47723. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  47724. var fn = dir.def && dir.def[hook];
  47725. if (fn) {
  47726. try {
  47727. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  47728. } catch (e) {
  47729. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  47730. }
  47731. }
  47732. }
  47733. var baseModules = [
  47734. ref,
  47735. directives
  47736. ];
  47737. /* */
  47738. function updateAttrs (oldVnode, vnode) {
  47739. var opts = vnode.componentOptions;
  47740. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  47741. return
  47742. }
  47743. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  47744. return
  47745. }
  47746. var key, cur, old;
  47747. var elm = vnode.elm;
  47748. var oldAttrs = oldVnode.data.attrs || {};
  47749. var attrs = vnode.data.attrs || {};
  47750. // clone observed objects, as the user probably wants to mutate it
  47751. if (isDef(attrs.__ob__)) {
  47752. attrs = vnode.data.attrs = extend({}, attrs);
  47753. }
  47754. for (key in attrs) {
  47755. cur = attrs[key];
  47756. old = oldAttrs[key];
  47757. if (old !== cur) {
  47758. setAttr(elm, key, cur);
  47759. }
  47760. }
  47761. // #4391: in IE9, setting type can reset value for input[type=radio]
  47762. // #6666: IE/Edge forces progress value down to 1 before setting a max
  47763. /* istanbul ignore if */
  47764. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  47765. setAttr(elm, 'value', attrs.value);
  47766. }
  47767. for (key in oldAttrs) {
  47768. if (isUndef(attrs[key])) {
  47769. if (isXlink(key)) {
  47770. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47771. } else if (!isEnumeratedAttr(key)) {
  47772. elm.removeAttribute(key);
  47773. }
  47774. }
  47775. }
  47776. }
  47777. function setAttr (el, key, value) {
  47778. if (el.tagName.indexOf('-') > -1) {
  47779. baseSetAttr(el, key, value);
  47780. } else if (isBooleanAttr(key)) {
  47781. // set attribute for blank value
  47782. // e.g. <option disabled>Select one</option>
  47783. if (isFalsyAttrValue(value)) {
  47784. el.removeAttribute(key);
  47785. } else {
  47786. // technically allowfullscreen is a boolean attribute for <iframe>,
  47787. // but Flash expects a value of "true" when used on <embed> tag
  47788. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  47789. ? 'true'
  47790. : key;
  47791. el.setAttribute(key, value);
  47792. }
  47793. } else if (isEnumeratedAttr(key)) {
  47794. el.setAttribute(key, convertEnumeratedValue(key, value));
  47795. } else if (isXlink(key)) {
  47796. if (isFalsyAttrValue(value)) {
  47797. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  47798. } else {
  47799. el.setAttributeNS(xlinkNS, key, value);
  47800. }
  47801. } else {
  47802. baseSetAttr(el, key, value);
  47803. }
  47804. }
  47805. function baseSetAttr (el, key, value) {
  47806. if (isFalsyAttrValue(value)) {
  47807. el.removeAttribute(key);
  47808. } else {
  47809. // #7138: IE10 & 11 fires input event when setting placeholder on
  47810. // <textarea>... block the first input event and remove the blocker
  47811. // immediately.
  47812. /* istanbul ignore if */
  47813. if (
  47814. isIE && !isIE9 &&
  47815. el.tagName === 'TEXTAREA' &&
  47816. key === 'placeholder' && value !== '' && !el.__ieph
  47817. ) {
  47818. var blocker = function (e) {
  47819. e.stopImmediatePropagation();
  47820. el.removeEventListener('input', blocker);
  47821. };
  47822. el.addEventListener('input', blocker);
  47823. // $flow-disable-line
  47824. el.__ieph = true; /* IE placeholder patched */
  47825. }
  47826. el.setAttribute(key, value);
  47827. }
  47828. }
  47829. var attrs = {
  47830. create: updateAttrs,
  47831. update: updateAttrs
  47832. };
  47833. /* */
  47834. function updateClass (oldVnode, vnode) {
  47835. var el = vnode.elm;
  47836. var data = vnode.data;
  47837. var oldData = oldVnode.data;
  47838. if (
  47839. isUndef(data.staticClass) &&
  47840. isUndef(data.class) && (
  47841. isUndef(oldData) || (
  47842. isUndef(oldData.staticClass) &&
  47843. isUndef(oldData.class)
  47844. )
  47845. )
  47846. ) {
  47847. return
  47848. }
  47849. var cls = genClassForVnode(vnode);
  47850. // handle transition classes
  47851. var transitionClass = el._transitionClasses;
  47852. if (isDef(transitionClass)) {
  47853. cls = concat(cls, stringifyClass(transitionClass));
  47854. }
  47855. // set the class
  47856. if (cls !== el._prevClass) {
  47857. el.setAttribute('class', cls);
  47858. el._prevClass = cls;
  47859. }
  47860. }
  47861. var klass = {
  47862. create: updateClass,
  47863. update: updateClass
  47864. };
  47865. /* */
  47866. var validDivisionCharRE = /[\w).+\-_$\]]/;
  47867. function parseFilters (exp) {
  47868. var inSingle = false;
  47869. var inDouble = false;
  47870. var inTemplateString = false;
  47871. var inRegex = false;
  47872. var curly = 0;
  47873. var square = 0;
  47874. var paren = 0;
  47875. var lastFilterIndex = 0;
  47876. var c, prev, i, expression, filters;
  47877. for (i = 0; i < exp.length; i++) {
  47878. prev = c;
  47879. c = exp.charCodeAt(i);
  47880. if (inSingle) {
  47881. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  47882. } else if (inDouble) {
  47883. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  47884. } else if (inTemplateString) {
  47885. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  47886. } else if (inRegex) {
  47887. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  47888. } else if (
  47889. c === 0x7C && // pipe
  47890. exp.charCodeAt(i + 1) !== 0x7C &&
  47891. exp.charCodeAt(i - 1) !== 0x7C &&
  47892. !curly && !square && !paren
  47893. ) {
  47894. if (expression === undefined) {
  47895. // first filter, end of expression
  47896. lastFilterIndex = i + 1;
  47897. expression = exp.slice(0, i).trim();
  47898. } else {
  47899. pushFilter();
  47900. }
  47901. } else {
  47902. switch (c) {
  47903. case 0x22: inDouble = true; break // "
  47904. case 0x27: inSingle = true; break // '
  47905. case 0x60: inTemplateString = true; break // `
  47906. case 0x28: paren++; break // (
  47907. case 0x29: paren--; break // )
  47908. case 0x5B: square++; break // [
  47909. case 0x5D: square--; break // ]
  47910. case 0x7B: curly++; break // {
  47911. case 0x7D: curly--; break // }
  47912. }
  47913. if (c === 0x2f) { // /
  47914. var j = i - 1;
  47915. var p = (void 0);
  47916. // find first non-whitespace prev char
  47917. for (; j >= 0; j--) {
  47918. p = exp.charAt(j);
  47919. if (p !== ' ') { break }
  47920. }
  47921. if (!p || !validDivisionCharRE.test(p)) {
  47922. inRegex = true;
  47923. }
  47924. }
  47925. }
  47926. }
  47927. if (expression === undefined) {
  47928. expression = exp.slice(0, i).trim();
  47929. } else if (lastFilterIndex !== 0) {
  47930. pushFilter();
  47931. }
  47932. function pushFilter () {
  47933. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  47934. lastFilterIndex = i + 1;
  47935. }
  47936. if (filters) {
  47937. for (i = 0; i < filters.length; i++) {
  47938. expression = wrapFilter(expression, filters[i]);
  47939. }
  47940. }
  47941. return expression
  47942. }
  47943. function wrapFilter (exp, filter) {
  47944. var i = filter.indexOf('(');
  47945. if (i < 0) {
  47946. // _f: resolveFilter
  47947. return ("_f(\"" + filter + "\")(" + exp + ")")
  47948. } else {
  47949. var name = filter.slice(0, i);
  47950. var args = filter.slice(i + 1);
  47951. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  47952. }
  47953. }
  47954. /* */
  47955. /* eslint-disable no-unused-vars */
  47956. function baseWarn (msg, range) {
  47957. console.error(("[Vue compiler]: " + msg));
  47958. }
  47959. /* eslint-enable no-unused-vars */
  47960. function pluckModuleFunction (
  47961. modules,
  47962. key
  47963. ) {
  47964. return modules
  47965. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  47966. : []
  47967. }
  47968. function addProp (el, name, value, range, dynamic) {
  47969. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  47970. el.plain = false;
  47971. }
  47972. function addAttr (el, name, value, range, dynamic) {
  47973. var attrs = dynamic
  47974. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  47975. : (el.attrs || (el.attrs = []));
  47976. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  47977. el.plain = false;
  47978. }
  47979. // add a raw attr (use this in preTransforms)
  47980. function addRawAttr (el, name, value, range) {
  47981. el.attrsMap[name] = value;
  47982. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  47983. }
  47984. function addDirective (
  47985. el,
  47986. name,
  47987. rawName,
  47988. value,
  47989. arg,
  47990. isDynamicArg,
  47991. modifiers,
  47992. range
  47993. ) {
  47994. (el.directives || (el.directives = [])).push(rangeSetItem({
  47995. name: name,
  47996. rawName: rawName,
  47997. value: value,
  47998. arg: arg,
  47999. isDynamicArg: isDynamicArg,
  48000. modifiers: modifiers
  48001. }, range));
  48002. el.plain = false;
  48003. }
  48004. function prependModifierMarker (symbol, name, dynamic) {
  48005. return dynamic
  48006. ? ("_p(" + name + ",\"" + symbol + "\")")
  48007. : symbol + name // mark the event as captured
  48008. }
  48009. function addHandler (
  48010. el,
  48011. name,
  48012. value,
  48013. modifiers,
  48014. important,
  48015. warn,
  48016. range,
  48017. dynamic
  48018. ) {
  48019. modifiers = modifiers || emptyObject;
  48020. // warn prevent and passive modifier
  48021. /* istanbul ignore if */
  48022. if (
  48023. warn &&
  48024. modifiers.prevent && modifiers.passive
  48025. ) {
  48026. warn(
  48027. 'passive and prevent can\'t be used together. ' +
  48028. 'Passive handler can\'t prevent default event.',
  48029. range
  48030. );
  48031. }
  48032. // normalize click.right and click.middle since they don't actually fire
  48033. // this is technically browser-specific, but at least for now browsers are
  48034. // the only target envs that have right/middle clicks.
  48035. if (modifiers.right) {
  48036. if (dynamic) {
  48037. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  48038. } else if (name === 'click') {
  48039. name = 'contextmenu';
  48040. delete modifiers.right;
  48041. }
  48042. } else if (modifiers.middle) {
  48043. if (dynamic) {
  48044. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  48045. } else if (name === 'click') {
  48046. name = 'mouseup';
  48047. }
  48048. }
  48049. // check capture modifier
  48050. if (modifiers.capture) {
  48051. delete modifiers.capture;
  48052. name = prependModifierMarker('!', name, dynamic);
  48053. }
  48054. if (modifiers.once) {
  48055. delete modifiers.once;
  48056. name = prependModifierMarker('~', name, dynamic);
  48057. }
  48058. /* istanbul ignore if */
  48059. if (modifiers.passive) {
  48060. delete modifiers.passive;
  48061. name = prependModifierMarker('&', name, dynamic);
  48062. }
  48063. var events;
  48064. if (modifiers.native) {
  48065. delete modifiers.native;
  48066. events = el.nativeEvents || (el.nativeEvents = {});
  48067. } else {
  48068. events = el.events || (el.events = {});
  48069. }
  48070. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  48071. if (modifiers !== emptyObject) {
  48072. newHandler.modifiers = modifiers;
  48073. }
  48074. var handlers = events[name];
  48075. /* istanbul ignore if */
  48076. if (Array.isArray(handlers)) {
  48077. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  48078. } else if (handlers) {
  48079. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  48080. } else {
  48081. events[name] = newHandler;
  48082. }
  48083. el.plain = false;
  48084. }
  48085. function getRawBindingAttr (
  48086. el,
  48087. name
  48088. ) {
  48089. return el.rawAttrsMap[':' + name] ||
  48090. el.rawAttrsMap['v-bind:' + name] ||
  48091. el.rawAttrsMap[name]
  48092. }
  48093. function getBindingAttr (
  48094. el,
  48095. name,
  48096. getStatic
  48097. ) {
  48098. var dynamicValue =
  48099. getAndRemoveAttr(el, ':' + name) ||
  48100. getAndRemoveAttr(el, 'v-bind:' + name);
  48101. if (dynamicValue != null) {
  48102. return parseFilters(dynamicValue)
  48103. } else if (getStatic !== false) {
  48104. var staticValue = getAndRemoveAttr(el, name);
  48105. if (staticValue != null) {
  48106. return JSON.stringify(staticValue)
  48107. }
  48108. }
  48109. }
  48110. // note: this only removes the attr from the Array (attrsList) so that it
  48111. // doesn't get processed by processAttrs.
  48112. // By default it does NOT remove it from the map (attrsMap) because the map is
  48113. // needed during codegen.
  48114. function getAndRemoveAttr (
  48115. el,
  48116. name,
  48117. removeFromMap
  48118. ) {
  48119. var val;
  48120. if ((val = el.attrsMap[name]) != null) {
  48121. var list = el.attrsList;
  48122. for (var i = 0, l = list.length; i < l; i++) {
  48123. if (list[i].name === name) {
  48124. list.splice(i, 1);
  48125. break
  48126. }
  48127. }
  48128. }
  48129. if (removeFromMap) {
  48130. delete el.attrsMap[name];
  48131. }
  48132. return val
  48133. }
  48134. function getAndRemoveAttrByRegex (
  48135. el,
  48136. name
  48137. ) {
  48138. var list = el.attrsList;
  48139. for (var i = 0, l = list.length; i < l; i++) {
  48140. var attr = list[i];
  48141. if (name.test(attr.name)) {
  48142. list.splice(i, 1);
  48143. return attr
  48144. }
  48145. }
  48146. }
  48147. function rangeSetItem (
  48148. item,
  48149. range
  48150. ) {
  48151. if (range) {
  48152. if (range.start != null) {
  48153. item.start = range.start;
  48154. }
  48155. if (range.end != null) {
  48156. item.end = range.end;
  48157. }
  48158. }
  48159. return item
  48160. }
  48161. /* */
  48162. /**
  48163. * Cross-platform code generation for component v-model
  48164. */
  48165. function genComponentModel (
  48166. el,
  48167. value,
  48168. modifiers
  48169. ) {
  48170. var ref = modifiers || {};
  48171. var number = ref.number;
  48172. var trim = ref.trim;
  48173. var baseValueExpression = '$$v';
  48174. var valueExpression = baseValueExpression;
  48175. if (trim) {
  48176. valueExpression =
  48177. "(typeof " + baseValueExpression + " === 'string'" +
  48178. "? " + baseValueExpression + ".trim()" +
  48179. ": " + baseValueExpression + ")";
  48180. }
  48181. if (number) {
  48182. valueExpression = "_n(" + valueExpression + ")";
  48183. }
  48184. var assignment = genAssignmentCode(value, valueExpression);
  48185. el.model = {
  48186. value: ("(" + value + ")"),
  48187. expression: JSON.stringify(value),
  48188. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  48189. };
  48190. }
  48191. /**
  48192. * Cross-platform codegen helper for generating v-model value assignment code.
  48193. */
  48194. function genAssignmentCode (
  48195. value,
  48196. assignment
  48197. ) {
  48198. var res = parseModel(value);
  48199. if (res.key === null) {
  48200. return (value + "=" + assignment)
  48201. } else {
  48202. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  48203. }
  48204. }
  48205. /**
  48206. * Parse a v-model expression into a base path and a final key segment.
  48207. * Handles both dot-path and possible square brackets.
  48208. *
  48209. * Possible cases:
  48210. *
  48211. * - test
  48212. * - test[key]
  48213. * - test[test1[key]]
  48214. * - test["a"][key]
  48215. * - xxx.test[a[a].test1[key]]
  48216. * - test.xxx.a["asa"][test1[key]]
  48217. *
  48218. */
  48219. var len, str, chr, index$1, expressionPos, expressionEndPos;
  48220. function parseModel (val) {
  48221. // Fix https://github.com/vuejs/vue/pull/7730
  48222. // allow v-model="obj.val " (trailing whitespace)
  48223. val = val.trim();
  48224. len = val.length;
  48225. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  48226. index$1 = val.lastIndexOf('.');
  48227. if (index$1 > -1) {
  48228. return {
  48229. exp: val.slice(0, index$1),
  48230. key: '"' + val.slice(index$1 + 1) + '"'
  48231. }
  48232. } else {
  48233. return {
  48234. exp: val,
  48235. key: null
  48236. }
  48237. }
  48238. }
  48239. str = val;
  48240. index$1 = expressionPos = expressionEndPos = 0;
  48241. while (!eof()) {
  48242. chr = next();
  48243. /* istanbul ignore if */
  48244. if (isStringStart(chr)) {
  48245. parseString(chr);
  48246. } else if (chr === 0x5B) {
  48247. parseBracket(chr);
  48248. }
  48249. }
  48250. return {
  48251. exp: val.slice(0, expressionPos),
  48252. key: val.slice(expressionPos + 1, expressionEndPos)
  48253. }
  48254. }
  48255. function next () {
  48256. return str.charCodeAt(++index$1)
  48257. }
  48258. function eof () {
  48259. return index$1 >= len
  48260. }
  48261. function isStringStart (chr) {
  48262. return chr === 0x22 || chr === 0x27
  48263. }
  48264. function parseBracket (chr) {
  48265. var inBracket = 1;
  48266. expressionPos = index$1;
  48267. while (!eof()) {
  48268. chr = next();
  48269. if (isStringStart(chr)) {
  48270. parseString(chr);
  48271. continue
  48272. }
  48273. if (chr === 0x5B) { inBracket++; }
  48274. if (chr === 0x5D) { inBracket--; }
  48275. if (inBracket === 0) {
  48276. expressionEndPos = index$1;
  48277. break
  48278. }
  48279. }
  48280. }
  48281. function parseString (chr) {
  48282. var stringQuote = chr;
  48283. while (!eof()) {
  48284. chr = next();
  48285. if (chr === stringQuote) {
  48286. break
  48287. }
  48288. }
  48289. }
  48290. /* */
  48291. var warn$1;
  48292. // in some cases, the event used has to be determined at runtime
  48293. // so we used some reserved tokens during compile.
  48294. var RANGE_TOKEN = '__r';
  48295. var CHECKBOX_RADIO_TOKEN = '__c';
  48296. function model (
  48297. el,
  48298. dir,
  48299. _warn
  48300. ) {
  48301. warn$1 = _warn;
  48302. var value = dir.value;
  48303. var modifiers = dir.modifiers;
  48304. var tag = el.tag;
  48305. var type = el.attrsMap.type;
  48306. {
  48307. // inputs with type="file" are read only and setting the input's
  48308. // value will throw an error.
  48309. if (tag === 'input' && type === 'file') {
  48310. warn$1(
  48311. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  48312. "File inputs are read only. Use a v-on:change listener instead.",
  48313. el.rawAttrsMap['v-model']
  48314. );
  48315. }
  48316. }
  48317. if (el.component) {
  48318. genComponentModel(el, value, modifiers);
  48319. // component v-model doesn't need extra runtime
  48320. return false
  48321. } else if (tag === 'select') {
  48322. genSelect(el, value, modifiers);
  48323. } else if (tag === 'input' && type === 'checkbox') {
  48324. genCheckboxModel(el, value, modifiers);
  48325. } else if (tag === 'input' && type === 'radio') {
  48326. genRadioModel(el, value, modifiers);
  48327. } else if (tag === 'input' || tag === 'textarea') {
  48328. genDefaultModel(el, value, modifiers);
  48329. } else if (!config.isReservedTag(tag)) {
  48330. genComponentModel(el, value, modifiers);
  48331. // component v-model doesn't need extra runtime
  48332. return false
  48333. } else {
  48334. warn$1(
  48335. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  48336. "v-model is not supported on this element type. " +
  48337. 'If you are working with contenteditable, it\'s recommended to ' +
  48338. 'wrap a library dedicated for that purpose inside a custom component.',
  48339. el.rawAttrsMap['v-model']
  48340. );
  48341. }
  48342. // ensure runtime directive metadata
  48343. return true
  48344. }
  48345. function genCheckboxModel (
  48346. el,
  48347. value,
  48348. modifiers
  48349. ) {
  48350. var number = modifiers && modifiers.number;
  48351. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48352. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  48353. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  48354. addProp(el, 'checked',
  48355. "Array.isArray(" + value + ")" +
  48356. "?_i(" + value + "," + valueBinding + ")>-1" + (
  48357. trueValueBinding === 'true'
  48358. ? (":(" + value + ")")
  48359. : (":_q(" + value + "," + trueValueBinding + ")")
  48360. )
  48361. );
  48362. addHandler(el, 'change',
  48363. "var $$a=" + value + "," +
  48364. '$$el=$event.target,' +
  48365. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  48366. 'if(Array.isArray($$a)){' +
  48367. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  48368. '$$i=_i($$a,$$v);' +
  48369. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  48370. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  48371. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  48372. null, true
  48373. );
  48374. }
  48375. function genRadioModel (
  48376. el,
  48377. value,
  48378. modifiers
  48379. ) {
  48380. var number = modifiers && modifiers.number;
  48381. var valueBinding = getBindingAttr(el, 'value') || 'null';
  48382. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  48383. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  48384. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  48385. }
  48386. function genSelect (
  48387. el,
  48388. value,
  48389. modifiers
  48390. ) {
  48391. var number = modifiers && modifiers.number;
  48392. var selectedVal = "Array.prototype.filter" +
  48393. ".call($event.target.options,function(o){return o.selected})" +
  48394. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  48395. "return " + (number ? '_n(val)' : 'val') + "})";
  48396. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  48397. var code = "var $$selectedVal = " + selectedVal + ";";
  48398. code = code + " " + (genAssignmentCode(value, assignment));
  48399. addHandler(el, 'change', code, null, true);
  48400. }
  48401. function genDefaultModel (
  48402. el,
  48403. value,
  48404. modifiers
  48405. ) {
  48406. var type = el.attrsMap.type;
  48407. // warn if v-bind:value conflicts with v-model
  48408. // except for inputs with v-bind:type
  48409. {
  48410. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  48411. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  48412. if (value$1 && !typeBinding) {
  48413. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  48414. warn$1(
  48415. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  48416. 'because the latter already expands to a value binding internally',
  48417. el.rawAttrsMap[binding]
  48418. );
  48419. }
  48420. }
  48421. var ref = modifiers || {};
  48422. var lazy = ref.lazy;
  48423. var number = ref.number;
  48424. var trim = ref.trim;
  48425. var needCompositionGuard = !lazy && type !== 'range';
  48426. var event = lazy
  48427. ? 'change'
  48428. : type === 'range'
  48429. ? RANGE_TOKEN
  48430. : 'input';
  48431. var valueExpression = '$event.target.value';
  48432. if (trim) {
  48433. valueExpression = "$event.target.value.trim()";
  48434. }
  48435. if (number) {
  48436. valueExpression = "_n(" + valueExpression + ")";
  48437. }
  48438. var code = genAssignmentCode(value, valueExpression);
  48439. if (needCompositionGuard) {
  48440. code = "if($event.target.composing)return;" + code;
  48441. }
  48442. addProp(el, 'value', ("(" + value + ")"));
  48443. addHandler(el, event, code, null, true);
  48444. if (trim || number) {
  48445. addHandler(el, 'blur', '$forceUpdate()');
  48446. }
  48447. }
  48448. /* */
  48449. // normalize v-model event tokens that can only be determined at runtime.
  48450. // it's important to place the event as the first in the array because
  48451. // the whole point is ensuring the v-model callback gets called before
  48452. // user-attached handlers.
  48453. function normalizeEvents (on) {
  48454. /* istanbul ignore if */
  48455. if (isDef(on[RANGE_TOKEN])) {
  48456. // IE input[type=range] only supports `change` event
  48457. var event = isIE ? 'change' : 'input';
  48458. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  48459. delete on[RANGE_TOKEN];
  48460. }
  48461. // This was originally intended to fix #4521 but no longer necessary
  48462. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  48463. /* istanbul ignore if */
  48464. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  48465. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  48466. delete on[CHECKBOX_RADIO_TOKEN];
  48467. }
  48468. }
  48469. var target$1;
  48470. function createOnceHandler$1 (event, handler, capture) {
  48471. var _target = target$1; // save current target element in closure
  48472. return function onceHandler () {
  48473. var res = handler.apply(null, arguments);
  48474. if (res !== null) {
  48475. remove$2(event, onceHandler, capture, _target);
  48476. }
  48477. }
  48478. }
  48479. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  48480. // implementation and does not fire microtasks in between event propagation, so
  48481. // safe to exclude.
  48482. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  48483. function add$1 (
  48484. name,
  48485. handler,
  48486. capture,
  48487. passive
  48488. ) {
  48489. // async edge case #6566: inner click event triggers patch, event handler
  48490. // attached to outer element during patch, and triggered again. This
  48491. // happens because browsers fire microtask ticks between event propagation.
  48492. // the solution is simple: we save the timestamp when a handler is attached,
  48493. // and the handler would only fire if the event passed to it was fired
  48494. // AFTER it was attached.
  48495. if (useMicrotaskFix) {
  48496. var attachedTimestamp = currentFlushTimestamp;
  48497. var original = handler;
  48498. handler = original._wrapper = function (e) {
  48499. if (
  48500. // no bubbling, should always fire.
  48501. // this is just a safety net in case event.timeStamp is unreliable in
  48502. // certain weird environments...
  48503. e.target === e.currentTarget ||
  48504. // event is fired after handler attachment
  48505. e.timeStamp >= attachedTimestamp ||
  48506. // bail for environments that have buggy event.timeStamp implementations
  48507. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  48508. // #9681 QtWebEngine event.timeStamp is negative value
  48509. e.timeStamp <= 0 ||
  48510. // #9448 bail if event is fired in another document in a multi-page
  48511. // electron/nw.js app, since event.timeStamp will be using a different
  48512. // starting reference
  48513. e.target.ownerDocument !== document
  48514. ) {
  48515. return original.apply(this, arguments)
  48516. }
  48517. };
  48518. }
  48519. target$1.addEventListener(
  48520. name,
  48521. handler,
  48522. supportsPassive
  48523. ? { capture: capture, passive: passive }
  48524. : capture
  48525. );
  48526. }
  48527. function remove$2 (
  48528. name,
  48529. handler,
  48530. capture,
  48531. _target
  48532. ) {
  48533. (_target || target$1).removeEventListener(
  48534. name,
  48535. handler._wrapper || handler,
  48536. capture
  48537. );
  48538. }
  48539. function updateDOMListeners (oldVnode, vnode) {
  48540. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  48541. return
  48542. }
  48543. var on = vnode.data.on || {};
  48544. var oldOn = oldVnode.data.on || {};
  48545. target$1 = vnode.elm;
  48546. normalizeEvents(on);
  48547. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  48548. target$1 = undefined;
  48549. }
  48550. var events = {
  48551. create: updateDOMListeners,
  48552. update: updateDOMListeners
  48553. };
  48554. /* */
  48555. var svgContainer;
  48556. function updateDOMProps (oldVnode, vnode) {
  48557. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  48558. return
  48559. }
  48560. var key, cur;
  48561. var elm = vnode.elm;
  48562. var oldProps = oldVnode.data.domProps || {};
  48563. var props = vnode.data.domProps || {};
  48564. // clone observed objects, as the user probably wants to mutate it
  48565. if (isDef(props.__ob__)) {
  48566. props = vnode.data.domProps = extend({}, props);
  48567. }
  48568. for (key in oldProps) {
  48569. if (!(key in props)) {
  48570. elm[key] = '';
  48571. }
  48572. }
  48573. for (key in props) {
  48574. cur = props[key];
  48575. // ignore children if the node has textContent or innerHTML,
  48576. // as these will throw away existing DOM nodes and cause removal errors
  48577. // on subsequent patches (#3360)
  48578. if (key === 'textContent' || key === 'innerHTML') {
  48579. if (vnode.children) { vnode.children.length = 0; }
  48580. if (cur === oldProps[key]) { continue }
  48581. // #6601 work around Chrome version <= 55 bug where single textNode
  48582. // replaced by innerHTML/textContent retains its parentNode property
  48583. if (elm.childNodes.length === 1) {
  48584. elm.removeChild(elm.childNodes[0]);
  48585. }
  48586. }
  48587. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  48588. // store value as _value as well since
  48589. // non-string values will be stringified
  48590. elm._value = cur;
  48591. // avoid resetting cursor position when value is the same
  48592. var strCur = isUndef(cur) ? '' : String(cur);
  48593. if (shouldUpdateValue(elm, strCur)) {
  48594. elm.value = strCur;
  48595. }
  48596. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  48597. // IE doesn't support innerHTML for SVG elements
  48598. svgContainer = svgContainer || document.createElement('div');
  48599. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  48600. var svg = svgContainer.firstChild;
  48601. while (elm.firstChild) {
  48602. elm.removeChild(elm.firstChild);
  48603. }
  48604. while (svg.firstChild) {
  48605. elm.appendChild(svg.firstChild);
  48606. }
  48607. } else if (
  48608. // skip the update if old and new VDOM state is the same.
  48609. // `value` is handled separately because the DOM value may be temporarily
  48610. // out of sync with VDOM state due to focus, composition and modifiers.
  48611. // This #4521 by skipping the unnecesarry `checked` update.
  48612. cur !== oldProps[key]
  48613. ) {
  48614. // some property updates can throw
  48615. // e.g. `value` on <progress> w/ non-finite value
  48616. try {
  48617. elm[key] = cur;
  48618. } catch (e) {}
  48619. }
  48620. }
  48621. }
  48622. // check platforms/web/util/attrs.js acceptValue
  48623. function shouldUpdateValue (elm, checkVal) {
  48624. return (!elm.composing && (
  48625. elm.tagName === 'OPTION' ||
  48626. isNotInFocusAndDirty(elm, checkVal) ||
  48627. isDirtyWithModifiers(elm, checkVal)
  48628. ))
  48629. }
  48630. function isNotInFocusAndDirty (elm, checkVal) {
  48631. // return true when textbox (.number and .trim) loses focus and its value is
  48632. // not equal to the updated value
  48633. var notInFocus = true;
  48634. // #6157
  48635. // work around IE bug when accessing document.activeElement in an iframe
  48636. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  48637. return notInFocus && elm.value !== checkVal
  48638. }
  48639. function isDirtyWithModifiers (elm, newVal) {
  48640. var value = elm.value;
  48641. var modifiers = elm._vModifiers; // injected by v-model runtime
  48642. if (isDef(modifiers)) {
  48643. if (modifiers.number) {
  48644. return toNumber(value) !== toNumber(newVal)
  48645. }
  48646. if (modifiers.trim) {
  48647. return value.trim() !== newVal.trim()
  48648. }
  48649. }
  48650. return value !== newVal
  48651. }
  48652. var domProps = {
  48653. create: updateDOMProps,
  48654. update: updateDOMProps
  48655. };
  48656. /* */
  48657. var parseStyleText = cached(function (cssText) {
  48658. var res = {};
  48659. var listDelimiter = /;(?![^(]*\))/g;
  48660. var propertyDelimiter = /:(.+)/;
  48661. cssText.split(listDelimiter).forEach(function (item) {
  48662. if (item) {
  48663. var tmp = item.split(propertyDelimiter);
  48664. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  48665. }
  48666. });
  48667. return res
  48668. });
  48669. // merge static and dynamic style data on the same vnode
  48670. function normalizeStyleData (data) {
  48671. var style = normalizeStyleBinding(data.style);
  48672. // static style is pre-processed into an object during compilation
  48673. // and is always a fresh object, so it's safe to merge into it
  48674. return data.staticStyle
  48675. ? extend(data.staticStyle, style)
  48676. : style
  48677. }
  48678. // normalize possible array / string values into Object
  48679. function normalizeStyleBinding (bindingStyle) {
  48680. if (Array.isArray(bindingStyle)) {
  48681. return toObject(bindingStyle)
  48682. }
  48683. if (typeof bindingStyle === 'string') {
  48684. return parseStyleText(bindingStyle)
  48685. }
  48686. return bindingStyle
  48687. }
  48688. /**
  48689. * parent component style should be after child's
  48690. * so that parent component's style could override it
  48691. */
  48692. function getStyle (vnode, checkChild) {
  48693. var res = {};
  48694. var styleData;
  48695. if (checkChild) {
  48696. var childNode = vnode;
  48697. while (childNode.componentInstance) {
  48698. childNode = childNode.componentInstance._vnode;
  48699. if (
  48700. childNode && childNode.data &&
  48701. (styleData = normalizeStyleData(childNode.data))
  48702. ) {
  48703. extend(res, styleData);
  48704. }
  48705. }
  48706. }
  48707. if ((styleData = normalizeStyleData(vnode.data))) {
  48708. extend(res, styleData);
  48709. }
  48710. var parentNode = vnode;
  48711. while ((parentNode = parentNode.parent)) {
  48712. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  48713. extend(res, styleData);
  48714. }
  48715. }
  48716. return res
  48717. }
  48718. /* */
  48719. var cssVarRE = /^--/;
  48720. var importantRE = /\s*!important$/;
  48721. var setProp = function (el, name, val) {
  48722. /* istanbul ignore if */
  48723. if (cssVarRE.test(name)) {
  48724. el.style.setProperty(name, val);
  48725. } else if (importantRE.test(val)) {
  48726. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  48727. } else {
  48728. var normalizedName = normalize(name);
  48729. if (Array.isArray(val)) {
  48730. // Support values array created by autoprefixer, e.g.
  48731. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  48732. // Set them one by one, and the browser will only set those it can recognize
  48733. for (var i = 0, len = val.length; i < len; i++) {
  48734. el.style[normalizedName] = val[i];
  48735. }
  48736. } else {
  48737. el.style[normalizedName] = val;
  48738. }
  48739. }
  48740. };
  48741. var vendorNames = ['Webkit', 'Moz', 'ms'];
  48742. var emptyStyle;
  48743. var normalize = cached(function (prop) {
  48744. emptyStyle = emptyStyle || document.createElement('div').style;
  48745. prop = camelize(prop);
  48746. if (prop !== 'filter' && (prop in emptyStyle)) {
  48747. return prop
  48748. }
  48749. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  48750. for (var i = 0; i < vendorNames.length; i++) {
  48751. var name = vendorNames[i] + capName;
  48752. if (name in emptyStyle) {
  48753. return name
  48754. }
  48755. }
  48756. });
  48757. function updateStyle (oldVnode, vnode) {
  48758. var data = vnode.data;
  48759. var oldData = oldVnode.data;
  48760. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  48761. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  48762. ) {
  48763. return
  48764. }
  48765. var cur, name;
  48766. var el = vnode.elm;
  48767. var oldStaticStyle = oldData.staticStyle;
  48768. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  48769. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  48770. var oldStyle = oldStaticStyle || oldStyleBinding;
  48771. var style = normalizeStyleBinding(vnode.data.style) || {};
  48772. // store normalized style under a different key for next diff
  48773. // make sure to clone it if it's reactive, since the user likely wants
  48774. // to mutate it.
  48775. vnode.data.normalizedStyle = isDef(style.__ob__)
  48776. ? extend({}, style)
  48777. : style;
  48778. var newStyle = getStyle(vnode, true);
  48779. for (name in oldStyle) {
  48780. if (isUndef(newStyle[name])) {
  48781. setProp(el, name, '');
  48782. }
  48783. }
  48784. for (name in newStyle) {
  48785. cur = newStyle[name];
  48786. if (cur !== oldStyle[name]) {
  48787. // ie9 setting to null has no effect, must use empty string
  48788. setProp(el, name, cur == null ? '' : cur);
  48789. }
  48790. }
  48791. }
  48792. var style = {
  48793. create: updateStyle,
  48794. update: updateStyle
  48795. };
  48796. /* */
  48797. var whitespaceRE = /\s+/;
  48798. /**
  48799. * Add class with compatibility for SVG since classList is not supported on
  48800. * SVG elements in IE
  48801. */
  48802. function addClass (el, cls) {
  48803. /* istanbul ignore if */
  48804. if (!cls || !(cls = cls.trim())) {
  48805. return
  48806. }
  48807. /* istanbul ignore else */
  48808. if (el.classList) {
  48809. if (cls.indexOf(' ') > -1) {
  48810. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  48811. } else {
  48812. el.classList.add(cls);
  48813. }
  48814. } else {
  48815. var cur = " " + (el.getAttribute('class') || '') + " ";
  48816. if (cur.indexOf(' ' + cls + ' ') < 0) {
  48817. el.setAttribute('class', (cur + cls).trim());
  48818. }
  48819. }
  48820. }
  48821. /**
  48822. * Remove class with compatibility for SVG since classList is not supported on
  48823. * SVG elements in IE
  48824. */
  48825. function removeClass (el, cls) {
  48826. /* istanbul ignore if */
  48827. if (!cls || !(cls = cls.trim())) {
  48828. return
  48829. }
  48830. /* istanbul ignore else */
  48831. if (el.classList) {
  48832. if (cls.indexOf(' ') > -1) {
  48833. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  48834. } else {
  48835. el.classList.remove(cls);
  48836. }
  48837. if (!el.classList.length) {
  48838. el.removeAttribute('class');
  48839. }
  48840. } else {
  48841. var cur = " " + (el.getAttribute('class') || '') + " ";
  48842. var tar = ' ' + cls + ' ';
  48843. while (cur.indexOf(tar) >= 0) {
  48844. cur = cur.replace(tar, ' ');
  48845. }
  48846. cur = cur.trim();
  48847. if (cur) {
  48848. el.setAttribute('class', cur);
  48849. } else {
  48850. el.removeAttribute('class');
  48851. }
  48852. }
  48853. }
  48854. /* */
  48855. function resolveTransition (def$$1) {
  48856. if (!def$$1) {
  48857. return
  48858. }
  48859. /* istanbul ignore else */
  48860. if (typeof def$$1 === 'object') {
  48861. var res = {};
  48862. if (def$$1.css !== false) {
  48863. extend(res, autoCssTransition(def$$1.name || 'v'));
  48864. }
  48865. extend(res, def$$1);
  48866. return res
  48867. } else if (typeof def$$1 === 'string') {
  48868. return autoCssTransition(def$$1)
  48869. }
  48870. }
  48871. var autoCssTransition = cached(function (name) {
  48872. return {
  48873. enterClass: (name + "-enter"),
  48874. enterToClass: (name + "-enter-to"),
  48875. enterActiveClass: (name + "-enter-active"),
  48876. leaveClass: (name + "-leave"),
  48877. leaveToClass: (name + "-leave-to"),
  48878. leaveActiveClass: (name + "-leave-active")
  48879. }
  48880. });
  48881. var hasTransition = inBrowser && !isIE9;
  48882. var TRANSITION = 'transition';
  48883. var ANIMATION = 'animation';
  48884. // Transition property/event sniffing
  48885. var transitionProp = 'transition';
  48886. var transitionEndEvent = 'transitionend';
  48887. var animationProp = 'animation';
  48888. var animationEndEvent = 'animationend';
  48889. if (hasTransition) {
  48890. /* istanbul ignore if */
  48891. if (window.ontransitionend === undefined &&
  48892. window.onwebkittransitionend !== undefined
  48893. ) {
  48894. transitionProp = 'WebkitTransition';
  48895. transitionEndEvent = 'webkitTransitionEnd';
  48896. }
  48897. if (window.onanimationend === undefined &&
  48898. window.onwebkitanimationend !== undefined
  48899. ) {
  48900. animationProp = 'WebkitAnimation';
  48901. animationEndEvent = 'webkitAnimationEnd';
  48902. }
  48903. }
  48904. // binding to window is necessary to make hot reload work in IE in strict mode
  48905. var raf = inBrowser
  48906. ? window.requestAnimationFrame
  48907. ? window.requestAnimationFrame.bind(window)
  48908. : setTimeout
  48909. : /* istanbul ignore next */ function (fn) { return fn(); };
  48910. function nextFrame (fn) {
  48911. raf(function () {
  48912. raf(fn);
  48913. });
  48914. }
  48915. function addTransitionClass (el, cls) {
  48916. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  48917. if (transitionClasses.indexOf(cls) < 0) {
  48918. transitionClasses.push(cls);
  48919. addClass(el, cls);
  48920. }
  48921. }
  48922. function removeTransitionClass (el, cls) {
  48923. if (el._transitionClasses) {
  48924. remove(el._transitionClasses, cls);
  48925. }
  48926. removeClass(el, cls);
  48927. }
  48928. function whenTransitionEnds (
  48929. el,
  48930. expectedType,
  48931. cb
  48932. ) {
  48933. var ref = getTransitionInfo(el, expectedType);
  48934. var type = ref.type;
  48935. var timeout = ref.timeout;
  48936. var propCount = ref.propCount;
  48937. if (!type) { return cb() }
  48938. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  48939. var ended = 0;
  48940. var end = function () {
  48941. el.removeEventListener(event, onEnd);
  48942. cb();
  48943. };
  48944. var onEnd = function (e) {
  48945. if (e.target === el) {
  48946. if (++ended >= propCount) {
  48947. end();
  48948. }
  48949. }
  48950. };
  48951. setTimeout(function () {
  48952. if (ended < propCount) {
  48953. end();
  48954. }
  48955. }, timeout + 1);
  48956. el.addEventListener(event, onEnd);
  48957. }
  48958. var transformRE = /\b(transform|all)(,|$)/;
  48959. function getTransitionInfo (el, expectedType) {
  48960. var styles = window.getComputedStyle(el);
  48961. // JSDOM may return undefined for transition properties
  48962. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  48963. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  48964. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  48965. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  48966. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  48967. var animationTimeout = getTimeout(animationDelays, animationDurations);
  48968. var type;
  48969. var timeout = 0;
  48970. var propCount = 0;
  48971. /* istanbul ignore if */
  48972. if (expectedType === TRANSITION) {
  48973. if (transitionTimeout > 0) {
  48974. type = TRANSITION;
  48975. timeout = transitionTimeout;
  48976. propCount = transitionDurations.length;
  48977. }
  48978. } else if (expectedType === ANIMATION) {
  48979. if (animationTimeout > 0) {
  48980. type = ANIMATION;
  48981. timeout = animationTimeout;
  48982. propCount = animationDurations.length;
  48983. }
  48984. } else {
  48985. timeout = Math.max(transitionTimeout, animationTimeout);
  48986. type = timeout > 0
  48987. ? transitionTimeout > animationTimeout
  48988. ? TRANSITION
  48989. : ANIMATION
  48990. : null;
  48991. propCount = type
  48992. ? type === TRANSITION
  48993. ? transitionDurations.length
  48994. : animationDurations.length
  48995. : 0;
  48996. }
  48997. var hasTransform =
  48998. type === TRANSITION &&
  48999. transformRE.test(styles[transitionProp + 'Property']);
  49000. return {
  49001. type: type,
  49002. timeout: timeout,
  49003. propCount: propCount,
  49004. hasTransform: hasTransform
  49005. }
  49006. }
  49007. function getTimeout (delays, durations) {
  49008. /* istanbul ignore next */
  49009. while (delays.length < durations.length) {
  49010. delays = delays.concat(delays);
  49011. }
  49012. return Math.max.apply(null, durations.map(function (d, i) {
  49013. return toMs(d) + toMs(delays[i])
  49014. }))
  49015. }
  49016. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  49017. // in a locale-dependent way, using a comma instead of a dot.
  49018. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  49019. // as a floor function) causing unexpected behaviors
  49020. function toMs (s) {
  49021. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  49022. }
  49023. /* */
  49024. function enter (vnode, toggleDisplay) {
  49025. var el = vnode.elm;
  49026. // call leave callback now
  49027. if (isDef(el._leaveCb)) {
  49028. el._leaveCb.cancelled = true;
  49029. el._leaveCb();
  49030. }
  49031. var data = resolveTransition(vnode.data.transition);
  49032. if (isUndef(data)) {
  49033. return
  49034. }
  49035. /* istanbul ignore if */
  49036. if (isDef(el._enterCb) || el.nodeType !== 1) {
  49037. return
  49038. }
  49039. var css = data.css;
  49040. var type = data.type;
  49041. var enterClass = data.enterClass;
  49042. var enterToClass = data.enterToClass;
  49043. var enterActiveClass = data.enterActiveClass;
  49044. var appearClass = data.appearClass;
  49045. var appearToClass = data.appearToClass;
  49046. var appearActiveClass = data.appearActiveClass;
  49047. var beforeEnter = data.beforeEnter;
  49048. var enter = data.enter;
  49049. var afterEnter = data.afterEnter;
  49050. var enterCancelled = data.enterCancelled;
  49051. var beforeAppear = data.beforeAppear;
  49052. var appear = data.appear;
  49053. var afterAppear = data.afterAppear;
  49054. var appearCancelled = data.appearCancelled;
  49055. var duration = data.duration;
  49056. // activeInstance will always be the <transition> component managing this
  49057. // transition. One edge case to check is when the <transition> is placed
  49058. // as the root node of a child component. In that case we need to check
  49059. // <transition>'s parent for appear check.
  49060. var context = activeInstance;
  49061. var transitionNode = activeInstance.$vnode;
  49062. while (transitionNode && transitionNode.parent) {
  49063. context = transitionNode.context;
  49064. transitionNode = transitionNode.parent;
  49065. }
  49066. var isAppear = !context._isMounted || !vnode.isRootInsert;
  49067. if (isAppear && !appear && appear !== '') {
  49068. return
  49069. }
  49070. var startClass = isAppear && appearClass
  49071. ? appearClass
  49072. : enterClass;
  49073. var activeClass = isAppear && appearActiveClass
  49074. ? appearActiveClass
  49075. : enterActiveClass;
  49076. var toClass = isAppear && appearToClass
  49077. ? appearToClass
  49078. : enterToClass;
  49079. var beforeEnterHook = isAppear
  49080. ? (beforeAppear || beforeEnter)
  49081. : beforeEnter;
  49082. var enterHook = isAppear
  49083. ? (typeof appear === 'function' ? appear : enter)
  49084. : enter;
  49085. var afterEnterHook = isAppear
  49086. ? (afterAppear || afterEnter)
  49087. : afterEnter;
  49088. var enterCancelledHook = isAppear
  49089. ? (appearCancelled || enterCancelled)
  49090. : enterCancelled;
  49091. var explicitEnterDuration = toNumber(
  49092. isObject(duration)
  49093. ? duration.enter
  49094. : duration
  49095. );
  49096. if (explicitEnterDuration != null) {
  49097. checkDuration(explicitEnterDuration, 'enter', vnode);
  49098. }
  49099. var expectsCSS = css !== false && !isIE9;
  49100. var userWantsControl = getHookArgumentsLength(enterHook);
  49101. var cb = el._enterCb = once(function () {
  49102. if (expectsCSS) {
  49103. removeTransitionClass(el, toClass);
  49104. removeTransitionClass(el, activeClass);
  49105. }
  49106. if (cb.cancelled) {
  49107. if (expectsCSS) {
  49108. removeTransitionClass(el, startClass);
  49109. }
  49110. enterCancelledHook && enterCancelledHook(el);
  49111. } else {
  49112. afterEnterHook && afterEnterHook(el);
  49113. }
  49114. el._enterCb = null;
  49115. });
  49116. if (!vnode.data.show) {
  49117. // remove pending leave element on enter by injecting an insert hook
  49118. mergeVNodeHook(vnode, 'insert', function () {
  49119. var parent = el.parentNode;
  49120. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  49121. if (pendingNode &&
  49122. pendingNode.tag === vnode.tag &&
  49123. pendingNode.elm._leaveCb
  49124. ) {
  49125. pendingNode.elm._leaveCb();
  49126. }
  49127. enterHook && enterHook(el, cb);
  49128. });
  49129. }
  49130. // start enter transition
  49131. beforeEnterHook && beforeEnterHook(el);
  49132. if (expectsCSS) {
  49133. addTransitionClass(el, startClass);
  49134. addTransitionClass(el, activeClass);
  49135. nextFrame(function () {
  49136. removeTransitionClass(el, startClass);
  49137. if (!cb.cancelled) {
  49138. addTransitionClass(el, toClass);
  49139. if (!userWantsControl) {
  49140. if (isValidDuration(explicitEnterDuration)) {
  49141. setTimeout(cb, explicitEnterDuration);
  49142. } else {
  49143. whenTransitionEnds(el, type, cb);
  49144. }
  49145. }
  49146. }
  49147. });
  49148. }
  49149. if (vnode.data.show) {
  49150. toggleDisplay && toggleDisplay();
  49151. enterHook && enterHook(el, cb);
  49152. }
  49153. if (!expectsCSS && !userWantsControl) {
  49154. cb();
  49155. }
  49156. }
  49157. function leave (vnode, rm) {
  49158. var el = vnode.elm;
  49159. // call enter callback now
  49160. if (isDef(el._enterCb)) {
  49161. el._enterCb.cancelled = true;
  49162. el._enterCb();
  49163. }
  49164. var data = resolveTransition(vnode.data.transition);
  49165. if (isUndef(data) || el.nodeType !== 1) {
  49166. return rm()
  49167. }
  49168. /* istanbul ignore if */
  49169. if (isDef(el._leaveCb)) {
  49170. return
  49171. }
  49172. var css = data.css;
  49173. var type = data.type;
  49174. var leaveClass = data.leaveClass;
  49175. var leaveToClass = data.leaveToClass;
  49176. var leaveActiveClass = data.leaveActiveClass;
  49177. var beforeLeave = data.beforeLeave;
  49178. var leave = data.leave;
  49179. var afterLeave = data.afterLeave;
  49180. var leaveCancelled = data.leaveCancelled;
  49181. var delayLeave = data.delayLeave;
  49182. var duration = data.duration;
  49183. var expectsCSS = css !== false && !isIE9;
  49184. var userWantsControl = getHookArgumentsLength(leave);
  49185. var explicitLeaveDuration = toNumber(
  49186. isObject(duration)
  49187. ? duration.leave
  49188. : duration
  49189. );
  49190. if (isDef(explicitLeaveDuration)) {
  49191. checkDuration(explicitLeaveDuration, 'leave', vnode);
  49192. }
  49193. var cb = el._leaveCb = once(function () {
  49194. if (el.parentNode && el.parentNode._pending) {
  49195. el.parentNode._pending[vnode.key] = null;
  49196. }
  49197. if (expectsCSS) {
  49198. removeTransitionClass(el, leaveToClass);
  49199. removeTransitionClass(el, leaveActiveClass);
  49200. }
  49201. if (cb.cancelled) {
  49202. if (expectsCSS) {
  49203. removeTransitionClass(el, leaveClass);
  49204. }
  49205. leaveCancelled && leaveCancelled(el);
  49206. } else {
  49207. rm();
  49208. afterLeave && afterLeave(el);
  49209. }
  49210. el._leaveCb = null;
  49211. });
  49212. if (delayLeave) {
  49213. delayLeave(performLeave);
  49214. } else {
  49215. performLeave();
  49216. }
  49217. function performLeave () {
  49218. // the delayed leave may have already been cancelled
  49219. if (cb.cancelled) {
  49220. return
  49221. }
  49222. // record leaving element
  49223. if (!vnode.data.show && el.parentNode) {
  49224. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  49225. }
  49226. beforeLeave && beforeLeave(el);
  49227. if (expectsCSS) {
  49228. addTransitionClass(el, leaveClass);
  49229. addTransitionClass(el, leaveActiveClass);
  49230. nextFrame(function () {
  49231. removeTransitionClass(el, leaveClass);
  49232. if (!cb.cancelled) {
  49233. addTransitionClass(el, leaveToClass);
  49234. if (!userWantsControl) {
  49235. if (isValidDuration(explicitLeaveDuration)) {
  49236. setTimeout(cb, explicitLeaveDuration);
  49237. } else {
  49238. whenTransitionEnds(el, type, cb);
  49239. }
  49240. }
  49241. }
  49242. });
  49243. }
  49244. leave && leave(el, cb);
  49245. if (!expectsCSS && !userWantsControl) {
  49246. cb();
  49247. }
  49248. }
  49249. }
  49250. // only used in dev mode
  49251. function checkDuration (val, name, vnode) {
  49252. if (typeof val !== 'number') {
  49253. warn(
  49254. "<transition> explicit " + name + " duration is not a valid number - " +
  49255. "got " + (JSON.stringify(val)) + ".",
  49256. vnode.context
  49257. );
  49258. } else if (isNaN(val)) {
  49259. warn(
  49260. "<transition> explicit " + name + " duration is NaN - " +
  49261. 'the duration expression might be incorrect.',
  49262. vnode.context
  49263. );
  49264. }
  49265. }
  49266. function isValidDuration (val) {
  49267. return typeof val === 'number' && !isNaN(val)
  49268. }
  49269. /**
  49270. * Normalize a transition hook's argument length. The hook may be:
  49271. * - a merged hook (invoker) with the original in .fns
  49272. * - a wrapped component method (check ._length)
  49273. * - a plain function (.length)
  49274. */
  49275. function getHookArgumentsLength (fn) {
  49276. if (isUndef(fn)) {
  49277. return false
  49278. }
  49279. var invokerFns = fn.fns;
  49280. if (isDef(invokerFns)) {
  49281. // invoker
  49282. return getHookArgumentsLength(
  49283. Array.isArray(invokerFns)
  49284. ? invokerFns[0]
  49285. : invokerFns
  49286. )
  49287. } else {
  49288. return (fn._length || fn.length) > 1
  49289. }
  49290. }
  49291. function _enter (_, vnode) {
  49292. if (vnode.data.show !== true) {
  49293. enter(vnode);
  49294. }
  49295. }
  49296. var transition = inBrowser ? {
  49297. create: _enter,
  49298. activate: _enter,
  49299. remove: function remove$$1 (vnode, rm) {
  49300. /* istanbul ignore else */
  49301. if (vnode.data.show !== true) {
  49302. leave(vnode, rm);
  49303. } else {
  49304. rm();
  49305. }
  49306. }
  49307. } : {};
  49308. var platformModules = [
  49309. attrs,
  49310. klass,
  49311. events,
  49312. domProps,
  49313. style,
  49314. transition
  49315. ];
  49316. /* */
  49317. // the directive module should be applied last, after all
  49318. // built-in modules have been applied.
  49319. var modules = platformModules.concat(baseModules);
  49320. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  49321. /**
  49322. * Not type checking this file because flow doesn't like attaching
  49323. * properties to Elements.
  49324. */
  49325. /* istanbul ignore if */
  49326. if (isIE9) {
  49327. // http://www.matts411.com/post/internet-explorer-9-oninput/
  49328. document.addEventListener('selectionchange', function () {
  49329. var el = document.activeElement;
  49330. if (el && el.vmodel) {
  49331. trigger(el, 'input');
  49332. }
  49333. });
  49334. }
  49335. var directive = {
  49336. inserted: function inserted (el, binding, vnode, oldVnode) {
  49337. if (vnode.tag === 'select') {
  49338. // #6903
  49339. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  49340. mergeVNodeHook(vnode, 'postpatch', function () {
  49341. directive.componentUpdated(el, binding, vnode);
  49342. });
  49343. } else {
  49344. setSelected(el, binding, vnode.context);
  49345. }
  49346. el._vOptions = [].map.call(el.options, getValue);
  49347. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  49348. el._vModifiers = binding.modifiers;
  49349. if (!binding.modifiers.lazy) {
  49350. el.addEventListener('compositionstart', onCompositionStart);
  49351. el.addEventListener('compositionend', onCompositionEnd);
  49352. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  49353. // switching focus before confirming composition choice
  49354. // this also fixes the issue where some browsers e.g. iOS Chrome
  49355. // fires "change" instead of "input" on autocomplete.
  49356. el.addEventListener('change', onCompositionEnd);
  49357. /* istanbul ignore if */
  49358. if (isIE9) {
  49359. el.vmodel = true;
  49360. }
  49361. }
  49362. }
  49363. },
  49364. componentUpdated: function componentUpdated (el, binding, vnode) {
  49365. if (vnode.tag === 'select') {
  49366. setSelected(el, binding, vnode.context);
  49367. // in case the options rendered by v-for have changed,
  49368. // it's possible that the value is out-of-sync with the rendered options.
  49369. // detect such cases and filter out values that no longer has a matching
  49370. // option in the DOM.
  49371. var prevOptions = el._vOptions;
  49372. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  49373. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  49374. // trigger change event if
  49375. // no matching option found for at least one value
  49376. var needReset = el.multiple
  49377. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  49378. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  49379. if (needReset) {
  49380. trigger(el, 'change');
  49381. }
  49382. }
  49383. }
  49384. }
  49385. };
  49386. function setSelected (el, binding, vm) {
  49387. actuallySetSelected(el, binding, vm);
  49388. /* istanbul ignore if */
  49389. if (isIE || isEdge) {
  49390. setTimeout(function () {
  49391. actuallySetSelected(el, binding, vm);
  49392. }, 0);
  49393. }
  49394. }
  49395. function actuallySetSelected (el, binding, vm) {
  49396. var value = binding.value;
  49397. var isMultiple = el.multiple;
  49398. if (isMultiple && !Array.isArray(value)) {
  49399. warn(
  49400. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  49401. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  49402. vm
  49403. );
  49404. return
  49405. }
  49406. var selected, option;
  49407. for (var i = 0, l = el.options.length; i < l; i++) {
  49408. option = el.options[i];
  49409. if (isMultiple) {
  49410. selected = looseIndexOf(value, getValue(option)) > -1;
  49411. if (option.selected !== selected) {
  49412. option.selected = selected;
  49413. }
  49414. } else {
  49415. if (looseEqual(getValue(option), value)) {
  49416. if (el.selectedIndex !== i) {
  49417. el.selectedIndex = i;
  49418. }
  49419. return
  49420. }
  49421. }
  49422. }
  49423. if (!isMultiple) {
  49424. el.selectedIndex = -1;
  49425. }
  49426. }
  49427. function hasNoMatchingOption (value, options) {
  49428. return options.every(function (o) { return !looseEqual(o, value); })
  49429. }
  49430. function getValue (option) {
  49431. return '_value' in option
  49432. ? option._value
  49433. : option.value
  49434. }
  49435. function onCompositionStart (e) {
  49436. e.target.composing = true;
  49437. }
  49438. function onCompositionEnd (e) {
  49439. // prevent triggering an input event for no reason
  49440. if (!e.target.composing) { return }
  49441. e.target.composing = false;
  49442. trigger(e.target, 'input');
  49443. }
  49444. function trigger (el, type) {
  49445. var e = document.createEvent('HTMLEvents');
  49446. e.initEvent(type, true, true);
  49447. el.dispatchEvent(e);
  49448. }
  49449. /* */
  49450. // recursively search for possible transition defined inside the component root
  49451. function locateNode (vnode) {
  49452. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  49453. ? locateNode(vnode.componentInstance._vnode)
  49454. : vnode
  49455. }
  49456. var show = {
  49457. bind: function bind (el, ref, vnode) {
  49458. var value = ref.value;
  49459. vnode = locateNode(vnode);
  49460. var transition$$1 = vnode.data && vnode.data.transition;
  49461. var originalDisplay = el.__vOriginalDisplay =
  49462. el.style.display === 'none' ? '' : el.style.display;
  49463. if (value && transition$$1) {
  49464. vnode.data.show = true;
  49465. enter(vnode, function () {
  49466. el.style.display = originalDisplay;
  49467. });
  49468. } else {
  49469. el.style.display = value ? originalDisplay : 'none';
  49470. }
  49471. },
  49472. update: function update (el, ref, vnode) {
  49473. var value = ref.value;
  49474. var oldValue = ref.oldValue;
  49475. /* istanbul ignore if */
  49476. if (!value === !oldValue) { return }
  49477. vnode = locateNode(vnode);
  49478. var transition$$1 = vnode.data && vnode.data.transition;
  49479. if (transition$$1) {
  49480. vnode.data.show = true;
  49481. if (value) {
  49482. enter(vnode, function () {
  49483. el.style.display = el.__vOriginalDisplay;
  49484. });
  49485. } else {
  49486. leave(vnode, function () {
  49487. el.style.display = 'none';
  49488. });
  49489. }
  49490. } else {
  49491. el.style.display = value ? el.__vOriginalDisplay : 'none';
  49492. }
  49493. },
  49494. unbind: function unbind (
  49495. el,
  49496. binding,
  49497. vnode,
  49498. oldVnode,
  49499. isDestroy
  49500. ) {
  49501. if (!isDestroy) {
  49502. el.style.display = el.__vOriginalDisplay;
  49503. }
  49504. }
  49505. };
  49506. var platformDirectives = {
  49507. model: directive,
  49508. show: show
  49509. };
  49510. /* */
  49511. var transitionProps = {
  49512. name: String,
  49513. appear: Boolean,
  49514. css: Boolean,
  49515. mode: String,
  49516. type: String,
  49517. enterClass: String,
  49518. leaveClass: String,
  49519. enterToClass: String,
  49520. leaveToClass: String,
  49521. enterActiveClass: String,
  49522. leaveActiveClass: String,
  49523. appearClass: String,
  49524. appearActiveClass: String,
  49525. appearToClass: String,
  49526. duration: [Number, String, Object]
  49527. };
  49528. // in case the child is also an abstract component, e.g. <keep-alive>
  49529. // we want to recursively retrieve the real component to be rendered
  49530. function getRealChild (vnode) {
  49531. var compOptions = vnode && vnode.componentOptions;
  49532. if (compOptions && compOptions.Ctor.options.abstract) {
  49533. return getRealChild(getFirstComponentChild(compOptions.children))
  49534. } else {
  49535. return vnode
  49536. }
  49537. }
  49538. function extractTransitionData (comp) {
  49539. var data = {};
  49540. var options = comp.$options;
  49541. // props
  49542. for (var key in options.propsData) {
  49543. data[key] = comp[key];
  49544. }
  49545. // events.
  49546. // extract listeners and pass them directly to the transition methods
  49547. var listeners = options._parentListeners;
  49548. for (var key$1 in listeners) {
  49549. data[camelize(key$1)] = listeners[key$1];
  49550. }
  49551. return data
  49552. }
  49553. function placeholder (h, rawChild) {
  49554. if (/\d-keep-alive$/.test(rawChild.tag)) {
  49555. return h('keep-alive', {
  49556. props: rawChild.componentOptions.propsData
  49557. })
  49558. }
  49559. }
  49560. function hasParentTransition (vnode) {
  49561. while ((vnode = vnode.parent)) {
  49562. if (vnode.data.transition) {
  49563. return true
  49564. }
  49565. }
  49566. }
  49567. function isSameChild (child, oldChild) {
  49568. return oldChild.key === child.key && oldChild.tag === child.tag
  49569. }
  49570. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  49571. var isVShowDirective = function (d) { return d.name === 'show'; };
  49572. var Transition = {
  49573. name: 'transition',
  49574. props: transitionProps,
  49575. abstract: true,
  49576. render: function render (h) {
  49577. var this$1 = this;
  49578. var children = this.$slots.default;
  49579. if (!children) {
  49580. return
  49581. }
  49582. // filter out text nodes (possible whitespaces)
  49583. children = children.filter(isNotTextNode);
  49584. /* istanbul ignore if */
  49585. if (!children.length) {
  49586. return
  49587. }
  49588. // warn multiple elements
  49589. if (children.length > 1) {
  49590. warn(
  49591. '<transition> can only be used on a single element. Use ' +
  49592. '<transition-group> for lists.',
  49593. this.$parent
  49594. );
  49595. }
  49596. var mode = this.mode;
  49597. // warn invalid mode
  49598. if (mode && mode !== 'in-out' && mode !== 'out-in'
  49599. ) {
  49600. warn(
  49601. 'invalid <transition> mode: ' + mode,
  49602. this.$parent
  49603. );
  49604. }
  49605. var rawChild = children[0];
  49606. // if this is a component root node and the component's
  49607. // parent container node also has transition, skip.
  49608. if (hasParentTransition(this.$vnode)) {
  49609. return rawChild
  49610. }
  49611. // apply transition data to child
  49612. // use getRealChild() to ignore abstract components e.g. keep-alive
  49613. var child = getRealChild(rawChild);
  49614. /* istanbul ignore if */
  49615. if (!child) {
  49616. return rawChild
  49617. }
  49618. if (this._leaving) {
  49619. return placeholder(h, rawChild)
  49620. }
  49621. // ensure a key that is unique to the vnode type and to this transition
  49622. // component instance. This key will be used to remove pending leaving nodes
  49623. // during entering.
  49624. var id = "__transition-" + (this._uid) + "-";
  49625. child.key = child.key == null
  49626. ? child.isComment
  49627. ? id + 'comment'
  49628. : id + child.tag
  49629. : isPrimitive(child.key)
  49630. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  49631. : child.key;
  49632. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  49633. var oldRawChild = this._vnode;
  49634. var oldChild = getRealChild(oldRawChild);
  49635. // mark v-show
  49636. // so that the transition module can hand over the control to the directive
  49637. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  49638. child.data.show = true;
  49639. }
  49640. if (
  49641. oldChild &&
  49642. oldChild.data &&
  49643. !isSameChild(child, oldChild) &&
  49644. !isAsyncPlaceholder(oldChild) &&
  49645. // #6687 component root is a comment node
  49646. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  49647. ) {
  49648. // replace old child transition data with fresh one
  49649. // important for dynamic transitions!
  49650. var oldData = oldChild.data.transition = extend({}, data);
  49651. // handle transition mode
  49652. if (mode === 'out-in') {
  49653. // return placeholder node and queue update when leave finishes
  49654. this._leaving = true;
  49655. mergeVNodeHook(oldData, 'afterLeave', function () {
  49656. this$1._leaving = false;
  49657. this$1.$forceUpdate();
  49658. });
  49659. return placeholder(h, rawChild)
  49660. } else if (mode === 'in-out') {
  49661. if (isAsyncPlaceholder(child)) {
  49662. return oldRawChild
  49663. }
  49664. var delayedLeave;
  49665. var performLeave = function () { delayedLeave(); };
  49666. mergeVNodeHook(data, 'afterEnter', performLeave);
  49667. mergeVNodeHook(data, 'enterCancelled', performLeave);
  49668. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  49669. }
  49670. }
  49671. return rawChild
  49672. }
  49673. };
  49674. /* */
  49675. var props = extend({
  49676. tag: String,
  49677. moveClass: String
  49678. }, transitionProps);
  49679. delete props.mode;
  49680. var TransitionGroup = {
  49681. props: props,
  49682. beforeMount: function beforeMount () {
  49683. var this$1 = this;
  49684. var update = this._update;
  49685. this._update = function (vnode, hydrating) {
  49686. var restoreActiveInstance = setActiveInstance(this$1);
  49687. // force removing pass
  49688. this$1.__patch__(
  49689. this$1._vnode,
  49690. this$1.kept,
  49691. false, // hydrating
  49692. true // removeOnly (!important, avoids unnecessary moves)
  49693. );
  49694. this$1._vnode = this$1.kept;
  49695. restoreActiveInstance();
  49696. update.call(this$1, vnode, hydrating);
  49697. };
  49698. },
  49699. render: function render (h) {
  49700. var tag = this.tag || this.$vnode.data.tag || 'span';
  49701. var map = Object.create(null);
  49702. var prevChildren = this.prevChildren = this.children;
  49703. var rawChildren = this.$slots.default || [];
  49704. var children = this.children = [];
  49705. var transitionData = extractTransitionData(this);
  49706. for (var i = 0; i < rawChildren.length; i++) {
  49707. var c = rawChildren[i];
  49708. if (c.tag) {
  49709. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  49710. children.push(c);
  49711. map[c.key] = c
  49712. ;(c.data || (c.data = {})).transition = transitionData;
  49713. } else {
  49714. var opts = c.componentOptions;
  49715. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  49716. warn(("<transition-group> children must be keyed: <" + name + ">"));
  49717. }
  49718. }
  49719. }
  49720. if (prevChildren) {
  49721. var kept = [];
  49722. var removed = [];
  49723. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  49724. var c$1 = prevChildren[i$1];
  49725. c$1.data.transition = transitionData;
  49726. c$1.data.pos = c$1.elm.getBoundingClientRect();
  49727. if (map[c$1.key]) {
  49728. kept.push(c$1);
  49729. } else {
  49730. removed.push(c$1);
  49731. }
  49732. }
  49733. this.kept = h(tag, null, kept);
  49734. this.removed = removed;
  49735. }
  49736. return h(tag, null, children)
  49737. },
  49738. updated: function updated () {
  49739. var children = this.prevChildren;
  49740. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  49741. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  49742. return
  49743. }
  49744. // we divide the work into three loops to avoid mixing DOM reads and writes
  49745. // in each iteration - which helps prevent layout thrashing.
  49746. children.forEach(callPendingCbs);
  49747. children.forEach(recordPosition);
  49748. children.forEach(applyTranslation);
  49749. // force reflow to put everything in position
  49750. // assign to this to avoid being removed in tree-shaking
  49751. // $flow-disable-line
  49752. this._reflow = document.body.offsetHeight;
  49753. children.forEach(function (c) {
  49754. if (c.data.moved) {
  49755. var el = c.elm;
  49756. var s = el.style;
  49757. addTransitionClass(el, moveClass);
  49758. s.transform = s.WebkitTransform = s.transitionDuration = '';
  49759. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  49760. if (e && e.target !== el) {
  49761. return
  49762. }
  49763. if (!e || /transform$/.test(e.propertyName)) {
  49764. el.removeEventListener(transitionEndEvent, cb);
  49765. el._moveCb = null;
  49766. removeTransitionClass(el, moveClass);
  49767. }
  49768. });
  49769. }
  49770. });
  49771. },
  49772. methods: {
  49773. hasMove: function hasMove (el, moveClass) {
  49774. /* istanbul ignore if */
  49775. if (!hasTransition) {
  49776. return false
  49777. }
  49778. /* istanbul ignore if */
  49779. if (this._hasMove) {
  49780. return this._hasMove
  49781. }
  49782. // Detect whether an element with the move class applied has
  49783. // CSS transitions. Since the element may be inside an entering
  49784. // transition at this very moment, we make a clone of it and remove
  49785. // all other transition classes applied to ensure only the move class
  49786. // is applied.
  49787. var clone = el.cloneNode();
  49788. if (el._transitionClasses) {
  49789. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  49790. }
  49791. addClass(clone, moveClass);
  49792. clone.style.display = 'none';
  49793. this.$el.appendChild(clone);
  49794. var info = getTransitionInfo(clone);
  49795. this.$el.removeChild(clone);
  49796. return (this._hasMove = info.hasTransform)
  49797. }
  49798. }
  49799. };
  49800. function callPendingCbs (c) {
  49801. /* istanbul ignore if */
  49802. if (c.elm._moveCb) {
  49803. c.elm._moveCb();
  49804. }
  49805. /* istanbul ignore if */
  49806. if (c.elm._enterCb) {
  49807. c.elm._enterCb();
  49808. }
  49809. }
  49810. function recordPosition (c) {
  49811. c.data.newPos = c.elm.getBoundingClientRect();
  49812. }
  49813. function applyTranslation (c) {
  49814. var oldPos = c.data.pos;
  49815. var newPos = c.data.newPos;
  49816. var dx = oldPos.left - newPos.left;
  49817. var dy = oldPos.top - newPos.top;
  49818. if (dx || dy) {
  49819. c.data.moved = true;
  49820. var s = c.elm.style;
  49821. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  49822. s.transitionDuration = '0s';
  49823. }
  49824. }
  49825. var platformComponents = {
  49826. Transition: Transition,
  49827. TransitionGroup: TransitionGroup
  49828. };
  49829. /* */
  49830. // install platform specific utils
  49831. Vue.config.mustUseProp = mustUseProp;
  49832. Vue.config.isReservedTag = isReservedTag;
  49833. Vue.config.isReservedAttr = isReservedAttr;
  49834. Vue.config.getTagNamespace = getTagNamespace;
  49835. Vue.config.isUnknownElement = isUnknownElement;
  49836. // install platform runtime directives & components
  49837. extend(Vue.options.directives, platformDirectives);
  49838. extend(Vue.options.components, platformComponents);
  49839. // install platform patch function
  49840. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  49841. // public mount method
  49842. Vue.prototype.$mount = function (
  49843. el,
  49844. hydrating
  49845. ) {
  49846. el = el && inBrowser ? query(el) : undefined;
  49847. return mountComponent(this, el, hydrating)
  49848. };
  49849. // devtools global hook
  49850. /* istanbul ignore next */
  49851. if (inBrowser) {
  49852. setTimeout(function () {
  49853. if (config.devtools) {
  49854. if (devtools) {
  49855. devtools.emit('init', Vue);
  49856. } else {
  49857. console[console.info ? 'info' : 'log'](
  49858. 'Download the Vue Devtools extension for a better development experience:\n' +
  49859. 'https://github.com/vuejs/vue-devtools'
  49860. );
  49861. }
  49862. }
  49863. if (config.productionTip !== false &&
  49864. typeof console !== 'undefined'
  49865. ) {
  49866. console[console.info ? 'info' : 'log'](
  49867. "You are running Vue in development mode.\n" +
  49868. "Make sure to turn on production mode when deploying for production.\n" +
  49869. "See more tips at https://vuejs.org/guide/deployment.html"
  49870. );
  49871. }
  49872. }, 0);
  49873. }
  49874. /* */
  49875. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  49876. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  49877. var buildRegex = cached(function (delimiters) {
  49878. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  49879. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  49880. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  49881. });
  49882. function parseText (
  49883. text,
  49884. delimiters
  49885. ) {
  49886. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  49887. if (!tagRE.test(text)) {
  49888. return
  49889. }
  49890. var tokens = [];
  49891. var rawTokens = [];
  49892. var lastIndex = tagRE.lastIndex = 0;
  49893. var match, index, tokenValue;
  49894. while ((match = tagRE.exec(text))) {
  49895. index = match.index;
  49896. // push text token
  49897. if (index > lastIndex) {
  49898. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  49899. tokens.push(JSON.stringify(tokenValue));
  49900. }
  49901. // tag token
  49902. var exp = parseFilters(match[1].trim());
  49903. tokens.push(("_s(" + exp + ")"));
  49904. rawTokens.push({ '@binding': exp });
  49905. lastIndex = index + match[0].length;
  49906. }
  49907. if (lastIndex < text.length) {
  49908. rawTokens.push(tokenValue = text.slice(lastIndex));
  49909. tokens.push(JSON.stringify(tokenValue));
  49910. }
  49911. return {
  49912. expression: tokens.join('+'),
  49913. tokens: rawTokens
  49914. }
  49915. }
  49916. /* */
  49917. function transformNode (el, options) {
  49918. var warn = options.warn || baseWarn;
  49919. var staticClass = getAndRemoveAttr(el, 'class');
  49920. if (staticClass) {
  49921. var res = parseText(staticClass, options.delimiters);
  49922. if (res) {
  49923. warn(
  49924. "class=\"" + staticClass + "\": " +
  49925. 'Interpolation inside attributes has been removed. ' +
  49926. 'Use v-bind or the colon shorthand instead. For example, ' +
  49927. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  49928. el.rawAttrsMap['class']
  49929. );
  49930. }
  49931. }
  49932. if (staticClass) {
  49933. el.staticClass = JSON.stringify(staticClass);
  49934. }
  49935. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  49936. if (classBinding) {
  49937. el.classBinding = classBinding;
  49938. }
  49939. }
  49940. function genData (el) {
  49941. var data = '';
  49942. if (el.staticClass) {
  49943. data += "staticClass:" + (el.staticClass) + ",";
  49944. }
  49945. if (el.classBinding) {
  49946. data += "class:" + (el.classBinding) + ",";
  49947. }
  49948. return data
  49949. }
  49950. var klass$1 = {
  49951. staticKeys: ['staticClass'],
  49952. transformNode: transformNode,
  49953. genData: genData
  49954. };
  49955. /* */
  49956. function transformNode$1 (el, options) {
  49957. var warn = options.warn || baseWarn;
  49958. var staticStyle = getAndRemoveAttr(el, 'style');
  49959. if (staticStyle) {
  49960. /* istanbul ignore if */
  49961. {
  49962. var res = parseText(staticStyle, options.delimiters);
  49963. if (res) {
  49964. warn(
  49965. "style=\"" + staticStyle + "\": " +
  49966. 'Interpolation inside attributes has been removed. ' +
  49967. 'Use v-bind or the colon shorthand instead. For example, ' +
  49968. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  49969. el.rawAttrsMap['style']
  49970. );
  49971. }
  49972. }
  49973. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  49974. }
  49975. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  49976. if (styleBinding) {
  49977. el.styleBinding = styleBinding;
  49978. }
  49979. }
  49980. function genData$1 (el) {
  49981. var data = '';
  49982. if (el.staticStyle) {
  49983. data += "staticStyle:" + (el.staticStyle) + ",";
  49984. }
  49985. if (el.styleBinding) {
  49986. data += "style:(" + (el.styleBinding) + "),";
  49987. }
  49988. return data
  49989. }
  49990. var style$1 = {
  49991. staticKeys: ['staticStyle'],
  49992. transformNode: transformNode$1,
  49993. genData: genData$1
  49994. };
  49995. /* */
  49996. var decoder;
  49997. var he = {
  49998. decode: function decode (html) {
  49999. decoder = decoder || document.createElement('div');
  50000. decoder.innerHTML = html;
  50001. return decoder.textContent
  50002. }
  50003. };
  50004. /* */
  50005. var isUnaryTag = makeMap(
  50006. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  50007. 'link,meta,param,source,track,wbr'
  50008. );
  50009. // Elements that you can, intentionally, leave open
  50010. // (and which close themselves)
  50011. var canBeLeftOpenTag = makeMap(
  50012. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  50013. );
  50014. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  50015. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  50016. var isNonPhrasingTag = makeMap(
  50017. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  50018. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  50019. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  50020. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  50021. 'title,tr,track'
  50022. );
  50023. /**
  50024. * Not type-checking this file because it's mostly vendor code.
  50025. */
  50026. // Regular Expressions for parsing tags and attributes
  50027. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50028. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  50029. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  50030. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  50031. var startTagOpen = new RegExp(("^<" + qnameCapture));
  50032. var startTagClose = /^\s*(\/?)>/;
  50033. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  50034. var doctype = /^<!DOCTYPE [^>]+>/i;
  50035. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  50036. var comment = /^<!\--/;
  50037. var conditionalComment = /^<!\[/;
  50038. // Special Elements (can contain anything)
  50039. var isPlainTextElement = makeMap('script,style,textarea', true);
  50040. var reCache = {};
  50041. var decodingMap = {
  50042. '&lt;': '<',
  50043. '&gt;': '>',
  50044. '&quot;': '"',
  50045. '&amp;': '&',
  50046. '&#10;': '\n',
  50047. '&#9;': '\t',
  50048. '&#39;': "'"
  50049. };
  50050. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  50051. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  50052. // #5992
  50053. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  50054. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  50055. function decodeAttr (value, shouldDecodeNewlines) {
  50056. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  50057. return value.replace(re, function (match) { return decodingMap[match]; })
  50058. }
  50059. function parseHTML (html, options) {
  50060. var stack = [];
  50061. var expectHTML = options.expectHTML;
  50062. var isUnaryTag$$1 = options.isUnaryTag || no;
  50063. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  50064. var index = 0;
  50065. var last, lastTag;
  50066. while (html) {
  50067. last = html;
  50068. // Make sure we're not in a plaintext content element like script/style
  50069. if (!lastTag || !isPlainTextElement(lastTag)) {
  50070. var textEnd = html.indexOf('<');
  50071. if (textEnd === 0) {
  50072. // Comment:
  50073. if (comment.test(html)) {
  50074. var commentEnd = html.indexOf('-->');
  50075. if (commentEnd >= 0) {
  50076. if (options.shouldKeepComment) {
  50077. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  50078. }
  50079. advance(commentEnd + 3);
  50080. continue
  50081. }
  50082. }
  50083. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  50084. if (conditionalComment.test(html)) {
  50085. var conditionalEnd = html.indexOf(']>');
  50086. if (conditionalEnd >= 0) {
  50087. advance(conditionalEnd + 2);
  50088. continue
  50089. }
  50090. }
  50091. // Doctype:
  50092. var doctypeMatch = html.match(doctype);
  50093. if (doctypeMatch) {
  50094. advance(doctypeMatch[0].length);
  50095. continue
  50096. }
  50097. // End tag:
  50098. var endTagMatch = html.match(endTag);
  50099. if (endTagMatch) {
  50100. var curIndex = index;
  50101. advance(endTagMatch[0].length);
  50102. parseEndTag(endTagMatch[1], curIndex, index);
  50103. continue
  50104. }
  50105. // Start tag:
  50106. var startTagMatch = parseStartTag();
  50107. if (startTagMatch) {
  50108. handleStartTag(startTagMatch);
  50109. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  50110. advance(1);
  50111. }
  50112. continue
  50113. }
  50114. }
  50115. var text = (void 0), rest = (void 0), next = (void 0);
  50116. if (textEnd >= 0) {
  50117. rest = html.slice(textEnd);
  50118. while (
  50119. !endTag.test(rest) &&
  50120. !startTagOpen.test(rest) &&
  50121. !comment.test(rest) &&
  50122. !conditionalComment.test(rest)
  50123. ) {
  50124. // < in plain text, be forgiving and treat it as text
  50125. next = rest.indexOf('<', 1);
  50126. if (next < 0) { break }
  50127. textEnd += next;
  50128. rest = html.slice(textEnd);
  50129. }
  50130. text = html.substring(0, textEnd);
  50131. }
  50132. if (textEnd < 0) {
  50133. text = html;
  50134. }
  50135. if (text) {
  50136. advance(text.length);
  50137. }
  50138. if (options.chars && text) {
  50139. options.chars(text, index - text.length, index);
  50140. }
  50141. } else {
  50142. var endTagLength = 0;
  50143. var stackedTag = lastTag.toLowerCase();
  50144. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  50145. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  50146. endTagLength = endTag.length;
  50147. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  50148. text = text
  50149. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  50150. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  50151. }
  50152. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  50153. text = text.slice(1);
  50154. }
  50155. if (options.chars) {
  50156. options.chars(text);
  50157. }
  50158. return ''
  50159. });
  50160. index += html.length - rest$1.length;
  50161. html = rest$1;
  50162. parseEndTag(stackedTag, index - endTagLength, index);
  50163. }
  50164. if (html === last) {
  50165. options.chars && options.chars(html);
  50166. if (!stack.length && options.warn) {
  50167. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  50168. }
  50169. break
  50170. }
  50171. }
  50172. // Clean up any remaining tags
  50173. parseEndTag();
  50174. function advance (n) {
  50175. index += n;
  50176. html = html.substring(n);
  50177. }
  50178. function parseStartTag () {
  50179. var start = html.match(startTagOpen);
  50180. if (start) {
  50181. var match = {
  50182. tagName: start[1],
  50183. attrs: [],
  50184. start: index
  50185. };
  50186. advance(start[0].length);
  50187. var end, attr;
  50188. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  50189. attr.start = index;
  50190. advance(attr[0].length);
  50191. attr.end = index;
  50192. match.attrs.push(attr);
  50193. }
  50194. if (end) {
  50195. match.unarySlash = end[1];
  50196. advance(end[0].length);
  50197. match.end = index;
  50198. return match
  50199. }
  50200. }
  50201. }
  50202. function handleStartTag (match) {
  50203. var tagName = match.tagName;
  50204. var unarySlash = match.unarySlash;
  50205. if (expectHTML) {
  50206. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  50207. parseEndTag(lastTag);
  50208. }
  50209. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  50210. parseEndTag(tagName);
  50211. }
  50212. }
  50213. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  50214. var l = match.attrs.length;
  50215. var attrs = new Array(l);
  50216. for (var i = 0; i < l; i++) {
  50217. var args = match.attrs[i];
  50218. var value = args[3] || args[4] || args[5] || '';
  50219. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  50220. ? options.shouldDecodeNewlinesForHref
  50221. : options.shouldDecodeNewlines;
  50222. attrs[i] = {
  50223. name: args[1],
  50224. value: decodeAttr(value, shouldDecodeNewlines)
  50225. };
  50226. if (options.outputSourceRange) {
  50227. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  50228. attrs[i].end = args.end;
  50229. }
  50230. }
  50231. if (!unary) {
  50232. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  50233. lastTag = tagName;
  50234. }
  50235. if (options.start) {
  50236. options.start(tagName, attrs, unary, match.start, match.end);
  50237. }
  50238. }
  50239. function parseEndTag (tagName, start, end) {
  50240. var pos, lowerCasedTagName;
  50241. if (start == null) { start = index; }
  50242. if (end == null) { end = index; }
  50243. // Find the closest opened tag of the same type
  50244. if (tagName) {
  50245. lowerCasedTagName = tagName.toLowerCase();
  50246. for (pos = stack.length - 1; pos >= 0; pos--) {
  50247. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  50248. break
  50249. }
  50250. }
  50251. } else {
  50252. // If no tag name is provided, clean shop
  50253. pos = 0;
  50254. }
  50255. if (pos >= 0) {
  50256. // Close all the open elements, up the stack
  50257. for (var i = stack.length - 1; i >= pos; i--) {
  50258. if (i > pos || !tagName &&
  50259. options.warn
  50260. ) {
  50261. options.warn(
  50262. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  50263. { start: stack[i].start, end: stack[i].end }
  50264. );
  50265. }
  50266. if (options.end) {
  50267. options.end(stack[i].tag, start, end);
  50268. }
  50269. }
  50270. // Remove the open elements from the stack
  50271. stack.length = pos;
  50272. lastTag = pos && stack[pos - 1].tag;
  50273. } else if (lowerCasedTagName === 'br') {
  50274. if (options.start) {
  50275. options.start(tagName, [], true, start, end);
  50276. }
  50277. } else if (lowerCasedTagName === 'p') {
  50278. if (options.start) {
  50279. options.start(tagName, [], false, start, end);
  50280. }
  50281. if (options.end) {
  50282. options.end(tagName, start, end);
  50283. }
  50284. }
  50285. }
  50286. }
  50287. /* */
  50288. var onRE = /^@|^v-on:/;
  50289. var dirRE = /^v-|^@|^:|^#/;
  50290. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  50291. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  50292. var stripParensRE = /^\(|\)$/g;
  50293. var dynamicArgRE = /^\[.*\]$/;
  50294. var argRE = /:(.*)$/;
  50295. var bindRE = /^:|^\.|^v-bind:/;
  50296. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  50297. var slotRE = /^v-slot(:|$)|^#/;
  50298. var lineBreakRE = /[\r\n]/;
  50299. var whitespaceRE$1 = /\s+/g;
  50300. var invalidAttributeRE = /[\s"'<>\/=]/;
  50301. var decodeHTMLCached = cached(he.decode);
  50302. var emptySlotScopeToken = "_empty_";
  50303. // configurable state
  50304. var warn$2;
  50305. var delimiters;
  50306. var transforms;
  50307. var preTransforms;
  50308. var postTransforms;
  50309. var platformIsPreTag;
  50310. var platformMustUseProp;
  50311. var platformGetTagNamespace;
  50312. var maybeComponent;
  50313. function createASTElement (
  50314. tag,
  50315. attrs,
  50316. parent
  50317. ) {
  50318. return {
  50319. type: 1,
  50320. tag: tag,
  50321. attrsList: attrs,
  50322. attrsMap: makeAttrsMap(attrs),
  50323. rawAttrsMap: {},
  50324. parent: parent,
  50325. children: []
  50326. }
  50327. }
  50328. /**
  50329. * Convert HTML string to AST.
  50330. */
  50331. function parse (
  50332. template,
  50333. options
  50334. ) {
  50335. warn$2 = options.warn || baseWarn;
  50336. platformIsPreTag = options.isPreTag || no;
  50337. platformMustUseProp = options.mustUseProp || no;
  50338. platformGetTagNamespace = options.getTagNamespace || no;
  50339. var isReservedTag = options.isReservedTag || no;
  50340. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  50341. transforms = pluckModuleFunction(options.modules, 'transformNode');
  50342. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  50343. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  50344. delimiters = options.delimiters;
  50345. var stack = [];
  50346. var preserveWhitespace = options.preserveWhitespace !== false;
  50347. var whitespaceOption = options.whitespace;
  50348. var root;
  50349. var currentParent;
  50350. var inVPre = false;
  50351. var inPre = false;
  50352. var warned = false;
  50353. function warnOnce (msg, range) {
  50354. if (!warned) {
  50355. warned = true;
  50356. warn$2(msg, range);
  50357. }
  50358. }
  50359. function closeElement (element) {
  50360. trimEndingWhitespace(element);
  50361. if (!inVPre && !element.processed) {
  50362. element = processElement(element, options);
  50363. }
  50364. // tree management
  50365. if (!stack.length && element !== root) {
  50366. // allow root elements with v-if, v-else-if and v-else
  50367. if (root.if && (element.elseif || element.else)) {
  50368. {
  50369. checkRootConstraints(element);
  50370. }
  50371. addIfCondition(root, {
  50372. exp: element.elseif,
  50373. block: element
  50374. });
  50375. } else {
  50376. warnOnce(
  50377. "Component template should contain exactly one root element. " +
  50378. "If you are using v-if on multiple elements, " +
  50379. "use v-else-if to chain them instead.",
  50380. { start: element.start }
  50381. );
  50382. }
  50383. }
  50384. if (currentParent && !element.forbidden) {
  50385. if (element.elseif || element.else) {
  50386. processIfConditions(element, currentParent);
  50387. } else {
  50388. if (element.slotScope) {
  50389. // scoped slot
  50390. // keep it in the children list so that v-else(-if) conditions can
  50391. // find it as the prev node.
  50392. var name = element.slotTarget || '"default"'
  50393. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  50394. }
  50395. currentParent.children.push(element);
  50396. element.parent = currentParent;
  50397. }
  50398. }
  50399. // final children cleanup
  50400. // filter out scoped slots
  50401. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  50402. // remove trailing whitespace node again
  50403. trimEndingWhitespace(element);
  50404. // check pre state
  50405. if (element.pre) {
  50406. inVPre = false;
  50407. }
  50408. if (platformIsPreTag(element.tag)) {
  50409. inPre = false;
  50410. }
  50411. // apply post-transforms
  50412. for (var i = 0; i < postTransforms.length; i++) {
  50413. postTransforms[i](element, options);
  50414. }
  50415. }
  50416. function trimEndingWhitespace (el) {
  50417. // remove trailing whitespace node
  50418. if (!inPre) {
  50419. var lastNode;
  50420. while (
  50421. (lastNode = el.children[el.children.length - 1]) &&
  50422. lastNode.type === 3 &&
  50423. lastNode.text === ' '
  50424. ) {
  50425. el.children.pop();
  50426. }
  50427. }
  50428. }
  50429. function checkRootConstraints (el) {
  50430. if (el.tag === 'slot' || el.tag === 'template') {
  50431. warnOnce(
  50432. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  50433. 'contain multiple nodes.',
  50434. { start: el.start }
  50435. );
  50436. }
  50437. if (el.attrsMap.hasOwnProperty('v-for')) {
  50438. warnOnce(
  50439. 'Cannot use v-for on stateful component root element because ' +
  50440. 'it renders multiple elements.',
  50441. el.rawAttrsMap['v-for']
  50442. );
  50443. }
  50444. }
  50445. parseHTML(template, {
  50446. warn: warn$2,
  50447. expectHTML: options.expectHTML,
  50448. isUnaryTag: options.isUnaryTag,
  50449. canBeLeftOpenTag: options.canBeLeftOpenTag,
  50450. shouldDecodeNewlines: options.shouldDecodeNewlines,
  50451. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  50452. shouldKeepComment: options.comments,
  50453. outputSourceRange: options.outputSourceRange,
  50454. start: function start (tag, attrs, unary, start$1, end) {
  50455. // check namespace.
  50456. // inherit parent ns if there is one
  50457. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  50458. // handle IE svg bug
  50459. /* istanbul ignore if */
  50460. if (isIE && ns === 'svg') {
  50461. attrs = guardIESVGBug(attrs);
  50462. }
  50463. var element = createASTElement(tag, attrs, currentParent);
  50464. if (ns) {
  50465. element.ns = ns;
  50466. }
  50467. {
  50468. if (options.outputSourceRange) {
  50469. element.start = start$1;
  50470. element.end = end;
  50471. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  50472. cumulated[attr.name] = attr;
  50473. return cumulated
  50474. }, {});
  50475. }
  50476. attrs.forEach(function (attr) {
  50477. if (invalidAttributeRE.test(attr.name)) {
  50478. warn$2(
  50479. "Invalid dynamic argument expression: attribute names cannot contain " +
  50480. "spaces, quotes, <, >, / or =.",
  50481. {
  50482. start: attr.start + attr.name.indexOf("["),
  50483. end: attr.start + attr.name.length
  50484. }
  50485. );
  50486. }
  50487. });
  50488. }
  50489. if (isForbiddenTag(element) && !isServerRendering()) {
  50490. element.forbidden = true;
  50491. warn$2(
  50492. 'Templates should only be responsible for mapping the state to the ' +
  50493. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  50494. "<" + tag + ">" + ', as they will not be parsed.',
  50495. { start: element.start }
  50496. );
  50497. }
  50498. // apply pre-transforms
  50499. for (var i = 0; i < preTransforms.length; i++) {
  50500. element = preTransforms[i](element, options) || element;
  50501. }
  50502. if (!inVPre) {
  50503. processPre(element);
  50504. if (element.pre) {
  50505. inVPre = true;
  50506. }
  50507. }
  50508. if (platformIsPreTag(element.tag)) {
  50509. inPre = true;
  50510. }
  50511. if (inVPre) {
  50512. processRawAttrs(element);
  50513. } else if (!element.processed) {
  50514. // structural directives
  50515. processFor(element);
  50516. processIf(element);
  50517. processOnce(element);
  50518. }
  50519. if (!root) {
  50520. root = element;
  50521. {
  50522. checkRootConstraints(root);
  50523. }
  50524. }
  50525. if (!unary) {
  50526. currentParent = element;
  50527. stack.push(element);
  50528. } else {
  50529. closeElement(element);
  50530. }
  50531. },
  50532. end: function end (tag, start, end$1) {
  50533. var element = stack[stack.length - 1];
  50534. // pop stack
  50535. stack.length -= 1;
  50536. currentParent = stack[stack.length - 1];
  50537. if (options.outputSourceRange) {
  50538. element.end = end$1;
  50539. }
  50540. closeElement(element);
  50541. },
  50542. chars: function chars (text, start, end) {
  50543. if (!currentParent) {
  50544. {
  50545. if (text === template) {
  50546. warnOnce(
  50547. 'Component template requires a root element, rather than just text.',
  50548. { start: start }
  50549. );
  50550. } else if ((text = text.trim())) {
  50551. warnOnce(
  50552. ("text \"" + text + "\" outside root element will be ignored."),
  50553. { start: start }
  50554. );
  50555. }
  50556. }
  50557. return
  50558. }
  50559. // IE textarea placeholder bug
  50560. /* istanbul ignore if */
  50561. if (isIE &&
  50562. currentParent.tag === 'textarea' &&
  50563. currentParent.attrsMap.placeholder === text
  50564. ) {
  50565. return
  50566. }
  50567. var children = currentParent.children;
  50568. if (inPre || text.trim()) {
  50569. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  50570. } else if (!children.length) {
  50571. // remove the whitespace-only node right after an opening tag
  50572. text = '';
  50573. } else if (whitespaceOption) {
  50574. if (whitespaceOption === 'condense') {
  50575. // in condense mode, remove the whitespace node if it contains
  50576. // line break, otherwise condense to a single space
  50577. text = lineBreakRE.test(text) ? '' : ' ';
  50578. } else {
  50579. text = ' ';
  50580. }
  50581. } else {
  50582. text = preserveWhitespace ? ' ' : '';
  50583. }
  50584. if (text) {
  50585. if (!inPre && whitespaceOption === 'condense') {
  50586. // condense consecutive whitespaces into single space
  50587. text = text.replace(whitespaceRE$1, ' ');
  50588. }
  50589. var res;
  50590. var child;
  50591. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  50592. child = {
  50593. type: 2,
  50594. expression: res.expression,
  50595. tokens: res.tokens,
  50596. text: text
  50597. };
  50598. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  50599. child = {
  50600. type: 3,
  50601. text: text
  50602. };
  50603. }
  50604. if (child) {
  50605. if (options.outputSourceRange) {
  50606. child.start = start;
  50607. child.end = end;
  50608. }
  50609. children.push(child);
  50610. }
  50611. }
  50612. },
  50613. comment: function comment (text, start, end) {
  50614. // adding anyting as a sibling to the root node is forbidden
  50615. // comments should still be allowed, but ignored
  50616. if (currentParent) {
  50617. var child = {
  50618. type: 3,
  50619. text: text,
  50620. isComment: true
  50621. };
  50622. if (options.outputSourceRange) {
  50623. child.start = start;
  50624. child.end = end;
  50625. }
  50626. currentParent.children.push(child);
  50627. }
  50628. }
  50629. });
  50630. return root
  50631. }
  50632. function processPre (el) {
  50633. if (getAndRemoveAttr(el, 'v-pre') != null) {
  50634. el.pre = true;
  50635. }
  50636. }
  50637. function processRawAttrs (el) {
  50638. var list = el.attrsList;
  50639. var len = list.length;
  50640. if (len) {
  50641. var attrs = el.attrs = new Array(len);
  50642. for (var i = 0; i < len; i++) {
  50643. attrs[i] = {
  50644. name: list[i].name,
  50645. value: JSON.stringify(list[i].value)
  50646. };
  50647. if (list[i].start != null) {
  50648. attrs[i].start = list[i].start;
  50649. attrs[i].end = list[i].end;
  50650. }
  50651. }
  50652. } else if (!el.pre) {
  50653. // non root node in pre blocks with no attributes
  50654. el.plain = true;
  50655. }
  50656. }
  50657. function processElement (
  50658. element,
  50659. options
  50660. ) {
  50661. processKey(element);
  50662. // determine whether this is a plain element after
  50663. // removing structural attributes
  50664. element.plain = (
  50665. !element.key &&
  50666. !element.scopedSlots &&
  50667. !element.attrsList.length
  50668. );
  50669. processRef(element);
  50670. processSlotContent(element);
  50671. processSlotOutlet(element);
  50672. processComponent(element);
  50673. for (var i = 0; i < transforms.length; i++) {
  50674. element = transforms[i](element, options) || element;
  50675. }
  50676. processAttrs(element);
  50677. return element
  50678. }
  50679. function processKey (el) {
  50680. var exp = getBindingAttr(el, 'key');
  50681. if (exp) {
  50682. {
  50683. if (el.tag === 'template') {
  50684. warn$2(
  50685. "<template> cannot be keyed. Place the key on real elements instead.",
  50686. getRawBindingAttr(el, 'key')
  50687. );
  50688. }
  50689. if (el.for) {
  50690. var iterator = el.iterator2 || el.iterator1;
  50691. var parent = el.parent;
  50692. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  50693. warn$2(
  50694. "Do not use v-for index as key on <transition-group> children, " +
  50695. "this is the same as not using keys.",
  50696. getRawBindingAttr(el, 'key'),
  50697. true /* tip */
  50698. );
  50699. }
  50700. }
  50701. }
  50702. el.key = exp;
  50703. }
  50704. }
  50705. function processRef (el) {
  50706. var ref = getBindingAttr(el, 'ref');
  50707. if (ref) {
  50708. el.ref = ref;
  50709. el.refInFor = checkInFor(el);
  50710. }
  50711. }
  50712. function processFor (el) {
  50713. var exp;
  50714. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  50715. var res = parseFor(exp);
  50716. if (res) {
  50717. extend(el, res);
  50718. } else {
  50719. warn$2(
  50720. ("Invalid v-for expression: " + exp),
  50721. el.rawAttrsMap['v-for']
  50722. );
  50723. }
  50724. }
  50725. }
  50726. function parseFor (exp) {
  50727. var inMatch = exp.match(forAliasRE);
  50728. if (!inMatch) { return }
  50729. var res = {};
  50730. res.for = inMatch[2].trim();
  50731. var alias = inMatch[1].trim().replace(stripParensRE, '');
  50732. var iteratorMatch = alias.match(forIteratorRE);
  50733. if (iteratorMatch) {
  50734. res.alias = alias.replace(forIteratorRE, '').trim();
  50735. res.iterator1 = iteratorMatch[1].trim();
  50736. if (iteratorMatch[2]) {
  50737. res.iterator2 = iteratorMatch[2].trim();
  50738. }
  50739. } else {
  50740. res.alias = alias;
  50741. }
  50742. return res
  50743. }
  50744. function processIf (el) {
  50745. var exp = getAndRemoveAttr(el, 'v-if');
  50746. if (exp) {
  50747. el.if = exp;
  50748. addIfCondition(el, {
  50749. exp: exp,
  50750. block: el
  50751. });
  50752. } else {
  50753. if (getAndRemoveAttr(el, 'v-else') != null) {
  50754. el.else = true;
  50755. }
  50756. var elseif = getAndRemoveAttr(el, 'v-else-if');
  50757. if (elseif) {
  50758. el.elseif = elseif;
  50759. }
  50760. }
  50761. }
  50762. function processIfConditions (el, parent) {
  50763. var prev = findPrevElement(parent.children);
  50764. if (prev && prev.if) {
  50765. addIfCondition(prev, {
  50766. exp: el.elseif,
  50767. block: el
  50768. });
  50769. } else {
  50770. warn$2(
  50771. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  50772. "used on element <" + (el.tag) + "> without corresponding v-if.",
  50773. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  50774. );
  50775. }
  50776. }
  50777. function findPrevElement (children) {
  50778. var i = children.length;
  50779. while (i--) {
  50780. if (children[i].type === 1) {
  50781. return children[i]
  50782. } else {
  50783. if (children[i].text !== ' ') {
  50784. warn$2(
  50785. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  50786. "will be ignored.",
  50787. children[i]
  50788. );
  50789. }
  50790. children.pop();
  50791. }
  50792. }
  50793. }
  50794. function addIfCondition (el, condition) {
  50795. if (!el.ifConditions) {
  50796. el.ifConditions = [];
  50797. }
  50798. el.ifConditions.push(condition);
  50799. }
  50800. function processOnce (el) {
  50801. var once$$1 = getAndRemoveAttr(el, 'v-once');
  50802. if (once$$1 != null) {
  50803. el.once = true;
  50804. }
  50805. }
  50806. // handle content being passed to a component as slot,
  50807. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  50808. function processSlotContent (el) {
  50809. var slotScope;
  50810. if (el.tag === 'template') {
  50811. slotScope = getAndRemoveAttr(el, 'scope');
  50812. /* istanbul ignore if */
  50813. if (slotScope) {
  50814. warn$2(
  50815. "the \"scope\" attribute for scoped slots have been deprecated and " +
  50816. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  50817. "can also be used on plain elements in addition to <template> to " +
  50818. "denote scoped slots.",
  50819. el.rawAttrsMap['scope'],
  50820. true
  50821. );
  50822. }
  50823. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  50824. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  50825. /* istanbul ignore if */
  50826. if (el.attrsMap['v-for']) {
  50827. warn$2(
  50828. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  50829. "(v-for takes higher priority). Use a wrapper <template> for the " +
  50830. "scoped slot to make it clearer.",
  50831. el.rawAttrsMap['slot-scope'],
  50832. true
  50833. );
  50834. }
  50835. el.slotScope = slotScope;
  50836. }
  50837. // slot="xxx"
  50838. var slotTarget = getBindingAttr(el, 'slot');
  50839. if (slotTarget) {
  50840. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  50841. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  50842. // preserve slot as an attribute for native shadow DOM compat
  50843. // only for non-scoped slots.
  50844. if (el.tag !== 'template' && !el.slotScope) {
  50845. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  50846. }
  50847. }
  50848. // 2.6 v-slot syntax
  50849. {
  50850. if (el.tag === 'template') {
  50851. // v-slot on <template>
  50852. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  50853. if (slotBinding) {
  50854. {
  50855. if (el.slotTarget || el.slotScope) {
  50856. warn$2(
  50857. "Unexpected mixed usage of different slot syntaxes.",
  50858. el
  50859. );
  50860. }
  50861. if (el.parent && !maybeComponent(el.parent)) {
  50862. warn$2(
  50863. "<template v-slot> can only appear at the root level inside " +
  50864. "the receiving component",
  50865. el
  50866. );
  50867. }
  50868. }
  50869. var ref = getSlotName(slotBinding);
  50870. var name = ref.name;
  50871. var dynamic = ref.dynamic;
  50872. el.slotTarget = name;
  50873. el.slotTargetDynamic = dynamic;
  50874. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  50875. }
  50876. } else {
  50877. // v-slot on component, denotes default slot
  50878. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  50879. if (slotBinding$1) {
  50880. {
  50881. if (!maybeComponent(el)) {
  50882. warn$2(
  50883. "v-slot can only be used on components or <template>.",
  50884. slotBinding$1
  50885. );
  50886. }
  50887. if (el.slotScope || el.slotTarget) {
  50888. warn$2(
  50889. "Unexpected mixed usage of different slot syntaxes.",
  50890. el
  50891. );
  50892. }
  50893. if (el.scopedSlots) {
  50894. warn$2(
  50895. "To avoid scope ambiguity, the default slot should also use " +
  50896. "<template> syntax when there are other named slots.",
  50897. slotBinding$1
  50898. );
  50899. }
  50900. }
  50901. // add the component's children to its default slot
  50902. var slots = el.scopedSlots || (el.scopedSlots = {});
  50903. var ref$1 = getSlotName(slotBinding$1);
  50904. var name$1 = ref$1.name;
  50905. var dynamic$1 = ref$1.dynamic;
  50906. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  50907. slotContainer.slotTarget = name$1;
  50908. slotContainer.slotTargetDynamic = dynamic$1;
  50909. slotContainer.children = el.children.filter(function (c) {
  50910. if (!c.slotScope) {
  50911. c.parent = slotContainer;
  50912. return true
  50913. }
  50914. });
  50915. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  50916. // remove children as they are returned from scopedSlots now
  50917. el.children = [];
  50918. // mark el non-plain so data gets generated
  50919. el.plain = false;
  50920. }
  50921. }
  50922. }
  50923. }
  50924. function getSlotName (binding) {
  50925. var name = binding.name.replace(slotRE, '');
  50926. if (!name) {
  50927. if (binding.name[0] !== '#') {
  50928. name = 'default';
  50929. } else {
  50930. warn$2(
  50931. "v-slot shorthand syntax requires a slot name.",
  50932. binding
  50933. );
  50934. }
  50935. }
  50936. return dynamicArgRE.test(name)
  50937. // dynamic [name]
  50938. ? { name: name.slice(1, -1), dynamic: true }
  50939. // static name
  50940. : { name: ("\"" + name + "\""), dynamic: false }
  50941. }
  50942. // handle <slot/> outlets
  50943. function processSlotOutlet (el) {
  50944. if (el.tag === 'slot') {
  50945. el.slotName = getBindingAttr(el, 'name');
  50946. if (el.key) {
  50947. warn$2(
  50948. "`key` does not work on <slot> because slots are abstract outlets " +
  50949. "and can possibly expand into multiple elements. " +
  50950. "Use the key on a wrapping element instead.",
  50951. getRawBindingAttr(el, 'key')
  50952. );
  50953. }
  50954. }
  50955. }
  50956. function processComponent (el) {
  50957. var binding;
  50958. if ((binding = getBindingAttr(el, 'is'))) {
  50959. el.component = binding;
  50960. }
  50961. if (getAndRemoveAttr(el, 'inline-template') != null) {
  50962. el.inlineTemplate = true;
  50963. }
  50964. }
  50965. function processAttrs (el) {
  50966. var list = el.attrsList;
  50967. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  50968. for (i = 0, l = list.length; i < l; i++) {
  50969. name = rawName = list[i].name;
  50970. value = list[i].value;
  50971. if (dirRE.test(name)) {
  50972. // mark element as dynamic
  50973. el.hasBindings = true;
  50974. // modifiers
  50975. modifiers = parseModifiers(name.replace(dirRE, ''));
  50976. // support .foo shorthand syntax for the .prop modifier
  50977. if (modifiers) {
  50978. name = name.replace(modifierRE, '');
  50979. }
  50980. if (bindRE.test(name)) { // v-bind
  50981. name = name.replace(bindRE, '');
  50982. value = parseFilters(value);
  50983. isDynamic = dynamicArgRE.test(name);
  50984. if (isDynamic) {
  50985. name = name.slice(1, -1);
  50986. }
  50987. if (
  50988. value.trim().length === 0
  50989. ) {
  50990. warn$2(
  50991. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  50992. );
  50993. }
  50994. if (modifiers) {
  50995. if (modifiers.prop && !isDynamic) {
  50996. name = camelize(name);
  50997. if (name === 'innerHtml') { name = 'innerHTML'; }
  50998. }
  50999. if (modifiers.camel && !isDynamic) {
  51000. name = camelize(name);
  51001. }
  51002. if (modifiers.sync) {
  51003. syncGen = genAssignmentCode(value, "$event");
  51004. if (!isDynamic) {
  51005. addHandler(
  51006. el,
  51007. ("update:" + (camelize(name))),
  51008. syncGen,
  51009. null,
  51010. false,
  51011. warn$2,
  51012. list[i]
  51013. );
  51014. if (hyphenate(name) !== camelize(name)) {
  51015. addHandler(
  51016. el,
  51017. ("update:" + (hyphenate(name))),
  51018. syncGen,
  51019. null,
  51020. false,
  51021. warn$2,
  51022. list[i]
  51023. );
  51024. }
  51025. } else {
  51026. // handler w/ dynamic event name
  51027. addHandler(
  51028. el,
  51029. ("\"update:\"+(" + name + ")"),
  51030. syncGen,
  51031. null,
  51032. false,
  51033. warn$2,
  51034. list[i],
  51035. true // dynamic
  51036. );
  51037. }
  51038. }
  51039. }
  51040. if ((modifiers && modifiers.prop) || (
  51041. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  51042. )) {
  51043. addProp(el, name, value, list[i], isDynamic);
  51044. } else {
  51045. addAttr(el, name, value, list[i], isDynamic);
  51046. }
  51047. } else if (onRE.test(name)) { // v-on
  51048. name = name.replace(onRE, '');
  51049. isDynamic = dynamicArgRE.test(name);
  51050. if (isDynamic) {
  51051. name = name.slice(1, -1);
  51052. }
  51053. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  51054. } else { // normal directives
  51055. name = name.replace(dirRE, '');
  51056. // parse arg
  51057. var argMatch = name.match(argRE);
  51058. var arg = argMatch && argMatch[1];
  51059. isDynamic = false;
  51060. if (arg) {
  51061. name = name.slice(0, -(arg.length + 1));
  51062. if (dynamicArgRE.test(arg)) {
  51063. arg = arg.slice(1, -1);
  51064. isDynamic = true;
  51065. }
  51066. }
  51067. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  51068. if (name === 'model') {
  51069. checkForAliasModel(el, value);
  51070. }
  51071. }
  51072. } else {
  51073. // literal attribute
  51074. {
  51075. var res = parseText(value, delimiters);
  51076. if (res) {
  51077. warn$2(
  51078. name + "=\"" + value + "\": " +
  51079. 'Interpolation inside attributes has been removed. ' +
  51080. 'Use v-bind or the colon shorthand instead. For example, ' +
  51081. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  51082. list[i]
  51083. );
  51084. }
  51085. }
  51086. addAttr(el, name, JSON.stringify(value), list[i]);
  51087. // #6887 firefox doesn't update muted state if set via attribute
  51088. // even immediately after element creation
  51089. if (!el.component &&
  51090. name === 'muted' &&
  51091. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  51092. addProp(el, name, 'true', list[i]);
  51093. }
  51094. }
  51095. }
  51096. }
  51097. function checkInFor (el) {
  51098. var parent = el;
  51099. while (parent) {
  51100. if (parent.for !== undefined) {
  51101. return true
  51102. }
  51103. parent = parent.parent;
  51104. }
  51105. return false
  51106. }
  51107. function parseModifiers (name) {
  51108. var match = name.match(modifierRE);
  51109. if (match) {
  51110. var ret = {};
  51111. match.forEach(function (m) { ret[m.slice(1)] = true; });
  51112. return ret
  51113. }
  51114. }
  51115. function makeAttrsMap (attrs) {
  51116. var map = {};
  51117. for (var i = 0, l = attrs.length; i < l; i++) {
  51118. if (
  51119. map[attrs[i].name] && !isIE && !isEdge
  51120. ) {
  51121. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  51122. }
  51123. map[attrs[i].name] = attrs[i].value;
  51124. }
  51125. return map
  51126. }
  51127. // for script (e.g. type="x/template") or style, do not decode content
  51128. function isTextTag (el) {
  51129. return el.tag === 'script' || el.tag === 'style'
  51130. }
  51131. function isForbiddenTag (el) {
  51132. return (
  51133. el.tag === 'style' ||
  51134. (el.tag === 'script' && (
  51135. !el.attrsMap.type ||
  51136. el.attrsMap.type === 'text/javascript'
  51137. ))
  51138. )
  51139. }
  51140. var ieNSBug = /^xmlns:NS\d+/;
  51141. var ieNSPrefix = /^NS\d+:/;
  51142. /* istanbul ignore next */
  51143. function guardIESVGBug (attrs) {
  51144. var res = [];
  51145. for (var i = 0; i < attrs.length; i++) {
  51146. var attr = attrs[i];
  51147. if (!ieNSBug.test(attr.name)) {
  51148. attr.name = attr.name.replace(ieNSPrefix, '');
  51149. res.push(attr);
  51150. }
  51151. }
  51152. return res
  51153. }
  51154. function checkForAliasModel (el, value) {
  51155. var _el = el;
  51156. while (_el) {
  51157. if (_el.for && _el.alias === value) {
  51158. warn$2(
  51159. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  51160. "You are binding v-model directly to a v-for iteration alias. " +
  51161. "This will not be able to modify the v-for source array because " +
  51162. "writing to the alias is like modifying a function local variable. " +
  51163. "Consider using an array of objects and use v-model on an object property instead.",
  51164. el.rawAttrsMap['v-model']
  51165. );
  51166. }
  51167. _el = _el.parent;
  51168. }
  51169. }
  51170. /* */
  51171. function preTransformNode (el, options) {
  51172. if (el.tag === 'input') {
  51173. var map = el.attrsMap;
  51174. if (!map['v-model']) {
  51175. return
  51176. }
  51177. var typeBinding;
  51178. if (map[':type'] || map['v-bind:type']) {
  51179. typeBinding = getBindingAttr(el, 'type');
  51180. }
  51181. if (!map.type && !typeBinding && map['v-bind']) {
  51182. typeBinding = "(" + (map['v-bind']) + ").type";
  51183. }
  51184. if (typeBinding) {
  51185. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  51186. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  51187. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  51188. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  51189. // 1. checkbox
  51190. var branch0 = cloneASTElement(el);
  51191. // process for on the main node
  51192. processFor(branch0);
  51193. addRawAttr(branch0, 'type', 'checkbox');
  51194. processElement(branch0, options);
  51195. branch0.processed = true; // prevent it from double-processed
  51196. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  51197. addIfCondition(branch0, {
  51198. exp: branch0.if,
  51199. block: branch0
  51200. });
  51201. // 2. add radio else-if condition
  51202. var branch1 = cloneASTElement(el);
  51203. getAndRemoveAttr(branch1, 'v-for', true);
  51204. addRawAttr(branch1, 'type', 'radio');
  51205. processElement(branch1, options);
  51206. addIfCondition(branch0, {
  51207. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  51208. block: branch1
  51209. });
  51210. // 3. other
  51211. var branch2 = cloneASTElement(el);
  51212. getAndRemoveAttr(branch2, 'v-for', true);
  51213. addRawAttr(branch2, ':type', typeBinding);
  51214. processElement(branch2, options);
  51215. addIfCondition(branch0, {
  51216. exp: ifCondition,
  51217. block: branch2
  51218. });
  51219. if (hasElse) {
  51220. branch0.else = true;
  51221. } else if (elseIfCondition) {
  51222. branch0.elseif = elseIfCondition;
  51223. }
  51224. return branch0
  51225. }
  51226. }
  51227. }
  51228. function cloneASTElement (el) {
  51229. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  51230. }
  51231. var model$1 = {
  51232. preTransformNode: preTransformNode
  51233. };
  51234. var modules$1 = [
  51235. klass$1,
  51236. style$1,
  51237. model$1
  51238. ];
  51239. /* */
  51240. function text (el, dir) {
  51241. if (dir.value) {
  51242. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  51243. }
  51244. }
  51245. /* */
  51246. function html (el, dir) {
  51247. if (dir.value) {
  51248. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  51249. }
  51250. }
  51251. var directives$1 = {
  51252. model: model,
  51253. text: text,
  51254. html: html
  51255. };
  51256. /* */
  51257. var baseOptions = {
  51258. expectHTML: true,
  51259. modules: modules$1,
  51260. directives: directives$1,
  51261. isPreTag: isPreTag,
  51262. isUnaryTag: isUnaryTag,
  51263. mustUseProp: mustUseProp,
  51264. canBeLeftOpenTag: canBeLeftOpenTag,
  51265. isReservedTag: isReservedTag,
  51266. getTagNamespace: getTagNamespace,
  51267. staticKeys: genStaticKeys(modules$1)
  51268. };
  51269. /* */
  51270. var isStaticKey;
  51271. var isPlatformReservedTag;
  51272. var genStaticKeysCached = cached(genStaticKeys$1);
  51273. /**
  51274. * Goal of the optimizer: walk the generated template AST tree
  51275. * and detect sub-trees that are purely static, i.e. parts of
  51276. * the DOM that never needs to change.
  51277. *
  51278. * Once we detect these sub-trees, we can:
  51279. *
  51280. * 1. Hoist them into constants, so that we no longer need to
  51281. * create fresh nodes for them on each re-render;
  51282. * 2. Completely skip them in the patching process.
  51283. */
  51284. function optimize (root, options) {
  51285. if (!root) { return }
  51286. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  51287. isPlatformReservedTag = options.isReservedTag || no;
  51288. // first pass: mark all non-static nodes.
  51289. markStatic$1(root);
  51290. // second pass: mark static roots.
  51291. markStaticRoots(root, false);
  51292. }
  51293. function genStaticKeys$1 (keys) {
  51294. return makeMap(
  51295. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  51296. (keys ? ',' + keys : '')
  51297. )
  51298. }
  51299. function markStatic$1 (node) {
  51300. node.static = isStatic(node);
  51301. if (node.type === 1) {
  51302. // do not make component slot content static. this avoids
  51303. // 1. components not able to mutate slot nodes
  51304. // 2. static slot content fails for hot-reloading
  51305. if (
  51306. !isPlatformReservedTag(node.tag) &&
  51307. node.tag !== 'slot' &&
  51308. node.attrsMap['inline-template'] == null
  51309. ) {
  51310. return
  51311. }
  51312. for (var i = 0, l = node.children.length; i < l; i++) {
  51313. var child = node.children[i];
  51314. markStatic$1(child);
  51315. if (!child.static) {
  51316. node.static = false;
  51317. }
  51318. }
  51319. if (node.ifConditions) {
  51320. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51321. var block = node.ifConditions[i$1].block;
  51322. markStatic$1(block);
  51323. if (!block.static) {
  51324. node.static = false;
  51325. }
  51326. }
  51327. }
  51328. }
  51329. }
  51330. function markStaticRoots (node, isInFor) {
  51331. if (node.type === 1) {
  51332. if (node.static || node.once) {
  51333. node.staticInFor = isInFor;
  51334. }
  51335. // For a node to qualify as a static root, it should have children that
  51336. // are not just static text. Otherwise the cost of hoisting out will
  51337. // outweigh the benefits and it's better off to just always render it fresh.
  51338. if (node.static && node.children.length && !(
  51339. node.children.length === 1 &&
  51340. node.children[0].type === 3
  51341. )) {
  51342. node.staticRoot = true;
  51343. return
  51344. } else {
  51345. node.staticRoot = false;
  51346. }
  51347. if (node.children) {
  51348. for (var i = 0, l = node.children.length; i < l; i++) {
  51349. markStaticRoots(node.children[i], isInFor || !!node.for);
  51350. }
  51351. }
  51352. if (node.ifConditions) {
  51353. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  51354. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  51355. }
  51356. }
  51357. }
  51358. }
  51359. function isStatic (node) {
  51360. if (node.type === 2) { // expression
  51361. return false
  51362. }
  51363. if (node.type === 3) { // text
  51364. return true
  51365. }
  51366. return !!(node.pre || (
  51367. !node.hasBindings && // no dynamic bindings
  51368. !node.if && !node.for && // not v-if or v-for or v-else
  51369. !isBuiltInTag(node.tag) && // not a built-in
  51370. isPlatformReservedTag(node.tag) && // not a component
  51371. !isDirectChildOfTemplateFor(node) &&
  51372. Object.keys(node).every(isStaticKey)
  51373. ))
  51374. }
  51375. function isDirectChildOfTemplateFor (node) {
  51376. while (node.parent) {
  51377. node = node.parent;
  51378. if (node.tag !== 'template') {
  51379. return false
  51380. }
  51381. if (node.for) {
  51382. return true
  51383. }
  51384. }
  51385. return false
  51386. }
  51387. /* */
  51388. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  51389. var fnInvokeRE = /\([^)]*?\);*$/;
  51390. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  51391. // KeyboardEvent.keyCode aliases
  51392. var keyCodes = {
  51393. esc: 27,
  51394. tab: 9,
  51395. enter: 13,
  51396. space: 32,
  51397. up: 38,
  51398. left: 37,
  51399. right: 39,
  51400. down: 40,
  51401. 'delete': [8, 46]
  51402. };
  51403. // KeyboardEvent.key aliases
  51404. var keyNames = {
  51405. // #7880: IE11 and Edge use `Esc` for Escape key name.
  51406. esc: ['Esc', 'Escape'],
  51407. tab: 'Tab',
  51408. enter: 'Enter',
  51409. // #9112: IE11 uses `Spacebar` for Space key name.
  51410. space: [' ', 'Spacebar'],
  51411. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  51412. up: ['Up', 'ArrowUp'],
  51413. left: ['Left', 'ArrowLeft'],
  51414. right: ['Right', 'ArrowRight'],
  51415. down: ['Down', 'ArrowDown'],
  51416. // #9112: IE11 uses `Del` for Delete key name.
  51417. 'delete': ['Backspace', 'Delete', 'Del']
  51418. };
  51419. // #4868: modifiers that prevent the execution of the listener
  51420. // need to explicitly return null so that we can determine whether to remove
  51421. // the listener for .once
  51422. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  51423. var modifierCode = {
  51424. stop: '$event.stopPropagation();',
  51425. prevent: '$event.preventDefault();',
  51426. self: genGuard("$event.target !== $event.currentTarget"),
  51427. ctrl: genGuard("!$event.ctrlKey"),
  51428. shift: genGuard("!$event.shiftKey"),
  51429. alt: genGuard("!$event.altKey"),
  51430. meta: genGuard("!$event.metaKey"),
  51431. left: genGuard("'button' in $event && $event.button !== 0"),
  51432. middle: genGuard("'button' in $event && $event.button !== 1"),
  51433. right: genGuard("'button' in $event && $event.button !== 2")
  51434. };
  51435. function genHandlers (
  51436. events,
  51437. isNative
  51438. ) {
  51439. var prefix = isNative ? 'nativeOn:' : 'on:';
  51440. var staticHandlers = "";
  51441. var dynamicHandlers = "";
  51442. for (var name in events) {
  51443. var handlerCode = genHandler(events[name]);
  51444. if (events[name] && events[name].dynamic) {
  51445. dynamicHandlers += name + "," + handlerCode + ",";
  51446. } else {
  51447. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  51448. }
  51449. }
  51450. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  51451. if (dynamicHandlers) {
  51452. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  51453. } else {
  51454. return prefix + staticHandlers
  51455. }
  51456. }
  51457. function genHandler (handler) {
  51458. if (!handler) {
  51459. return 'function(){}'
  51460. }
  51461. if (Array.isArray(handler)) {
  51462. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  51463. }
  51464. var isMethodPath = simplePathRE.test(handler.value);
  51465. var isFunctionExpression = fnExpRE.test(handler.value);
  51466. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  51467. if (!handler.modifiers) {
  51468. if (isMethodPath || isFunctionExpression) {
  51469. return handler.value
  51470. }
  51471. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  51472. } else {
  51473. var code = '';
  51474. var genModifierCode = '';
  51475. var keys = [];
  51476. for (var key in handler.modifiers) {
  51477. if (modifierCode[key]) {
  51478. genModifierCode += modifierCode[key];
  51479. // left/right
  51480. if (keyCodes[key]) {
  51481. keys.push(key);
  51482. }
  51483. } else if (key === 'exact') {
  51484. var modifiers = (handler.modifiers);
  51485. genModifierCode += genGuard(
  51486. ['ctrl', 'shift', 'alt', 'meta']
  51487. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  51488. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  51489. .join('||')
  51490. );
  51491. } else {
  51492. keys.push(key);
  51493. }
  51494. }
  51495. if (keys.length) {
  51496. code += genKeyFilter(keys);
  51497. }
  51498. // Make sure modifiers like prevent and stop get executed after key filtering
  51499. if (genModifierCode) {
  51500. code += genModifierCode;
  51501. }
  51502. var handlerCode = isMethodPath
  51503. ? ("return " + (handler.value) + "($event)")
  51504. : isFunctionExpression
  51505. ? ("return (" + (handler.value) + ")($event)")
  51506. : isFunctionInvocation
  51507. ? ("return " + (handler.value))
  51508. : handler.value;
  51509. return ("function($event){" + code + handlerCode + "}")
  51510. }
  51511. }
  51512. function genKeyFilter (keys) {
  51513. return (
  51514. // make sure the key filters only apply to KeyboardEvents
  51515. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  51516. // key events that do not have keyCode property...
  51517. "if(!$event.type.indexOf('key')&&" +
  51518. (keys.map(genFilterCode).join('&&')) + ")return null;"
  51519. )
  51520. }
  51521. function genFilterCode (key) {
  51522. var keyVal = parseInt(key, 10);
  51523. if (keyVal) {
  51524. return ("$event.keyCode!==" + keyVal)
  51525. }
  51526. var keyCode = keyCodes[key];
  51527. var keyName = keyNames[key];
  51528. return (
  51529. "_k($event.keyCode," +
  51530. (JSON.stringify(key)) + "," +
  51531. (JSON.stringify(keyCode)) + "," +
  51532. "$event.key," +
  51533. "" + (JSON.stringify(keyName)) +
  51534. ")"
  51535. )
  51536. }
  51537. /* */
  51538. function on (el, dir) {
  51539. if (dir.modifiers) {
  51540. warn("v-on without argument does not support modifiers.");
  51541. }
  51542. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  51543. }
  51544. /* */
  51545. function bind$1 (el, dir) {
  51546. el.wrapData = function (code) {
  51547. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  51548. };
  51549. }
  51550. /* */
  51551. var baseDirectives = {
  51552. on: on,
  51553. bind: bind$1,
  51554. cloak: noop
  51555. };
  51556. /* */
  51557. var CodegenState = function CodegenState (options) {
  51558. this.options = options;
  51559. this.warn = options.warn || baseWarn;
  51560. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  51561. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  51562. this.directives = extend(extend({}, baseDirectives), options.directives);
  51563. var isReservedTag = options.isReservedTag || no;
  51564. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51565. this.onceId = 0;
  51566. this.staticRenderFns = [];
  51567. this.pre = false;
  51568. };
  51569. function generate (
  51570. ast,
  51571. options
  51572. ) {
  51573. var state = new CodegenState(options);
  51574. var code = ast ? genElement(ast, state) : '_c("div")';
  51575. return {
  51576. render: ("with(this){return " + code + "}"),
  51577. staticRenderFns: state.staticRenderFns
  51578. }
  51579. }
  51580. function genElement (el, state) {
  51581. if (el.parent) {
  51582. el.pre = el.pre || el.parent.pre;
  51583. }
  51584. if (el.staticRoot && !el.staticProcessed) {
  51585. return genStatic(el, state)
  51586. } else if (el.once && !el.onceProcessed) {
  51587. return genOnce(el, state)
  51588. } else if (el.for && !el.forProcessed) {
  51589. return genFor(el, state)
  51590. } else if (el.if && !el.ifProcessed) {
  51591. return genIf(el, state)
  51592. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  51593. return genChildren(el, state) || 'void 0'
  51594. } else if (el.tag === 'slot') {
  51595. return genSlot(el, state)
  51596. } else {
  51597. // component or element
  51598. var code;
  51599. if (el.component) {
  51600. code = genComponent(el.component, el, state);
  51601. } else {
  51602. var data;
  51603. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  51604. data = genData$2(el, state);
  51605. }
  51606. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  51607. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  51608. }
  51609. // module transforms
  51610. for (var i = 0; i < state.transforms.length; i++) {
  51611. code = state.transforms[i](el, code);
  51612. }
  51613. return code
  51614. }
  51615. }
  51616. // hoist static sub-trees out
  51617. function genStatic (el, state) {
  51618. el.staticProcessed = true;
  51619. // Some elements (templates) need to behave differently inside of a v-pre
  51620. // node. All pre nodes are static roots, so we can use this as a location to
  51621. // wrap a state change and reset it upon exiting the pre node.
  51622. var originalPreState = state.pre;
  51623. if (el.pre) {
  51624. state.pre = el.pre;
  51625. }
  51626. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  51627. state.pre = originalPreState;
  51628. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  51629. }
  51630. // v-once
  51631. function genOnce (el, state) {
  51632. el.onceProcessed = true;
  51633. if (el.if && !el.ifProcessed) {
  51634. return genIf(el, state)
  51635. } else if (el.staticInFor) {
  51636. var key = '';
  51637. var parent = el.parent;
  51638. while (parent) {
  51639. if (parent.for) {
  51640. key = parent.key;
  51641. break
  51642. }
  51643. parent = parent.parent;
  51644. }
  51645. if (!key) {
  51646. state.warn(
  51647. "v-once can only be used inside v-for that is keyed. ",
  51648. el.rawAttrsMap['v-once']
  51649. );
  51650. return genElement(el, state)
  51651. }
  51652. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  51653. } else {
  51654. return genStatic(el, state)
  51655. }
  51656. }
  51657. function genIf (
  51658. el,
  51659. state,
  51660. altGen,
  51661. altEmpty
  51662. ) {
  51663. el.ifProcessed = true; // avoid recursion
  51664. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  51665. }
  51666. function genIfConditions (
  51667. conditions,
  51668. state,
  51669. altGen,
  51670. altEmpty
  51671. ) {
  51672. if (!conditions.length) {
  51673. return altEmpty || '_e()'
  51674. }
  51675. var condition = conditions.shift();
  51676. if (condition.exp) {
  51677. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  51678. } else {
  51679. return ("" + (genTernaryExp(condition.block)))
  51680. }
  51681. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  51682. function genTernaryExp (el) {
  51683. return altGen
  51684. ? altGen(el, state)
  51685. : el.once
  51686. ? genOnce(el, state)
  51687. : genElement(el, state)
  51688. }
  51689. }
  51690. function genFor (
  51691. el,
  51692. state,
  51693. altGen,
  51694. altHelper
  51695. ) {
  51696. var exp = el.for;
  51697. var alias = el.alias;
  51698. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  51699. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  51700. if (state.maybeComponent(el) &&
  51701. el.tag !== 'slot' &&
  51702. el.tag !== 'template' &&
  51703. !el.key
  51704. ) {
  51705. state.warn(
  51706. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  51707. "v-for should have explicit keys. " +
  51708. "See https://vuejs.org/guide/list.html#key for more info.",
  51709. el.rawAttrsMap['v-for'],
  51710. true /* tip */
  51711. );
  51712. }
  51713. el.forProcessed = true; // avoid recursion
  51714. return (altHelper || '_l') + "((" + exp + ")," +
  51715. "function(" + alias + iterator1 + iterator2 + "){" +
  51716. "return " + ((altGen || genElement)(el, state)) +
  51717. '})'
  51718. }
  51719. function genData$2 (el, state) {
  51720. var data = '{';
  51721. // directives first.
  51722. // directives may mutate the el's other properties before they are generated.
  51723. var dirs = genDirectives(el, state);
  51724. if (dirs) { data += dirs + ','; }
  51725. // key
  51726. if (el.key) {
  51727. data += "key:" + (el.key) + ",";
  51728. }
  51729. // ref
  51730. if (el.ref) {
  51731. data += "ref:" + (el.ref) + ",";
  51732. }
  51733. if (el.refInFor) {
  51734. data += "refInFor:true,";
  51735. }
  51736. // pre
  51737. if (el.pre) {
  51738. data += "pre:true,";
  51739. }
  51740. // record original tag name for components using "is" attribute
  51741. if (el.component) {
  51742. data += "tag:\"" + (el.tag) + "\",";
  51743. }
  51744. // module data generation functions
  51745. for (var i = 0; i < state.dataGenFns.length; i++) {
  51746. data += state.dataGenFns[i](el);
  51747. }
  51748. // attributes
  51749. if (el.attrs) {
  51750. data += "attrs:" + (genProps(el.attrs)) + ",";
  51751. }
  51752. // DOM props
  51753. if (el.props) {
  51754. data += "domProps:" + (genProps(el.props)) + ",";
  51755. }
  51756. // event handlers
  51757. if (el.events) {
  51758. data += (genHandlers(el.events, false)) + ",";
  51759. }
  51760. if (el.nativeEvents) {
  51761. data += (genHandlers(el.nativeEvents, true)) + ",";
  51762. }
  51763. // slot target
  51764. // only for non-scoped slots
  51765. if (el.slotTarget && !el.slotScope) {
  51766. data += "slot:" + (el.slotTarget) + ",";
  51767. }
  51768. // scoped slots
  51769. if (el.scopedSlots) {
  51770. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  51771. }
  51772. // component v-model
  51773. if (el.model) {
  51774. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  51775. }
  51776. // inline-template
  51777. if (el.inlineTemplate) {
  51778. var inlineTemplate = genInlineTemplate(el, state);
  51779. if (inlineTemplate) {
  51780. data += inlineTemplate + ",";
  51781. }
  51782. }
  51783. data = data.replace(/,$/, '') + '}';
  51784. // v-bind dynamic argument wrap
  51785. // v-bind with dynamic arguments must be applied using the same v-bind object
  51786. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  51787. if (el.dynamicAttrs) {
  51788. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  51789. }
  51790. // v-bind data wrap
  51791. if (el.wrapData) {
  51792. data = el.wrapData(data);
  51793. }
  51794. // v-on data wrap
  51795. if (el.wrapListeners) {
  51796. data = el.wrapListeners(data);
  51797. }
  51798. return data
  51799. }
  51800. function genDirectives (el, state) {
  51801. var dirs = el.directives;
  51802. if (!dirs) { return }
  51803. var res = 'directives:[';
  51804. var hasRuntime = false;
  51805. var i, l, dir, needRuntime;
  51806. for (i = 0, l = dirs.length; i < l; i++) {
  51807. dir = dirs[i];
  51808. needRuntime = true;
  51809. var gen = state.directives[dir.name];
  51810. if (gen) {
  51811. // compile-time directive that manipulates AST.
  51812. // returns true if it also needs a runtime counterpart.
  51813. needRuntime = !!gen(el, dir, state.warn);
  51814. }
  51815. if (needRuntime) {
  51816. hasRuntime = true;
  51817. 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))) : '') + "},";
  51818. }
  51819. }
  51820. if (hasRuntime) {
  51821. return res.slice(0, -1) + ']'
  51822. }
  51823. }
  51824. function genInlineTemplate (el, state) {
  51825. var ast = el.children[0];
  51826. if (el.children.length !== 1 || ast.type !== 1) {
  51827. state.warn(
  51828. 'Inline-template components must have exactly one child element.',
  51829. { start: el.start }
  51830. );
  51831. }
  51832. if (ast && ast.type === 1) {
  51833. var inlineRenderFns = generate(ast, state.options);
  51834. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  51835. }
  51836. }
  51837. function genScopedSlots (
  51838. el,
  51839. slots,
  51840. state
  51841. ) {
  51842. // by default scoped slots are considered "stable", this allows child
  51843. // components with only scoped slots to skip forced updates from parent.
  51844. // but in some cases we have to bail-out of this optimization
  51845. // for example if the slot contains dynamic names, has v-if or v-for on them...
  51846. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  51847. var slot = slots[key];
  51848. return (
  51849. slot.slotTargetDynamic ||
  51850. slot.if ||
  51851. slot.for ||
  51852. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  51853. )
  51854. });
  51855. // #9534: if a component with scoped slots is inside a conditional branch,
  51856. // it's possible for the same component to be reused but with different
  51857. // compiled slot content. To avoid that, we generate a unique key based on
  51858. // the generated code of all the slot contents.
  51859. var needsKey = !!el.if;
  51860. // OR when it is inside another scoped slot or v-for (the reactivity may be
  51861. // disconnected due to the intermediate scope variable)
  51862. // #9438, #9506
  51863. // TODO: this can be further optimized by properly analyzing in-scope bindings
  51864. // and skip force updating ones that do not actually use scope variables.
  51865. if (!needsForceUpdate) {
  51866. var parent = el.parent;
  51867. while (parent) {
  51868. if (
  51869. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  51870. parent.for
  51871. ) {
  51872. needsForceUpdate = true;
  51873. break
  51874. }
  51875. if (parent.if) {
  51876. needsKey = true;
  51877. }
  51878. parent = parent.parent;
  51879. }
  51880. }
  51881. var generatedSlots = Object.keys(slots)
  51882. .map(function (key) { return genScopedSlot(slots[key], state); })
  51883. .join(',');
  51884. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  51885. }
  51886. function hash(str) {
  51887. var hash = 5381;
  51888. var i = str.length;
  51889. while(i) {
  51890. hash = (hash * 33) ^ str.charCodeAt(--i);
  51891. }
  51892. return hash >>> 0
  51893. }
  51894. function containsSlotChild (el) {
  51895. if (el.type === 1) {
  51896. if (el.tag === 'slot') {
  51897. return true
  51898. }
  51899. return el.children.some(containsSlotChild)
  51900. }
  51901. return false
  51902. }
  51903. function genScopedSlot (
  51904. el,
  51905. state
  51906. ) {
  51907. var isLegacySyntax = el.attrsMap['slot-scope'];
  51908. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  51909. return genIf(el, state, genScopedSlot, "null")
  51910. }
  51911. if (el.for && !el.forProcessed) {
  51912. return genFor(el, state, genScopedSlot)
  51913. }
  51914. var slotScope = el.slotScope === emptySlotScopeToken
  51915. ? ""
  51916. : String(el.slotScope);
  51917. var fn = "function(" + slotScope + "){" +
  51918. "return " + (el.tag === 'template'
  51919. ? el.if && isLegacySyntax
  51920. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  51921. : genChildren(el, state) || 'undefined'
  51922. : genElement(el, state)) + "}";
  51923. // reverse proxy v-slot without scope on this.$slots
  51924. var reverseProxy = slotScope ? "" : ",proxy:true";
  51925. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  51926. }
  51927. function genChildren (
  51928. el,
  51929. state,
  51930. checkSkip,
  51931. altGenElement,
  51932. altGenNode
  51933. ) {
  51934. var children = el.children;
  51935. if (children.length) {
  51936. var el$1 = children[0];
  51937. // optimize single v-for
  51938. if (children.length === 1 &&
  51939. el$1.for &&
  51940. el$1.tag !== 'template' &&
  51941. el$1.tag !== 'slot'
  51942. ) {
  51943. var normalizationType = checkSkip
  51944. ? state.maybeComponent(el$1) ? ",1" : ",0"
  51945. : "";
  51946. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  51947. }
  51948. var normalizationType$1 = checkSkip
  51949. ? getNormalizationType(children, state.maybeComponent)
  51950. : 0;
  51951. var gen = altGenNode || genNode;
  51952. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  51953. }
  51954. }
  51955. // determine the normalization needed for the children array.
  51956. // 0: no normalization needed
  51957. // 1: simple normalization needed (possible 1-level deep nested array)
  51958. // 2: full normalization needed
  51959. function getNormalizationType (
  51960. children,
  51961. maybeComponent
  51962. ) {
  51963. var res = 0;
  51964. for (var i = 0; i < children.length; i++) {
  51965. var el = children[i];
  51966. if (el.type !== 1) {
  51967. continue
  51968. }
  51969. if (needsNormalization(el) ||
  51970. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  51971. res = 2;
  51972. break
  51973. }
  51974. if (maybeComponent(el) ||
  51975. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  51976. res = 1;
  51977. }
  51978. }
  51979. return res
  51980. }
  51981. function needsNormalization (el) {
  51982. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  51983. }
  51984. function genNode (node, state) {
  51985. if (node.type === 1) {
  51986. return genElement(node, state)
  51987. } else if (node.type === 3 && node.isComment) {
  51988. return genComment(node)
  51989. } else {
  51990. return genText(node)
  51991. }
  51992. }
  51993. function genText (text) {
  51994. return ("_v(" + (text.type === 2
  51995. ? text.expression // no need for () because already wrapped in _s()
  51996. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  51997. }
  51998. function genComment (comment) {
  51999. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  52000. }
  52001. function genSlot (el, state) {
  52002. var slotName = el.slotName || '"default"';
  52003. var children = genChildren(el, state);
  52004. var res = "_t(" + slotName + (children ? ("," + children) : '');
  52005. var attrs = el.attrs || el.dynamicAttrs
  52006. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  52007. // slot props are camelized
  52008. name: camelize(attr.name),
  52009. value: attr.value,
  52010. dynamic: attr.dynamic
  52011. }); }))
  52012. : null;
  52013. var bind$$1 = el.attrsMap['v-bind'];
  52014. if ((attrs || bind$$1) && !children) {
  52015. res += ",null";
  52016. }
  52017. if (attrs) {
  52018. res += "," + attrs;
  52019. }
  52020. if (bind$$1) {
  52021. res += (attrs ? '' : ',null') + "," + bind$$1;
  52022. }
  52023. return res + ')'
  52024. }
  52025. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  52026. function genComponent (
  52027. componentName,
  52028. el,
  52029. state
  52030. ) {
  52031. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52032. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  52033. }
  52034. function genProps (props) {
  52035. var staticProps = "";
  52036. var dynamicProps = "";
  52037. for (var i = 0; i < props.length; i++) {
  52038. var prop = props[i];
  52039. var value = transformSpecialNewlines(prop.value);
  52040. if (prop.dynamic) {
  52041. dynamicProps += (prop.name) + "," + value + ",";
  52042. } else {
  52043. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  52044. }
  52045. }
  52046. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  52047. if (dynamicProps) {
  52048. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  52049. } else {
  52050. return staticProps
  52051. }
  52052. }
  52053. // #3895, #4268
  52054. function transformSpecialNewlines (text) {
  52055. return text
  52056. .replace(/\u2028/g, '\\u2028')
  52057. .replace(/\u2029/g, '\\u2029')
  52058. }
  52059. /* */
  52060. // these keywords should not appear inside expressions, but operators like
  52061. // typeof, instanceof and in are allowed
  52062. var prohibitedKeywordRE = new RegExp('\\b' + (
  52063. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  52064. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  52065. 'extends,finally,continue,debugger,function,arguments'
  52066. ).split(',').join('\\b|\\b') + '\\b');
  52067. // these unary operators should not be used as property/method names
  52068. var unaryOperatorsRE = new RegExp('\\b' + (
  52069. 'delete,typeof,void'
  52070. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  52071. // strip strings in expressions
  52072. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  52073. // detect problematic expressions in a template
  52074. function detectErrors (ast, warn) {
  52075. if (ast) {
  52076. checkNode(ast, warn);
  52077. }
  52078. }
  52079. function checkNode (node, warn) {
  52080. if (node.type === 1) {
  52081. for (var name in node.attrsMap) {
  52082. if (dirRE.test(name)) {
  52083. var value = node.attrsMap[name];
  52084. if (value) {
  52085. var range = node.rawAttrsMap[name];
  52086. if (name === 'v-for') {
  52087. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  52088. } else if (name === 'v-slot' || name[0] === '#') {
  52089. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  52090. } else if (onRE.test(name)) {
  52091. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  52092. } else {
  52093. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  52094. }
  52095. }
  52096. }
  52097. }
  52098. if (node.children) {
  52099. for (var i = 0; i < node.children.length; i++) {
  52100. checkNode(node.children[i], warn);
  52101. }
  52102. }
  52103. } else if (node.type === 2) {
  52104. checkExpression(node.expression, node.text, warn, node);
  52105. }
  52106. }
  52107. function checkEvent (exp, text, warn, range) {
  52108. var stripped = exp.replace(stripStringRE, '');
  52109. var keywordMatch = stripped.match(unaryOperatorsRE);
  52110. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  52111. warn(
  52112. "avoid using JavaScript unary operator as property name: " +
  52113. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  52114. range
  52115. );
  52116. }
  52117. checkExpression(exp, text, warn, range);
  52118. }
  52119. function checkFor (node, text, warn, range) {
  52120. checkExpression(node.for || '', text, warn, range);
  52121. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  52122. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  52123. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  52124. }
  52125. function checkIdentifier (
  52126. ident,
  52127. type,
  52128. text,
  52129. warn,
  52130. range
  52131. ) {
  52132. if (typeof ident === 'string') {
  52133. try {
  52134. new Function(("var " + ident + "=_"));
  52135. } catch (e) {
  52136. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  52137. }
  52138. }
  52139. }
  52140. function checkExpression (exp, text, warn, range) {
  52141. try {
  52142. new Function(("return " + exp));
  52143. } catch (e) {
  52144. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  52145. if (keywordMatch) {
  52146. warn(
  52147. "avoid using JavaScript keyword as property name: " +
  52148. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  52149. range
  52150. );
  52151. } else {
  52152. warn(
  52153. "invalid expression: " + (e.message) + " in\n\n" +
  52154. " " + exp + "\n\n" +
  52155. " Raw expression: " + (text.trim()) + "\n",
  52156. range
  52157. );
  52158. }
  52159. }
  52160. }
  52161. function checkFunctionParameterExpression (exp, text, warn, range) {
  52162. try {
  52163. new Function(exp, '');
  52164. } catch (e) {
  52165. warn(
  52166. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  52167. " " + exp + "\n\n" +
  52168. " Raw expression: " + (text.trim()) + "\n",
  52169. range
  52170. );
  52171. }
  52172. }
  52173. /* */
  52174. var range = 2;
  52175. function generateCodeFrame (
  52176. source,
  52177. start,
  52178. end
  52179. ) {
  52180. if ( start === void 0 ) start = 0;
  52181. if ( end === void 0 ) end = source.length;
  52182. var lines = source.split(/\r?\n/);
  52183. var count = 0;
  52184. var res = [];
  52185. for (var i = 0; i < lines.length; i++) {
  52186. count += lines[i].length + 1;
  52187. if (count >= start) {
  52188. for (var j = i - range; j <= i + range || end > count; j++) {
  52189. if (j < 0 || j >= lines.length) { continue }
  52190. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  52191. var lineLength = lines[j].length;
  52192. if (j === i) {
  52193. // push underline
  52194. var pad = start - (count - lineLength) + 1;
  52195. var length = end > count ? lineLength - pad : end - start;
  52196. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  52197. } else if (j > i) {
  52198. if (end > count) {
  52199. var length$1 = Math.min(end - count, lineLength);
  52200. res.push(" | " + repeat$1("^", length$1));
  52201. }
  52202. count += lineLength + 1;
  52203. }
  52204. }
  52205. break
  52206. }
  52207. }
  52208. return res.join('\n')
  52209. }
  52210. function repeat$1 (str, n) {
  52211. var result = '';
  52212. if (n > 0) {
  52213. while (true) { // eslint-disable-line
  52214. if (n & 1) { result += str; }
  52215. n >>>= 1;
  52216. if (n <= 0) { break }
  52217. str += str;
  52218. }
  52219. }
  52220. return result
  52221. }
  52222. /* */
  52223. function createFunction (code, errors) {
  52224. try {
  52225. return new Function(code)
  52226. } catch (err) {
  52227. errors.push({ err: err, code: code });
  52228. return noop
  52229. }
  52230. }
  52231. function createCompileToFunctionFn (compile) {
  52232. var cache = Object.create(null);
  52233. return function compileToFunctions (
  52234. template,
  52235. options,
  52236. vm
  52237. ) {
  52238. options = extend({}, options);
  52239. var warn$$1 = options.warn || warn;
  52240. delete options.warn;
  52241. /* istanbul ignore if */
  52242. {
  52243. // detect possible CSP restriction
  52244. try {
  52245. new Function('return 1');
  52246. } catch (e) {
  52247. if (e.toString().match(/unsafe-eval|CSP/)) {
  52248. warn$$1(
  52249. 'It seems you are using the standalone build of Vue.js in an ' +
  52250. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  52251. 'The template compiler cannot work in this environment. Consider ' +
  52252. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  52253. 'templates into render functions.'
  52254. );
  52255. }
  52256. }
  52257. }
  52258. // check cache
  52259. var key = options.delimiters
  52260. ? String(options.delimiters) + template
  52261. : template;
  52262. if (cache[key]) {
  52263. return cache[key]
  52264. }
  52265. // compile
  52266. var compiled = compile(template, options);
  52267. // check compilation errors/tips
  52268. {
  52269. if (compiled.errors && compiled.errors.length) {
  52270. if (options.outputSourceRange) {
  52271. compiled.errors.forEach(function (e) {
  52272. warn$$1(
  52273. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  52274. generateCodeFrame(template, e.start, e.end),
  52275. vm
  52276. );
  52277. });
  52278. } else {
  52279. warn$$1(
  52280. "Error compiling template:\n\n" + template + "\n\n" +
  52281. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  52282. vm
  52283. );
  52284. }
  52285. }
  52286. if (compiled.tips && compiled.tips.length) {
  52287. if (options.outputSourceRange) {
  52288. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  52289. } else {
  52290. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  52291. }
  52292. }
  52293. }
  52294. // turn code into functions
  52295. var res = {};
  52296. var fnGenErrors = [];
  52297. res.render = createFunction(compiled.render, fnGenErrors);
  52298. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  52299. return createFunction(code, fnGenErrors)
  52300. });
  52301. // check function generation errors.
  52302. // this should only happen if there is a bug in the compiler itself.
  52303. // mostly for codegen development use
  52304. /* istanbul ignore if */
  52305. {
  52306. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  52307. warn$$1(
  52308. "Failed to generate render function:\n\n" +
  52309. fnGenErrors.map(function (ref) {
  52310. var err = ref.err;
  52311. var code = ref.code;
  52312. return ((err.toString()) + " in\n\n" + code + "\n");
  52313. }).join('\n'),
  52314. vm
  52315. );
  52316. }
  52317. }
  52318. return (cache[key] = res)
  52319. }
  52320. }
  52321. /* */
  52322. function createCompilerCreator (baseCompile) {
  52323. return function createCompiler (baseOptions) {
  52324. function compile (
  52325. template,
  52326. options
  52327. ) {
  52328. var finalOptions = Object.create(baseOptions);
  52329. var errors = [];
  52330. var tips = [];
  52331. var warn = function (msg, range, tip) {
  52332. (tip ? tips : errors).push(msg);
  52333. };
  52334. if (options) {
  52335. if (options.outputSourceRange) {
  52336. // $flow-disable-line
  52337. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  52338. warn = function (msg, range, tip) {
  52339. var data = { msg: msg };
  52340. if (range) {
  52341. if (range.start != null) {
  52342. data.start = range.start + leadingSpaceLength;
  52343. }
  52344. if (range.end != null) {
  52345. data.end = range.end + leadingSpaceLength;
  52346. }
  52347. }
  52348. (tip ? tips : errors).push(data);
  52349. };
  52350. }
  52351. // merge custom modules
  52352. if (options.modules) {
  52353. finalOptions.modules =
  52354. (baseOptions.modules || []).concat(options.modules);
  52355. }
  52356. // merge custom directives
  52357. if (options.directives) {
  52358. finalOptions.directives = extend(
  52359. Object.create(baseOptions.directives || null),
  52360. options.directives
  52361. );
  52362. }
  52363. // copy other options
  52364. for (var key in options) {
  52365. if (key !== 'modules' && key !== 'directives') {
  52366. finalOptions[key] = options[key];
  52367. }
  52368. }
  52369. }
  52370. finalOptions.warn = warn;
  52371. var compiled = baseCompile(template.trim(), finalOptions);
  52372. {
  52373. detectErrors(compiled.ast, warn);
  52374. }
  52375. compiled.errors = errors;
  52376. compiled.tips = tips;
  52377. return compiled
  52378. }
  52379. return {
  52380. compile: compile,
  52381. compileToFunctions: createCompileToFunctionFn(compile)
  52382. }
  52383. }
  52384. }
  52385. /* */
  52386. // `createCompilerCreator` allows creating compilers that use alternative
  52387. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  52388. // Here we just export a default compiler using the default parts.
  52389. var createCompiler = createCompilerCreator(function baseCompile (
  52390. template,
  52391. options
  52392. ) {
  52393. var ast = parse(template.trim(), options);
  52394. if (options.optimize !== false) {
  52395. optimize(ast, options);
  52396. }
  52397. var code = generate(ast, options);
  52398. return {
  52399. ast: ast,
  52400. render: code.render,
  52401. staticRenderFns: code.staticRenderFns
  52402. }
  52403. });
  52404. /* */
  52405. var ref$1 = createCompiler(baseOptions);
  52406. var compile = ref$1.compile;
  52407. var compileToFunctions = ref$1.compileToFunctions;
  52408. /* */
  52409. // check whether current browser encodes a char inside attribute values
  52410. var div;
  52411. function getShouldDecode (href) {
  52412. div = div || document.createElement('div');
  52413. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  52414. return div.innerHTML.indexOf('&#10;') > 0
  52415. }
  52416. // #3663: IE encodes newlines inside attribute values while other browsers don't
  52417. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  52418. // #6828: chrome encodes content in a[href]
  52419. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  52420. /* */
  52421. var idToTemplate = cached(function (id) {
  52422. var el = query(id);
  52423. return el && el.innerHTML
  52424. });
  52425. var mount = Vue.prototype.$mount;
  52426. Vue.prototype.$mount = function (
  52427. el,
  52428. hydrating
  52429. ) {
  52430. el = el && query(el);
  52431. /* istanbul ignore if */
  52432. if (el === document.body || el === document.documentElement) {
  52433. warn(
  52434. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  52435. );
  52436. return this
  52437. }
  52438. var options = this.$options;
  52439. // resolve template/el and convert to render function
  52440. if (!options.render) {
  52441. var template = options.template;
  52442. if (template) {
  52443. if (typeof template === 'string') {
  52444. if (template.charAt(0) === '#') {
  52445. template = idToTemplate(template);
  52446. /* istanbul ignore if */
  52447. if (!template) {
  52448. warn(
  52449. ("Template element not found or is empty: " + (options.template)),
  52450. this
  52451. );
  52452. }
  52453. }
  52454. } else if (template.nodeType) {
  52455. template = template.innerHTML;
  52456. } else {
  52457. {
  52458. warn('invalid template option:' + template, this);
  52459. }
  52460. return this
  52461. }
  52462. } else if (el) {
  52463. template = getOuterHTML(el);
  52464. }
  52465. if (template) {
  52466. /* istanbul ignore if */
  52467. if (config.performance && mark) {
  52468. mark('compile');
  52469. }
  52470. var ref = compileToFunctions(template, {
  52471. outputSourceRange: "development" !== 'production',
  52472. shouldDecodeNewlines: shouldDecodeNewlines,
  52473. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  52474. delimiters: options.delimiters,
  52475. comments: options.comments
  52476. }, this);
  52477. var render = ref.render;
  52478. var staticRenderFns = ref.staticRenderFns;
  52479. options.render = render;
  52480. options.staticRenderFns = staticRenderFns;
  52481. /* istanbul ignore if */
  52482. if (config.performance && mark) {
  52483. mark('compile end');
  52484. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  52485. }
  52486. }
  52487. }
  52488. return mount.call(this, el, hydrating)
  52489. };
  52490. /**
  52491. * Get outerHTML of elements, taking care
  52492. * of SVG elements in IE as well.
  52493. */
  52494. function getOuterHTML (el) {
  52495. if (el.outerHTML) {
  52496. return el.outerHTML
  52497. } else {
  52498. var container = document.createElement('div');
  52499. container.appendChild(el.cloneNode(true));
  52500. return container.innerHTML
  52501. }
  52502. }
  52503. Vue.compile = compileToFunctions;
  52504. module.exports = Vue;
  52505. /* 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))
  52506. /***/ }),
  52507. /***/ "./node_modules/vue/dist/vue.common.js":
  52508. /*!*********************************************!*\
  52509. !*** ./node_modules/vue/dist/vue.common.js ***!
  52510. \*********************************************/
  52511. /*! no static exports found */
  52512. /***/ (function(module, exports, __webpack_require__) {
  52513. if (false) {} else {
  52514. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  52515. }
  52516. /***/ }),
  52517. /***/ "./node_modules/webpack/buildin/global.js":
  52518. /*!***********************************!*\
  52519. !*** (webpack)/buildin/global.js ***!
  52520. \***********************************/
  52521. /*! no static exports found */
  52522. /***/ (function(module, exports) {
  52523. var g;
  52524. // This works in non-strict mode
  52525. g = (function() {
  52526. return this;
  52527. })();
  52528. try {
  52529. // This works if eval is allowed (see CSP)
  52530. g = g || new Function("return this")();
  52531. } catch (e) {
  52532. // This works if the window reference is available
  52533. if (typeof window === "object") g = window;
  52534. }
  52535. // g can still be undefined, but nothing to do about it...
  52536. // We return undefined, instead of nothing here, so it's
  52537. // easier to handle this case. if(!global) { ...}
  52538. module.exports = g;
  52539. /***/ }),
  52540. /***/ "./node_modules/webpack/buildin/module.js":
  52541. /*!***********************************!*\
  52542. !*** (webpack)/buildin/module.js ***!
  52543. \***********************************/
  52544. /*! no static exports found */
  52545. /***/ (function(module, exports) {
  52546. module.exports = function(module) {
  52547. if (!module.webpackPolyfill) {
  52548. module.deprecate = function() {};
  52549. module.paths = [];
  52550. // module.parent = undefined by default
  52551. if (!module.children) module.children = [];
  52552. Object.defineProperty(module, "loaded", {
  52553. enumerable: true,
  52554. get: function() {
  52555. return module.l;
  52556. }
  52557. });
  52558. Object.defineProperty(module, "id", {
  52559. enumerable: true,
  52560. get: function() {
  52561. return module.i;
  52562. }
  52563. });
  52564. module.webpackPolyfill = 1;
  52565. }
  52566. return module;
  52567. };
  52568. /***/ }),
  52569. /***/ "./resources/js/app.js":
  52570. /*!*****************************!*\
  52571. !*** ./resources/js/app.js ***!
  52572. \*****************************/
  52573. /*! no static exports found */
  52574. /***/ (function(module, exports, __webpack_require__) {
  52575. /**
  52576. * First we will load all of this project's JavaScript dependencies which
  52577. * includes Vue and other libraries. It is a great starting point when
  52578. * building robust, powerful web applications using Vue and Laravel.
  52579. */
  52580. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  52581. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  52582. /**
  52583. * The following block of code may be used to automatically register your
  52584. * Vue components. It will recursively scan this directory for the Vue
  52585. * components and automatically register them with their "basename".
  52586. *
  52587. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  52588. */
  52589. // const files = require.context('./', true, /\.vue$/i)
  52590. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  52591. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  52592. Vue.component('probdesc', __webpack_require__(/*! ./components/probdesc.vue */ "./resources/js/components/probdesc.vue")["default"]);
  52593. /**
  52594. * Next, we will create a fresh Vue application instance and attach it to
  52595. * the page. Then, you may begin adding components to this application
  52596. * or customize the JavaScript scaffolding to fit your unique needs.
  52597. */
  52598. var app = new Vue({
  52599. el: '#app'
  52600. });
  52601. /***/ }),
  52602. /***/ "./resources/js/bootstrap.js":
  52603. /*!***********************************!*\
  52604. !*** ./resources/js/bootstrap.js ***!
  52605. \***********************************/
  52606. /*! no exports provided */
  52607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52608. "use strict";
  52609. __webpack_require__.r(__webpack_exports__);
  52610. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  52611. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  52612. /**
  52613. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  52614. * for JavaScript based Bootstrap features such as modals and tabs. This
  52615. * code may be modified to fit the specific needs of your application.
  52616. */
  52617. try {
  52618. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  52619. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  52620. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  52621. } catch (e) {}
  52622. /**
  52623. * We'll load the axios HTTP library which allows us to easily issue requests
  52624. * to our Laravel back-end. This library automatically handles sending the
  52625. * CSRF token as a header based on the value of the "XSRF" token cookie.
  52626. */
  52627. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  52628. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  52629. /**
  52630. * Echo exposes an expressive API for subscribing to channels and listening
  52631. * for events that are broadcast by Laravel. Echo and event broadcasting
  52632. * allows your team to easily build robust real-time web applications.
  52633. */
  52634. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  52635. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  52636. broadcaster: 'pusher',
  52637. key: "upccrt",
  52638. wsHost: window.location.hostname,
  52639. wsPort: 6001,
  52640. disableStats: true
  52641. });
  52642. /***/ }),
  52643. /***/ "./resources/js/components/ExampleComponent.vue":
  52644. /*!******************************************************!*\
  52645. !*** ./resources/js/components/ExampleComponent.vue ***!
  52646. \******************************************************/
  52647. /*! exports provided: default */
  52648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52649. "use strict";
  52650. __webpack_require__.r(__webpack_exports__);
  52651. /* harmony import */ var _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52652. /* harmony import */ var _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ExampleComponent.vue?vue&type=script&lang=js& */ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52653. /* empty/unused harmony star reexport *//* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  52654. /* normalize component */
  52655. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52656. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52657. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52658. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52659. false,
  52660. null,
  52661. null,
  52662. null
  52663. )
  52664. /* hot reload */
  52665. if (false) { var api; }
  52666. component.options.__file = "resources/js/components/ExampleComponent.vue"
  52667. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52668. /***/ }),
  52669. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  52670. /*!*******************************************************************************!*\
  52671. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  52672. \*******************************************************************************/
  52673. /*! exports provided: default */
  52674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52675. "use strict";
  52676. __webpack_require__.r(__webpack_exports__);
  52677. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&");
  52678. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52679. /***/ }),
  52680. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  52681. /*!*************************************************************************************!*\
  52682. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  52683. \*************************************************************************************/
  52684. /*! exports provided: render, staticRenderFns */
  52685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52686. "use strict";
  52687. __webpack_require__.r(__webpack_exports__);
  52688. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./ExampleComponent.vue?vue&type=template&id=299e239e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&");
  52689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52691. /***/ }),
  52692. /***/ "./resources/js/components/probdesc.vue":
  52693. /*!**********************************************!*\
  52694. !*** ./resources/js/components/probdesc.vue ***!
  52695. \**********************************************/
  52696. /*! exports provided: default */
  52697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52698. "use strict";
  52699. __webpack_require__.r(__webpack_exports__);
  52700. /* harmony import */ var _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./probdesc.vue?vue&type=template&id=b2bce49e& */ "./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&");
  52701. /* harmony import */ var _probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./probdesc.vue?vue&type=script&lang=js& */ "./resources/js/components/probdesc.vue?vue&type=script&lang=js&");
  52702. /* empty/unused harmony star reexport *//* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js");
  52703. /* normalize component */
  52704. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  52705. _probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  52706. _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["render"],
  52707. _probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  52708. false,
  52709. null,
  52710. null,
  52711. null
  52712. )
  52713. /* hot reload */
  52714. if (false) { var api; }
  52715. component.options.__file = "resources/js/components/probdesc.vue"
  52716. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  52717. /***/ }),
  52718. /***/ "./resources/js/components/probdesc.vue?vue&type=script&lang=js&":
  52719. /*!***********************************************************************!*\
  52720. !*** ./resources/js/components/probdesc.vue?vue&type=script&lang=js& ***!
  52721. \***********************************************************************/
  52722. /*! exports provided: default */
  52723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52724. "use strict";
  52725. __webpack_require__.r(__webpack_exports__);
  52726. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/babel-loader/lib??ref--4-0!../../../node_modules/vue-loader/lib??vue-loader-options!./probdesc.vue?vue&type=script&lang=js& */ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=script&lang=js&");
  52727. /* empty/unused harmony star reexport */ /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_4_0_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__["default"]);
  52728. /***/ }),
  52729. /***/ "./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&":
  52730. /*!*****************************************************************************!*\
  52731. !*** ./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e& ***!
  52732. \*****************************************************************************/
  52733. /*! exports provided: render, staticRenderFns */
  52734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52735. "use strict";
  52736. __webpack_require__.r(__webpack_exports__);
  52737. /* harmony import */ var _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! -!../../../node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!../../../node_modules/vue-loader/lib??vue-loader-options!./probdesc.vue?vue&type=template&id=b2bce49e& */ "./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/probdesc.vue?vue&type=template&id=b2bce49e&");
  52738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "render", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["render"]; });
  52739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return _node_modules_vue_loader_lib_loaders_templateLoader_js_vue_loader_options_node_modules_vue_loader_lib_index_js_vue_loader_options_probdesc_vue_vue_type_template_id_b2bce49e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"]; });
  52740. /***/ }),
  52741. /***/ "./resources/sass/app.scss":
  52742. /*!*********************************!*\
  52743. !*** ./resources/sass/app.scss ***!
  52744. \*********************************/
  52745. /*! no static exports found */
  52746. /***/ (function(module, exports) {
  52747. // removed by extract-text-webpack-plugin
  52748. /***/ }),
  52749. /***/ 0:
  52750. /*!*************************************************************!*\
  52751. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  52752. \*************************************************************/
  52753. /*! no static exports found */
  52754. /***/ (function(module, exports, __webpack_require__) {
  52755. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  52756. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  52757. /***/ })
  52758. /******/ });